Build script fix: make sure that run-build-docker-jobs-image.sh always
[arvados.git] / sdk / cwl / tests / test_job.py
1 import unittest
2 import mock
3 import arvados_cwl
4
5 class TestJob(unittest.TestCase):
6
7     # The test passes no builder.resources
8     # Hence the default resources will apply: {'cores': 1, 'ram': 1024, 'outdirSize': 1024, 'tmpdirSize': 1024}
9     def test_run(self):
10         runner = mock.MagicMock()
11         runner.project_uuid = "zzzzz-8i9sb-zzzzzzzzzzzzzzz"
12         tool = {
13             "inputs": [],
14             "outputs": [],
15             "baseCommand": "ls"
16         }
17         arvtool = arvados_cwl.ArvadosCommandTool(runner, tool)
18         arvtool.formatgraph = None
19         for j in arvtool.job({}, "", mock.MagicMock()):
20             j.run()
21         runner.api.jobs().create.assert_called_with(body={
22             'owner_uuid': 'zzzzz-8i9sb-zzzzzzzzzzzzzzz',
23             'runtime_constraints': {},
24             'script_parameters': {
25                 'tasks': [{
26                     'task.env': {'TMPDIR': '$(task.tmpdir)'},
27                     'command': ['ls']
28                 }],
29                 'crunchrunner': 'ff6fc71e593081ef9733afacaeee15ea+140/crunchrunner'
30             },
31             'script_version': 'master',
32             'minimum_script_version': '9e5b98e8f5f4727856b53447191f9c06e3da2ba6',
33             'repository': 'arvados',
34             'script': 'crunchrunner',
35             'runtime_constraints': {
36                 'min_cores_per_node': 1,
37                 'min_ram_mb_per_node': 1024,
38                 'min_scratch_mb_per_node': 2048 # tmpdirSize + outdirSize
39             }
40         }, find_or_create=True)
41
42     # The test passes some fields in builder.resources
43     # For the remaining fields, the defaults will apply: {'cores': 1, 'ram': 1024, 'outdirSize': 1024, 'tmpdirSize': 1024}
44     def test_resource_requirements(self):
45         runner = mock.MagicMock()
46         runner.project_uuid = "zzzzz-8i9sb-zzzzzzzzzzzzzzz"
47         tool = {
48             "inputs": [],
49             "outputs": [],
50             "hints": [{
51                 "class": "ResourceRequirement",
52                 "coresMin": 3,
53                 "ramMin": 3000,
54                 "tmpdirMin": 4000
55             }],
56             "baseCommand": "ls"
57         }
58         arvtool = arvados_cwl.ArvadosCommandTool(runner, tool)
59         arvtool.formatgraph = None
60         for j in arvtool.job({}, "", mock.MagicMock()):
61             j.run()
62         runner.api.jobs().create.assert_called_with(body={
63             'owner_uuid': 'zzzzz-8i9sb-zzzzzzzzzzzzzzz',
64             'runtime_constraints': {},
65             'script_parameters': {
66                 'tasks': [{
67                     'task.env': {'TMPDIR': '$(task.tmpdir)'},
68                     'command': ['ls']
69                 }],
70                 'crunchrunner': 'ff6fc71e593081ef9733afacaeee15ea+140/crunchrunner'
71             },
72             'script_version': 'master',
73             'minimum_script_version': '9e5b98e8f5f4727856b53447191f9c06e3da2ba6',
74             'repository': 'arvados',
75             'script': 'crunchrunner',
76             'runtime_constraints': {
77                 'min_cores_per_node': 3,
78                 'min_ram_mb_per_node': 3000,
79                 'min_scratch_mb_per_node': 5024 # tmpdirSize + outdirSize
80             }
81         }, find_or_create=True)