@@ -23,7 +23,7 @@ class IntegrationTest(unittest.TestCase):
2323 def setUpClass (cls ):
2424 # cwl
2525 cls .cwl_dockstore_url = 'https://dockstore.org:8443/api/ga4gh/v2/tools/quay.io%2Fbriandoconnor%2Fdockstore-tool-md5sum/versions/master/plain-CWL/descriptor/%2FDockstore.cwl'
26- cls .cwl_local_path = os .path .abspath ('testdata/md5sum.cwl' )
26+ cls .cwl_local_path = "file://" + os .path .abspath ('testdata/md5sum.cwl' )
2727 cls .cwl_json_input = "file://" + os .path .abspath ('testdata/md5sum.json' )
2828 cls .cwl_attachments = ['file://' + os .path .abspath ('testdata/md5sum.input' ),
2929 'file://' + os .path .abspath ('testdata/dockstore-tool-md5sum.cwl' )]
@@ -52,22 +52,24 @@ def tearDown(self):
5252 time .sleep (3 )
5353 except OSError as e :
5454 print (e )
55- if os .path .exists ('workflows' ):
56- shutil .rmtree ('workflows' )
5755 unittest .TestCase .tearDown (self )
5856
5957 def test_dockstore_md5sum (self ):
6058 """HTTP md5sum cwl (dockstore), run it on the wes-service server, and check for the correct output."""
61- outfile_path , _ = self .run_md5sum (wf_input = self .cwl_dockstore_url ,
59+ outfile_path , run_id = self .run_md5sum (wf_input = self .cwl_dockstore_url ,
6260 json_input = self .cwl_json_input ,
6361 workflow_attachment = self .cwl_attachments )
62+ state = self .wait_for_finish (run_id )
63+ assert state == "COMPLETE"
6464 self .assertTrue (check_for_file (outfile_path ), 'Output file was not found: ' + str (outfile_path ))
6565
6666 def test_local_md5sum (self ):
6767 """LOCAL md5sum cwl to the wes-service server, and check for the correct output."""
6868 outfile_path , run_id = self .run_md5sum (wf_input = self .cwl_local_path ,
6969 json_input = self .cwl_json_input ,
7070 workflow_attachment = self .cwl_attachments )
71+ state = self .wait_for_finish (run_id )
72+ assert state == "COMPLETE"
7173 self .assertTrue (check_for_file (outfile_path ), 'Output file was not found: ' + str (outfile_path ))
7274
7375 def test_run_attachments (self ):
@@ -76,6 +78,8 @@ def test_run_attachments(self):
7678 json_input = self .cwl_json_input ,
7779 workflow_attachment = self .cwl_attachments )
7880 get_response = self .client .get_run_log (run_id )["request" ]
81+ state = self .wait_for_finish (run_id )
82+ assert state == "COMPLETE"
7983 self .assertTrue (check_for_file (outfile_path ), 'Output file was not found: ' + get_response ["workflow_attachment" ])
8084 attachment_tool_path = get_response ["workflow_attachment" ][7 :] + "/dockstore-tool-md5sum.cwl"
8185 self .assertTrue (check_for_file (attachment_tool_path ), 'Attachment file was not found: ' + get_response ["workflow_attachment" ])
@@ -90,7 +94,7 @@ def test_get_service_info(self):
9094 assert 'workflow_type_versions' in r
9195 assert 'supported_wes_versions' in r
9296 assert 'supported_filesystem_protocols' in r
93- assert 'engine_versions ' in r
97+ assert 'workflow_engine_versions ' in r
9498
9599 def test_list_runs (self ):
96100 """
@@ -121,6 +125,18 @@ def run_md5sum(self, wf_input, json_input, workflow_attachment=None):
121125 output_dir = os .path .abspath (os .path .join ('workflows' , response ['run_id' ], 'outdir' ))
122126 return os .path .join (output_dir , 'md5sum.txt' ), response ['run_id' ]
123127
128+ def wait_for_finish (self , run_id , seconds = 120 ):
129+ """Return True if a file exists within a certain amount of time."""
130+ wait_counter = 0
131+ r = self .client .get_run_status (run_id )
132+ while r ["state" ] in ("QUEUED" , "INITIALIZING" , "RUNNING" ):
133+ time .sleep (1 )
134+ wait_counter += 1
135+ if wait_counter > seconds :
136+ return None
137+ r = self .client .get_run_status (run_id )
138+ return r ["state" ]
139+
124140
125141def get_server_pids ():
126142 try :
@@ -149,9 +165,13 @@ def setUp(self):
149165 Start a (local) wes-service server to make requests against.
150166 Use cwltool as the wes-service server 'backend'.
151167 """
168+ if os .path .exists ('workflows' ):
169+ shutil .rmtree ('workflows' )
152170 self .wes_server_process = subprocess .Popen (
153- 'python {}' .format (os .path .abspath ('wes_service/wes_service_main.py' )),
154- shell = True )
171+ ['python' , os .path .abspath ('wes_service/wes_service_main.py' ),
172+ '--backend=wes_service.cwl_runner' ,
173+ '--port=8080' ,
174+ '--debug' ])
155175 time .sleep (5 )
156176
157177
0 commit comments