diff --git a/Dockerfile b/Dockerfile index b1511121e69..120560aa3e4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -86,14 +86,9 @@ ENTRYPOINT ["/tmpmount"] # setup a playground for us to spawn containers in COPY tests/integration/multi-arch.bash tests/integration/ -ENV ROOTFS /busybox +ENV ROOTFS /opensuse RUN mkdir -p "${ROOTFS}" RUN . tests/integration/multi-arch.bash \ - && curl -fsSL `get_busybox` | tar xfJC - "${ROOTFS}" - -ENV DEBIAN_ROOTFS /debian -RUN mkdir -p "${DEBIAN_ROOTFS}" -RUN . tests/integration/multi-arch.bash \ - && get_and_extract_debian "$DEBIAN_ROOTFS" + && get_and_extract_opensuse "$ROOTFS" COPY . . diff --git a/Vagrantfile.centos7 b/Vagrantfile.centos7 index 7342e4ab1ed..dfcfb1eae7f 100644 --- a/Vagrantfile.centos7 +++ b/Vagrantfile.centos7 @@ -50,9 +50,9 @@ EOF # Add a user for rootless tests useradd -u2000 -m -d/home/rootless -s/bin/bash rootless - # Add busybox for libcontainer/integration tests + # Add opensuse for libcontainer/integration tests . /vagrant/tests/integration/multi-arch.bash \ - && mkdir /busybox \ - && curl -fsSL $(get_busybox) | tar xfJC - /busybox + && mkdir /opensuse \ + && get_and_extract_opensuse /opensuse SHELL end diff --git a/Vagrantfile.fedora32 b/Vagrantfile.fedora32 index 6b3dc652ec0..639ffd89b98 100644 --- a/Vagrantfile.fedora32 +++ b/Vagrantfile.fedora32 @@ -35,11 +35,10 @@ EOF curl -o /usr/local/bin/umoci -fsSL https://github.com/opencontainers/umoci/releases/download/v0.4.5/umoci.amd64 chmod +x /usr/local/bin/umoci - # Add busybox for libcontainer/integration tests + # Add opensuse for libcontainer/integration tests . /vagrant/tests/integration/multi-arch.bash \ - && mkdir /busybox /debian \ - && curl -fsSL $(get_busybox) | tar xfJC - /busybox \ - && get_and_extract_debian /debian + && mkdir /opensuse \ + && get_and_extract_opensuse /opensuse # Delegate cgroup v2 controllers to rootless user via --systemd-cgroup mkdir -p /etc/systemd/system/user@.service.d diff --git a/libcontainer/integration/exec_test.go b/libcontainer/integration/exec_test.go index ada513b557e..5f287ba24b5 100644 --- a/libcontainer/integration/exec_test.go +++ b/libcontainer/integration/exec_test.go @@ -480,7 +480,7 @@ func TestAdditionalGroups(t *testing.T) { Env: standardEnvironment, Stdin: nil, Stdout: &stdout, - AdditionalGroups: []string{"plugdev", "audio"}, + AdditionalGroups: []string{"video", "audio"}, Init: true, } err = container.Run(&pconfig) @@ -496,8 +496,8 @@ func TestAdditionalGroups(t *testing.T) { t.Fatalf("Listed groups do not contain the audio group as expected: %v", outputGroups) } - if !strings.Contains(outputGroups, "plugdev") { - t.Fatalf("Listed groups do not contain the plugdev group as expected: %v", outputGroups) + if !strings.Contains(outputGroups, "video") { + t.Fatalf("Listed groups do not contain the video group as expected: %v", outputGroups) } } @@ -665,11 +665,7 @@ func testPids(t *testing.T, systemd bool) { if err != nil && strings.Contains(err.Error(), "no such directory for pids.max") { t.Skip("PIDs cgroup is unsupported") } - if err != nil && !strings.Contains(out.String(), "sh: can't fork") { - ok(t, err) - } - - if err == nil { + if !strings.Contains(out.String(), "/bin/sh: fork: retry: Resource temporarily unavailable") { t.Fatalf("expected fork() to fail with restrictive pids limit") } diff --git a/libcontainer/integration/execin_test.go b/libcontainer/integration/execin_test.go index 14f8a596406..af65526f126 100644 --- a/libcontainer/integration/execin_test.go +++ b/libcontainer/integration/execin_test.go @@ -179,7 +179,7 @@ func TestExecInAdditionalGroups(t *testing.T) { Env: standardEnvironment, Stdin: nil, Stdout: &stdout, - AdditionalGroups: []string{"plugdev", "audio"}, + AdditionalGroups: []string{"video", "audio"}, } err = container.Run(&pconfig) ok(t, err) @@ -197,8 +197,8 @@ func TestExecInAdditionalGroups(t *testing.T) { t.Fatalf("Listed groups do not contain the audio group as expected: %v", outputGroups) } - if !strings.Contains(outputGroups, "plugdev") { - t.Fatalf("Listed groups do not contain the plugdev group as expected: %v", outputGroups) + if !strings.Contains(outputGroups, "video") { + t.Fatalf("Listed groups do not contain the video group as expected: %v", outputGroups) } } @@ -285,7 +285,7 @@ func TestExecInTTY(t *testing.T) { var stdout bytes.Buffer ps := &libcontainer.Process{ Cwd: "/", - Args: []string{"ps"}, + Args: []string{"ps", "x"}, Env: standardEnvironment, } parent, child, err := utils.NewSockPair("console") @@ -345,7 +345,7 @@ func TestExecInTTY(t *testing.T) { out := stdout.String() if !strings.Contains(out, "cat") || !strings.Contains(out, "ps") { - t.Fatalf("unexpected running process, output %q", out) + t.Fatalf("unexpected running process, output:\n %v", out) } if strings.Contains(out, "\r") { t.Fatalf("unexpected carriage-return in output") diff --git a/libcontainer/integration/init_test.go b/libcontainer/integration/init_test.go index f5180eac022..c4967244af5 100644 --- a/libcontainer/integration/init_test.go +++ b/libcontainer/integration/init_test.go @@ -11,7 +11,7 @@ import ( "github.com/sirupsen/logrus" ) -// init runs the libcontainer initialization code because of the busybox style needs +// init runs the libcontainer initialization code because of the debian style needs // to work around the go runtime and the issues with forking func init() { if len(os.Args) < 2 || os.Args[1] != "init" { diff --git a/libcontainer/integration/seccomp_test.go b/libcontainer/integration/seccomp_test.go index 75319e7e84e..ed35b92e9ee 100644 --- a/libcontainer/integration/seccomp_test.go +++ b/libcontainer/integration/seccomp_test.go @@ -46,7 +46,7 @@ func TestSeccompDenyGetcwdWithErrno(t *testing.T) { buffers := newStdBuffers() pwd := &libcontainer.Process{ Cwd: "/", - Args: []string{"pwd"}, + Args: []string{"/bin/sh", "-c", "pwd"}, Env: standardEnvironment, Stdin: buffers.Stdin, Stdout: buffers.Stdout, @@ -60,7 +60,7 @@ func TestSeccompDenyGetcwdWithErrno(t *testing.T) { } ps, err := pwd.Wait() if err == nil { - t.Fatal("Expecting error (negative return code); instead exited cleanly!") + t.Fatalf("Expecting error (negative return code); instead exited cleanly!") } var exitCode int @@ -77,10 +77,10 @@ func TestSeccompDenyGetcwdWithErrno(t *testing.T) { t.Fatalf("Getcwd should fail with negative exit code, instead got %d!", exitCode) } - expected := "pwd: getcwd: No such process" + expected := "getcwd: cannot access parent directories: No such process" actual := strings.Trim(buffers.Stderr.String(), "\n") - if actual != expected { - t.Fatalf("Expected output %s but got %s\n", expected, actual) + if !strings.Contains(actual, expected) { + t.Fatalf("Expected output to contain `%s` but got `%s`\n", expected, actual) } } @@ -115,7 +115,7 @@ func TestSeccompDenyGetcwd(t *testing.T) { buffers := newStdBuffers() pwd := &libcontainer.Process{ Cwd: "/", - Args: []string{"pwd"}, + Args: []string{"/bin/sh", "-c", "pwd"}, Env: standardEnvironment, Stdin: buffers.Stdin, Stdout: buffers.Stdout, @@ -146,10 +146,10 @@ func TestSeccompDenyGetcwd(t *testing.T) { t.Fatalf("Getcwd should fail with negative exit code, instead got %d!", exitCode) } - expected := "pwd: getcwd: Operation not permitted" + expected := "getcwd: cannot access parent directories: Operation not permitted" actual := strings.Trim(buffers.Stderr.String(), "\n") - if actual != expected { - t.Fatalf("Expected output %s but got %s\n", expected, actual) + if !strings.Contains(actual, expected) { + t.Fatalf("Expected output to contain `%s` but got `%s`\n", expected, actual) } } @@ -191,7 +191,7 @@ func TestSeccompPermitWriteConditional(t *testing.T) { buffers := newStdBuffers() dmesg := &libcontainer.Process{ Cwd: "/", - Args: []string{"busybox", "ls", "/"}, + Args: []string{"ls", "/"}, Env: standardEnvironment, Stdin: buffers.Stdin, Stdout: buffers.Stdout, @@ -253,7 +253,7 @@ func TestSeccompDenyWriteConditional(t *testing.T) { buffers := newStdBuffers() dmesg := &libcontainer.Process{ Cwd: "/", - Args: []string{"busybox", "ls", "does_not_exist"}, + Args: []string{"ls", "does_not_exist"}, Env: standardEnvironment, Stdin: buffers.Stdin, Stdout: buffers.Stdout, @@ -433,11 +433,11 @@ func TestSeccompMultipleConditionSameArgDeniesStdout(t *testing.T) { } buffers, exitCode, err := runContainer(config, "", "ls", "/") - if err != nil { - t.Fatalf("%s: %s", buffers, err) + if err == nil { + t.Fatalf("Container returned without error when we expected an error, code: `%d`, stdout: `%s`, stderr: `%s`", exitCode, buffers.Stdout.String(), buffers.Stderr.String()) } - if exitCode != 0 { - t.Fatalf("exit code not 0. code %d buffers %s", exitCode, buffers) + if exitCode != -1 { + t.Fatalf("exit code not -1. code: `%d`, stdout: `%s`, stderr: `%s`", exitCode, buffers.Stdout.String(), buffers.Stderr.String()) } // Verify that nothing was printed if len(buffers.Stdout.String()) != 0 { diff --git a/libcontainer/integration/utils_test.go b/libcontainer/integration/utils_test.go index 8b2d714e235..89ec9c8ec58 100644 --- a/libcontainer/integration/utils_test.go +++ b/libcontainer/integration/utils_test.go @@ -92,7 +92,7 @@ func newTestBundle() (string, error) { return dir, nil } -// newRootfs creates a new tmp directory and copies the busybox root filesystem +// newRootfs creates a new tmp directory and copies the opensuse root filesystem func newRootfs() (string, error) { dir, err := ioutil.TempDir("", "") if err != nil { @@ -101,7 +101,7 @@ func newRootfs() (string, error) { if err := os.MkdirAll(dir, 0700); err != nil { return "", err } - if err := copyBusybox(dir); err != nil { + if err := copyOpensuse(dir); err != nil { return "", err } return dir, nil @@ -111,10 +111,10 @@ func remove(dir string) { os.RemoveAll(dir) } -// copyBusybox copies the rootfs for a busybox container created for the test image +// copyOpensuse copies the rootfs for a opensuse container created for the test image // into the new directory for the specific test -func copyBusybox(dest string) error { - out, err := exec.Command("sh", "-c", fmt.Sprintf("cp -a /busybox/* %s/", dest)).CombinedOutput() +func copyOpensuse(dest string) error { + out, err := exec.Command("sh", "-c", fmt.Sprintf("cp -a /opensuse/rootfs/* %s/", dest)).CombinedOutput() if err != nil { return fmt.Errorf("copy error %q: %q", err, out) } diff --git a/tests/integration/cgroups.bats b/tests/integration/cgroups.bats index 4e81ac50c04..aeccb5c9333 100644 --- a/tests/integration/cgroups.bats +++ b/tests/integration/cgroups.bats @@ -6,24 +6,24 @@ function teardown() { rm -f $BATS_TMPDIR/runc-cgroups-integration-test.json teardown_running_container test_cgroups_kmem teardown_running_container test_cgroups_permissions - teardown_busybox + teardown_container } function setup() { teardown - setup_busybox + setup_container } @test "runc update --kernel-memory{,-tcp} (initialized)" { [[ "$ROOTLESS" -ne 0 ]] && requires rootless_cgroup requires cgroups_kmem - set_cgroups_path "$BUSYBOX_BUNDLE" + set_cgroups_path "$BUNDLE" # Set some initial known values - update_config '.linux.resources.memory |= {"kernel": 16777216, "kernelTCP": 11534336}' ${BUSYBOX_BUNDLE} + update_config '.linux.resources.memory |= {"kernel": 16777216, "kernelTCP": 11534336}' ${BUNDLE} - # run a detached busybox to work with + # run a detached container to work with runc run -d --console-socket $CONSOLE_SOCKET test_cgroups_kmem [ "$status" -eq 0 ] @@ -45,9 +45,9 @@ function setup() { [[ "$ROOTLESS" -ne 0 ]] && requires rootless_cgroup requires cgroups_kmem - set_cgroups_path "$BUSYBOX_BUNDLE" + set_cgroups_path "$BUNDLE" - # run a detached busybox to work with + # run a detached container to work with runc run -d --console-socket $CONSOLE_SOCKET test_cgroups_kmem [ "$status" -eq 0 ] @@ -74,7 +74,7 @@ function setup() { # systemd controls the permission, so error does not happen requires no_systemd - set_cgroups_path "$BUSYBOX_BUNDLE" + set_cgroups_path "$BUNDLE" runc run -d --console-socket $CONSOLE_SOCKET test_cgroups_permissions [ "$status" -eq 1 ] @@ -87,7 +87,7 @@ function setup() { # systemd controls the permission, so error does not happen requires no_systemd - set_resources_limit "$BUSYBOX_BUNDLE" + set_resources_limit "$BUNDLE" runc run -d --console-socket $CONSOLE_SOCKET test_cgroups_permissions [ "$status" -eq 1 ] @@ -97,8 +97,8 @@ function setup() { @test "runc create (limits + cgrouppath + permission on the cgroup dir) succeeds" { [[ "$ROOTLESS" -ne 0 ]] && requires rootless_cgroup - set_cgroups_path "$BUSYBOX_BUNDLE" - set_resources_limit "$BUSYBOX_BUNDLE" + set_cgroups_path "$BUNDLE" + set_resources_limit "$BUNDLE" runc run -d --console-socket $CONSOLE_SOCKET test_cgroups_permissions [ "$status" -eq 0 ] @@ -118,8 +118,8 @@ function setup() { @test "runc exec (limits + cgrouppath + permission on the cgroup dir) succeeds" { [[ "$ROOTLESS" -ne 0 ]] && requires rootless_cgroup - set_cgroups_path "$BUSYBOX_BUNDLE" - set_resources_limit "$BUSYBOX_BUNDLE" + set_cgroups_path "$BUNDLE" + set_resources_limit "$BUNDLE" runc run -d --console-socket $CONSOLE_SOCKET test_cgroups_permissions [ "$status" -eq 0 ] @@ -132,8 +132,8 @@ function setup() { @test "runc exec (cgroup v2 + init process in non-root cgroup) succeeds" { requires root cgroups_v2 - set_cgroups_path "$BUSYBOX_BUNDLE" - set_cgroup_mount_writable "$BUSYBOX_BUNDLE" + set_cgroups_path "$BUNDLE" + set_cgroup_mount_writable "$BUNDLE" runc run -d --console-socket $CONSOLE_SOCKET test_cgroups_group [ "$status" -eq 0 ] diff --git a/tests/integration/checkpoint.bats b/tests/integration/checkpoint.bats index 00947427cd2..8aa035917ee 100644 --- a/tests/integration/checkpoint.bats +++ b/tests/integration/checkpoint.bats @@ -6,12 +6,12 @@ function setup() { # XXX: currently criu require root containers. requires criu root - teardown_busybox - setup_busybox + teardown_container + setup_container } function teardown() { - teardown_busybox + teardown_container } function setup_pipes() { @@ -42,27 +42,27 @@ function check_pipes() { } function simple_cr() { - runc run -d --console-socket $CONSOLE_SOCKET test_busybox + runc run -d --console-socket $CONSOLE_SOCKET test_container [ "$status" -eq 0 ] - testcontainer test_busybox running + testcontainer test_container running for i in `seq 2`; do # checkpoint the running container - runc --criu "$CRIU" checkpoint --work-path ./work-dir test_busybox + runc --criu "$CRIU" checkpoint --work-path ./work-dir test_container cat ./work-dir/dump.log | grep -B 5 Error || true [ "$status" -eq 0 ] - # after checkpoint busybox is no longer running - testcontainer test_busybox checkpointed + # after checkpoint container is no longer running + testcontainer test_container checkpointed # restore from checkpoint - runc --criu "$CRIU" restore -d --work-path ./work-dir --console-socket $CONSOLE_SOCKET test_busybox + runc --criu "$CRIU" restore -d --work-path ./work-dir --console-socket $CONSOLE_SOCKET test_container cat ./work-dir/restore.log | grep -B 5 Error || true [ "$status" -eq 0 ] - # busybox should be back up and running - testcontainer test_busybox running + # container should be back up and running + testcontainer test_container running done } @@ -83,40 +83,40 @@ function simple_cr() { @test "checkpoint --pre-dump and restore" { setup_pipes - # run busybox - __runc run -d test_busybox <&60 >&51 2>&51 + # run container + __runc run -d test_container <&60 >&51 2>&51 [ $? -eq 0 ] - testcontainer test_busybox running + testcontainer test_container running #test checkpoint pre-dump mkdir parent-dir - runc --criu "$CRIU" checkpoint --pre-dump --image-path ./parent-dir test_busybox + runc --criu "$CRIU" checkpoint --pre-dump --image-path ./parent-dir test_container [ "$status" -eq 0 ] - # busybox should still be running - testcontainer test_busybox running + # container should still be running + testcontainer test_container running # checkpoint the running container mkdir image-dir mkdir work-dir - runc --criu "$CRIU" checkpoint --parent-path ./parent-dir --work-path ./work-dir --image-path ./image-dir test_busybox + runc --criu "$CRIU" checkpoint --parent-path ./parent-dir --work-path ./work-dir --image-path ./image-dir test_container cat ./work-dir/dump.log | grep -B 5 Error || true [ "$status" -eq 0 ] - # after checkpoint busybox is no longer running - testcontainer test_busybox checkpointed + # after checkpoint container is no longer running + testcontainer test_container checkpointed # restore from checkpoint - __runc --criu "$CRIU" restore -d --work-path ./work-dir --image-path ./image-dir test_busybox <&60 >&51 2>&51 + __runc --criu "$CRIU" restore -d --work-path ./work-dir --image-path ./image-dir test_container <&60 >&51 2>&51 ret=$? cat ./work-dir/restore.log | grep -B 5 Error || true [ $ret -eq 0 ] - # busybox should be back up and running - testcontainer test_busybox running + # container should be back up and running + testcontainer test_container running - runc exec --cwd /bin test_busybox echo ok + runc exec --cwd /bin test_container echo ok [ "$status" -eq 0 ] [[ ${output} == "ok" ]] @@ -138,11 +138,11 @@ function simple_cr() { # TCP port for lazy migration port=27277 - # run busybox - __runc run -d test_busybox <&60 >&51 2>&51 + # run container + __runc run -d test_container <&60 >&51 2>&51 [ $? -eq 0 ] - testcontainer test_busybox running + testcontainer test_container running # checkpoint the running container mkdir image-dir @@ -154,7 +154,7 @@ function simple_cr() { exec 70/proc/self/fd/72 exec 72>&- - __runc --criu "$CRIU" checkpoint --lazy-pages --page-server 0.0.0.0:${port} --status-fd 71 --work-path ./work-dir --image-path ./image-dir test_busybox & + __runc --criu "$CRIU" checkpoint --lazy-pages --page-server 0.0.0.0:${port} --status-fd 71 --work-path ./work-dir --image-path ./image-dir test_container & cpt_pid=$! # wait for lazy page server to be ready @@ -179,15 +179,15 @@ function simple_cr() { # in time when the last page is lazily transferred to the destination. # Killing the CRIU on the checkpoint side will let the container # continue to run if the migration failed at some point. - __runc --criu "$CRIU" restore -d --work-path ./image-dir --image-path ./image-dir --lazy-pages test_busybox_restore <&60 >&51 2>&51 + __runc --criu "$CRIU" restore -d --work-path ./image-dir --image-path ./image-dir --lazy-pages test_container_restore <&60 >&51 2>&51 ret=$? cat ./work-dir/restore.log | grep -B 5 Error || true [ $ret -eq 0 ] - # busybox should be back up and running - testcontainer test_busybox_restore running + # container should be back up and running + testcontainer test_container_restore running - runc exec --cwd /bin test_busybox_restore echo ok + runc exec --cwd /bin test_container_restore echo ok [ "$status" -eq 0 ] [[ ${output} == "ok" ]] @@ -221,34 +221,34 @@ function simple_cr() { # tell runc which network namespace to use update_config '(.. | select(.type? == "network")) .path |= "'"$ns_path"'"' - runc run -d --console-socket $CONSOLE_SOCKET test_busybox + runc run -d --console-socket $CONSOLE_SOCKET test_container [ "$status" -eq 0 ] - testcontainer test_busybox running + testcontainer test_container running for i in `seq 2`; do # checkpoint the running container; this automatically tells CRIU to # handle the network namespace defined in config.json as an external - runc --criu "$CRIU" checkpoint --work-path ./work-dir test_busybox + runc --criu "$CRIU" checkpoint --work-path ./work-dir test_container # if you are having problems getting criu to work uncomment the following dump: - #cat /run/opencontainer/containers/test_busybox/criu.work/dump.log + #cat /run/opencontainer/containers/test_container/criu.work/dump.log cat ./work-dir/dump.log | grep -B 5 Error || true [ "$status" -eq 0 ] - # after checkpoint busybox is no longer running - testcontainer test_busybox checkpointed + # after checkpoint container is no longer running + testcontainer test_container checkpointed # restore from checkpoint; this should restore the container into the existing network namespace - runc --criu "$CRIU" restore -d --work-path ./work-dir --console-socket $CONSOLE_SOCKET test_busybox + runc --criu "$CRIU" restore -d --work-path ./work-dir --console-socket $CONSOLE_SOCKET test_container ret=$? cat ./work-dir/restore.log | grep -B 5 Error || true [ "$ret" -eq 0 ] - # busybox should be back up and running - testcontainer test_busybox running + # container should be back up and running + testcontainer test_container running # container should be running in same network namespace as before - pid=`__runc state test_busybox | jq '.pid'` + pid=`__runc state test_container | jq '.pid'` ns_inode_new=`readlink /proc/$pid/ns/net | sed -e 's/.*\[\(.*\)\]/\1/'` echo "old network namespace inode $ns_inode" echo "new network namespace inode $ns_inode_new" @@ -277,31 +277,31 @@ function simple_cr() { # Make sure the RPC defined configuration file overwrites the previous echo "log-file=$tmplog2" > $tmp - runc run -d --console-socket $CONSOLE_SOCKET test_busybox + runc run -d --console-socket $CONSOLE_SOCKET test_container [ "$status" -eq 0 ] - testcontainer test_busybox running + testcontainer test_container running # checkpoint the running container - runc --criu "$CRIU" checkpoint --work-path ./work-dir test_busybox + runc --criu "$CRIU" checkpoint --work-path ./work-dir test_container cat ./work-dir/dump.log | grep -B 5 Error || true [ "$status" -eq 0 ] ! test -f ./work-dir/$tmplog1 test -f ./work-dir/$tmplog2 - # after checkpoint busybox is no longer running - testcontainer test_busybox checkpointed + # after checkpoint container is no longer running + testcontainer test_container checkpointed test -f ./work-dir/$tmplog2 && unlink ./work-dir/$tmplog2 # restore from checkpoint - runc --criu "$CRIU" restore -d --work-path ./work-dir --console-socket $CONSOLE_SOCKET test_busybox + runc --criu "$CRIU" restore -d --work-path ./work-dir --console-socket $CONSOLE_SOCKET test_container cat ./work-dir/restore.log | grep -B 5 Error || true [ "$status" -eq 0 ] ! test -f ./work-dir/$tmplog1 test -f ./work-dir/$tmplog2 - # busybox should be back up and running - testcontainer test_busybox running + # container should be back up and running + testcontainer test_container running unlink $tmp test -f ./work-dir/$tmplog2 && unlink ./work-dir/$tmplog2 } diff --git a/tests/integration/create.bats b/tests/integration/create.bats index abd4da24dbc..4aa1aed1c4e 100644 --- a/tests/integration/create.bats +++ b/tests/integration/create.bats @@ -3,63 +3,63 @@ load helpers function setup() { - teardown_busybox - setup_busybox + teardown_container + setup_container } function teardown() { - teardown_busybox + teardown_container } @test "runc create" { - runc create --console-socket $CONSOLE_SOCKET test_busybox + runc create --console-socket $CONSOLE_SOCKET test_container [ "$status" -eq 0 ] - testcontainer test_busybox created + testcontainer test_container created # start the command - runc start test_busybox + runc start test_container [ "$status" -eq 0 ] - testcontainer test_busybox running + testcontainer test_container running } @test "runc create exec" { - runc create --console-socket $CONSOLE_SOCKET test_busybox + runc create --console-socket $CONSOLE_SOCKET test_container [ "$status" -eq 0 ] - testcontainer test_busybox created + testcontainer test_container created - runc exec test_busybox true + runc exec test_container true [ "$status" -eq 0 ] - testcontainer test_busybox created + testcontainer test_container created # start the command - runc start test_busybox + runc start test_container [ "$status" -eq 0 ] - testcontainer test_busybox running + testcontainer test_container running } @test "runc create --pid-file" { - runc create --pid-file pid.txt --console-socket $CONSOLE_SOCKET test_busybox + runc create --pid-file pid.txt --console-socket $CONSOLE_SOCKET test_container [ "$status" -eq 0 ] - testcontainer test_busybox created + testcontainer test_container created # check pid.txt was generated [ -e pid.txt ] run cat pid.txt [ "$status" -eq 0 ] - [[ ${lines[0]} == $(__runc state test_busybox | jq '.pid') ]] + [[ ${lines[0]} == $(__runc state test_container | jq '.pid') ]] # start the command - runc start test_busybox + runc start test_container [ "$status" -eq 0 ] - testcontainer test_busybox running + testcontainer test_container running } @test "runc create --pid-file with new CWD" { @@ -69,21 +69,21 @@ function teardown() { run cd pid_file [ "$status" -eq 0 ] - runc create --pid-file pid.txt -b $BUSYBOX_BUNDLE --console-socket $CONSOLE_SOCKET test_busybox + runc create --pid-file pid.txt -b $BUNDLE --console-socket $CONSOLE_SOCKET test_container [ "$status" -eq 0 ] - testcontainer test_busybox created + testcontainer test_container created # check pid.txt was generated [ -e pid.txt ] run cat pid.txt [ "$status" -eq 0 ] - [[ ${lines[0]} == $(__runc state test_busybox | jq '.pid') ]] + [[ ${lines[0]} == $(__runc state test_container | jq '.pid') ]] # start the command - runc start test_busybox + runc start test_container [ "$status" -eq 0 ] - testcontainer test_busybox running + testcontainer test_container running } diff --git a/tests/integration/debug.bats b/tests/integration/debug.bats index e02cf4a1f37..6e5eaae86f9 100644 --- a/tests/integration/debug.bats +++ b/tests/integration/debug.bats @@ -3,17 +3,20 @@ load helpers function setup() { - teardown_hello - setup_hello + teardown_container + setup_container + + # Setup a process that terminates (instead of /bin/bash) + update_config '.process.args = ["echo", "DEFAULT_COMMAND"]' $BUNDLE } function teardown() { - teardown_hello + teardown_container } @test "global --debug" { - # run hello-world - runc --debug run test_hello + # run container-world + runc --debug run test_container echo "${output}" [ "$status" -eq 0 ] @@ -24,8 +27,8 @@ function teardown() { } @test "global --debug to --log" { - # run hello-world - runc --log log.out --debug run test_hello + # run container-world + runc --log log.out --debug run test_container [ "$status" -eq 0 ] # check output does not include debug info @@ -43,8 +46,8 @@ function teardown() { } @test "global --debug to --log --log-format 'text'" { - # run hello-world - runc --log log.out --log-format "text" --debug run test_hello + # run container-world + runc --log log.out --log-format "text" --debug run test_container [ "$status" -eq 0 ] # check output does not include debug info @@ -62,8 +65,8 @@ function teardown() { } @test "global --debug to --log --log-format 'json'" { - # run hello-world - runc --log log.out --log-format "json" --debug run test_hello + # run container-world + runc --log log.out --log-format "json" --debug run test_container [ "$status" -eq 0 ] # check output does not include debug info diff --git a/tests/integration/delete.bats b/tests/integration/delete.bats index bccd52e7245..d0c533b7c51 100644 --- a/tests/integration/delete.bats +++ b/tests/integration/delete.bats @@ -3,47 +3,47 @@ load helpers function setup() { - teardown_busybox - setup_busybox + teardown_container + setup_container } function teardown() { - teardown_busybox + teardown_container } @test "runc delete" { - # run busybox detached - runc run -d --console-socket $CONSOLE_SOCKET test_busybox + # run container detached + runc run -d --console-socket $CONSOLE_SOCKET test_container [ "$status" -eq 0 ] # check state - testcontainer test_busybox running + testcontainer test_container running - runc kill test_busybox KILL + runc kill test_container KILL [ "$status" -eq 0 ] - # wait for busybox to be in the destroyed state - retry 10 1 eval "__runc state test_busybox | grep -q 'stopped'" + # wait for container to be in the destroyed state + retry 10 1 eval "__runc state test_container | grep -q 'stopped'" - # delete test_busybox - runc delete test_busybox + # delete test_container + runc delete test_container [ "$status" -eq 0 ] - runc state test_busybox + runc state test_container [ "$status" -ne 0 ] } @test "runc delete --force" { - # run busybox detached - runc run -d --console-socket $CONSOLE_SOCKET test_busybox + # run container detached + runc run -d --console-socket $CONSOLE_SOCKET test_container [ "$status" -eq 0 ] # check state - testcontainer test_busybox running + testcontainer test_container running - # force delete test_busybox - runc delete --force test_busybox + # force delete test_container + runc delete --force test_container - runc state test_busybox + runc state test_container [ "$status" -ne 0 ] } @@ -54,21 +54,21 @@ function teardown() { @test "runc delete --force in cgroupv2 with subcgroups" { requires cgroups_v2 root - set_cgroups_path "$BUSYBOX_BUNDLE" - set_cgroup_mount_writable "$BUSYBOX_BUNDLE" + set_cgroups_path "$BUNDLE" + set_cgroup_mount_writable "$BUNDLE" - # run busybox detached - runc run -d --console-socket $CONSOLE_SOCKET test_busybox + # run container detached + runc run -d --console-socket $CONSOLE_SOCKET test_container [ "$status" -eq 0 ] # check state - testcontainer test_busybox running + testcontainer test_container running # create a sub process - __runc exec -d test_busybox sleep 1d + __runc exec -d test_container sleep 1d # find the pid of sleep - pid=$(__runc exec test_busybox ps -a | grep 1d | awk '{print $1}') + pid=$(__runc exec test_container ps -a | grep 1d | awk '{print $1}') [[ ${pid} =~ [0-9]+ ]] # create subcgroups @@ -82,17 +82,17 @@ function teardown() { echo ${pid} > cgroup.threads cat cgroup.threads EOF - cat nest.sh | runc exec test_busybox sh + cat nest.sh | runc exec test_container sh [ "$status" -eq 0 ] [[ "$output" =~ [0-9]+ ]] # check create subcgroups success [ -d $CGROUP_PATH/foo ] - # force delete test_busybox - runc delete --force test_busybox + # force delete test_container + runc delete --force test_container - runc state test_busybox + runc state test_container [ "$status" -ne 0 ] # check delete subcgroups success diff --git a/tests/integration/events.bats b/tests/integration/events.bats index a69ef9bbeb5..17f6933dc30 100644 --- a/tests/integration/events.bats +++ b/tests/integration/events.bats @@ -3,12 +3,12 @@ load helpers function setup() { - teardown_busybox - setup_busybox + teardown_container + setup_container } function teardown() { - teardown_busybox + teardown_container } @test "events --stats" { @@ -16,14 +16,14 @@ function teardown() { requires root init_cgroup_paths - # run busybox detached - runc run -d --console-socket $CONSOLE_SOCKET test_busybox + # run container detached + runc run -d --console-socket $CONSOLE_SOCKET test_container [ "$status" -eq 0 ] # generate stats - runc events --stats test_busybox + runc events --stats test_container [ "$status" -eq 0 ] - [[ "${lines[0]}" == [\{]"\"type\""[:]"\"stats\""[,]"\"id\""[:]"\"test_busybox\""[,]* ]] + [[ "${lines[0]}" == [\{]"\"type\""[:]"\"stats\""[,]"\"id\""[:]"\"test_container\""[,]* ]] [[ "${lines[0]}" == *"data"* ]] } @@ -32,18 +32,18 @@ function teardown() { requires root init_cgroup_paths - # run busybox detached - runc run -d --console-socket $CONSOLE_SOCKET test_busybox + # run container detached + runc run -d --console-socket $CONSOLE_SOCKET test_container [ "$status" -eq 0 ] # spawn two sub processes (shells) # the first sub process is an event logger that sends stats events to events.log - # the second sub process waits for an event that includes test_busybox then - # kills the test_busybox container which causes the event logger to exit - (__runc events test_busybox > events.log) & + # the second sub process waits for an event that includes test_container then + # kills the test_container container which causes the event logger to exit + (__runc events test_container > events.log) & ( - retry 10 1 eval "grep -q 'test_busybox' events.log" - teardown_running_container test_busybox + retry 10 1 eval "grep -q 'test_container' events.log" + teardown_running_container test_container ) & wait # wait for the above sub shells to finish @@ -51,7 +51,7 @@ function teardown() { run cat events.log [ "$status" -eq 0 ] - [[ "${lines[0]}" == [\{]"\"type\""[:]"\"stats\""[,]"\"id\""[:]"\"test_busybox\""[,]* ]] + [[ "${lines[0]}" == [\{]"\"type\""[:]"\"stats\""[,]"\"id\""[:]"\"test_container\""[,]* ]] [[ "${lines[0]}" == *"data"* ]] } @@ -60,25 +60,25 @@ function teardown() { requires root init_cgroup_paths - # run busybox detached - runc run -d --console-socket $CONSOLE_SOCKET test_busybox + # run container detached + runc run -d --console-socket $CONSOLE_SOCKET test_container [ "$status" -eq 0 ] # spawn two sub processes (shells) # the first sub process is an event logger that sends stats events to events.log once a second - # the second sub process tries 3 times for an event that incudes test_busybox - # pausing 1s between each attempt then kills the test_busybox container which + # the second sub process tries 3 times for an event that incudes test_container + # pausing 1s between each attempt then kills the test_container container which # causes the event logger to exit - (__runc events --interval 1s test_busybox > events.log) & + (__runc events --interval 1s test_container > events.log) & ( - retry 3 1 eval "grep -q 'test_busybox' events.log" - teardown_running_container test_busybox + retry 3 1 eval "grep -q 'test_container' events.log" + teardown_running_container test_container ) & wait # wait for the above sub shells to finish [ -e events.log ] - run eval "grep -q 'test_busybox' events.log" + run eval "grep -q 'test_container' events.log" [ "$status" -eq 0 ] } @@ -87,8 +87,8 @@ function teardown() { requires root init_cgroup_paths - # run busybox detached - runc run -d --console-socket $CONSOLE_SOCKET test_busybox + # run container detached + runc run -d --console-socket $CONSOLE_SOCKET test_container [ "$status" -eq 0 ] #prove there is no carry over of events.log from a prior test @@ -96,19 +96,19 @@ function teardown() { # spawn two sub processes (shells) # the first sub process is an event logger that sends stats events to events.log once every 100ms - # the second sub process tries 3 times for an event that incudes test_busybox - # pausing 100s between each attempt then kills the test_busybox container which + # the second sub process tries 3 times for an event that incudes test_container + # pausing 100s between each attempt then kills the test_container container which # causes the event logger to exit - (__runc events --interval 100ms test_busybox > events.log) & + (__runc events --interval 100ms test_container > events.log) & ( - retry 3 0.100 eval "grep -q 'test_busybox' events.log" - teardown_running_container test_busybox + retry 3 0.100 eval "grep -q 'test_container' events.log" + teardown_running_container test_container ) & wait # wait for the above sub shells to finish [ -e events.log ] - run eval "grep -q 'test_busybox' events.log" + run eval "grep -q 'test_container' events.log" [ "$status" -eq 0 ] } @@ -118,24 +118,24 @@ function teardown() { init_cgroup_paths # we need the container to hit OOM, so disable swap - update_config '(.. | select(.resources? != null)) .resources.memory |= {"limit": 33554432, "swap": 33554432}' ${BUSYBOX_BUNDLE} + update_config '(.. | select(.resources? != null)) .resources.memory |= {"limit": 33554432, "swap": 33554432}' ${BUNDLE} - # run busybox detached - runc run -d --console-socket $CONSOLE_SOCKET test_busybox + # run container detached + runc run -d --console-socket $CONSOLE_SOCKET test_container [ "$status" -eq 0 ] # spawn two sub processes (shells) # the first sub process is an event logger that sends stats events to events.log # the second sub process exec a memory hog process to cause a oom condition # and waits for an oom event - (__runc events test_busybox > events.log) & + (__runc events test_container > events.log) & ( - retry 10 1 eval "grep -q 'test_busybox' events.log" - __runc exec -d test_busybox sh -c 'test=$(dd if=/dev/urandom ibs=5120k)' + retry 10 1 eval "grep -q 'test_container' events.log" + __runc exec -d test_container sh -c 'test=$(dd if=/dev/urandom ibs=5120k)' retry 10 1 eval "grep -q 'oom' events.log" - __runc delete -f test_busybox + __runc delete -f test_container ) & wait # wait for the above sub shells to finish - grep -q '{"type":"oom","id":"test_busybox"}' events.log + grep -q '{"type":"oom","id":"test_container"}' events.log } diff --git a/tests/integration/exec.bats b/tests/integration/exec.bats index 19647c155c1..94d45023c9b 100644 --- a/tests/integration/exec.bats +++ b/tests/integration/exec.bats @@ -3,31 +3,31 @@ load helpers function setup() { - teardown_busybox - setup_busybox + teardown_container + setup_container } function teardown() { - teardown_busybox + teardown_container } @test "runc exec" { - # run busybox detached - runc run -d --console-socket $CONSOLE_SOCKET test_busybox + # run container detached + runc run -d --console-socket $CONSOLE_SOCKET test_container [ "$status" -eq 0 ] - runc exec test_busybox echo Hello from exec + runc exec test_container echo Hello from exec [ "$status" -eq 0 ] echo text echoed = "'""${output}""'" [[ "${output}" == *"Hello from exec"* ]] } @test "runc exec --pid-file" { - # run busybox detached - runc run -d --console-socket $CONSOLE_SOCKET test_busybox + # run container detached + runc run -d --console-socket $CONSOLE_SOCKET test_container [ "$status" -eq 0 ] - runc exec --pid-file pid.txt test_busybox echo Hello from exec + runc exec --pid-file pid.txt test_container echo Hello from exec [ "$status" -eq 0 ] echo text echoed = "'""${output}""'" [[ "${output}" == *"Hello from exec"* ]] @@ -38,7 +38,7 @@ function teardown() { run cat pid.txt [ "$status" -eq 0 ] [[ ${lines[0]} =~ [0-9]+ ]] - [[ ${lines[0]} != $(__runc state test_busybox | jq '.pid') ]] + [[ ${lines[0]} != $(__runc state test_container | jq '.pid') ]] } @test "runc exec --pid-file with new CWD" { @@ -48,11 +48,11 @@ function teardown() { run cd pid_file [ "$status" -eq 0 ] - # run busybox detached - runc run -d -b $BUSYBOX_BUNDLE --console-socket $CONSOLE_SOCKET test_busybox + # run container detached + runc run -d -b $BUNDLE --console-socket $CONSOLE_SOCKET test_container [ "$status" -eq 0 ] - runc exec --pid-file pid.txt test_busybox echo Hello from exec + runc exec --pid-file pid.txt test_container echo Hello from exec [ "$status" -eq 0 ] echo text echoed = "'""${output}""'" [[ "${output}" == *"Hello from exec"* ]] @@ -63,15 +63,15 @@ function teardown() { run cat pid.txt [ "$status" -eq 0 ] [[ ${lines[0]} =~ [0-9]+ ]] - [[ ${lines[0]} != $(__runc state test_busybox | jq '.pid') ]] + [[ ${lines[0]} != $(__runc state test_container | jq '.pid') ]] } @test "runc exec ls -la" { - # run busybox detached - runc run -d --console-socket $CONSOLE_SOCKET test_busybox + # run container detached + runc run -d --console-socket $CONSOLE_SOCKET test_container [ "$status" -eq 0 ] - runc exec test_busybox ls -la + runc exec test_container ls -la [ "$status" -eq 0 ] [[ ${lines[0]} == *"total"* ]] [[ ${lines[1]} == *"."* ]] @@ -79,21 +79,21 @@ function teardown() { } @test "runc exec ls -la with --cwd" { - # run busybox detached - runc run -d --console-socket $CONSOLE_SOCKET test_busybox + # run container detached + runc run -d --console-socket $CONSOLE_SOCKET test_container [ "$status" -eq 0 ] - runc exec --cwd /bin test_busybox pwd + runc exec --cwd /bin test_container pwd [ "$status" -eq 0 ] [[ ${output} == "/bin"* ]] } @test "runc exec --env" { - # run busybox detached - runc run -d --console-socket $CONSOLE_SOCKET test_busybox + # run container detached + runc run -d --console-socket $CONSOLE_SOCKET test_container [ "$status" -eq 0 ] - runc exec --env RUNC_EXEC_TEST=true test_busybox env + runc exec --env RUNC_EXEC_TEST=true test_container env [ "$status" -eq 0 ] [[ ${output} == *"RUNC_EXEC_TEST=true"* ]] @@ -103,11 +103,11 @@ function teardown() { # --user can't work in rootless containers that don't have idmap. [[ "$ROOTLESS" -ne 0 ]] && requires rootless_idmap - # run busybox detached - runc run -d --console-socket $CONSOLE_SOCKET test_busybox + # run container detached + runc run -d --console-socket $CONSOLE_SOCKET test_container [ "$status" -eq 0 ] - runc exec --user 1000:1000 test_busybox id + runc exec --user 1000:1000 test_container id [ "$status" -eq 0 ] [[ "${output}" == "uid=1000 gid=1000"* ]] @@ -116,25 +116,25 @@ function teardown() { @test "runc exec --additional-gids" { requires root - # run busybox detached - runc run -d --console-socket $CONSOLE_SOCKET test_busybox + # run container detached + runc run -d --console-socket $CONSOLE_SOCKET test_container [ "$status" -eq 0 ] - wait_for_container 15 1 test_busybox + wait_for_container 15 1 test_container - runc exec --user 1000:1000 --additional-gids 100 --additional-gids 65534 test_busybox id + runc exec --user 1000:1000 --additional-gids 100 --additional-gids 65534 test_container id [ "$status" -eq 0 ] - [[ ${output} == "uid=1000 gid=1000 groups=100(users),65534(nogroup)" ]] + [[ ${output} == "uid=1000 gid=1000 groups=1000,100(users),65534" ]] } @test "runc exec --preserve-fds" { - # run busybox detached - runc run -d --console-socket $CONSOLE_SOCKET test_busybox + # run container detached + runc run -d --console-socket $CONSOLE_SOCKET test_container [ "$status" -eq 0 ] - run bash -c "cat hello > preserve-fds.test; exec 3 preserve-fds.test; exec 3 /dev/null || true umount $LIBPATH/$HOOKLIBCC.1.0.0 &> /dev/null || true - teardown_debian - setup_debian + teardown_container + setup_container } function teardown() { @@ -21,7 +21,7 @@ function teardown() { umount $LIBPATH/$HOOKLIBCC.1.0.0 &> /dev/null || true rm -f $HOOKLIBCR.1.0.0 $HOOKLIBCC.1.0.0 - teardown_debian + teardown_container } @test "runc run (hooks library tests)" { @@ -47,10 +47,11 @@ function teardown() { .hooks |= . + {"createRuntime": [{"path": "/bin/sh", "args": ["/bin/sh", "-c", $create_runtime_hook]}]} | .hooks |= . + {"createContainer": [{"path": "/bin/sh", "args": ["/bin/sh", "-c", $create_container_hook]}]} | .hooks |= . + {"startContainer": [{"path": "/bin/sh", "args": ["/bin/sh", "-c", "ldconfig"]}]} | - .process.args = ["/bin/sh", "-c", "ldconfig -p | grep librunc"]' $DEBIAN_BUNDLE/config.json) + .process.args = ["/bin/sh", "-c", "ldconfig -p | grep librunc"]' $BUNDLE/config.json) echo "${CONFIG}" > config.json + update_config '.root.readonly = false' $bundle - runc run test_debian + runc run test_container [ "$status" -eq 0 ] echo "Checking create-runtime library" diff --git a/tests/integration/kill.bats b/tests/integration/kill.bats index ef8de3b2805..ac0ebb2eaee 100644 --- a/tests/integration/kill.bats +++ b/tests/integration/kill.bats @@ -3,32 +3,32 @@ load helpers function setup() { - teardown_busybox - setup_busybox + teardown_container + setup_container } function teardown() { - teardown_busybox + teardown_container } -@test "kill detached busybox" { - # run busybox detached - runc run -d --console-socket $CONSOLE_SOCKET test_busybox +@test "kill detached container" { + # run container detached + runc run -d --console-socket $CONSOLE_SOCKET test_container [ "$status" -eq 0 ] # check state - testcontainer test_busybox running + testcontainer test_container running - runc kill test_busybox KILL + runc kill test_container KILL [ "$status" -eq 0 ] - retry 10 1 eval "__runc state test_busybox | grep -q 'stopped'" + retry 10 1 eval "__runc state test_container | grep -q 'stopped'" # we should ensure kill work after the container stopped - runc kill -a test_busybox 0 + runc kill -a test_container 0 [ "$status" -eq 0 ] - runc delete test_busybox + runc delete test_container [ "$status" -eq 0 ] } diff --git a/tests/integration/list.bats b/tests/integration/list.bats index 0a938c0a0c6..8ceae6aea57 100644 --- a/tests/integration/list.bats +++ b/tests/integration/list.bats @@ -3,54 +3,56 @@ load helpers function setup() { - teardown_running_container_inroot test_box1 $HELLO_BUNDLE - teardown_running_container_inroot test_box2 $HELLO_BUNDLE - teardown_running_container_inroot test_box3 $HELLO_BUNDLE - teardown_busybox - setup_busybox + teardown_running_container_inroot test_box1 $BUNDLE + teardown_running_container_inroot test_box2 $BUNDLE + teardown_running_container_inroot test_box3 $BUNDLE + teardown_container + setup_container } function teardown() { - teardown_running_container_inroot test_box1 $HELLO_BUNDLE - teardown_running_container_inroot test_box2 $HELLO_BUNDLE - teardown_running_container_inroot test_box3 $HELLO_BUNDLE - teardown_busybox + teardown_running_container_inroot test_box1 $BUNDLE + teardown_running_container_inroot test_box2 $BUNDLE + teardown_running_container_inroot test_box3 $BUNDLE + teardown_container } @test "list" { - # run a few busyboxes detached - ROOT=$HELLO_BUNDLE runc run -d --console-socket $CONSOLE_SOCKET test_box1 + # run a few containeres detached + update_config '.process.args = ["sleep", "10"]' $BUNDLE + runc run -d --console-socket $CONSOLE_SOCKET test_box1 [ "$status" -eq 0 ] - ROOT=$HELLO_BUNDLE runc run -d --console-socket $CONSOLE_SOCKET test_box2 + runc run -d --console-socket $CONSOLE_SOCKET test_box2 [ "$status" -eq 0 ] - ROOT=$HELLO_BUNDLE runc run -d --console-socket $CONSOLE_SOCKET test_box3 + runc run -d --console-socket $CONSOLE_SOCKET test_box3 [ "$status" -eq 0 ] - ROOT=$HELLO_BUNDLE runc list + runc list [ "$status" -eq 0 ] + [[ ${lines[0]} =~ ID\ +PID\ +STATUS\ +BUNDLE\ +CREATED+ ]] - [[ "${lines[1]}" == *"test_box1"*[0-9]*"running"*$BUSYBOX_BUNDLE*[0-9]* ]] - [[ "${lines[2]}" == *"test_box2"*[0-9]*"running"*$BUSYBOX_BUNDLE*[0-9]* ]] - [[ "${lines[3]}" == *"test_box3"*[0-9]*"running"*$BUSYBOX_BUNDLE*[0-9]* ]] + [[ "${lines[1]}" == *"test_box1"*[0-9]*"running"*$BUNDLE*[0-9]* ]] + [[ "${lines[2]}" == *"test_box2"*[0-9]*"running"*$BUNDLE*[0-9]* ]] + [[ "${lines[3]}" == *"test_box3"*[0-9]*"running"*$BUNDLE*[0-9]* ]] - ROOT=$HELLO_BUNDLE runc list -q + runc list -q [ "$status" -eq 0 ] [[ "${lines[0]}" == "test_box1" ]] [[ "${lines[1]}" == "test_box2" ]] [[ "${lines[2]}" == "test_box3" ]] - ROOT=$HELLO_BUNDLE runc list --format table + runc list --format table [ "$status" -eq 0 ] [[ ${lines[0]} =~ ID\ +PID\ +STATUS\ +BUNDLE\ +CREATED+ ]] - [[ "${lines[1]}" == *"test_box1"*[0-9]*"running"*$BUSYBOX_BUNDLE*[0-9]* ]] - [[ "${lines[2]}" == *"test_box2"*[0-9]*"running"*$BUSYBOX_BUNDLE*[0-9]* ]] - [[ "${lines[3]}" == *"test_box3"*[0-9]*"running"*$BUSYBOX_BUNDLE*[0-9]* ]] + [[ "${lines[1]}" == *"test_box1"*[0-9]*"running"*$BUNDLE*[0-9]* ]] + [[ "${lines[2]}" == *"test_box2"*[0-9]*"running"*$BUNDLE*[0-9]* ]] + [[ "${lines[3]}" == *"test_box3"*[0-9]*"running"*$BUNDLE*[0-9]* ]] - ROOT=$HELLO_BUNDLE runc list --format json + runc list --format json [ "$status" -eq 0 ] - [[ "${lines[0]}" == [\[][\{]"\"ociVersion\""[:]"\""*[0-9][\.]*[0-9][\.]*[0-9]*"\""[,]"\"id\""[:]"\"test_box1\""[,]"\"pid\""[:]*[0-9][,]"\"status\""[:]*"\"running\""[,]"\"bundle\""[:]*$BUSYBOX_BUNDLE*[,]"\"rootfs\""[:]"\""*"\""[,]"\"created\""[:]*[0-9]*[\}]* ]] - [[ "${lines[0]}" == *[,][\{]"\"ociVersion\""[:]"\""*[0-9][\.]*[0-9][\.]*[0-9]*"\""[,]"\"id\""[:]"\"test_box2\""[,]"\"pid\""[:]*[0-9][,]"\"status\""[:]*"\"running\""[,]"\"bundle\""[:]*$BUSYBOX_BUNDLE*[,]"\"rootfs\""[:]"\""*"\""[,]"\"created\""[:]*[0-9]*[\}]* ]] - [[ "${lines[0]}" == *[,][\{]"\"ociVersion\""[:]"\""*[0-9][\.]*[0-9][\.]*[0-9]*"\""[,]"\"id\""[:]"\"test_box3\""[,]"\"pid\""[:]*[0-9][,]"\"status\""[:]*"\"running\""[,]"\"bundle\""[:]*$BUSYBOX_BUNDLE*[,]"\"rootfs\""[:]"\""*"\""[,]"\"created\""[:]*[0-9]*[\}][\]] ]] + [[ "${lines[0]}" == [\[][\{]"\"ociVersion\""[:]"\""*[0-9][\.]*[0-9][\.]*[0-9]*"\""[,]"\"id\""[:]"\"test_box1\""[,]"\"pid\""[:]*[0-9][,]"\"status\""[:]*"\"running\""[,]"\"bundle\""[:]*$BUNDLE*[,]"\"rootfs\""[:]"\""*"\""[,]"\"created\""[:]*[0-9]*[\}]* ]] + [[ "${lines[0]}" == *[,][\{]"\"ociVersion\""[:]"\""*[0-9][\.]*[0-9][\.]*[0-9]*"\""[,]"\"id\""[:]"\"test_box2\""[,]"\"pid\""[:]*[0-9][,]"\"status\""[:]*"\"running\""[,]"\"bundle\""[:]*$BUNDLE*[,]"\"rootfs\""[:]"\""*"\""[,]"\"created\""[:]*[0-9]*[\}]* ]] + [[ "${lines[0]}" == *[,][\{]"\"ociVersion\""[:]"\""*[0-9][\.]*[0-9][\.]*[0-9]*"\""[,]"\"id\""[:]"\"test_box3\""[,]"\"pid\""[:]*[0-9][,]"\"status\""[:]*"\"running\""[,]"\"bundle\""[:]*$BUNDLE*[,]"\"rootfs\""[:]"\""*"\""[,]"\"created\""[:]*[0-9]*[\}][\]] ]] } diff --git a/tests/integration/mask.bats b/tests/integration/mask.bats index 79c08153eea..2177d6b080a 100644 --- a/tests/integration/mask.bats +++ b/tests/integration/mask.bats @@ -3,57 +3,57 @@ load helpers function setup() { - teardown_busybox - setup_busybox + teardown_container + setup_container # Create fake rootfs. mkdir rootfs/testdir echo "Forbidden information!" > rootfs/testfile # add extra masked paths - update_config '(.. | select(.maskedPaths? != null)) .maskedPaths += ["/testdir", "/testfile"]' + update_config '(.. | select(.maskedPaths? != null)) .maskedPaths += ["/testdir", "/testfile"]' } function teardown() { - teardown_busybox + teardown_container } @test "mask paths [file]" { - # run busybox detached - runc run -d --console-socket $CONSOLE_SOCKET test_busybox + # run container detached + runc run -d --console-socket $CONSOLE_SOCKET test_container [ "$status" -eq 0 ] - runc exec test_busybox cat /testfile + runc exec test_container cat /testfile [ "$status" -eq 0 ] [[ "${output}" == "" ]] - runc exec test_busybox rm -f /testfile + runc exec test_container rm -f /testfile [ "$status" -eq 1 ] [[ "${output}" == *"Read-only file system"* ]] - runc exec test_busybox umount /testfile - [ "$status" -eq 1 ] - [[ "${output}" == *"Operation not permitted"* ]] + runc exec test_container umount /testfile + [ "$status" -eq 32 ] + [[ "${output}" == *"must be superuser to unmount"* ]] } @test "mask paths [directory]" { - # run busybox detached - runc run -d --console-socket $CONSOLE_SOCKET test_busybox + # run container detached + runc run -d --console-socket $CONSOLE_SOCKET test_container [ "$status" -eq 0 ] - runc exec test_busybox ls /testdir + runc exec test_container ls /testdir [ "$status" -eq 0 ] [[ "${output}" == "" ]] - runc exec test_busybox touch /testdir/foo + runc exec test_container touch /testdir/foo [ "$status" -eq 1 ] [[ "${output}" == *"Read-only file system"* ]] - runc exec test_busybox rm -rf /testdir + runc exec test_container rm -rf /testdir [ "$status" -eq 1 ] [[ "${output}" == *"Read-only file system"* ]] - runc exec test_busybox umount /testdir - [ "$status" -eq 1 ] - [[ "${output}" == *"Operation not permitted"* ]] + runc exec test_container umount /testdir + [ "$status" -eq 32 ] + [[ "${output}" == *"must be superuser to unmount"* ]] } diff --git a/tests/integration/mounts.bats b/tests/integration/mounts.bats index bf2afa3d565..db7092de1d8 100644 --- a/tests/integration/mounts.bats +++ b/tests/integration/mounts.bats @@ -3,12 +3,12 @@ load helpers function setup() { - teardown_busybox - setup_busybox + teardown_container + setup_container } function teardown() { - teardown_busybox + teardown_container } @test "runc run [bind mount]" { diff --git a/tests/integration/multi-arch.bash b/tests/integration/multi-arch.bash index c0519146b0b..997169fbd02 100644 --- a/tests/integration/multi-arch.bash +++ b/tests/integration/multi-arch.bash @@ -1,43 +1,26 @@ #!/bin/bash -get_busybox() { - case $(go env GOARCH) in - arm64) - echo 'https://github.com/docker-library/busybox/raw/dist-arm64v8/glibc/busybox.tar.xz' - ;; - *) - echo 'https://github.com/docker-library/busybox/raw/dist-amd64/glibc/busybox.tar.xz' - ;; - esac -} -get_hello() { - case $(go env GOARCH) in - arm64) - echo 'hello-world-aarch64.tar' - ;; - *) - echo 'hello-world.tar' - ;; - esac -} +get_and_extract_opensuse() { + local tmp=$(mktemp -d) + local opensuse="opensuse:3.11.6" + local rootless=$(id -u) + local args=() -get_and_extract_debian() { - tmp=$(mktemp -d) cd "$tmp" - - debian="debian:3.11.6" - case $(go env GOARCH) in arm64) - skopeo copy docker://arm64v8/debian:buster "oci:$debian" + skopeo copy docker://arm64v8/opensuse/leap:15.1 "oci:$opensuse" ;; *) - skopeo copy docker://amd64/debian:buster "oci:$debian" + skopeo copy docker://opensuse/leap:15.1 "oci:$opensuse" ;; esac - args="$([ -z "${ROOTLESS_TESTPATH+x}" ] && echo "--rootless")" - umoci unpack $args --image "$debian" "$1" + if [ "$ROOTLESS" -ne 0 ]; then + args+=("--rootless") + fi + umoci unpack "${args[@]}" --image "$opensuse" "$1" + chmod -R 755 "$1/rootfs/var/lib/ca-certificates/" cd - rm -rf "$tmp" diff --git a/tests/integration/pause.bats b/tests/integration/pause.bats index f2576f34a6c..101b8ce0ecc 100644 --- a/tests/integration/pause.bats +++ b/tests/integration/pause.bats @@ -3,78 +3,78 @@ load helpers function setup() { - teardown_busybox - setup_busybox + teardown_container + setup_container } function teardown() { - teardown_busybox + teardown_container } @test "runc pause and resume" { if [[ "$ROOTLESS" -ne 0 ]] then requires rootless_cgroup - set_cgroups_path "$BUSYBOX_BUNDLE" + set_cgroups_path "$BUNDLE" fi requires cgroups_freezer - # run busybox detached - runc run -d --console-socket $CONSOLE_SOCKET test_busybox + # run container detached + runc run -d --console-socket $CONSOLE_SOCKET test_container [ "$status" -eq 0 ] - testcontainer test_busybox running + testcontainer test_container running - # pause busybox - runc pause test_busybox + # pause container + runc pause test_container [ "$status" -eq 0 ] - # test state of busybox is paused - testcontainer test_busybox paused + # test state of container is paused + testcontainer test_container paused - # resume busybox - runc resume test_busybox + # resume container + runc resume test_container [ "$status" -eq 0 ] - # test state of busybox is back to running - testcontainer test_busybox running + # test state of container is back to running + testcontainer test_container running } @test "runc pause and resume with nonexist container" { if [[ "$ROOTLESS" -ne 0 ]] then requires rootless_cgroup - set_cgroups_path "$BUSYBOX_BUNDLE" + set_cgroups_path "$BUNDLE" fi requires cgroups_freezer - # run test_busybox detached - runc run -d --console-socket $CONSOLE_SOCKET test_busybox + # run test_container detached + runc run -d --console-socket $CONSOLE_SOCKET test_container [ "$status" -eq 0 ] - testcontainer test_busybox running + testcontainer test_container running - # pause test_busybox and nonexistent container - runc pause test_busybox + # pause test_container and nonexistent container + runc pause test_container [ "$status" -eq 0 ] runc pause nonexistent [ "$status" -ne 0 ] - # test state of test_busybox is paused - testcontainer test_busybox paused + # test state of test_container is paused + testcontainer test_container paused - # resume test_busybox and nonexistent container - runc resume test_busybox + # resume test_container and nonexistent container + runc resume test_container [ "$status" -eq 0 ] runc resume nonexistent [ "$status" -ne 0 ] - # test state of test_busybox is back to running - testcontainer test_busybox running + # test state of test_container is back to running + testcontainer test_container running - # delete test_busybox - runc delete --force test_busybox + # delete test_container + runc delete --force test_container - runc state test_busybox + runc state test_container [ "$status" -ne 0 ] } diff --git a/tests/integration/ps.bats b/tests/integration/ps.bats index e8ea5532e21..9325955ce07 100644 --- a/tests/integration/ps.bats +++ b/tests/integration/ps.bats @@ -3,26 +3,26 @@ load helpers function setup() { - teardown_busybox - setup_busybox + teardown_container + setup_container } function teardown() { - teardown_busybox + teardown_container } @test "ps" { # ps is not supported, it requires cgroups requires root - # start busybox detached - runc run -d --console-socket $CONSOLE_SOCKET test_busybox + # start container detached + runc run -d --console-socket $CONSOLE_SOCKET test_container [ "$status" -eq 0 ] # check state - testcontainer test_busybox running + testcontainer test_container running - runc ps test_busybox + runc ps test_container [ "$status" -eq 0 ] [[ ${lines[0]} =~ UID\ +PID\ +PPID\ +C\ +STIME\ +TTY\ +TIME\ +CMD+ ]] [[ "${lines[1]}" == *"$(id -un 2>/dev/null)"*[0-9]* ]] @@ -32,14 +32,14 @@ function teardown() { # ps is not supported, it requires cgroups requires root - # start busybox detached - runc run -d --console-socket $CONSOLE_SOCKET test_busybox + # start container detached + runc run -d --console-socket $CONSOLE_SOCKET test_container [ "$status" -eq 0 ] # check state - testcontainer test_busybox running + testcontainer test_container running - runc ps -f json test_busybox + runc ps -f json test_container [ "$status" -eq 0 ] [[ ${lines[0]} =~ [0-9]+ ]] } @@ -48,14 +48,14 @@ function teardown() { # ps is not supported, it requires cgroups requires root - # start busybox detached - runc run -d --console-socket $CONSOLE_SOCKET test_busybox + # start container detached + runc run -d --console-socket $CONSOLE_SOCKET test_container [ "$status" -eq 0 ] # check state - testcontainer test_busybox running + testcontainer test_container running - runc ps test_busybox -e -x + runc ps test_container -e -x [ "$status" -eq 0 ] [[ ${lines[0]} =~ \ +PID\ +TTY\ +STAT\ +TIME\ +COMMAND+ ]] [[ "${lines[1]}" =~ [0-9]+ ]] @@ -64,23 +64,23 @@ function teardown() { @test "ps after the container stopped" { # ps requires cgroups [[ "$ROOTLESS" -ne 0 ]] && requires rootless_cgroup - set_cgroups_path "$BUSYBOX_BUNDLE" + set_cgroups_path "$BUNDLE" - # start busybox detached - runc run -d --console-socket $CONSOLE_SOCKET test_busybox + # start container detached + runc run -d --console-socket $CONSOLE_SOCKET test_container [ "$status" -eq 0 ] # check state - testcontainer test_busybox running + testcontainer test_container running - runc ps test_busybox + runc ps test_container [ "$status" -eq 0 ] - runc kill test_busybox KILL + runc kill test_container KILL [ "$status" -eq 0 ] - retry 10 1 eval "__runc state test_busybox | grep -q 'stopped'" + retry 10 1 eval "__runc state test_container | grep -q 'stopped'" - runc ps test_busybox + runc ps test_container [ "$status" -eq 0 ] } diff --git a/tests/integration/root.bats b/tests/integration/root.bats index 90b53b4b476..958c73a52d4 100644 --- a/tests/integration/root.bats +++ b/tests/integration/root.bats @@ -3,48 +3,48 @@ load helpers function setup() { - teardown_running_container_inroot test_dotbox $HELLO_BUNDLE - teardown_busybox - setup_busybox + teardown_running_container_inroot test_dotbox $BUNDLE + teardown_container + setup_container } function teardown() { - teardown_running_container_inroot test_dotbox $HELLO_BUNDLE - teardown_busybox + teardown_running_container_inroot test_dotbox $BUNDLE + teardown_container } @test "global --root" { - # run busybox detached using $HELLO_BUNDLE for state - ROOT=$HELLO_BUNDLE runc run -d --console-socket $CONSOLE_SOCKET test_dotbox + # run container detached using $BUNDLE for state + ROOT=$BUNDLE runc run -d --console-socket $CONSOLE_SOCKET test_dotbox [ "$status" -eq 0 ] - # run busybox detached in default root - runc run -d --console-socket $CONSOLE_SOCKET test_busybox + # run container detached in default root + runc run -d --console-socket $CONSOLE_SOCKET test_container [ "$status" -eq 0 ] - runc state test_busybox + runc state test_container [ "$status" -eq 0 ] [[ "${output}" == *"running"* ]] - ROOT=$HELLO_BUNDLE runc state test_dotbox + ROOT=$BUNDLE runc state test_dotbox [ "$status" -eq 0 ] [[ "${output}" == *"running"* ]] - ROOT=$HELLO_BUNDLE runc state test_busybox + ROOT=$BUNDLE runc state test_container [ "$status" -ne 0 ] runc state test_dotbox [ "$status" -ne 0 ] - runc kill test_busybox KILL + runc kill test_container KILL [ "$status" -eq 0 ] - retry 10 1 eval "__runc state test_busybox | grep -q 'stopped'" - runc delete test_busybox + retry 10 1 eval "__runc state test_container | grep -q 'stopped'" + runc delete test_container [ "$status" -eq 0 ] - ROOT=$HELLO_BUNDLE runc kill test_dotbox KILL + ROOT=$BUNDLE runc kill test_dotbox KILL [ "$status" -eq 0 ] - retry 10 1 eval "ROOT='$HELLO_BUNDLE' __runc state test_dotbox | grep -q 'stopped'" - ROOT=$HELLO_BUNDLE runc delete test_dotbox + retry 10 1 eval "ROOT='$BUNDLE' __runc state test_dotbox | grep -q 'stopped'" + ROOT=$BUNDLE runc delete test_dotbox [ "$status" -eq 0 ] } diff --git a/tests/integration/spec.bats b/tests/integration/spec.bats index 1aa3881587f..6447d77501c 100644 --- a/tests/integration/spec.bats +++ b/tests/integration/spec.bats @@ -3,23 +3,17 @@ load helpers function setup() { - # initial cleanup in case a prior test exited and did not cleanup - cd "$INTEGRATION_ROOT" - run rm -f -r "$HELLO_BUNDLE" - - # setup hello-world for spec generation testing - run mkdir "$HELLO_BUNDLE" - run mkdir "$HELLO_BUNDLE"/rootfs - run tar -C "$HELLO_BUNDLE"/rootfs -xf "$HELLO_IMAGE" + teardown_container + setup_container + rm "$BUNDLE"/config.json } function teardown() { - cd "$INTEGRATION_ROOT" - run rm -f -r "$HELLO_BUNDLE" + teardown_container } @test "spec generation cwd" { - cd "$HELLO_BUNDLE" + cd "$BUNDLE" # note this test runs from the bundle not the integration root # test that config.json does not exist after the above partial setup @@ -36,11 +30,11 @@ function teardown() { run bash -c "grep -A2 'args' config.json | grep 'sh'" [[ "${output}" == *"sh"* ]] - # change the default args parameter from sh to hello - update_config '(.. | select(.? == "sh")) |= "/hello"' + # change the default args parameter from sh to echo + update_config '.process.args = ["echo", "hello"]' $BUNDLE - # ensure the generated spec works by running hello-world - runc run test_hello + # ensure the generated spec works by running container-world + runc run test_container [ "$status" -eq 0 ] } @@ -48,26 +42,26 @@ function teardown() { # note this test runs from the integration root not the bundle # test that config.json does not exist after the above partial setup - [ ! -e "$HELLO_BUNDLE"/config.json ] + [ ! -e "$BUNDLE"/config.json ] # test generation of spec does not return an error - runc_spec "$HELLO_BUNDLE" + runc_spec "$BUNDLE" [ "$status" -eq 0 ] # test generation of spec created our config.json (spec) - [ -e "$HELLO_BUNDLE"/config.json ] + [ -e "$BUNDLE"/config.json ] - # change the default args parameter from sh to hello - update_config '(.. | select(.? == "sh")) |= "/hello"' $HELLO_BUNDLE + # change the default args parameter from sh to echo + update_config '.process.args = ["echo", "hello"]' $BUNDLE - # ensure the generated spec works by running hello-world - runc run --bundle "$HELLO_BUNDLE" test_hello + # ensure the generated spec works by running container-world + runc run --bundle "$BUNDLE" test_container [ "$status" -eq 0 ] } @test "spec validator" { TESTDIR=$(pwd) - cd "$HELLO_BUNDLE" + cd "$BUNDLE" run git clone https://github.com/opencontainers/runtime-spec.git src/runtime-spec [ "$status" -eq 0 ] diff --git a/tests/integration/start.bats b/tests/integration/start.bats index 1f0ea8e1c3b..30cff5cf56e 100644 --- a/tests/integration/start.bats +++ b/tests/integration/start.bats @@ -3,29 +3,29 @@ load helpers function setup() { - teardown_busybox - setup_busybox + teardown_container + setup_container } function teardown() { - teardown_busybox + teardown_container } @test "runc start" { - runc create --console-socket $CONSOLE_SOCKET test_busybox + runc create --console-socket $CONSOLE_SOCKET test_container [ "$status" -eq 0 ] - testcontainer test_busybox created + testcontainer test_container created - # start container test_busybox - runc start test_busybox + # start container test_container + runc start test_container [ "$status" -eq 0 ] - testcontainer test_busybox running + testcontainer test_container running - # delete test_busybox - runc delete --force test_busybox + # delete test_container + runc delete --force test_container - runc state test_busybox + runc state test_container [ "$status" -ne 0 ] } diff --git a/tests/integration/start_detached.bats b/tests/integration/start_detached.bats index 80672e47d77..12c2deef932 100644 --- a/tests/integration/start_detached.bats +++ b/tests/integration/start_detached.bats @@ -3,21 +3,21 @@ load helpers function setup() { - teardown_busybox - setup_busybox + teardown_container + setup_container } function teardown() { - teardown_busybox + teardown_container } @test "runc run detached" { - # run busybox detached - runc run -d --console-socket $CONSOLE_SOCKET test_busybox + # run container detached + runc run -d --console-socket $CONSOLE_SOCKET test_container [ "$status" -eq 0 ] # check state - testcontainer test_busybox running + testcontainer test_container running } @test "runc run detached ({u,g}id != 0)" { @@ -29,28 +29,28 @@ function teardown() { update_config ' (.. | select(.uid? == 0)) .uid |= 1000 | (.. | select(.gid? == 0)) .gid |= 100' - # run busybox detached - runc run -d --console-socket $CONSOLE_SOCKET test_busybox + # run container detached + runc run -d --console-socket $CONSOLE_SOCKET test_container [ "$status" -eq 0 ] # check state - testcontainer test_busybox running + testcontainer test_container running } @test "runc run detached --pid-file" { - # run busybox detached - runc run --pid-file pid.txt -d --console-socket $CONSOLE_SOCKET test_busybox + # run container detached + runc run --pid-file pid.txt -d --console-socket $CONSOLE_SOCKET test_container [ "$status" -eq 0 ] # check state - testcontainer test_busybox running + testcontainer test_container running # check pid.txt was generated [ -e pid.txt ] run cat pid.txt [ "$status" -eq 0 ] - [[ ${lines[0]} == $(__runc state test_busybox | jq '.pid') ]] + [[ ${lines[0]} == $(__runc state test_container | jq '.pid') ]] } @test "runc run detached --pid-file with new CWD" { @@ -60,17 +60,17 @@ function teardown() { run cd pid_file [ "$status" -eq 0 ] - # run busybox detached - runc run --pid-file pid.txt -d -b $BUSYBOX_BUNDLE --console-socket $CONSOLE_SOCKET test_busybox + # run container detached + runc run --pid-file pid.txt -d -b $BUNDLE --console-socket $CONSOLE_SOCKET test_container [ "$status" -eq 0 ] # check state - testcontainer test_busybox running + testcontainer test_container running # check pid.txt was generated [ -e pid.txt ] run cat pid.txt [ "$status" -eq 0 ] - [[ ${lines[0]} == $(__runc state test_busybox | jq '.pid') ]] + [[ ${lines[0]} == $(__runc state test_container | jq '.pid') ]] } diff --git a/tests/integration/start_hello.bats b/tests/integration/start_hello.bats index e4200eb4b16..1b60fc8781f 100644 --- a/tests/integration/start_hello.bats +++ b/tests/integration/start_hello.bats @@ -3,17 +3,20 @@ load helpers function setup() { - teardown_hello - setup_hello + teardown_container + setup_container + + # Setup a process that terminates (instead of /bin/bash) + update_config '.process.args = ["echo", "Hello"]' $BUNDLE } function teardown() { - teardown_hello + teardown_container } @test "runc run" { - # run hello-world - runc run test_hello + # run container-world + runc run test_container [ "$status" -eq 0 ] # check expected output @@ -26,11 +29,11 @@ function teardown() { # replace "uid": 0 with "uid": 1000 # and do a similar thing for gid. - update_config ' (.. | select(.uid? == 0)) .uid |= 1000 - | (.. | select(.gid? == 0)) .gid |= 100' + update_config ' (.. | select(.uid? == 0)) .uid |= 1000 + | (.. | select(.gid? == 0)) .gid |= 100' - # run hello-world - runc run test_hello + # run container-world + runc run test_container [ "$status" -eq 0 ] # check expected output @@ -43,15 +46,15 @@ function teardown() { cd rootfs update_config '(.. | select(. == "rootfs")) |= "."' - # run hello-world - runc run test_hello + # run container-world + runc run test_container [ "$status" -eq 0 ] [[ "${output}" == *"Hello"* ]] } @test "runc run --pid-file" { - # run hello-world - runc run --pid-file pid.txt test_hello + # run container-world + runc run --pid-file pid.txt test_container [ "$status" -eq 0 ] [[ "${output}" == *"Hello"* ]] diff --git a/tests/integration/state.bats b/tests/integration/state.bats index 68dae38b593..757d049fe6f 100644 --- a/tests/integration/state.bats +++ b/tests/integration/state.bats @@ -3,36 +3,36 @@ load helpers function setup() { - teardown_busybox - setup_busybox + teardown_container + setup_container } function teardown() { - teardown_busybox + teardown_container } @test "state (kill + delete)" { - runc state test_busybox + runc state test_container [ "$status" -ne 0 ] - # run busybox detached - runc run -d --console-socket $CONSOLE_SOCKET test_busybox + # run container detached + runc run -d --console-socket $CONSOLE_SOCKET test_container [ "$status" -eq 0 ] # check state - testcontainer test_busybox running + testcontainer test_container running - runc kill test_busybox KILL + runc kill test_container KILL [ "$status" -eq 0 ] - # wait for busybox to be in the destroyed state - retry 10 1 eval "__runc state test_busybox | grep -q 'stopped'" + # wait for container to be in the destroyed state + retry 10 1 eval "__runc state test_container | grep -q 'stopped'" - # delete test_busybox - runc delete test_busybox + # delete test_container + runc delete test_container [ "$status" -eq 0 ] - runc state test_busybox + runc state test_container [ "$status" -ne 0 ] } @@ -40,27 +40,27 @@ function teardown() { # XXX: pause and resume require cgroups. requires root - runc state test_busybox + runc state test_container [ "$status" -ne 0 ] - # run busybox detached - runc run -d --console-socket $CONSOLE_SOCKET test_busybox + # run container detached + runc run -d --console-socket $CONSOLE_SOCKET test_container [ "$status" -eq 0 ] # check state - testcontainer test_busybox running + testcontainer test_container running - # pause busybox - runc pause test_busybox + # pause container + runc pause test_container [ "$status" -eq 0 ] - # test state of busybox is paused - testcontainer test_busybox paused + # test state of container is paused + testcontainer test_container paused - # resume busybox - runc resume test_busybox + # resume container + runc resume test_container [ "$status" -eq 0 ] - # test state of busybox is back to running - testcontainer test_busybox running + # test state of container is back to running + testcontainer test_container running } diff --git a/tests/integration/testdata/hello-world-aarch64.tar b/tests/integration/testdata/hello-world-aarch64.tar deleted file mode 100644 index 186c8aefc47..00000000000 Binary files a/tests/integration/testdata/hello-world-aarch64.tar and /dev/null differ diff --git a/tests/integration/testdata/hello-world.tar b/tests/integration/testdata/hello-world.tar deleted file mode 100644 index aec830e2ec6..00000000000 Binary files a/tests/integration/testdata/hello-world.tar and /dev/null differ diff --git a/tests/integration/tty.bats b/tests/integration/tty.bats index e18857fc7dd..efcbd708ba0 100644 --- a/tests/integration/tty.bats +++ b/tests/integration/tty.bats @@ -3,20 +3,20 @@ load helpers function setup() { - teardown_busybox - setup_busybox + teardown_container + setup_container } function teardown() { - teardown_busybox + teardown_container } @test "runc run [tty ptsname]" { # Replace sh script with readlink. update_config '(.. | select(.[]? == "sh")) += ["-c", "for file in /proc/self/fd/[012]; do readlink $file; done"]' - # run busybox - runc run test_busybox + # run container + runc run test_container [ "$status" -eq 0 ] [[ ${lines[0]} =~ /dev/pts/+ ]] [[ ${lines[1]} =~ /dev/pts/+ ]] @@ -31,8 +31,8 @@ function teardown() { # Replace sh script with stat. update_config '(.. | select(.[]? == "sh")) += ["-c", "stat -c %u:%g $(tty) | tr : \\\\n"]' - # run busybox - runc run test_busybox + # run container + runc run test_container [ "$status" -eq 0 ] [[ ${lines[0]} =~ 0 ]] # This is set by the default config.json (it corresponds to the standard tty group). @@ -50,8 +50,8 @@ function teardown() { | (.. | select(.gid? == 0)) .gid |= 100 | (.. | select(.[]? == "sh")) += ["-c", "stat -c %u:%g $(tty) | tr : \\\\n"]' - # run busybox - runc run test_busybox + # run container + runc run test_container [ "$status" -eq 0 ] [[ ${lines[0]} =~ 1000 ]] # This is set by the default config.json (it corresponds to the standard tty group). @@ -59,15 +59,15 @@ function teardown() { } @test "runc exec [tty ptsname]" { - # run busybox detached - runc run -d --console-socket $CONSOLE_SOCKET test_busybox + # run container detached + runc run -d --console-socket $CONSOLE_SOCKET test_container [ "$status" -eq 0 ] # make sure we're running - testcontainer test_busybox running + testcontainer test_container running # run the exec - runc exec -t test_busybox sh -c 'for file in /proc/self/fd/[012]; do readlink $file; done' + runc exec -t test_container sh -c 'for file in /proc/self/fd/[012]; do readlink $file; done' [ "$status" -eq 0 ] [[ ${lines[0]} =~ /dev/pts/+ ]] [[ ${lines[1]} =~ /dev/pts/+ ]] @@ -79,15 +79,15 @@ function teardown() { # TODO: this can be made as a change to the gid test. [[ "$ROOTLESS" -ne 0 ]] && requires rootless_idmap - # run busybox detached - runc run -d --console-socket $CONSOLE_SOCKET test_busybox + # run container detached + runc run -d --console-socket $CONSOLE_SOCKET test_container [ "$status" -eq 0 ] # make sure we're running - testcontainer test_busybox running + testcontainer test_container running # run the exec - runc exec -t test_busybox sh -c 'stat -c %u:%g $(tty) | tr : \\n' + runc exec -t test_container sh -c 'stat -c %u:%g $(tty) | tr : \\n' [ "$status" -eq 0 ] [[ ${lines[0]} =~ 0 ]] [[ ${lines[1]} =~ 5 ]] @@ -102,15 +102,15 @@ function teardown() { update_config ' (.. | select(.uid? == 0)) .uid |= 1000 | (.. | select(.gid? == 0)) .gid |= 100' - # run busybox detached - runc run -d --console-socket $CONSOLE_SOCKET test_busybox + # run container detached + runc run -d --console-socket $CONSOLE_SOCKET test_container [ "$status" -eq 0 ] # make sure we're running - testcontainer test_busybox running + testcontainer test_container running # run the exec - runc exec -t test_busybox sh -c 'stat -c %u:%g $(tty) | tr : \\n' + runc exec -t test_container sh -c 'stat -c %u:%g $(tty) | tr : \\n' [ "$status" -eq 0 ] [[ ${lines[0]} =~ 1000 ]] [[ ${lines[1]} =~ 5 ]] @@ -120,12 +120,12 @@ function teardown() { # allow writing to filesystem update_config '(.. | select(.readonly? != null)) .readonly |= false' - # run busybox detached - runc run -d --console-socket $CONSOLE_SOCKET test_busybox + # run container detached + runc run -d --console-socket $CONSOLE_SOCKET test_container [ "$status" -eq 0 ] # make sure we're running - testcontainer test_busybox running + testcontainer test_container running tty_info_with_consize_size=$( cat < "$target_runtime" done - # run a detached busybox + # run a detached container runc run -d --console-socket $CONSOLE_SOCKET test_update_rt [ "$status" -eq 0 ]