瀏覽代碼

Cache connections by default

George S. Baugh 8 年之前
父節點
當前提交
90bf6a6143
共有 4 個文件被更改,包括 14 次插入1 次删除
  1. 1 0
      Changes
  2. 8 0
      bin/testrail-results
  3. 3 1
      lib/TestRail/API.pm
  4. 2 0
      lib/TestRail/Utils/Find.pm

+ 1 - 0
Changes

@@ -3,6 +3,7 @@ Revision history for Perl module TestRail::API
 0.039 2017-02-20 TEODESIAN
     - Fix issue where follow_post_redirect could not be passed to constructor
     - Add getRunResults, getRunResultsPaginated Methods in TestRail::API
+    - Cache connections by default for speedups
 
 0.038 2017-01-23 TEODESIAN
     - Optimize TestRail::Utils::Find::getResults and testrail-results

+ 8 - 0
bin/testrail-results

@@ -133,6 +133,8 @@ sub run {
         'd|defect=s@'     => \$opts->{'defects'},
         'v|version=s@'    => \$opts->{'versions'},
         'c|cachefile=s'   => \$opts->{'cachefile'},
+        'f|fast'          => \$opts->{'fast'},
+        't|testsuite'     => \$opts->{'testsuite'},
         'json'            => \$opts->{'json'},
         'h|help'          => \$opts->{'help'},
     );
@@ -165,6 +167,12 @@ sub run {
         $opts->{'plan_ids'} = $prior_plans;
     }
 
+    if ($opts->{'fast'}) {
+        my $project = $tr->getProjectByName($opts->{project});
+        $opts->{testsuite} = $tr->getTestsuiteByName($project->{id},$opts->{testsuite});
+        confess("Could not determine the relevant testsuite!") unless ref($opts->{testsuite}) eq 'HASH';
+    }
+
     my ($res,$seen_plans) = TestRail::Utils::Find::getResults($tr,$opts,$prior_runs,@{$params{'args'}});
 
     #Make sure subsequent runs keep ignoring the prior plans

+ 3 - 1
lib/TestRail/API.pm

@@ -106,7 +106,9 @@ sub new {
         tr_fields        => undef,
         default_request  => undef,
         global_limit     => 250, #Discovered by experimentation
-        browser          => new LWP::UserAgent(),
+        browser          => new LWP::UserAgent(
+            keep_alive => 1,
+        ),
         do_post_redirect => $do_post_redirect
     };
 

+ 2 - 0
lib/TestRail/Utils/Find.pm

@@ -345,6 +345,8 @@ Valid Options:
 
 =item B<defects> - ARRAYREF of defects of which at least one must be present in a result.
 
+=item B<fast> - Whether to get only the latest result from the test in your run(s).  This can significantly speed up operations.
+
 =back
 
 =cut