Skip to content

Commit

Permalink
Switch to Ubuntu Focal for all integration testing
Browse files Browse the repository at this point in the history
Signed-off-by: Renaud Gaubert <rgaubert@nvidia.com>
  • Loading branch information
Renaud Gaubert committed Jul 30, 2020
1 parent 73b43d7 commit 66deae3
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 64 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ ENTRYPOINT ["/tmpmount"]

# setup a playground for us to spawn containers in
COPY tests/integration/multi-arch.bash tests/integration/
ENV ROOTFS /opensuse
ENV ROOTFS /ubuntu
RUN mkdir -p "${ROOTFS}"
RUN /bin/bash -c '. tests/integration/multi-arch.bash \
&& get_and_extract_opensuse "$ROOTFS"'
&& get_and_extract_ubuntu "$ROOTFS"'

COPY . .
6 changes: 3 additions & 3 deletions Vagrantfile.centos7
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ EOF
# Add a user for rootless tests
useradd -u2000 -m -d/home/rootless -s/bin/bash rootless
# Add opensuse for libcontainer/integration tests
# Add ubuntu for libcontainer/integration tests
. /vagrant/tests/integration/multi-arch.bash \
&& mkdir /opensuse \
&& get_and_extract_opensuse /opensuse
&& mkdir /ubuntu \
&& get_and_extract_ubuntu /ubuntu
SHELL
end
6 changes: 3 additions & 3 deletions Vagrantfile.fedora32
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ EOF
curl -o /usr/local/bin/umoci -fsSL https://github.com/opencontainers/umoci/releases/download/v0.4.6/umoci.amd64
chmod +x /usr/local/bin/umoci
# Add opensuse for libcontainer/integration tests
# Add ubuntu for libcontainer/integration tests
. /vagrant/tests/integration/multi-arch.bash \
&& mkdir /opensuse \
&& get_and_extract_opensuse /opensuse
&& mkdir /ubuntu \
&& get_and_extract_ubuntu /ubuntu
# Delegate cgroup v2 controllers to rootless user via --systemd-cgroup
mkdir -p /etc/systemd/system/user@.service.d
Expand Down
4 changes: 2 additions & 2 deletions libcontainer/integration/exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -665,8 +665,8 @@ 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 !strings.Contains(out.String(), "/bin/sh: fork: retry: Resource temporarily unavailable") {
t.Fatalf("expected fork() to fail with restrictive pids limit")
if !strings.Contains(out.String(), "/bin/sh: 0: Cannot fork") {
t.Fatalf("expected fork() to fail with restrictive pids limit, stdout: %q", out.String())
}

// Minimal restrictions are not really supported, due to quirks in using Go
Expand Down
42 changes: 4 additions & 38 deletions libcontainer/integration/seccomp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,26 +58,9 @@ func TestSeccompDenyGetcwdWithErrno(t *testing.T) {
if err != nil {
t.Fatal(err)
}
ps, err := pwd.Wait()
if err == nil {
t.Fatal("Expecting error (negative return code); instead exited cleanly!")
}

var exitCode int
status := ps.Sys().(syscall.WaitStatus)
if status.Exited() {
exitCode = status.ExitStatus()
} else if status.Signaled() {
exitCode = -int(status.Signal())
} else {
t.Fatalf("Unrecognized exit reason!")
}

if exitCode == 0 {
t.Fatalf("Getcwd should fail with negative exit code, instead got %d!", exitCode)
}
pwd.Wait()

expected := "getcwd: cannot access parent directories: No such process"
expected := "getcwd() failed: No such process"
actual := strings.Trim(buffers.Stderr.String(), "\n")
if !strings.Contains(actual, expected) {
t.Fatalf("Expected output to contain %q but got %q\n", expected, actual)
Expand Down Expand Up @@ -127,26 +110,9 @@ func TestSeccompDenyGetcwd(t *testing.T) {
if err != nil {
t.Fatal(err)
}
ps, err := pwd.Wait()
if err == nil {
t.Fatal("Expecting error (negative return code); instead exited cleanly!")
}

var exitCode int
status := ps.Sys().(syscall.WaitStatus)
if status.Exited() {
exitCode = status.ExitStatus()
} else if status.Signaled() {
exitCode = -int(status.Signal())
} else {
t.Fatalf("Unrecognized exit reason!")
}

if exitCode == 0 {
t.Fatalf("Getcwd should fail with negative exit code, instead got %d!", exitCode)
}
pwd.Wait()

expected := "getcwd: cannot access parent directories: Operation not permitted"
expected := "getcwd() failed: Operation not permitted"
actual := strings.Trim(buffers.Stderr.String(), "\n")
if !strings.Contains(actual, expected) {
t.Fatalf("Expected output to contain %q but got %q\n", expected, actual)
Expand Down
10 changes: 5 additions & 5 deletions libcontainer/integration/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func newTestBundle() (string, error) {
return dir, nil
}

// newRootfs creates a new tmp directory and copies the opensuse root filesystem
// newRootfs creates a new tmp directory and copies the ubuntu root filesystem
func newRootfs() (string, error) {
dir, err := ioutil.TempDir("", "")
if err != nil {
Expand All @@ -101,7 +101,7 @@ func newRootfs() (string, error) {
if err := os.MkdirAll(dir, 0700); err != nil {
return "", err
}
if err := copyOpensuse(dir); err != nil {
if err := copyUbuntu(dir); err != nil {
return "", err
}
return dir, nil
Expand All @@ -111,10 +111,10 @@ func remove(dir string) {
os.RemoveAll(dir)
}

// copyOpensuse copies the rootfs for a opensuse container created for the test image
// copyUbuntu copies the rootfs for an Ubuntu container created for the test image
// into the new directory for the specific test
func copyOpensuse(dest string) error {
out, err := exec.Command("sh", "-c", fmt.Sprintf("cp -a /opensuse/rootfs/* %s/", dest)).CombinedOutput()
func copyUbuntu(dest string) error {
out, err := exec.Command("sh", "-c", fmt.Sprintf("cp -a /ubuntu/rootfs/* %s/", dest)).CombinedOutput()
if err != nil {
return fmt.Errorf("copy error %q: %q", err, out)
}
Expand Down
5 changes: 3 additions & 2 deletions tests/integration/exec.bats
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function teardown() {

runc exec --cwd /bin test_container pwd
[ "$status" -eq 0 ]
[[ ${output} == "/bin"* ]]
[[ ${output} == "/usr/bin"* ]]
}

@test "runc exec --env" {
Expand Down Expand Up @@ -117,7 +117,8 @@ function teardown() {
runc exec --user 1000:1000 --additional-gids 100 --additional-gids 65534 test_container id
[ "$status" -eq 0 ]

[[ ${output} == "uid=1000 gid=1000 groups=1000,100(users),65534" ]]
echo "${output}"
[[ ${output} == "uid=1000 gid=1000 groups=1000,100(users),65534(nogroup)" ]]
}

@test "runc exec --preserve-fds" {
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/helpers.bash
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ function setup_container() {
local rootless_rootfs="/tmp/cached-rootfs"
setup_recvtty

get_and_extract_opensuse $BUNDLE
get_and_extract_ubuntu $BUNDLE

cd "$BUNDLE"
rm -f ./config.json
Expand Down
16 changes: 8 additions & 8 deletions tests/integration/multi-arch.bash
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
#! /bin/bash

get_and_extract_opensuse() {
local cache="/tmp/opensuse-cache"
local opensuse="opensuse:3.11.6"
get_and_extract_ubuntu() {
local cache="/tmp/ubuntu-cache"
local ubuntu="ubuntu:latest"
local rootless=$(id -u)
local args=()

if [ "$rootless" -ne 0 ]; then
cache="/tmp/opensuse-cache-rootless"
cache="/tmp/ubuntu-cache-rootless"
fi

mkdir -p "$cache"
cd "$cache"

if [ ! -d "$cache/opensuse" ]; then
if [ ! -d "$cache/ubuntu" ]; then
case $(go env GOARCH) in
arm64)
skopeo copy docker://arm64v8/opensuse/leap:15.1 "oci:$opensuse"
skopeo copy docker://arm64v8/ubuntu:focal "oci:$ubuntu"
;;
*)
skopeo copy docker://opensuse/leap:15.1 "oci:$opensuse"
skopeo copy docker://ubuntu:focal "oci:$ubuntu"
;;
esac
fi
Expand All @@ -29,7 +29,7 @@ get_and_extract_opensuse() {
args+=("--rootless")
fi

umoci unpack "${args[@]}" --image "$opensuse" "$cache"
umoci unpack "${args[@]}" --image "$ubuntu" "$cache"
fi

rm -r -f "$1"
Expand Down

0 comments on commit 66deae3

Please sign in to comment.