Skip to content

Commit d37c558

Browse files
authored
Merge pull request #1433 from avagin/wait_for_container
tests: don't call wait_for_container after synchronous operations
2 parents 7ffea26 + a9e15e7 commit d37c558

File tree

15 files changed

+43
-97
lines changed

15 files changed

+43
-97
lines changed

tests/integration/cgroups.bats

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ EOF
4747
# run a detached busybox to work with
4848
runc run -d --console-socket $CONSOLE_SOCKET test_cgroups_kmem
4949
[ "$status" -eq 0 ]
50-
wait_for_container 15 1 test_cgroups_kmem
5150

5251
# update kernel memory limit
5352
runc update test_cgroups_kmem --kernel-memory 50331648
@@ -67,7 +66,6 @@ EOF
6766
# run a detached busybox to work with
6867
runc run -d --console-socket $CONSOLE_SOCKET test_cgroups_kmem
6968
[ "$status" -eq 0 ]
70-
wait_for_container 15 1 test_cgroups_kmem
7169

7270
# update kernel memory limit
7371
runc update test_cgroups_kmem --kernel-memory 50331648

tests/integration/checkpoint.bats

Lines changed: 41 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -67,21 +67,33 @@ function teardown() {
6767
# setting terminal and root:readonly: to false
6868
sed -i 's;"terminal": true;"terminal": false;' config.json
6969
sed -i 's;"readonly": true;"readonly": false;' config.json
70-
sed -i 's/"sh"/"sh","-c","while :; do date; sleep 1; done"/' config.json
70+
sed -i 's/"sh"/"sh","-c","for i in `seq 10`; do read xxx || continue; echo ponG $xxx; done"/' config.json
7171

72-
(
73-
# run busybox (not detached)
74-
runc run test_busybox
75-
[ "$status" -eq 0 ]
76-
) &
72+
# The following code creates pipes for stdin and stdout.
73+
# CRIU can't handle fifo-s, so we need all these tricks.
74+
fifo=`mktemp -u /tmp/runc-fifo-XXXXXX`
75+
mkfifo $fifo
7776

78-
# check state
79-
wait_for_container 15 1 test_busybox
77+
# stdout
78+
cat $fifo | cat $fifo &
79+
pid=$!
80+
exec 50</proc/$pid/fd/0
81+
exec 51>/proc/$pid/fd/0
8082

81-
runc state test_busybox
82-
[ "$status" -eq 0 ]
83-
[[ "${output}" == *"running"* ]]
83+
# stdin
84+
cat $fifo | cat $fifo &
85+
pid=$!
86+
exec 60</proc/$pid/fd/0
87+
exec 61>/proc/$pid/fd/0
88+
89+
echo -n > $fifo
90+
unlink $fifo
8491

92+
# run busybox (not detached)
93+
__runc run -d test_busybox <&60 >&51 2>&51
94+
[ $? -eq 0 ]
95+
96+
testcontainer test_busybox running
8597

8698
#test checkpoint pre-dump
8799
mkdir parent-dir
@@ -95,24 +107,32 @@ function teardown() {
95107

96108
# checkpoint the running container
97109
mkdir image-dir
98-
runc --criu "$CRIU" checkpoint --parent-path ./parent-dir --image-path ./image-dir test_busybox
110+
mkdir work-dir
111+
runc --criu "$CRIU" checkpoint --parent-path ./parent-dir --work-path ./work-dir --image-path ./image-dir test_busybox
112+
cat ./work-dir/dump.log | grep -B 5 Error || true
99113
[ "$status" -eq 0 ]
100114

101115
# after checkpoint busybox is no longer running
102116
runc state test_busybox
103117
[ "$status" -ne 0 ]
104118

105119
# restore from checkpoint
106-
(
107-
runc --criu "$CRIU" restore --image-path ./image-dir test_busybox
108-
[ "$status" -eq 0 ]
109-
) &
110-
111-
# check state
112-
wait_for_container 15 1 test_busybox
120+
__runc --criu "$CRIU" restore -d --work-path ./work-dir --image-path ./image-dir test_busybox <&60 >&51 2>&51
121+
ret=$?
122+
cat ./work-dir/restore.log | grep -B 5 Error || true
123+
[ $ret -eq 0 ]
113124

114125
# busybox should be back up and running
115-
runc state test_busybox
126+
testcontainer test_busybox running
127+
128+
runc exec --cwd /bin test_busybox echo ok
116129
[ "$status" -eq 0 ]
117-
[[ "${output}" == *"running"* ]]
130+
[[ ${output} == "ok" ]]
131+
132+
echo Ping >&61
133+
exec 61>&-
134+
exec 51>&-
135+
run cat <&50
136+
[ "$status" -eq 0 ]
137+
[[ "${output}" == *"ponG Ping"* ]]
118138
}

tests/integration/delete.bats

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ function teardown() {
1717
[ "$status" -eq 0 ]
1818

1919
# check state
20-
wait_for_container 15 1 test_busybox
21-
2220
testcontainer test_busybox running
2321

2422
runc kill test_busybox KILL
@@ -40,8 +38,6 @@ function teardown() {
4038
[ "$status" -eq 0 ]
4139

4240
# check state
43-
wait_for_container 15 1 test_busybox
44-
4541
testcontainer test_busybox running
4642

4743
# force delete test_busybox

tests/integration/events.bats

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ function teardown() {
1919
runc run -d --console-socket $CONSOLE_SOCKET test_busybox
2020
[ "$status" -eq 0 ]
2121

22-
# check state
23-
wait_for_container 15 1 test_busybox
24-
2522
# generate stats
2623
runc events --stats test_busybox
2724
[ "$status" -eq 0 ]
@@ -37,9 +34,6 @@ function teardown() {
3734
runc run -d --console-socket $CONSOLE_SOCKET test_busybox
3835
[ "$status" -eq 0 ]
3936

40-
# check state
41-
wait_for_container 15 1 test_busybox
42-
4337
# spawn two sub processes (shells)
4438
# the first sub process is an event logger that sends stats events to events.log
4539
# the second sub process waits for an event that incudes test_busybox then
@@ -67,9 +61,6 @@ function teardown() {
6761
runc run -d --console-socket $CONSOLE_SOCKET test_busybox
6862
[ "$status" -eq 0 ]
6963

70-
# check state
71-
wait_for_container 15 1 test_busybox
72-
7364
# spawn two sub processes (shells)
7465
# the first sub process is an event logger that sends stats events to events.log once a second
7566
# the second sub process tries 3 times for an event that incudes test_busybox
@@ -96,9 +87,6 @@ function teardown() {
9687
runc run -d --console-socket $CONSOLE_SOCKET test_busybox
9788
[ "$status" -eq 0 ]
9889

99-
# check state
100-
wait_for_container 15 1 test_busybox
101-
10290
#prove there is no carry over of events.log from a prior test
10391
[ ! -e events.log ]
10492

tests/integration/exec.bats

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ function teardown() {
1616
runc run -d --console-socket $CONSOLE_SOCKET test_busybox
1717
[ "$status" -eq 0 ]
1818

19-
wait_for_container 15 1 test_busybox
20-
2119
runc exec test_busybox echo Hello from exec
2220
[ "$status" -eq 0 ]
2321
echo text echoed = "'""${output}""'"
@@ -29,8 +27,6 @@ function teardown() {
2927
runc run -d --console-socket $CONSOLE_SOCKET test_busybox
3028
[ "$status" -eq 0 ]
3129

32-
wait_for_container 15 1 test_busybox
33-
3430
runc exec --pid-file pid.txt test_busybox echo Hello from exec
3531
[ "$status" -eq 0 ]
3632
echo text echoed = "'""${output}""'"
@@ -56,8 +52,6 @@ function teardown() {
5652
runc run -d -b $BUSYBOX_BUNDLE --console-socket $CONSOLE_SOCKET test_busybox
5753
[ "$status" -eq 0 ]
5854

59-
wait_for_container 15 1 test_busybox
60-
6155
runc exec --pid-file pid.txt test_busybox echo Hello from exec
6256
[ "$status" -eq 0 ]
6357
echo text echoed = "'""${output}""'"
@@ -77,8 +71,6 @@ function teardown() {
7771
runc run -d --console-socket $CONSOLE_SOCKET test_busybox
7872
[ "$status" -eq 0 ]
7973

80-
wait_for_container 15 1 test_busybox
81-
8274
runc exec test_busybox ls -la
8375
[ "$status" -eq 0 ]
8476
[[ ${lines[0]} == *"total"* ]]
@@ -91,8 +83,6 @@ function teardown() {
9183
runc run -d --console-socket $CONSOLE_SOCKET test_busybox
9284
[ "$status" -eq 0 ]
9385

94-
wait_for_container 15 1 test_busybox
95-
9686
runc exec --cwd /bin test_busybox pwd
9787
[ "$status" -eq 0 ]
9888
[[ ${output} == "/bin" ]]
@@ -103,8 +93,6 @@ function teardown() {
10393
runc run -d --console-socket $CONSOLE_SOCKET test_busybox
10494
[ "$status" -eq 0 ]
10595

106-
wait_for_container 15 1 test_busybox
107-
10896
runc exec --env RUNC_EXEC_TEST=true test_busybox env
10997
[ "$status" -eq 0 ]
11098

@@ -119,8 +107,6 @@ function teardown() {
119107
runc run -d --console-socket $CONSOLE_SOCKET test_busybox
120108
[ "$status" -eq 0 ]
121109

122-
wait_for_container 15 1 test_busybox
123-
124110
runc exec --user 1000:1000 test_busybox id
125111
[ "$status" -eq 0 ]
126112

tests/integration/kill.bats

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ function teardown() {
1818
[ "$status" -eq 0 ]
1919

2020
# check state
21-
wait_for_container 15 1 test_busybox
22-
2321
testcontainer test_busybox running
2422

2523
runc kill test_busybox KILL

tests/integration/list.bats

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,12 @@ function teardown() {
2121
# run a few busyboxes detached
2222
ROOT=$HELLO_BUNDLE runc run -d --console-socket $CONSOLE_SOCKET test_box1
2323
[ "$status" -eq 0 ]
24-
wait_for_container_inroot 15 1 test_box1 $HELLO_BUNDLE
2524

2625
ROOT=$HELLO_BUNDLE runc run -d --console-socket $CONSOLE_SOCKET test_box2
2726
[ "$status" -eq 0 ]
28-
wait_for_container_inroot 15 1 test_box2 $HELLO_BUNDLE
2927

3028
ROOT=$HELLO_BUNDLE runc run -d --console-socket $CONSOLE_SOCKET test_box3
3129
[ "$status" -eq 0 ]
32-
wait_for_container_inroot 15 1 test_box3 $HELLO_BUNDLE
3330

3431
ROOT=$HELLO_BUNDLE runc list
3532
[ "$status" -eq 0 ]

tests/integration/mask.bats

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ function teardown() {
2323
runc run -d --console-socket $CONSOLE_SOCKET test_busybox
2424
[ "$status" -eq 0 ]
2525

26-
wait_for_container 15 1 test_busybox
27-
2826
runc exec test_busybox cat /testfile
2927
[ "$status" -eq 0 ]
3028
[[ "${output}" == "" ]]
@@ -43,8 +41,6 @@ function teardown() {
4341
runc run -d --console-socket $CONSOLE_SOCKET test_busybox
4442
[ "$status" -eq 0 ]
4543

46-
wait_for_container 15 1 test_busybox
47-
4844
runc exec test_busybox ls /testdir
4945
[ "$status" -eq 0 ]
5046
[[ "${output}" == "" ]]

tests/integration/pause.bats

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function teardown() {
1919
runc run -d --console-socket $CONSOLE_SOCKET test_busybox
2020
[ "$status" -eq 0 ]
2121

22-
wait_for_container 15 1 test_busybox
22+
testcontainer test_busybox running
2323

2424
# pause busybox
2525
runc pause test_busybox
@@ -44,7 +44,7 @@ function teardown() {
4444
runc run -d --console-socket $CONSOLE_SOCKET test_busybox
4545
[ "$status" -eq 0 ]
4646

47-
wait_for_container 15 1 test_busybox
47+
testcontainer test_busybox running
4848

4949
# pause test_busybox and nonexistent container
5050
runc pause test_busybox

tests/integration/ps.bats

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ function teardown() {
2020
[ "$status" -eq 0 ]
2121

2222
# check state
23-
wait_for_container 15 1 test_busybox
24-
2523
testcontainer test_busybox running
2624

2725
runc ps test_busybox
@@ -39,8 +37,6 @@ function teardown() {
3937
[ "$status" -eq 0 ]
4038

4139
# check state
42-
wait_for_container 15 1 test_busybox
43-
4440
testcontainer test_busybox running
4541

4642
runc ps -f json test_busybox
@@ -57,8 +53,6 @@ function teardown() {
5753
[ "$status" -eq 0 ]
5854

5955
# check state
60-
wait_for_container 15 1 test_busybox
61-
6256
testcontainer test_busybox running
6357

6458
runc ps test_busybox -e -x

0 commit comments

Comments
 (0)