Skip to content

Commit a64cc98

Browse files
Merge pull request #20912 from edsantiago/fix_some_cp_flakes
systests: cp: add wait_for_ready
2 parents 72ceb6e + 4d2125b commit a64cc98

File tree

1 file changed

+34
-11
lines changed

1 file changed

+34
-11
lines changed

test/system/065-cp.bats

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ load helpers
2222
mkdir -p $srcdir/subdir
2323
echo "${randomcontent[2]}" > $srcdir/subdir/dotfile.
2424

25-
run_podman run -d --name destrunning --workdir=/srv $IMAGE sh -c "mkdir /srv/subdir; sleep infinity"
25+
run_podman run -d --name destrunning --workdir=/srv $IMAGE sh -c "mkdir /srv/subdir; echo READY; sleep infinity"
26+
wait_for_ready destrunning
2627

2728
# Commit the image for testing non-running containers
2829
run_podman commit -q destrunning
@@ -177,7 +178,9 @@ load helpers
177178
echo ${randomcontent[0]} > /tmp/dotfile.;
178179
echo ${randomcontent[1]} > /srv/containerfile1;
179180
echo ${randomcontent[2]} > /srv/subdir/containerfile2;
181+
echo READY;
180182
sleep infinity"
183+
wait_for_ready srcrunning
181184

182185
# Commit the image for testing non-running containers
183186
run_podman commit -q srcrunning
@@ -238,7 +241,9 @@ load helpers
238241
echo ${randomcontent[0]} > /tmp/dotfile.;
239242
echo ${randomcontent[1]} > /srv/containerfile1;
240243
echo ${randomcontent[2]} > /srv/subdir/containerfile2;
244+
echo READY;
241245
sleep infinity"
246+
wait_for_ready srcrunning
242247

243248
# Commit the image for testing non-running containers
244249
run_podman commit -q srcrunning
@@ -329,7 +334,8 @@ load helpers
329334
mkdir -p $srcdir/dir.
330335
cp -r $srcdir/dir/* $srcdir/dir.
331336

332-
run_podman run -d --name destrunning --workdir=/srv $IMAGE sh -c "mkdir /srv/subdir; sleep infinity"
337+
run_podman run -d --name destrunning --workdir=/srv $IMAGE sh -c "mkdir /srv/subdir; echo READY;sleep infinity"
338+
wait_for_ready destrunning
333339

334340
# Commit the image for testing non-running containers
335341
run_podman commit -q destrunning
@@ -391,7 +397,9 @@ load helpers
391397
echo ${randomcontent[0]} > /srv/subdir/containerfile0; \
392398
echo ${randomcontent[1]} > /srv/subdir/containerfile1; \
393399
mkdir /tmp/subdir.; cp /srv/subdir/* /tmp/subdir./; \
400+
echo READY;
394401
sleep infinity"
402+
wait_for_ready srcrunning
395403

396404
# Commit the image for testing non-running containers
397405
run_podman commit -q srcrunning
@@ -460,7 +468,9 @@ load helpers
460468
echo ${randomcontent[0]} > /srv/subdir/containerfile0; \
461469
echo ${randomcontent[1]} > /srv/subdir/containerfile1; \
462470
mkdir /tmp/subdir.; cp /srv/subdir/* /tmp/subdir./; \
471+
echo READY;
463472
sleep infinity"
473+
wait_for_ready srcrunning
464474

465475
# Commit the image for testing non-running containers
466476
run_podman commit -q srcrunning
@@ -549,7 +559,9 @@ load helpers
549559
run_podman run -d --name srcrunning $IMAGE sh -c "echo ${randomcontent[0]} > /tmp/containerfile0; \
550560
echo ${randomcontent[1]} > /tmp/containerfile1; \
551561
mkdir /tmp/sub && cd /tmp/sub && ln -s .. weirdlink; \
562+
echo READY;
552563
sleep infinity"
564+
wait_for_ready srcrunning
553565

554566
# Commit the image for testing non-running containers
555567
run_podman commit -q srcrunning
@@ -749,7 +761,8 @@ load helpers
749761
sh -c "mkdir /tmp/d1;ln -s /tmp/nonesuch1 /tmp/d1/x;
750762
mkdir /tmp/d2;ln -s /tmp/nonesuch2 /tmp/d2/x;
751763
mkdir /tmp/d3;
752-
trap 'exit 0' 15;while :;do sleep 0.5;done"
764+
trap 'exit 0' 15;echo READY;while :;do sleep 0.5;done"
765+
wait_for_ready cpcontainer
753766

754767
# Copy file from host into container, into a file named 'x'
755768
# Note that the second has a trailing slash, implying a directory.
@@ -912,8 +925,10 @@ load helpers
912925
rand_content_file=$(random_string 50)
913926
rand_content_dir=$(random_string 50)
914927

915-
run_podman run -d --name ctr-file $IMAGE sh -c "echo '$rand_content_file' > /tmp/foo; sleep infinity"
916-
run_podman run -d --name ctr-dir $IMAGE sh -c "mkdir /tmp/foo; echo '$rand_content_dir' > /tmp/foo/file.txt; sleep infinity"
928+
run_podman run -d --name ctr-file $IMAGE sh -c "echo '$rand_content_file' > /tmp/foo; echo READY; sleep infinity"
929+
run_podman run -d --name ctr-dir $IMAGE sh -c "mkdir /tmp/foo; echo '$rand_content_dir' > /tmp/foo/file.txt; echo READY; sleep infinity"
930+
wait_for_ready ctr-file
931+
wait_for_ready ctr-dir
917932

918933
# overwrite a directory with a file
919934
run_podman 125 cp ctr-file:/tmp/foo ctr-dir:/tmp
@@ -946,8 +961,10 @@ load helpers
946961
rand_content_file=$(random_string 50)
947962
rand_content_dir=$(random_string 50)
948963

949-
run_podman run -d --name ctr-file $IMAGE sh -c "echo '$rand_content_file' > /tmp/foo; sleep infinity"
950-
run_podman run -d --name ctr-dir $IMAGE sh -c "mkdir /tmp/foo; echo '$rand_content_dir' > /tmp/foo/file.txt; sleep infinity"
964+
run_podman run -d --name ctr-file $IMAGE sh -c "echo '$rand_content_file' > /tmp/foo; echo READY; sleep infinity"
965+
run_podman run -d --name ctr-dir $IMAGE sh -c "mkdir /tmp/foo; echo '$rand_content_dir' > /tmp/foo/file.txt; echo READY; sleep infinity"
966+
wait_for_ready ctr-file
967+
wait_for_ready ctr-dir
951968

952969
# overwrite a directory with a file
953970
mkdir $hostdir/foo
@@ -978,8 +995,10 @@ load helpers
978995
rand_content_file=$(random_string 50)
979996
rand_content_dir=$(random_string 50)
980997

981-
run_podman run -d --name ctr-dir $IMAGE sh -c "mkdir /tmp/foo; sleep infinity"
982-
run_podman run -d --name ctr-file $IMAGE sh -c "touch /tmp/foo; sleep infinity"
998+
run_podman run -d --name ctr-dir $IMAGE sh -c "mkdir /tmp/foo; echo READY; sleep infinity"
999+
run_podman run -d --name ctr-file $IMAGE sh -c "touch /tmp/foo; echo READY; sleep infinity"
1000+
wait_for_ready ctr-dir
1001+
wait_for_ready ctr-file
9831002

9841003
# overwrite a directory with a file
9851004
echo "$rand_content_file" > $hostdir/foo
@@ -1025,7 +1044,9 @@ load helpers
10251044
dstdir=$PODMAN_TMPDIR/dst
10261045
mkdir -p $dstdir
10271046

1028-
run_podman run -d --name=test-ctr --rm $IMAGE sh -c "mkdir -p /foo/test1. /foo/test2; touch /foo/test1./file1 /foo/test2/file2; sleep infinity"
1047+
run_podman run -d --name=test-ctr --rm $IMAGE sh -c "mkdir -p /foo/test1. /foo/test2; touch /foo/test1./file1 /foo/test2/file2; echo READY;sleep infinity"
1048+
wait_for_ready test-ctr
1049+
10291050
run_podman cp test-ctr:/foo/test1. $dstdir/foo
10301051
run /bin/ls -1 $dstdir/foo
10311052
assert "$output" = "file1" "ls [local]/foo: only file1 was copied, nothing more"
@@ -1034,7 +1055,9 @@ load helpers
10341055
}
10351056

10361057
@test "podman cp - dot notation - container to container" {
1037-
run_podman run -d --name=src-ctr --rm $IMAGE sh -c "mkdir -p /foo/test1. /foo/test2; touch /foo/test1./file1 /foo/test2/file2; sleep infinity"
1058+
run_podman run -d --name=src-ctr --rm $IMAGE sh -c "mkdir -p /foo/test1. /foo/test2; touch /foo/test1./file1 /foo/test2/file2; echo READY;sleep infinity"
1059+
wait_for_ready src-ctr
1060+
10381061
run_podman run -d --name=dest-ctr --rm $IMAGE sleep infinity
10391062
run_podman cp src-ctr:/foo/test1. dest-ctr:/foo
10401063

0 commit comments

Comments
 (0)