Skip to content

Commit

Permalink
Merge pull request #20912 from edsantiago/fix_some_cp_flakes
Browse files Browse the repository at this point in the history
systests: cp: add wait_for_ready
  • Loading branch information
openshift-merge-bot[bot] authored Dec 6, 2023
2 parents 72ceb6e + 4d2125b commit a64cc98
Showing 1 changed file with 34 additions and 11 deletions.
45 changes: 34 additions & 11 deletions test/system/065-cp.bats
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ load helpers
mkdir -p $srcdir/subdir
echo "${randomcontent[2]}" > $srcdir/subdir/dotfile.

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

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

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

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

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

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

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

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

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

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

run_podman run -d --name ctr-file $IMAGE sh -c "echo '$rand_content_file' > /tmp/foo; sleep infinity"
run_podman run -d --name ctr-dir $IMAGE sh -c "mkdir /tmp/foo; echo '$rand_content_dir' > /tmp/foo/file.txt; sleep infinity"
run_podman run -d --name ctr-file $IMAGE sh -c "echo '$rand_content_file' > /tmp/foo; echo READY; sleep infinity"
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"
wait_for_ready ctr-file
wait_for_ready ctr-dir

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

run_podman run -d --name ctr-file $IMAGE sh -c "echo '$rand_content_file' > /tmp/foo; sleep infinity"
run_podman run -d --name ctr-dir $IMAGE sh -c "mkdir /tmp/foo; echo '$rand_content_dir' > /tmp/foo/file.txt; sleep infinity"
run_podman run -d --name ctr-file $IMAGE sh -c "echo '$rand_content_file' > /tmp/foo; echo READY; sleep infinity"
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"
wait_for_ready ctr-file
wait_for_ready ctr-dir

# overwrite a directory with a file
mkdir $hostdir/foo
Expand Down Expand Up @@ -978,8 +995,10 @@ load helpers
rand_content_file=$(random_string 50)
rand_content_dir=$(random_string 50)

run_podman run -d --name ctr-dir $IMAGE sh -c "mkdir /tmp/foo; sleep infinity"
run_podman run -d --name ctr-file $IMAGE sh -c "touch /tmp/foo; sleep infinity"
run_podman run -d --name ctr-dir $IMAGE sh -c "mkdir /tmp/foo; echo READY; sleep infinity"
run_podman run -d --name ctr-file $IMAGE sh -c "touch /tmp/foo; echo READY; sleep infinity"
wait_for_ready ctr-dir
wait_for_ready ctr-file

# overwrite a directory with a file
echo "$rand_content_file" > $hostdir/foo
Expand Down Expand Up @@ -1025,7 +1044,9 @@ load helpers
dstdir=$PODMAN_TMPDIR/dst
mkdir -p $dstdir

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"
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"
wait_for_ready test-ctr

run_podman cp test-ctr:/foo/test1. $dstdir/foo
run /bin/ls -1 $dstdir/foo
assert "$output" = "file1" "ls [local]/foo: only file1 was copied, nothing more"
Expand All @@ -1034,7 +1055,9 @@ load helpers
}

@test "podman cp - dot notation - container to container" {
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"
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"
wait_for_ready src-ctr

run_podman run -d --name=dest-ctr --rm $IMAGE sleep infinity
run_podman cp src-ctr:/foo/test1. dest-ctr:/foo

Expand Down

0 comments on commit a64cc98

Please sign in to comment.