Skip to content

Commit

Permalink
cp system tests: reduce number of exec's
Browse files Browse the repository at this point in the history
Reduce the amount of `podman exec`s in the cp system tests.
Exec is expensive and a number of them could easily be combined
into the container command.

This cuts down the costs of running the tests by around 25 percent
on my local machine.

Signed-off-by: Valentin Rothberg <[email protected]>
  • Loading branch information
vrothberg committed Jul 27, 2021
1 parent 6fe03b2 commit 0aec93e
Showing 1 changed file with 31 additions and 31 deletions.
62 changes: 31 additions & 31 deletions test/system/065-cp.bats
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ load helpers
mkdir -p $srcdir/subdir
echo "${randomcontent[2]}" > $srcdir/subdir/dotfile.

run_podman run -d --name cpcontainer --workdir=/srv $IMAGE sleep infinity
run_podman exec cpcontainer mkdir /srv/subdir
run_podman run -d --name cpcontainer --workdir=/srv $IMAGE sh -c "mkdir /srv/subdir; sleep infinity"

# Commit the image for testing non-running containers
run_podman commit -q cpcontainer
Expand All @@ -41,7 +40,6 @@ load helpers
0 | /tmp | /tmp/hostfile0 | copy to /tmp
1 | /tmp/ | /tmp/hostfile1 | copy to /tmp/
2 | /tmp/. | /tmp/hostfile2 | copy to /tmp/.
0 | /tmp/hostfile2 | /tmp/hostfile2 | overwrite previous copy
0 | /tmp/anotherbase.txt | /tmp/anotherbase.txt | copy to /tmp, new name
0 | . | /srv/hostfile0 | copy to workdir (rel path), new name
1 | ./ | /srv/hostfile1 | copy to workdir (rel path), new name
Expand Down Expand Up @@ -175,11 +173,12 @@ load helpers
random-1-$(random_string 15)
random-2-$(random_string 20)
)
run_podman run -d --name cpcontainer --workdir=/srv $IMAGE sleep infinity
run_podman exec cpcontainer sh -c "echo ${randomcontent[0]} > /tmp/containerfile"
run_podman exec cpcontainer sh -c "echo ${randomcontent[0]} > /tmp/dotfile."
run_podman exec cpcontainer sh -c "echo ${randomcontent[1]} > /srv/containerfile1"
run_podman exec cpcontainer sh -c "mkdir /srv/subdir; echo ${randomcontent[2]} > /srv/subdir/containerfile2"
run_podman run -d --name cpcontainer --workdir=/srv $IMAGE sh -c "mkdir /srv/subdir;
echo ${randomcontent[0]} > /tmp/containerfile;
echo ${randomcontent[0]} > /tmp/dotfile.;
echo ${randomcontent[1]} > /srv/containerfile1;
echo ${randomcontent[2]} > /srv/subdir/containerfile2;
sleep infinity"

# Commit the image for testing non-running containers
run_podman commit -q cpcontainer
Expand Down Expand Up @@ -233,11 +232,13 @@ load helpers
random-1-$(random_string 15)
random-2-$(random_string 20)
)
run_podman run -d --name cpcontainer --workdir=/srv $IMAGE sleep infinity
run_podman exec cpcontainer sh -c "echo ${randomcontent[0]} > /tmp/containerfile"
run_podman exec cpcontainer sh -c "echo ${randomcontent[0]} > /tmp/dotfile."
run_podman exec cpcontainer sh -c "echo ${randomcontent[1]} > /srv/containerfile1"
run_podman exec cpcontainer sh -c "mkdir /srv/subdir; echo ${randomcontent[2]} > /srv/subdir/containerfile2"

run_podman run -d --name cpcontainer --workdir=/srv $IMAGE sh -c "mkdir /srv/subdir;
echo ${randomcontent[0]} > /tmp/containerfile;
echo ${randomcontent[0]} > /tmp/dotfile.;
echo ${randomcontent[1]} > /srv/containerfile1;
echo ${randomcontent[2]} > /srv/subdir/containerfile2;
sleep infinity"

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

run_podman run -d --name cpcontainer --workdir=/srv $IMAGE sleep infinity
run_podman exec cpcontainer mkdir /srv/subdir
run_podman run -d --name cpcontainer --workdir=/srv $IMAGE sh -c "mkdir /srv/subdir; sleep infinity"

# Commit the image for testing non-running containers
run_podman commit -q cpcontainer
Expand Down Expand Up @@ -399,12 +399,12 @@ load helpers
random-0-$(random_string 10)
random-1-$(random_string 15)
)
run_podman run -d --name cpcontainer --workdir=/srv $IMAGE sleep infinity
run_podman exec cpcontainer sh -c "mkdir /srv/subdir; echo ${randomcontent[0]} > /srv/subdir/containerfile0"
run_podman exec cpcontainer sh -c "echo ${randomcontent[1]} > /srv/subdir/containerfile1"
# "." and "dir/." will copy the contents, so make sure that a dir ending
# with dot is treated correctly.
run_podman exec cpcontainer sh -c 'mkdir /tmp/subdir.; cp /srv/subdir/* /tmp/subdir./'

run_podman run -d --name cpcontainer --workdir=/srv $IMAGE sh -c "mkdir /srv/subdir;
echo ${randomcontent[0]} > /srv/subdir/containerfile0; \
echo ${randomcontent[1]} > /srv/subdir/containerfile1; \
mkdir /tmp/subdir.; cp /srv/subdir/* /tmp/subdir./; \
sleep infinity"

# Commit the image for testing non-running containers
run_podman commit -q cpcontainer
Expand Down Expand Up @@ -473,12 +473,12 @@ load helpers
random-0-$(random_string 10)
random-1-$(random_string 15)
)
run_podman run -d --name cpcontainer --workdir=/srv $IMAGE sleep infinity
run_podman exec cpcontainer sh -c "mkdir /srv/subdir; echo ${randomcontent[0]} > /srv/subdir/containerfile0"
run_podman exec cpcontainer sh -c "echo ${randomcontent[1]} > /srv/subdir/containerfile1"
# "." and "dir/." will copy the contents, so make sure that a dir ending
# with dot is treated correctly.
run_podman exec cpcontainer sh -c 'mkdir /tmp/subdir.; cp /srv/subdir/* /tmp/subdir./'

run_podman run -d --name cpcontainer --workdir=/srv $IMAGE sh -c "mkdir /srv/subdir;
echo ${randomcontent[0]} > /srv/subdir/containerfile0; \
echo ${randomcontent[1]} > /srv/subdir/containerfile1; \
mkdir /tmp/subdir.; cp /srv/subdir/* /tmp/subdir./; \
sleep infinity"

# Commit the image for testing non-running containers
run_podman commit -q cpcontainer
Expand Down Expand Up @@ -581,10 +581,10 @@ ${randomcontent[1]}" "$description"
random-1-$(random_string 15)
)

run_podman run -d --name cpcontainer $IMAGE sleep infinity
run_podman exec cpcontainer sh -c "echo ${randomcontent[0]} > /tmp/containerfile0"
run_podman exec cpcontainer sh -c "echo ${randomcontent[1]} > /tmp/containerfile1"
run_podman exec cpcontainer sh -c "mkdir /tmp/sub && cd /tmp/sub && ln -s .. weirdlink"
run_podman run -d --name cpcontainer $IMAGE sh -c "echo ${randomcontent[0]} > /tmp/containerfile0; \
echo ${randomcontent[1]} > /tmp/containerfile1; \
mkdir /tmp/sub && cd /tmp/sub && ln -s .. weirdlink; \
sleep infinity"

# Commit the image for testing non-running containers
run_podman commit -q cpcontainer
Expand Down

0 comments on commit 0aec93e

Please sign in to comment.