88import shutil
99import logging
1010import sys
11+ import requests
1112
1213pkg_root = os .path .abspath (os .path .join (os .path .dirname (__file__ ), '..' )) # noqa
1314sys .path .insert (0 , pkg_root ) # noqa
@@ -60,7 +61,7 @@ def test_dockstore_md5sum(self):
6061 json_input = self .cwl_json_input ,
6162 workflow_attachment = self .cwl_attachments )
6263 state = self .wait_for_finish (run_id )
63- assert state == "COMPLETE"
64+ self . check_complete ( run_id )
6465 self .assertTrue (check_for_file (outfile_path ), 'Output file was not found: ' + str (outfile_path ))
6566
6667 def test_local_md5sum (self ):
@@ -69,7 +70,7 @@ def test_local_md5sum(self):
6970 json_input = self .cwl_json_input ,
7071 workflow_attachment = self .cwl_attachments )
7172 state = self .wait_for_finish (run_id )
72- assert state == "COMPLETE"
73+ self . check_complete ( run_id )
7374 self .assertTrue (check_for_file (outfile_path ), 'Output file was not found: ' + str (outfile_path ))
7475
7576 def test_run_attachments (self ):
@@ -79,7 +80,7 @@ def test_run_attachments(self):
7980 workflow_attachment = self .cwl_attachments )
8081 get_response = self .client .get_run_log (run_id )["request" ]
8182 state = self .wait_for_finish (run_id )
82- assert state == "COMPLETE"
83+ self . check_complete ( run_id )
8384 self .assertTrue (check_for_file (outfile_path ), 'Output file was not found: ' + get_response ["workflow_attachment" ])
8485 attachment_tool_path = get_response ["workflow_attachment" ][7 :] + "/dockstore-tool-md5sum.cwl"
8586 self .assertTrue (check_for_file (attachment_tool_path ), 'Attachment file was not found: ' + get_response ["workflow_attachment" ])
@@ -137,6 +138,14 @@ def wait_for_finish(self, run_id, seconds=120):
137138 r = self .client .get_run_status (run_id )
138139 return r ["state" ]
139140
141+ def check_complete (self , run_id ):
142+ s = self .client .get_run_log (run_id )
143+ if s ["state" ] != "COMPLETE" :
144+ logging .info (str (s ["run_log" ]["stderr" ]))
145+ if str (s ["run_log" ]["stderr" ]).startswith ("http" ):
146+ logs = requests .get (s ["run_log" ]["stderr" ], headers = auth ).text
147+ logging .info ("Run log:\n " + logs )
148+ assert s ["state" ] == "COMPLETE"
140149
141150def get_server_pids ():
142151 try :
0 commit comments