Skip to content

Commit

Permalink
AlpineImage > CommonImage
Browse files Browse the repository at this point in the history
Signed-off-by: apostasie <[email protected]>
  • Loading branch information
apostasie committed Oct 21, 2024
1 parent 3bb441d commit df523fe
Show file tree
Hide file tree
Showing 17 changed files with 123 additions and 284 deletions.
6 changes: 3 additions & 3 deletions cmd/nerdctl/container/container_create_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ func TestIssue2993(t *testing.T) {
Setup: func(data test.Data, helpers test.Helpers) {
dataRoot := data.TempDir()

helpers.Ensure("run", "--data-root", dataRoot, "--name", data.Identifier(), "-d", testutil.AlpineImage, "sleep", "infinity")
helpers.Ensure("run", "--data-root", dataRoot, "--name", data.Identifier(), "-d", testutil.CommonImage, "sleep", "infinity")

h := getAddrHash(defaults.DefaultAddress)
dataStore := filepath.Join(dataRoot, h)
Expand All @@ -223,7 +223,7 @@ func TestIssue2993(t *testing.T) {
helpers.Anyhow("rm", "--data-root", data.TempDir(), "-f", data.Identifier())
},
Command: func(data test.Data, helpers test.Helpers) test.TestableCommand {
return helpers.Command("run", "--data-root", data.TempDir(), "--name", data.Identifier(), "-d", testutil.AlpineImage, "sleep", "infinity")
return helpers.Command("run", "--data-root", data.TempDir(), "--name", data.Identifier(), "-d", testutil.CommonImage, "sleep", "infinity")
},
Expected: func(data test.Data, helpers test.Helpers) *test.Expected {
return &test.Expected{
Expand All @@ -246,7 +246,7 @@ func TestIssue2993(t *testing.T) {
Setup: func(data test.Data, helpers test.Helpers) {
dataRoot := data.TempDir()

helpers.Ensure("run", "--data-root", dataRoot, "--name", data.Identifier(), "-d", testutil.AlpineImage, "sleep", "infinity")
helpers.Ensure("run", "--data-root", dataRoot, "--name", data.Identifier(), "-d", testutil.CommonImage, "sleep", "infinity")

h := getAddrHash(defaults.DefaultAddress)
dataStore := filepath.Join(dataRoot, h)
Expand Down
4 changes: 2 additions & 2 deletions cmd/nerdctl/container/container_inspect_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,9 @@ func TestContainerInspectState(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
defer base.Cmd("rm", "-f", tc.containerName).Run()
if tc.want.Error != "" {
base.Cmd("run", "--name", tc.containerName, testutil.AlpineImage, tc.cmd).AssertFail()
base.Cmd("run", "--name", tc.containerName, testutil.CommonImage, tc.cmd).AssertFail()
} else {
base.Cmd("run", "--name", tc.containerName, testutil.AlpineImage, tc.cmd).AssertOK()
base.Cmd("run", "--name", tc.containerName, testutil.CommonImage, tc.cmd).AssertOK()
}
inspect := base.InspectContainer(tc.containerName)
assert.Assert(t, strings.Contains(inspect.State.Error, tc.want.Error), fmt.Sprintf("expected: %s, actual: %s", tc.want.Error, inspect.State.Error))
Expand Down
10 changes: 5 additions & 5 deletions cmd/nerdctl/container/container_restart_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ func TestRestartPIDContainer(t *testing.T) {
base := testutil.NewBase(t)

baseContainerName := testutil.Identifier(t)
base.Cmd("run", "-d", "--name", baseContainerName, testutil.AlpineImage, "sleep", "infinity").AssertOK()
base.Cmd("run", "-d", "--name", baseContainerName, testutil.CommonImage, "sleep", "infinity").AssertOK()
defer base.Cmd("rm", "-f", baseContainerName).Run()

sharedContainerName := fmt.Sprintf("%s-shared", baseContainerName)
base.Cmd("run", "-d", "--name", sharedContainerName, fmt.Sprintf("--pid=container:%s", baseContainerName), testutil.AlpineImage, "sleep", "infinity").AssertOK()
base.Cmd("run", "-d", "--name", sharedContainerName, fmt.Sprintf("--pid=container:%s", baseContainerName), testutil.CommonImage, "sleep", "infinity").AssertOK()
defer base.Cmd("rm", "-f", sharedContainerName).Run()

base.Cmd("restart", baseContainerName).AssertOK()
Expand All @@ -79,11 +79,11 @@ func TestRestartIPCContainer(t *testing.T) {
const shmSize = "32m"
baseContainerName := testutil.Identifier(t)
defer base.Cmd("rm", "-f", baseContainerName).Run()
base.Cmd("run", "-d", "--shm-size", shmSize, "--ipc", "shareable", "--name", baseContainerName, testutil.AlpineImage, "sleep", "infinity").AssertOK()
base.Cmd("run", "-d", "--shm-size", shmSize, "--ipc", "shareable", "--name", baseContainerName, testutil.CommonImage, "sleep", "infinity").AssertOK()

sharedContainerName := fmt.Sprintf("%s-shared", baseContainerName)
defer base.Cmd("rm", "-f", sharedContainerName).Run()
base.Cmd("run", "-d", "--name", sharedContainerName, fmt.Sprintf("--ipc=container:%s", baseContainerName), testutil.AlpineImage, "sleep", "infinity").AssertOK()
base.Cmd("run", "-d", "--name", sharedContainerName, fmt.Sprintf("--ipc=container:%s", baseContainerName), testutil.CommonImage, "sleep", "infinity").AssertOK()

base.Cmd("stop", baseContainerName).Run()
base.Cmd("stop", sharedContainerName).Run()
Expand All @@ -104,7 +104,7 @@ func TestRestartWithTime(t *testing.T) {
base := testutil.NewBase(t)
tID := testutil.Identifier(t)

base.Cmd("run", "-d", "--name", tID, testutil.AlpineImage, "sleep", "infinity").AssertOK()
base.Cmd("run", "-d", "--name", tID, testutil.CommonImage, "sleep", "infinity").AssertOK()
defer base.Cmd("rm", "-f", tID).AssertOK()

inspect := base.InspectContainer(tID)
Expand Down
20 changes: 10 additions & 10 deletions cmd/nerdctl/container/container_run_cgroup_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,19 @@ func TestRunCgroupV2(t *testing.T) {
"--memory", "42m",
"--pids-limit", "42",
"--cpu-shares", "2000", "--cpuset-cpus", "0-1",
"-w", "/sys/fs/cgroup", testutil.AlpineImage,
"-w", "/sys/fs/cgroup", testutil.CommonImage,
"cat", "cpu.max", "memory.max", "memory.swap.max",
"pids.max", "cpu.weight", "cpuset.cpus", "cpuset.mems").AssertOutExactly(expected1)
base.Cmd("run", "--rm",
"--cpu-quota", "42000", "--cpuset-mems", "0",
"--cpu-period", "100000", "--memory", "42m", "--memory-reservation", "6m", "--memory-swap", "100m",
"--pids-limit", "42", "--cpu-shares", "2000", "--cpuset-cpus", "0-1",
"-w", "/sys/fs/cgroup", testutil.AlpineImage,
"-w", "/sys/fs/cgroup", testutil.CommonImage,
"cat", "cpu.max", "memory.max", "memory.swap.max", "memory.low", "pids.max",
"cpu.weight", "cpuset.cpus", "cpuset.mems").AssertOutExactly(expected2)

base.Cmd("run", "--name", testutil.Identifier(t)+"-testUpdate1", "-w", "/sys/fs/cgroup", "-d",
testutil.AlpineImage, "sleep", "infinity").AssertOK()
testutil.CommonImage, "sleep", "infinity").AssertOK()
defer base.Cmd("rm", "-f", testutil.Identifier(t)+"-testUpdate1").Run()
update := []string{"update", "--cpu-quota", "42000", "--cpuset-mems", "0", "--cpu-period", "100000",
"--memory", "42m",
Expand All @@ -115,7 +115,7 @@ func TestRunCgroupV2(t *testing.T) {

defer base.Cmd("rm", "-f", testutil.Identifier(t)+"-testUpdate2").Run()
base.Cmd("run", "--name", testutil.Identifier(t)+"-testUpdate2", "-w", "/sys/fs/cgroup", "-d",
testutil.AlpineImage, "sleep", "infinity").AssertOK()
testutil.CommonImage, "sleep", "infinity").AssertOK()
base.EnsureContainerStarted(testutil.Identifier(t) + "-testUpdate2")

base.Cmd("update", "--cpu-quota", "42000", "--cpuset-mems", "0", "--cpu-period", "100000",
Expand Down Expand Up @@ -165,8 +165,8 @@ func TestRunCgroupV1(t *testing.T) {
cpusetCpus := "/sys/fs/cgroup/cpuset/cpuset.cpus"

const expected = "42000\n100000\n0\n44040192\n6291456\n104857600\n0\n42\n2000\n0-1\n"
base.Cmd("run", "--rm", "--cpus", "0.42", "--cpuset-mems", "0", "--memory", "42m", "--memory-reservation", "6m", "--memory-swap", "100m", "--memory-swappiness", "0", "--pids-limit", "42", "--cpu-shares", "2000", "--cpuset-cpus", "0-1", testutil.AlpineImage, "cat", quota, period, cpusetMems, memoryLimit, memoryReservation, memorySwap, memorySwappiness, pidsLimit, cpuShare, cpusetCpus).AssertOutExactly(expected)
base.Cmd("run", "--rm", "--cpu-quota", "42000", "--cpu-period", "100000", "--cpuset-mems", "0", "--memory", "42m", "--memory-reservation", "6m", "--memory-swap", "100m", "--memory-swappiness", "0", "--pids-limit", "42", "--cpu-shares", "2000", "--cpuset-cpus", "0-1", testutil.AlpineImage, "cat", quota, period, cpusetMems, memoryLimit, memoryReservation, memorySwap, memorySwappiness, pidsLimit, cpuShare, cpusetCpus).AssertOutExactly(expected)
base.Cmd("run", "--rm", "--cpus", "0.42", "--cpuset-mems", "0", "--memory", "42m", "--memory-reservation", "6m", "--memory-swap", "100m", "--memory-swappiness", "0", "--pids-limit", "42", "--cpu-shares", "2000", "--cpuset-cpus", "0-1", testutil.CommonImage, "cat", quota, period, cpusetMems, memoryLimit, memoryReservation, memorySwap, memorySwappiness, pidsLimit, cpuShare, cpusetCpus).AssertOutExactly(expected)
base.Cmd("run", "--rm", "--cpu-quota", "42000", "--cpu-period", "100000", "--cpuset-mems", "0", "--memory", "42m", "--memory-reservation", "6m", "--memory-swap", "100m", "--memory-swappiness", "0", "--pids-limit", "42", "--cpu-shares", "2000", "--cpuset-cpus", "0-1", testutil.CommonImage, "cat", quota, period, cpusetMems, memoryLimit, memoryReservation, memorySwap, memorySwappiness, pidsLimit, cpuShare, cpusetCpus).AssertOutExactly(expected)
}

func TestRunDevice(t *testing.T) {
Expand Down Expand Up @@ -199,7 +199,7 @@ func TestRunDevice(t *testing.T) {
"--name", containerName,
"--device", lo[0].Device+":r",
"--device", lo[1].Device,
testutil.AlpineImage, "sleep", "infinity").Run()
testutil.CommonImage, "sleep", "infinity").Run()

base.Cmd("exec", containerName, "cat", lo[0].Device).AssertOutContains(loContent[0])
base.Cmd("exec", containerName, "cat", lo[1].Device).AssertOutContains(loContent[1])
Expand Down Expand Up @@ -290,7 +290,7 @@ func TestRunCgroupConf(t *testing.T) {
if !info.MemoryLimit {
t.Skip("test requires MemoryLimit")
}
base.Cmd("run", "--rm", "--cgroup-conf", "memory.high=33554432", "-w", "/sys/fs/cgroup", testutil.AlpineImage,
base.Cmd("run", "--rm", "--cgroup-conf", "memory.high=33554432", "-w", "/sys/fs/cgroup", testutil.CommonImage,
"cat", "memory.high").AssertOutExactly("33554432\n")
}

Expand Down Expand Up @@ -331,7 +331,7 @@ func TestRunCgroupParent(t *testing.T) {
containerName,
"--cgroupns=host",
"--cgroup-parent", parent,
testutil.AlpineImage,
testutil.CommonImage,
"sleep",
"infinity",
).AssertOK()
Expand Down Expand Up @@ -364,7 +364,7 @@ func TestRunBlkioWeightCgroupV2(t *testing.T) {
containerName := testutil.Identifier(t)
defer base.Cmd("rm", "-f", containerName).AssertOK()
// when bfq io scheduler is used, the io.weight knob is exposed as io.bfq.weight
base.Cmd("run", "--name", containerName, "--blkio-weight", "300", "-w", "/sys/fs/cgroup", testutil.AlpineImage, "sleep", "infinity").AssertOK()
base.Cmd("run", "--name", containerName, "--blkio-weight", "300", "-w", "/sys/fs/cgroup", testutil.CommonImage, "sleep", "infinity").AssertOK()
base.Cmd("exec", containerName, "cat", "io.bfq.weight").AssertOutExactly("default 300\n")
base.Cmd("update", containerName, "--blkio-weight", "400").AssertOK()
base.Cmd("exec", containerName, "cat", "io.bfq.weight").AssertOutExactly("default 400\n")
Expand Down
Loading

0 comments on commit df523fe

Please sign in to comment.