Skip to content

Commit 4c048dc

Browse files
committed
Adds a more elaborate depends_on test
1 parent e0809eb commit 4c048dc

File tree

3 files changed

+235
-12
lines changed

3 files changed

+235
-12
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ tools/sgx_enable
1919
venv/
2020
lib/hardware_info_root.py
2121
tools/cluster/cleanup.sh
22+
node_modules/
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
# test-container-1
2+
# ├── test-container-2
3+
# │ ├── test-container-3
4+
# │ │ ├── test-container-5
5+
# │ │ │ ├── test-container-15
6+
# │ │ │ │ └── test-container-20
7+
# │ │ │ └── test-container-6
8+
# │ │ ├── test-container-9
9+
# │ │ │ └── test-container-17
10+
# │ │ └── test-container-13
11+
# │ │ └── test-container-19
12+
# │ ├── test-container-4
13+
# │ │ ├── test-container-6
14+
# │ │ ├── test-container-10
15+
# │ │ │ └── test-container-17
16+
# │ │ ├── test-container-14
17+
# │ │ │ └── test-container-19
18+
# │ │ └── test-container-7
19+
# │ │ └── test-container-16
20+
# │ └── test-container-8
21+
# │ └── test-container-16
22+
# │ └── test-container-20
23+
# └── test-container-7
24+
# └── test-container-16
25+
# └── test-container-20
26+
# └── test-container-11
27+
# └── test-container-18
28+
# └── test-container-12
29+
# └── test-container-18
30+
31+
name: Test depends_on with loads of depends
32+
author: Didi Hoffmann
33+
description: test
34+
35+
services:
36+
test-container-20:
37+
image: alpine
38+
depends_on:
39+
- test-container-16
40+
- test-container-15
41+
42+
test-container-19:
43+
image: alpine
44+
depends_on:
45+
- test-container-14
46+
- test-container-13
47+
48+
test-container-18:
49+
image: alpine
50+
depends_on:
51+
- test-container-12
52+
- test-container-11
53+
54+
test-container-17:
55+
image: alpine
56+
depends_on:
57+
- test-container-10
58+
- test-container-9
59+
60+
test-container-16:
61+
image: alpine
62+
depends_on:
63+
- test-container-8
64+
- test-container-7
65+
66+
test-container-15:
67+
image: alpine
68+
depends_on:
69+
- test-container-6
70+
- test-container-5
71+
72+
test-container-14:
73+
image: alpine
74+
depends_on:
75+
- test-container-4
76+
77+
test-container-13:
78+
image: alpine
79+
depends_on:
80+
- test-container-3
81+
82+
test-container-12:
83+
image: alpine
84+
depends_on:
85+
- test-container-2
86+
87+
test-container-11:
88+
image: alpine
89+
depends_on:
90+
- test-container-1
91+
92+
test-container-10:
93+
image: alpine
94+
depends_on:
95+
- test-container-4
96+
97+
test-container-9:
98+
image: alpine
99+
depends_on:
100+
- test-container-3
101+
102+
test-container-8:
103+
image: alpine
104+
depends_on:
105+
- test-container-2
106+
107+
test-container-7:
108+
image: alpine
109+
depends_on:
110+
- test-container-1
111+
112+
test-container-6:
113+
image: alpine
114+
depends_on:
115+
- test-container-4
116+
117+
test-container-5:
118+
image: alpine
119+
depends_on:
120+
- test-container-3
121+
122+
test-container-4:
123+
image: alpine
124+
depends_on:
125+
- test-container-2
126+
127+
test-container-3:
128+
image: alpine
129+
depends_on:
130+
- test-container-1
131+
132+
test-container-2:
133+
image: alpine
134+
depends_on:
135+
- test-container-1
136+
137+
test-container-1:
138+
image: alpine
139+
140+
141+
flow:
142+
- name: dummy
143+
container: test-container-1
144+
commands:
145+
- type: console
146+
command: pwd

tests/test_usage_scenario.py

Lines changed: 88 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,17 @@ def get_contents_of_bound_volume(runner):
222222
Tests.cleanup(runner)
223223
return ls
224224

225+
def assert_order(text, first, second):
226+
index1 = text.find(first)
227+
index2 = text.find(second)
228+
229+
assert index1 != -1 and index2 != -1, \
230+
Tests.assertion_info(f"stdout contain the container names '{first}' and '{second}'.", \
231+
f"stdout doesn't contain '{first}' and/or '{second}'.")
232+
233+
assert index1 < index2, Tests.assertion_info(f'{first} should start first, \
234+
because it is a dependency of {second}.', f'{second} started first')
235+
225236
# depends_on: [array] (optional)
226237
# Array of container names to express dependencies
227238
def test_depends_on_order():
@@ -236,20 +247,85 @@ def test_depends_on_order():
236247
runner.cleanup()
237248

238249
# Expected order: test-container-2, test-container-4, test-container-3, test-container-1
239-
assert_order(out.getvalue(), "test-container-2", "test-container-4")
240-
assert_order(out.getvalue(), "test-container-4", "test-container-3")
241-
assert_order(out.getvalue(), "test-container-3", "test-container-1")
250+
assert_order(out.getvalue(), 'test-container-2', 'test-container-4')
251+
assert_order(out.getvalue(), 'test-container-4', 'test-container-3')
252+
assert_order(out.getvalue(), 'test-container-3', 'test-container-1')
242253

243-
def assert_order(text, first, second):
244-
index1 = text.find(first)
245-
index2 = text.find(second)
246254

247-
assert index1 != -1 and index2 != -1, \
248-
Tests.assertion_info(f"stdout contain the container names '{first}' and '{second}'.", \
249-
f"stdout doesn't contain '{first}' and/or '{second}'.")
250-
251-
assert index1 < index2, Tests.assertion_info(f'{first} should start first, \
252-
because it is a dependency of {second}.', f'{second} started first')
255+
def test_depends_on_huge():
256+
out = io.StringIO()
257+
err = io.StringIO()
258+
runner = Tests.setup_runner(usage_scenario='depends_on_huge.yml', dry_run=True)
259+
260+
with redirect_stdout(out), redirect_stderr(err):
261+
try:
262+
Tests.run_until(runner, 'setup_services')
263+
finally:
264+
runner.cleanup()
265+
266+
# For test-container-20
267+
assert_order(out.getvalue(), 'test-container-16', 'test-container-20')
268+
assert_order(out.getvalue(), 'test-container-15', 'test-container-20')
269+
270+
# For test-container-19
271+
assert_order(out.getvalue(), 'test-container-14', 'test-container-19')
272+
assert_order(out.getvalue(), 'test-container-13', 'test-container-19')
273+
274+
# For test-container-18
275+
assert_order(out.getvalue(), 'test-container-12', 'test-container-18')
276+
assert_order(out.getvalue(), 'test-container-11', 'test-container-18')
277+
278+
# For test-container-17
279+
assert_order(out.getvalue(), 'test-container-10', 'test-container-17')
280+
assert_order(out.getvalue(), 'test-container-9', 'test-container-17')
281+
282+
# For test-container-16
283+
assert_order(out.getvalue(), 'test-container-8', 'test-container-16')
284+
assert_order(out.getvalue(), 'test-container-7', 'test-container-16')
285+
286+
# For test-container-15
287+
assert_order(out.getvalue(), 'test-container-6', 'test-container-15')
288+
assert_order(out.getvalue(), 'test-container-5', 'test-container-15')
289+
290+
# For test-container-14
291+
assert_order(out.getvalue(), 'test-container-4', 'test-container-14')
292+
293+
# For test-container-13
294+
assert_order(out.getvalue(), 'test-container-3', 'test-container-13')
295+
296+
# For test-container-12
297+
assert_order(out.getvalue(), 'test-container-2', 'test-container-12')
298+
299+
# For test-container-11
300+
assert_order(out.getvalue(), 'test-container-1', 'test-container-11')
301+
302+
# For test-container-10
303+
assert_order(out.getvalue(), 'test-container-4', 'test-container-10')
304+
305+
# For test-container-9
306+
assert_order(out.getvalue(), 'test-container-3', 'test-container-9')
307+
308+
# For test-container-8
309+
assert_order(out.getvalue(), 'test-container-2', 'test-container-8')
310+
311+
# For test-container-7
312+
assert_order(out.getvalue(), 'test-container-1', 'test-container-7')
313+
314+
# For test-container-6
315+
assert_order(out.getvalue(), 'test-container-4', 'test-container-6')
316+
317+
# For test-container-5
318+
assert_order(out.getvalue(), 'test-container-3', 'test-container-5')
319+
320+
# For test-container-4
321+
assert_order(out.getvalue(), 'test-container-2', 'test-container-4')
322+
323+
# For test-container-3
324+
assert_order(out.getvalue(), 'test-container-1', 'test-container-3')
325+
326+
# For test-container-2
327+
assert_order(out.getvalue(), 'test-container-1', 'test-container-2')
328+
253329

254330
def test_depends_on_error_not_running():
255331
runner = Tests.setup_runner(usage_scenario='depends_on_error_not_running.yml', dry_run=True)

0 commit comments

Comments
 (0)