From c11472d31dc77bda2c8804023fc5d18a5f0d2ed1 Mon Sep 17 00:00:00 2001 From: Phil Estes Date: Tue, 10 Nov 2020 09:32:56 -0500 Subject: [PATCH 1/4] Add Go test runs to GitHub Actions CI Disable devmapper for now until test issues are fixed. Signed-off-by: Phil Estes --- .github/workflows/ci.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4f8303d9a..eea258566 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -205,6 +205,11 @@ jobs: git checkout "${SHIM_COMMIT}" GO111MODULE=on go build -mod=vendor -o "${bindir}/containerd-shim-runhcs-v1.exe" ./cmd/containerd-shim-runhcs-v1 + - name: Tests + env: + CGO_ENABLED: 1 + run: mingw32-make.exe test root-test + - name: Integration 1 env: CGO_ENABLED: 1 @@ -282,6 +287,15 @@ jobs: sudo make install working-directory: src/github.com/containerd/containerd + - name: Tests + env: + GOPROXY: direct + SKIPTESTS: github.com/containerd/containerd/snapshots/devmapper + run: | + make test + sudo -E PATH=$PATH GOPATH=$GOPATH GOPROXY=$GOPROXY make root-test + working-directory: src/github.com/containerd/containerd + - name: Integration 1 env: GOPROXY: direct From af2fb4eb777880fda0ba9004422d70742f4df7c1 Mon Sep 17 00:00:00 2001 From: Phil Estes Date: Tue, 10 Nov 2020 10:55:00 -0500 Subject: [PATCH 2/4] Allow oom adj test to run in environments with a score GitHub Actions process wrapper sets score adj to 500 for any process; the OOM score adj test expected default adj to be 0 during test. Signed-off-by: Phil Estes --- sys/oom_unix_test.go | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/sys/oom_unix_test.go b/sys/oom_unix_test.go index 9bad2db53..e6be852bc 100644 --- a/sys/oom_unix_test.go +++ b/sys/oom_unix_test.go @@ -30,7 +30,7 @@ import ( ) func TestSetPositiveOomScoreAdjustment(t *testing.T) { - adjustment, err := adjustOom(123) + _, adjustment, err := adjustOom(123) if err != nil { t.Error(err) return @@ -44,7 +44,7 @@ func TestSetNegativeOomScoreAdjustmentWhenPrivileged(t *testing.T) { return } - adjustment, err := adjustOom(-123) + _, adjustment, err := adjustOom(-123) if err != nil { t.Error(err) return @@ -58,32 +58,37 @@ func TestSetNegativeOomScoreAdjustmentWhenUnprivilegedHasNoEffect(t *testing.T) return } - adjustment, err := adjustOom(-123) + initial, adjustment, err := adjustOom(-123) if err != nil { t.Error(err) return } - assert.Check(t, is.Equal(adjustment, 0)) + assert.Check(t, is.Equal(adjustment, initial)) } -func adjustOom(adjustment int) (int, error) { +func adjustOom(adjustment int) (int, int, error) { cmd := exec.Command("sleep", "100") if err := cmd.Start(); err != nil { - return 0, err + return 0, 0, err } defer cmd.Process.Kill() pid, err := waitForPid(cmd.Process) if err != nil { - return 0, err + return 0, 0, err + } + initial, err := GetOOMScoreAdj(pid) + if err != nil { + return 0, 0, err } if err := SetOOMScore(pid, adjustment); err != nil { - return 0, err + return 0, 0, err } - return GetOOMScoreAdj(pid) + adj, err := GetOOMScoreAdj(pid) + return initial, adj, err } func waitForPid(process *os.Process) (int, error) { From 027ee569a3bcebed1f55f0aabdb5c0db35fc79cf Mon Sep 17 00:00:00 2001 From: Phil Estes Date: Thu, 19 Nov 2020 08:40:22 -0500 Subject: [PATCH 3/4] Import crypto for all snapshotters during testsuite Fixes runtime panic for testing snapshotters Signed-off-by: Phil Estes --- snapshots/testsuite/testsuite.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/snapshots/testsuite/testsuite.go b/snapshots/testsuite/testsuite.go index b2434025f..367a00837 100644 --- a/snapshots/testsuite/testsuite.go +++ b/snapshots/testsuite/testsuite.go @@ -18,6 +18,8 @@ package testsuite import ( "context" + //nolint:golint + _ "crypto/sha256" "fmt" "io/ioutil" "math/rand" From 85d9fe3e8ce823894fc47122f46da0dfabd9c657 Mon Sep 17 00:00:00 2001 From: Phil Estes Date: Thu, 19 Nov 2020 10:59:40 -0500 Subject: [PATCH 4/4] Adjust overlay tests to expect "index=off" When running tests on any modern distro, this assumption will work. If we need to make it work with kernels where we don't append this option it will require some more involved changes. Signed-off-by: Phil Estes --- snapshots/overlay/overlay_test.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/snapshots/overlay/overlay_test.go b/snapshots/overlay/overlay_test.go index 7671b83dc..77eed8530 100644 --- a/snapshots/overlay/overlay_test.go +++ b/snapshots/overlay/overlay_test.go @@ -174,6 +174,7 @@ func testOverlayOverlayMount(t *testing.T, newSnapshotter testsuite.SnapshotterF lower = "lowerdir=" + getParents(ctx, o, root, "/tmp/layer2")[0] ) for i, v := range []string{ + "index=off", work, upper, lower, @@ -334,12 +335,12 @@ func testOverlayView(t *testing.T, newSnapshotter testsuite.SnapshotterFunc) { if m.Source != "overlay" { t.Errorf("mount source should be overlay but received %q", m.Source) } - if len(m.Options) != 1 { - t.Errorf("expected 1 mount option but got %d", len(m.Options)) + if len(m.Options) != 2 { + t.Errorf("expected 1 additional mount option but got %d", len(m.Options)) } lowers := getParents(ctx, o, root, "/tmp/view2") expected = fmt.Sprintf("lowerdir=%s:%s", lowers[0], lowers[1]) - if m.Options[0] != expected { + if m.Options[1] != expected { t.Errorf("expected option %q but received %q", expected, m.Options[0]) } }