2761: wait for the pipeline run to complete or until wait time exceeds.
authorradhika <radhika@curoverse.com>
Wed, 10 Sep 2014 19:32:39 +0000 (15:32 -0400)
committerradhika <radhika@curoverse.com>
Wed, 10 Sep 2014 19:32:39 +0000 (15:32 -0400)
apps/workbench/config/application.default.yml
apps/workbench/test/diagnostics/pipeline_test.rb
apps/workbench/test/diagnostics_test_helper.rb

index 2b1a49b5aa86b11a790296f9e483f65679726a32..2106aa222295494df54a043941e813ac88f1d415 100644 (file)
@@ -156,12 +156,18 @@ common:
   #   input_paths: an array of inputs for the pipeline. Use either a collection's "uuid"
   #     or a file's "uuid/file_name" path in this array. If the pipeline does not require
   #     any inputs, this can be omitted. 
+  #   max_wait_seconds: max time in seconds to wait for the pipeline run to complete.
+  #     Default value of 30 seconds is used when this value is not provided.
   #diagnostics_testing_user_tokens:
   #  active: eu33jurqntstmwo05h1jr3eblmi961e802703y6657s8zb14r
   #diagnostics_testing_pipeline_fields:
-  #  tutorial pipeline:
+  #  pipeline with one input:
   #    template_uuid: zzzzz-p5p6p-rxj8d71854j9idn
-  #    input_paths: [zzzzz-4zz18-u9pmni8msw9zm9n]
-  #  tutorial pipeline 2:
+  #    input_paths: [qr1hi-4zz18-wu1s009qgnvgjc9]
+  #    max_wait_seconds: 100
+  #  pipeline with two inputs:
+  #    template_uuid: zzzzz-p5p6p-kfwus81of6y3ezs
+  #    input_paths: [2051b5d448fbd489ab00bbdedbee1ffa+91, e5e440c9c486df057e1bf6a7feac25be+77/alignment_summary_metrics.txt]
+  #    max_wait_seconds: 200
+  #  pipeline with no inputs:
   #    template_uuid: zzzzz-p5p6p-kfwus81of6y3ezs
-  #    input_paths: [zzzzz-4zz18-u9pmni8msw9zm9n]
index 2f20b00a00a1d8b4178cf50e05d5ad3a0d690602..f5e903f94aaa39abbd8eeea288a8e6053c522b6f 100644 (file)
@@ -37,9 +37,12 @@ class PipelineTest < DiagnosticsTest
         # This pipeline needs input. So, Run should be disabled
         page.assert_selector 'a.disabled,button.disabled', text: 'Run'
 
-        inputs_needed = page.all('.btn', text: 'Choose')
-        inputs_needed.each_with_index do |input_needed, index|
-          input_needed.click
+        index = 0
+        while true
+          inputs_needed = page.all('.btn', text: 'Choose')
+          break if !inputs_needed.any?
+
+          inputs_needed[0].click
           within('.modal-dialog') do
             look_for = pipeline_config['input_paths'][index]
             found = page.has_text?(look_for)
@@ -52,15 +55,19 @@ class PipelineTest < DiagnosticsTest
             end
             find('button', text: 'OK').click
             wait_for_ajax
+            index += 1
           end
         end
       end
 
-      # Run this pipeline instance
+      # All needed input are filled in. Run this pipeline now
       find('a,button', text: 'Run').click
 
       # Pipeline is running. We have a "Stop" button instead now.
       page.assert_selector 'a,button', text: 'Stop'
+
+      # Wait for pipeline run to complete
+      wait_until_page_has 'Complete', pipeline_config['max_wait_seconds']
     end
   end
 
index 2d378f3cc253a2ed6dfa4346a8ed79a74b874b1d..a78bf6649f2dc51ca8f9aa80349c53c36381c347 100644 (file)
@@ -12,4 +12,11 @@ class DiagnosticsTest < ActionDispatch::IntegrationTest
     Rails.configuration.diagnostics_testing_pipeline_fields[pipeline_to_run]
   end
 
+  def wait_until_page_has text_to_look_for, max_time=30
+    max_time = 30 if (!max_time || (max_time.to_s != max_time.to_i.to_s))
+    Timeout.timeout(max_time) do
+      loop until page.has_text?(text_to_look_for)
+    end
+  end
+
 end