Skip to content

Commit 1b94da9

Browse files
authored
Merge pull request containerd#3402 from apostasie/ci-fix-tests
CI/test fixing
2 parents 7910442 + 935ee8a commit 1b94da9

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

cmd/nerdctl/container/container_run_security_linux_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,8 @@ func TestRunApparmor(t *testing.T) {
182182
attrCurrentEnforceExpected := fmt.Sprintf("%s (enforce)\n", defaultProfile)
183183
base.Cmd("run", "--rm", testutil.AlpineImage, "cat", attrCurrentPath).AssertOutExactly(attrCurrentEnforceExpected)
184184
base.Cmd("run", "--rm", "--security-opt", "apparmor="+defaultProfile, testutil.AlpineImage, "cat", attrCurrentPath).AssertOutExactly(attrCurrentEnforceExpected)
185-
base.Cmd("run", "--rm", "--security-opt", "apparmor=unconfined", testutil.AlpineImage, "cat", attrCurrentPath).AssertOutExactly("unconfined\n")
186-
base.Cmd("run", "--rm", "--privileged", testutil.AlpineImage, "cat", attrCurrentPath).AssertOutExactly("unconfined\n")
185+
base.Cmd("run", "--rm", "--security-opt", "apparmor=unconfined", testutil.AlpineImage, "cat", attrCurrentPath).AssertOutContains("unconfined")
186+
base.Cmd("run", "--rm", "--privileged", testutil.AlpineImage, "cat", attrCurrentPath).AssertOutContains("unconfined")
187187
}
188188

189189
// TestRunSeccompCapSysPtrace tests https://github.com/containerd/nerdctl/issues/976

cmd/nerdctl/image/image_load_linux_test.go

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,35 @@ import (
3232
func TestLoadStdinFromPipe(t *testing.T) {
3333
t.Parallel()
3434
base := testutil.NewBase(t)
35-
35+
img := testutil.Identifier(t)
3636
tmp := t.TempDir()
37-
img := testutil.Identifier(t) + "image"
38-
base.Cmd("pull", testutil.CommonImage).AssertOK()
39-
base.Cmd("tag", testutil.CommonImage, img).AssertOK()
40-
base.Cmd("save", img, "-o", filepath.Join(tmp, "common.tar")).AssertOK()
41-
base.Cmd("rmi", "-f", img).AssertOK()
42-
loadCmd := strings.Join(base.Cmd("load").Command, " ")
4337
output := filepath.Join(tmp, "output")
4438

39+
setup := func() {
40+
base.Cmd("pull", testutil.CommonImage).AssertOK()
41+
base.Cmd("tag", testutil.CommonImage, img).AssertOK()
42+
base.Cmd("save", img, "-o", filepath.Join(tmp, "common.tar")).AssertOK()
43+
base.Cmd("rmi", "-f", img).AssertOK()
44+
}
45+
46+
tearDown := func() {
47+
base.Cmd("rmi", "-f", img).AssertOK()
48+
}
49+
50+
t.Cleanup(tearDown)
51+
tearDown()
52+
53+
setup()
54+
55+
loadCmd := strings.Join(base.Cmd("load").Command, " ")
4556
combined, err := exec.Command("sh", "-euxc", fmt.Sprintf("`cat %s/common.tar | %s > %s`", tmp, loadCmd, output)).CombinedOutput()
4657
assert.NilError(t, err, "failed with error %s and combined output is %s", err, string(combined))
58+
4759
fb, err := os.ReadFile(output)
4860
assert.NilError(t, err)
4961

5062
assert.Assert(t, strings.Contains(string(fb), fmt.Sprintf("Loaded image: %s:latest", img)))
51-
base.Cmd("images").AssertOutContains(testutil.ImageRepo(testutil.CommonImage))
63+
base.Cmd("images").AssertOutContains(img)
5264
}
5365

5466
func TestLoadStdinEmpty(t *testing.T) {

0 commit comments

Comments
 (0)