Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
158 changes: 158 additions & 0 deletions tests/functional/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,164 @@ def get_registry_no_auto_pyramid(_container):
result = mocked_sub_requests(self.app, self.client.deploy, test_id, cwl=package)
assert result.success

def test_deploy_multi_cwl(self):
"""
Test deploying multiple CWL files (workflow with tools) using the CLI.
"""
# Create tool CWL definitions
tool1_id = f"{self.test_process_prefix}tool-1"
tool1_cwl = {
"cwlVersion": "v1.2",
"class": "CommandLineTool",
"id": tool1_id,
"baseCommand": ["echo"],
"requirements": {
"DockerRequirement": {
"dockerPull": "debian:stretch-slim"
}
},
"inputs": {"input": {"type": "string", "inputBinding": {"position": 1}}},
"outputs": {"output": {"type": "stdout"}},
"stdout": "output.txt"
}

tool2_id = f"{self.test_process_prefix}tool-2"
tool2_cwl = {
"cwlVersion": "v1.2",
"class": "CommandLineTool",
"id": tool2_id,
"baseCommand": ["cat"],
"requirements": {
"DockerRequirement": {
"dockerPull": "debian:stretch-slim"
}
},
"inputs": {"file": {"type": "File", "inputBinding": {"position": 1}}},
"outputs": {"output": {"type": "stdout"}},
"stdout": "output.txt"
}

# Create workflow that uses the tools
test_id = f"{self.test_process_prefix}multi-cwl-workflow"
workflow_cwl = {
"cwlVersion": "v1.2",
"class": "Workflow",
"id": test_id,
"inputs": {
"message": {"type": "string"}
},
"outputs": {
"result": {
"type": "File",
"outputSource": "step2/output"
}
},
"steps": {
"step1": {
"run": tool1_id,
"in": {"input": "message"},
"out": ["output"]
},
"step2": {
"run": tool2_id,
"in": {"file": "step1/output"},
"out": ["output"]
}
}
}

with tempfile.TemporaryDirectory() as tmp_dir:
tool1_path = os.path.join(tmp_dir, "tool-1.cwl")
tool2_path = os.path.join(tmp_dir, "tool-2.cwl")
workflow_path = os.path.join(tmp_dir, "workflow.cwl")

with open(tool1_path, "w", encoding="utf-8") as f:
json.dump(tool1_cwl, f)
with open(tool2_path, "w", encoding="utf-8") as f:
json.dump(tool2_cwl, f)
with open(workflow_path, "w", encoding="utf-8") as f:
json.dump(workflow_cwl, f)

# Deploy using list of CWL files
result = mocked_sub_requests(
self.app,
self.client.deploy,
test_id,
cwl=[tool1_path, tool2_path, workflow_path]
)

assert result.success
assert "processSummary" in result.body
assert result.body["processSummary"]["id"] == test_id
assert "deploymentDone" in result.body
assert result.body["deploymentDone"] is True

# Verify the workflow was deployed
result = mocked_sub_requests(self.app, self.client.describe, test_id)
assert result.success
assert result.body["id"] == test_id
assert result.body["processDescriptionURL"]

def test_deploy_multi_cwl_tools_only(self):
"""
Test deploying multiple CWL tool files using the CLI.
"""
tool1_id = f"{self.test_process_prefix}multi-tool-1"
tool1_cwl = {
"cwlVersion": "v1.2",
"class": "CommandLineTool",
"id": tool1_id,
"baseCommand": ["echo"],
"requirements": {
"DockerRequirement": {
"dockerPull": "debian:stretch-slim"
}
},
"inputs": {"input": {"type": "string", "inputBinding": {"position": 1}}},
"outputs": {"output": {"type": "stdout"}},
"stdout": "output.txt"
}

tool2_id = f"{self.test_process_prefix}multi-tool-2"
tool2_cwl = {
"cwlVersion": "v1.2",
"class": "CommandLineTool",
"id": tool2_id,
"baseCommand": ["cat"],
"requirements": {
"DockerRequirement": {
"dockerPull": "debian:stretch-slim"
}
},
"inputs": {"file": {"type": "File", "inputBinding": {"position": 1}}},
"outputs": {"output": {"type": "stdout"}},
"stdout": "output.txt"
}

with tempfile.TemporaryDirectory() as tmp_dir:
tool1_path = os.path.join(tmp_dir, "tool-1.cwl")
tool2_path = os.path.join(tmp_dir, "tool-2.cwl")

with open(tool1_path, "w", encoding="utf-8") as f:
json.dump(tool1_cwl, f)
with open(tool2_path, "w", encoding="utf-8") as f:
json.dump(tool2_cwl, f)

# Deploy using list of CWL files - should deploy the first tool as main
result = mocked_sub_requests(
self.app,
self.client.deploy,
tool1_id,
cwl=[tool1_path, tool2_path]
)

assert result.success
assert "processSummary" in result.body
# When deploying multiple tools without workflow, first tool becomes main
assert result.body["processSummary"]["id"] == tool1_id
assert "deploymentDone" in result.body
assert result.body["deploymentDone"] is True

def test_undeploy(self):
# deploy a new process to leave the test one available
other_payload = copy.deepcopy(self.test_payload["Echo"])
Expand Down
Loading
Loading