Ver código fonte

Add support for passing in the plan ID

case CPANEL-34940: It has been observed on a production TestRail
instance that getPlanByName is quite a bit slower than getting it by ID.
Allow callers to speed things up by passing in a plan ID if they
already know it.
J. Nick Koston 5 anos atrás
pai
commit
c2f6c84648

+ 1 - 0
lib/App/Prove/Plugin/TestRail.pm

@@ -116,6 +116,7 @@ sub load {
     $ENV{'TESTRAIL_PROJ'}      = $params->{project};
     $ENV{'TESTRAIL_RUN'}       = $params->{run};
     $ENV{'TESTRAIL_PLAN'}      = $params->{plan};
+    $ENV{'TESTRAIL_PLAN_ID'}   = $params->{plan_id};
     $ENV{'TESTRAIL_CONFIGS'}   = $params->{configs};
     $ENV{'TESTRAIL_VERSION'}   = $params->{version};
     $ENV{'TESTRAIL_STEPS'}     = $params->{step_results};

+ 1 - 0
lib/Test/Rail/Harness.pm

@@ -50,6 +50,7 @@ sub make_parser {
     $args->{'project'}  = $ENV{'TESTRAIL_PROJ'};
     $args->{'run'}      = $ENV{'TESTRAIL_RUN'};
     $args->{'plan'}     = $ENV{'TESTRAIL_PLAN'};
+    $args->{'plan_id'}  = $ENV{'TESTRAIL_PLAN_ID'};
     @configs = split(/:/,$ENV{'TESTRAIL_CONFIGS'}) if $ENV{'TESTRAIL_CONFIGS'};
     $args->{'configs'}         = \@configs if scalar(@configs);
     $args->{'result_options'}  = {'version' => $ENV{'TESTRAIL_VERSION'}} if $ENV{'TESTRAIL_VERSION'};

+ 6 - 1
lib/Test/Rail/Parser.pm

@@ -151,6 +151,7 @@ sub new {
         'project_id'   => delete $opts->{'project_id'},
         'step_results' => delete $opts->{'step_results'},
         'plan'         => delete $opts->{'plan'},
+        'plan_id'      => delete $opts->{'plan_id'},
         'configs'      => delete $opts->{'configs'} // [],
         'testsuite_id' => delete $opts->{'testsuite_id'},
         'testsuite'    => delete $opts->{'testsuite'},
@@ -249,7 +250,11 @@ sub new {
 
     if ($tropts->{'plan'}) {
         #Attempt to find run, filtered by configurations
-        $plan = $tr->getPlanByName($tropts->{'project_id'},$tropts->{'plan'});
+        if ( $tropts->{'plan_id'} ) {
+          $plan = $tr->getPlanByID( $tropts->{'plan_id'} );
+        } else {
+          $plan = $tr->getPlanByName( $tropts->{'project_id'}, $tropts->{'plan'} );
+        }
         confess("Test plan provided is completed, and spawning was not indicated") if (ref $plan eq 'HASH') && $plan->{'is_completed'} && (!$tropts->{'testsuite_id'});
         if ($plan && !$plan->{'is_completed'}) {
             $tropts->{'plan'} = $plan;