Skip to content

Commit 9337b3b

Browse files
authored
Merge pull request #1548 from Letty5411/0619-test
bugfix: refine tests with specifying CMD
2 parents 5dc2082 + 03f6a0d commit 9337b3b

File tree

9 files changed

+32
-25
lines changed

9 files changed

+32
-25
lines changed

test/api_container_logs_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ func (suite *APIContainerLogsSuite) TestNoShowStdoutAndShowStderr(c *check.C) {
5757
resp, err := request.Get(fmt.Sprintf("/containers/%s/logs", name))
5858
c.Assert(err, check.IsNil)
5959
CheckRespStatus(c, resp, http.StatusBadRequest)
60-
61-
DelContainerForceOk(c, name)
6260
}
6361

6462
// TestStdout tests stdout stream.

test/cli_alikernel_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ func (suite *PouchAliKernelSuite) TestAliKernelDiskQuotaWorks(c *check.C) {
5656

5757
// generate a file larger than 1G should fail.
5858
expct = icmd.Expected{
59-
// TODO: Add exit code check when pouch exec return the exit code of process
60-
Error: "Disk quota exceeded",
59+
ExitCode: 1,
60+
Error: "Disk quota exceeded",
6161
}
6262
cmd := "dd if=/dev/zero of=/mnt/test bs=1024k count=1500"
6363
err = command.PouchRun("exec", funcname, "sh", "-c", cmd).Compare(expct)

test/cli_restart_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func (suite *PouchRestartSuite) TearDownTest(c *check.C) {
3434
func (suite *PouchRestartSuite) TestPouchRestart(c *check.C) {
3535
name := "TestPouchRestart"
3636

37-
res := command.PouchRun("run", "-d", "--cpu-share", "20", "--name", name, busyboxImage)
37+
res := command.PouchRun("run", "-d", "--name", name, busyboxImage, "top")
3838
defer DelContainerForceMultyTime(c, name)
3939
res.Assert(c, icmd.Success)
4040

@@ -76,7 +76,8 @@ func (suite *PouchRestartSuite) TestPouchRestartPausedContainer(c *check.C) {
7676
func (suite *PouchRestartSuite) TestPouchRestartMultiContainers(c *check.C) {
7777
containernames := []string{"TestPouchRestartMultiContainer-1", "TestPouchRestartMultiContainer-2"}
7878
for _, name := range containernames {
79-
res := command.PouchRun("run", "-d", "--cpu-share", "20", "--name", name, busyboxImage)
79+
res := command.PouchRun("run", "-d",
80+
"--name", name, busyboxImage, "top")
8081
defer DelContainerForceMultyTime(c, name)
8182
res.Assert(c, icmd.Success)
8283
}

test/cli_run_blkio_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func (suite *PouchRunBlkioSuite) TestRunWithBlkioWeight(c *check.C) {
107107
name := "test-run-with-blkio-weight"
108108

109109
res := command.PouchRun("run", "-d", "--name", name,
110-
"--blkio-weight", "500", busyboxImage)
110+
"--blkio-weight", "500", busyboxImage, "top")
111111
defer DelContainerForceMultyTime(c, name)
112112
res.Assert(c, icmd.Success)
113113
}

test/cli_run_pid_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func (suite *PouchRunPidSuite) TestRunWithPIDMode(c *check.C) {
3838
name := "test-run-with-pid-mode"
3939

4040
res := command.PouchRun("run", "-d", "--name", name,
41-
"--pid", "host", busyboxImage)
41+
"--pid", "host", busyboxImage, "top")
4242
defer DelContainerForceMultyTime(c, name)
4343

4444
res.Assert(c, icmd.Success)

test/cli_run_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func (suite *PouchRunSuite) TestRunWithIPCMode(c *check.C) {
145145
name := "test-run-with-ipc-mode"
146146

147147
res := command.PouchRun("run", "-d", "--name", name,
148-
"--ipc", "host", busyboxImage)
148+
"--ipc", "host", busyboxImage, "top")
149149
defer DelContainerForceMultyTime(c, name)
150150

151151
res.Assert(c, icmd.Success)
@@ -156,7 +156,7 @@ func (suite *PouchRunSuite) TestRunWithUTSMode(c *check.C) {
156156
name := "test-run-with-uts-mode"
157157

158158
res := command.PouchRun("run", "-d", "--name", name,
159-
"--uts", "host", busyboxImage)
159+
"--uts", "host", busyboxImage, "top")
160160
defer DelContainerForceMultyTime(c, name)
161161

162162
res.Assert(c, icmd.Success)
@@ -186,7 +186,7 @@ func (suite *PouchRunSuite) TestRunWithAppArmor(c *check.C) {
186186
name := "run-apparmor"
187187

188188
res := command.PouchRun("run", "-d", "--name", name,
189-
"--security-opt", appArmor, busyboxImage)
189+
"--security-opt", appArmor, busyboxImage, "top")
190190
defer DelContainerForceMultyTime(c, name)
191191

192192
res.Assert(c, icmd.Success)
@@ -200,7 +200,7 @@ func (suite *PouchRunSuite) TestRunWithSeccomp(c *check.C) {
200200
name := "run-seccomp"
201201

202202
res := command.PouchRun("run", "-d", "--name", name,
203-
"--security-opt", seccomp, busyboxImage)
203+
"--security-opt", seccomp, busyboxImage, "top")
204204
defer DelContainerForceMultyTime(c, name)
205205

206206
res.Assert(c, icmd.Success)
@@ -281,7 +281,7 @@ func (suite *PouchRunSuite) TestRunWithAnnotation(c *check.C) {
281281
cname := "TestRunWithAnnotation"
282282
res := command.PouchRun("run", "-d", "--annotation", "a=b",
283283
"--annotation", "foo=bar",
284-
"--name", cname, busyboxImage).Assert(c, icmd.Success)
284+
"--name", cname, busyboxImage, "top").Assert(c, icmd.Success)
285285
defer DelContainerForceMultyTime(c, cname)
286286
res.Assert(c, icmd.Success)
287287

test/cli_start_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ func (suite *PouchStartSuite) TestStartWithPrivilege(c *check.C) {
247247
func (suite *PouchStartSuite) TestStartWithAnnotation(c *check.C) {
248248
name := "start-annotation"
249249

250-
res := command.PouchRun("create", "--name", name, "--annotation", "a=b", busyboxImage)
250+
res := command.PouchRun("create", "--name", name, "--annotation", "a=b", busyboxImage, "top")
251251
res.Assert(c, icmd.Success)
252252
defer DelContainerForceMultyTime(c, name)
253253

@@ -279,7 +279,8 @@ func (suite *PouchStartSuite) TestStartWithExitCode(c *check.C) {
279279
func (suite *PouchStartSuite) TestStartWithUlimit(c *check.C) {
280280
name := "start-ulimit"
281281

282-
res := command.PouchRun("create", "--name", name, "--ulimit", "nproc=256", busyboxImage)
282+
res := command.PouchRun("create", "--name", name,
283+
"--ulimit", "nproc=256", busyboxImage, "top")
283284
res.Assert(c, icmd.Success)
284285
defer DelContainerForceMultyTime(c, name)
285286

@@ -290,7 +291,8 @@ func (suite *PouchStartSuite) TestStartWithUlimit(c *check.C) {
290291
func (suite *PouchStartSuite) TestStartWithPidsLimit(c *check.C) {
291292
name := "TestStartWithPidsLimit"
292293
pidfile := "/sys/fs/cgroup/pids/pids.max"
293-
res := command.PouchRun("create", "--pids-limit", "10", "--name", name, busyboxImage, "cat", pidfile)
294+
res := command.PouchRun("create", "--pids-limit", "10",
295+
"--name", name, busyboxImage, "cat", pidfile)
294296
res.Assert(c, icmd.Success)
295297
defer DelContainerForceMultyTime(c, name)
296298

test/cli_upgrade_test.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func (suite *PouchUpgradeSuite) TeadDownTest(c *check.C) {
4141
func (suite *PouchUpgradeSuite) TestPouchUpgrade(c *check.C) {
4242
name := "TestPouchUpgrade"
4343

44-
res := command.PouchRun("run", "-d", "--name", name, busyboxImage)
44+
res := command.PouchRun("run", "-d", "--name", name, busyboxImage, "top")
4545
defer DelContainerForceMultyTime(c, name)
4646
res.Assert(c, icmd.Success)
4747

@@ -57,7 +57,7 @@ func (suite *PouchUpgradeSuite) TestPouchUpgrade(c *check.C) {
5757
func (suite *PouchUpgradeSuite) TestPouchUpgradeNoChange(c *check.C) {
5858
name := "TestPouchUpgradeNoChange"
5959

60-
res := command.PouchRun("run", "-d", "--name", name, busyboxImage)
60+
res := command.PouchRun("run", "-d", "--name", name, busyboxImage, "top")
6161
defer DelContainerForceMultyTime(c, name)
6262
res.Assert(c, icmd.Success)
6363

@@ -92,11 +92,13 @@ func (suite *PouchUpgradeSuite) TestPouchUpgradeStoppedContainer(c *check.C) {
9292
func (suite *PouchUpgradeSuite) TestPouchUpgradeContainerMemCpu(c *check.C) {
9393
name := "TestPouchUpgradeContainerMemCpu"
9494

95-
res := command.PouchRun("run", "-d", "-m", "300m", "--cpu-share", "20", "--name", name, busyboxImage, "top")
95+
res := command.PouchRun("run", "-d", "-m", "300m",
96+
"--cpu-share", "20", "--name", name, busyboxImage, "top")
9697
defer DelContainerForceMultyTime(c, name)
9798
res.Assert(c, icmd.Success)
9899

99-
command.PouchRun("upgrade", "-m", "500m", "--cpu-share", "40", "--name", name, busyboxImage125).Assert(c, icmd.Success)
100+
command.PouchRun("upgrade", "-m", "500m",
101+
"--cpu-share", "40", "--name", name, busyboxImage125).Assert(c, icmd.Success)
100102

101103
output := command.PouchRun("inspect", name).Stdout()
102104
result := []types.ContainerJSON{}
@@ -143,11 +145,13 @@ func (suite *PouchUpgradeSuite) TestPouchUpgradeContainerMemCpu(c *check.C) {
143145
func (suite *PouchUpgradeSuite) TestPouchUpgradeContainerLabels(c *check.C) {
144146
name := "TestPouchUpgradeContainerLabels"
145147

146-
res := command.PouchRun("run", "-d", "--label", "test=foo", "--name", name, busyboxImage)
148+
res := command.PouchRun("run", "-d", "--label", "test=foo",
149+
"--name", name, busyboxImage)
147150
defer DelContainerForceMultyTime(c, name)
148151
res.Assert(c, icmd.Success)
149152

150-
command.PouchRun("upgrade", "--label", "test1=bar", "--name", name, busyboxImage125).Assert(c, icmd.Success)
153+
command.PouchRun("upgrade", "--label", "test1=bar",
154+
"--name", name, busyboxImage125).Assert(c, icmd.Success)
151155

152156
output := command.PouchRun("inspect", name).Stdout()
153157
result := []types.ContainerJSON{}

test/z_cli_daemon_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,16 @@ func (suite *PouchDaemonSuite) TestDaemonCgroupParent(c *check.C) {
4040

4141
cname := "TestDaemonCgroupParent"
4242
{
43-
result := command.PouchRun("--host", daemon.Listen, "pull", busyboxImage)
43+
44+
result := RunWithSpecifiedDaemon(dcfg, "pull", busyboxImage)
4445
if result.ExitCode != 0 {
4546
dcfg.DumpLog()
4647
c.Fatalf("pull image failed, err:%v", result)
4748
}
4849
}
4950
{
50-
result := command.PouchRun("--host", daemon.Listen, "run", "-d", "--name", cname, busyboxImage)
51+
result := RunWithSpecifiedDaemon(dcfg, "run",
52+
"-d", "--name", cname, busyboxImage, "top")
5153
if result.ExitCode != 0 {
5254
dcfg.DumpLog()
5355
c.Fatalf("run container failed, err:%v", result)
@@ -56,7 +58,7 @@ func (suite *PouchDaemonSuite) TestDaemonCgroupParent(c *check.C) {
5658
defer DelContainerForceMultyTime(c, cname)
5759

5860
// test if the value is in inspect result
59-
output := command.PouchRun("inspect", "--host", daemon.Listen, cname).Stdout()
61+
output := RunWithSpecifiedDaemon(dcfg, "inspect", cname).Stdout()
6062
result := []types.ContainerJSON{}
6163
if err := json.Unmarshal([]byte(output), &result); err != nil {
6264
c.Errorf("failed to decode inspect output: %v", err)

0 commit comments

Comments
 (0)