Skip to content

Commit 6574402

Browse files
author
Peter Amstutz
committed
test_integration also tests Arvados backend
1 parent 63effb9 commit 6574402

File tree

2 files changed

+41
-17
lines changed

2 files changed

+41
-17
lines changed

test/test_integration.py

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def test_dockstore_md5sum(self):
6262
workflow_attachment=self.cwl_attachments)
6363
state = self.wait_for_finish(run_id)
6464
self.check_complete(run_id)
65-
self.assertTrue(check_for_file(outfile_path), 'Output file was not found: ' + str(outfile_path))
65+
self.assertTrue(self.check_for_file(outfile_path), 'Output file was not found: ' + str(outfile_path))
6666

6767
def test_local_md5sum(self):
6868
"""LOCAL md5sum cwl to the wes-service server, and check for the correct output."""
@@ -71,7 +71,7 @@ def test_local_md5sum(self):
7171
workflow_attachment=self.cwl_attachments)
7272
state = self.wait_for_finish(run_id)
7373
self.check_complete(run_id)
74-
self.assertTrue(check_for_file(outfile_path), 'Output file was not found: ' + str(outfile_path))
74+
self.assertTrue(self.check_for_file(outfile_path), 'Output file was not found: ' + str(outfile_path))
7575

7676
def test_run_attachments(self):
7777
"""LOCAL md5sum cwl to the wes-service server, check for attachments."""
@@ -81,9 +81,9 @@ def test_run_attachments(self):
8181
get_response = self.client.get_run_log(run_id)["request"]
8282
state = self.wait_for_finish(run_id)
8383
self.check_complete(run_id)
84-
self.assertTrue(check_for_file(outfile_path), 'Output file was not found: ' + get_response["workflow_attachment"])
84+
self.assertTrue(self.check_for_file(outfile_path), 'Output file was not found: ' + get_response["workflow_attachment"])
8585
attachment_tool_path = get_response["workflow_attachment"][7:] + "/dockstore-tool-md5sum.cwl"
86-
self.assertTrue(check_for_file(attachment_tool_path), 'Attachment file was not found: ' + get_response["workflow_attachment"])
86+
self.assertTrue(self.check_for_file(attachment_tool_path), 'Attachment file was not found: ' + get_response["workflow_attachment"])
8787

8888
def test_get_service_info(self):
8989
"""
@@ -143,10 +143,21 @@ def check_complete(self, run_id):
143143
if s["state"] != "COMPLETE":
144144
logging.info(str(s["run_log"]["stderr"]))
145145
if str(s["run_log"]["stderr"]).startswith("http"):
146-
logs = requests.get(s["run_log"]["stderr"], headers=auth).text
146+
logs = requests.get(s["run_log"]["stderr"], headers=self.client.auth).text
147147
logging.info("Run log:\n" + logs)
148148
assert s["state"] == "COMPLETE"
149149

150+
def check_for_file(self, filepath, seconds=120):
151+
"""Return True if a file exists within a certain amount of time."""
152+
wait_counter = 0
153+
while not os.path.exists(filepath):
154+
time.sleep(1)
155+
wait_counter += 1
156+
if wait_counter > seconds:
157+
return False
158+
return True
159+
160+
150161
def get_server_pids():
151162
try:
152163
pids = subprocess.check_output(['pgrep', '-f', 'wes_service_main.py']).strip().split()
@@ -155,16 +166,6 @@ def get_server_pids():
155166
return pids
156167

157168

158-
def check_for_file(filepath, seconds=120):
159-
"""Return True if a file exists within a certain amount of time."""
160-
wait_counter = 0
161-
while not os.path.exists(filepath):
162-
time.sleep(1)
163-
wait_counter += 1
164-
if wait_counter > seconds:
165-
return False
166-
return True
167-
168169

169170
class CwltoolTest(IntegrationTest):
170171
"""Test using cwltool."""
@@ -205,8 +206,31 @@ def test_local_wdl(self):
205206
outfile_path, run_id = self.run_md5sum(wf_input=self.wdl_local_path,
206207
json_input=self.wdl_json_input,
207208
workflow_attachment=self.wdl_attachments)
208-
self.assertTrue(check_for_file(outfile_path), 'Output file was not found: ' + str(outfile_path))
209+
self.assertTrue(self.check_for_file(outfile_path), 'Output file was not found: ' + str(outfile_path))
210+
211+
212+
class ArvadosTest(IntegrationTest):
213+
"""Test using arvados-cwl-runner."""
214+
215+
def setUp(self):
216+
"""
217+
Start a (local) wes-service server to make requests against.
218+
Use arvados-cwl-runner as the wes-service server 'backend'.
219+
Requires ARVADOS_API_HOST and ARVADOS_API_TOKEN to be set in the environment.
220+
"""
221+
if os.path.exists('workflows'):
222+
shutil.rmtree('workflows')
223+
self.wes_server_process = subprocess.Popen(
224+
['python', os.path.abspath('wes_service/wes_service_main.py'),
225+
'--backend=wes_service.arvados_wes',
226+
'--port=8080',
227+
'--debug'])
228+
self.client.auth = {"Authorization": "Bearer " + os.environ["ARVADOS_API_TOKEN"]}
229+
time.sleep(5)
209230

231+
def check_for_file(self, filepath, seconds=120):
232+
# Doesn't make sense for arvados
233+
return True
210234

211235
# Prevent pytest/unittest's discovery from attempting to discover the base test class.
212236
del IntegrationTest

wes_service/arvados_wes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def invoke_cwl_runner(self, cr_uuid, workflow_url, workflow_params,
145145
# a-c-r submission processes from seeing each other.
146146

147147
cmd = ["arvados-cwl-runner", "--submit-request-uuid="+cr_uuid,
148-
"--submit", "--no-wait", "--api=containers"]
148+
"--submit", "--no-wait", "--api=containers", "--debug"]
149149

150150
if project_uuid:
151151
cmd.append("--project-uuid="+project_uuid)

0 commit comments

Comments
 (0)