@@ -40,14 +40,13 @@ func (suite *PouchCreateSuite) TearDownTest(c *check.C) {
4040func (suite * PouchCreateSuite ) TestCreateName (c * check.C ) {
4141 name := "create-normal"
4242 res := command .PouchRun ("create" , "--name" , name , busyboxImage )
43-
43+ defer DelContainerForceMultyTime ( c , name )
4444 res .Assert (c , icmd .Success )
4545
4646 // create command should add newline at the end of result
4747 digStr := strings .TrimSpace (res .Combined ())
4848 c .Assert (res .Combined (), check .Equals , fmt .Sprintf ("%s\n " , digStr ))
4949
50- defer DelContainerForceMultyTime (c , name )
5150}
5251
5352// TestCreateNameByImageID is to verify the correctness of creating contaier with specified name by image id.
@@ -59,27 +58,25 @@ func (suite *PouchCreateSuite) TestCreateNameByImageID(c *check.C) {
5958 imageID := imagesListToKV (res .Combined ())[busyboxImage ][0 ]
6059
6160 res = command .PouchRun ("create" , "--name" , name , imageID )
62-
61+ defer DelContainerForceMultyTime ( c , name )
6362 res .Assert (c , icmd .Success )
6463
6564 digHexStr := strings .TrimSpace (res .Combined ())
6665 _ , err := digest .Parse (fmt .Sprintf ("%s:%s" , digest .SHA256 , digHexStr ))
6766 c .Assert (err , check .IsNil )
6867
69- DelContainerForceMultyTime (c , name )
7068}
7169
7270// TestCreateDuplicateContainerName is to verify duplicate container names.
7371func (suite * PouchCreateSuite ) TestCreateDuplicateContainerName (c * check.C ) {
7472 name := "duplicate"
7573
7674 res := command .PouchRun ("create" , "--name" , name , busyboxImage )
77- res .Assert (c , icmd .Success )
78-
7975 defer DelContainerForceMultyTime (c , name )
76+ res .Assert (c , icmd .Success )
8077
8178 res = command .PouchRun ("create" , "--name" , name , busyboxImage )
82- c .Assert (res .Error , check .NotNil )
79+ c .Assert (res .Stderr () , check .NotNil )
8380
8481 if out := res .Combined (); ! strings .Contains (out , "already exist" ) {
8582 c .Fatalf ("unexpected output %s expected already exist\n " , out )
@@ -92,9 +89,9 @@ func (suite *PouchCreateSuite) TestCreateDuplicateContainerName(c *check.C) {
9289func (suite * PouchCreateSuite ) TestCreateWithArgs (c * check.C ) {
9390 name := "TestCreateWithArgs"
9491 res := command .PouchRun ("create" , "--name" , name , busyboxImage , "/bin/ls" )
95- res .Assert (c , icmd .Success )
96-
9792 defer DelContainerForceMultyTime (c , name )
93+
94+ res .Assert (c , icmd .Success )
9895}
9996
10097// TestCreateWithTTY is to verify tty flag.
@@ -103,9 +100,9 @@ func (suite *PouchCreateSuite) TestCreateWithArgs(c *check.C) {
103100func (suite * PouchCreateSuite ) TestCreateWithTTY (c * check.C ) {
104101 name := "TestCreateWithTTY"
105102 res := command .PouchRun ("create" , "-t" , "--name" , name , busyboxImage )
106- res .Assert (c , icmd .Success )
107-
108103 defer DelContainerForceMultyTime (c , name )
104+
105+ res .Assert (c , icmd .Success )
109106}
110107
111108// TestPouchCreateVolume is to verify volume flag.
@@ -120,9 +117,9 @@ func (suite *PouchCreateSuite) TestPouchCreateVolume(c *check.C) {
120117 }
121118
122119 res := command .PouchRun ("create" , "-v /tmp:/tmp" , "--name" , funcname , busyboxImage )
123- res .Assert (c , icmd .Success )
124-
125120 defer DelContainerForceMultyTime (c , funcname )
121+
122+ res .Assert (c , icmd .Success )
126123}
127124
128125// TestCreateInWrongWay tries to run create in wrong way.
@@ -137,7 +134,7 @@ func (suite *PouchCreateSuite) TestCreateInWrongWay(c *check.C) {
137134 // {name: "missing image name", args: ""},
138135 } {
139136 res := command .PouchRun ("create" , tc .args )
140- c .Assert (res .Error , check .NotNil , check .Commentf (tc .name ))
137+ c .Assert (res .Stderr () , check .NotNil , check .Commentf (tc .name ))
141138 }
142139}
143140
@@ -147,8 +144,8 @@ func (suite *PouchCreateSuite) TestCreateWithLabels(c *check.C) {
147144 name := "create-label"
148145
149146 res := command .PouchRun ("create" , "--name" , name , "-l" , label , busyboxImage )
150- res .Assert (c , icmd .Success )
151147 defer DelContainerForceMultyTime (c , name )
148+ res .Assert (c , icmd .Success )
152149
153150 output := command .PouchRun ("inspect" , name ).Stdout ()
154151
@@ -169,8 +166,8 @@ func (suite *PouchCreateSuite) TestCreateWithSysctls(c *check.C) {
169166 name := "create-sysctl"
170167
171168 res := command .PouchRun ("create" , "--name" , name , "--sysctl" , sysctl , busyboxImage )
172- res .Assert (c , icmd .Success )
173169 defer DelContainerForceMultyTime (c , name )
170+ res .Assert (c , icmd .Success )
174171
175172 output := command .PouchRun ("inspect" , name ).Stdout ()
176173
@@ -191,8 +188,8 @@ func (suite *PouchCreateSuite) TestCreateWithAppArmor(c *check.C) {
191188 name := "create-apparmor"
192189
193190 res := command .PouchRun ("create" , "--name" , name , "--security-opt" , appArmor , busyboxImage )
194- res .Assert (c , icmd .Success )
195191 defer DelContainerForceMultyTime (c , name )
192+ res .Assert (c , icmd .Success )
196193
197194 output := command .PouchRun ("inspect" , name ).Stdout ()
198195
@@ -219,8 +216,8 @@ func (suite *PouchCreateSuite) TestCreateWithSeccomp(c *check.C) {
219216 name := "create-seccomp"
220217
221218 res := command .PouchRun ("create" , "--name" , name , "--security-opt" , seccomp , busyboxImage )
222- res .Assert (c , icmd .Success )
223219 defer DelContainerForceMultyTime (c , name )
220+ res .Assert (c , icmd .Success )
224221
225222 output := command .PouchRun ("inspect" , name ).Stdout ()
226223
@@ -247,8 +244,8 @@ func (suite *PouchCreateSuite) TestCreateWithCapability(c *check.C) {
247244 name := "create-capability"
248245
249246 res := command .PouchRun ("create" , "--name" , name , "--cap-add" , capability , busyboxImage , "brctl" , "addbr" , "foobar" )
250- res .Assert (c , icmd .Success )
251247 defer DelContainerForceMultyTime (c , name )
248+ res .Assert (c , icmd .Success )
252249
253250 output := command .PouchRun ("inspect" , name ).Stdout ()
254251
@@ -274,8 +271,8 @@ func (suite *PouchCreateSuite) TestCreateWithPrivilege(c *check.C) {
274271 name := "create-privilege"
275272
276273 res := command .PouchRun ("create" , "--name" , name , "--privileged" , busyboxImage , "brctl" , "addbr" , "foobar" )
277- res .Assert (c , icmd .Success )
278274 defer DelContainerForceMultyTime (c , name )
275+ res .Assert (c , icmd .Success )
279276
280277 output := command .PouchRun ("inspect" , name ).Stdout ()
281278
@@ -291,6 +288,7 @@ func (suite *PouchCreateSuite) TestCreateEnableLxcfs(c *check.C) {
291288 name := "create-lxcfs"
292289
293290 res := command .PouchRun ("create" , "--name" , name , "--enableLxcfs=true" , busyboxImage )
291+ defer DelContainerForceMultyTime (c , name )
294292 res .Assert (c , icmd .Success )
295293
296294 output := command .PouchRun ("inspect" , name ).Stdout ()
@@ -311,6 +309,8 @@ func (suite *PouchCreateSuite) TestCreateWithEnv(c *check.C) {
311309 name := "TestCreateWithEnv"
312310
313311 res := command .PouchRun ("create" , "--name" , name , "-e TEST=true" , busyboxImage )
312+ defer DelContainerForceMultyTime (c , name )
313+
314314 res .Assert (c , icmd .Success )
315315
316316 output := command .PouchRun ("inspect" , name ).Stdout ()
@@ -334,6 +334,7 @@ func (suite *PouchCreateSuite) TestCreateWithWorkDir(c *check.C) {
334334 name := "TestCreateWithWorkDir"
335335
336336 res := command .PouchRun ("create" , "--name" , name , "-w /tmp/test" , busyboxImage )
337+ defer DelContainerForceMultyTime (c , name )
337338 res .Assert (c , icmd .Success )
338339
339340 output := command .PouchRun ("inspect" , name ).Stdout ()
@@ -353,6 +354,8 @@ func (suite *PouchCreateSuite) TestCreateWithUser(c *check.C) {
353354 user := "1001"
354355
355356 res := command .PouchRun ("create" , "--name" , name , "--user" , user , busyboxImage )
357+ defer DelContainerForceMultyTime (c , name )
358+
356359 res .Assert (c , icmd .Success )
357360
358361 output := command .PouchRun ("inspect" , name ).Stdout ()
@@ -370,6 +373,8 @@ func (suite *PouchCreateSuite) TestCreateWithIntelRdt(c *check.C) {
370373 intelRdt := "L3:<cache_id0>=<cbm0>"
371374
372375 res := command .PouchRun ("create" , "--name" , name , "--intel-rdt-l3-cbm" , intelRdt , busyboxImage )
376+ defer DelContainerForceMultyTime (c , name )
377+
373378 res .Assert (c , icmd .Success )
374379
375380 output := command .PouchRun ("inspect" , name ).Stdout ()
@@ -387,7 +392,11 @@ func (suite *PouchCreateSuite) TestCreateWithAliOSMemoryOptions(c *check.C) {
387392 memoryWmarkRatio := "30"
388393 memoryExtra := "50"
389394
390- res := command .PouchRun ("create" , "--name" , name , "--memory-wmark-ratio" , memoryWmarkRatio , "--memory-extra" , memoryExtra , "--memory-force-empty-ctl" , "1" , "--sche-lat-switch" , "1" , busyboxImage )
395+ res := command .PouchRun ("create" , "--name" , name , "--memory-wmark-ratio" ,
396+ memoryWmarkRatio , "--memory-extra" , memoryExtra , "--memory-force-empty-ctl" , "1" ,
397+ "--sche-lat-switch" , "1" , busyboxImage )
398+ defer DelContainerForceMultyTime (c , name )
399+
391400 res .Assert (c , icmd .Success )
392401
393402 output := command .PouchRun ("inspect" , name ).Stdout ()
@@ -407,7 +416,10 @@ func (suite *PouchCreateSuite) TestCreateWithOOMOption(c *check.C) {
407416 name := "TestCreateWithOOMOption"
408417 oomScore := "100"
409418
410- res := command .PouchRun ("create" , "--name" , name , "--oom-score-adj" , oomScore , "--oom-kill-disable" , busyboxImage )
419+ res := command .PouchRun ("create" , "--name" , name , "--oom-score-adj" , oomScore ,
420+ "--oom-kill-disable" , busyboxImage )
421+ defer DelContainerForceMultyTime (c , name )
422+
411423 res .Assert (c , icmd .Success )
412424
413425 output := command .PouchRun ("inspect" , name ).Stdout ()
@@ -423,7 +435,10 @@ func (suite *PouchCreateSuite) TestCreateWithOOMOption(c *check.C) {
423435// TestCreateWithAnnotation tests creating container with annotation.
424436func (suite * PouchCreateSuite ) TestCreateWithAnnotation (c * check.C ) {
425437 cname := "TestCreateWithAnnotation"
426- command .PouchRun ("create" , "--annotation" , "a=b" , "--annotation" , "foo=bar" , "--name" , cname , busyboxImage ).Stdout ()
438+ res := command .PouchRun ("create" , "--annotation" , "a=b" , "--annotation" , "foo=bar" ,
439+ "--name" , cname , busyboxImage )
440+ defer DelContainerForceMultyTime (c , cname )
441+ res .Assert (c , icmd .Success )
427442
428443 output := command .PouchRun ("inspect" , cname ).Stdout ()
429444 result := []types.ContainerJSON {}
@@ -445,7 +460,9 @@ func (suite *PouchCreateSuite) TestCreateWithAnnotation(c *check.C) {
445460// TestCreateWithUlimit tests creating container with annotation.
446461func (suite * PouchCreateSuite ) TestCreateWithUlimit (c * check.C ) {
447462 cname := "TestCreateWithUlimit"
448- command .PouchRun ("create" , "--ulimit" , "nproc=21" , "--name" , cname , busyboxImage ).Assert (c , icmd .Success )
463+ res := command .PouchRun ("create" , "--ulimit" , "nproc=21" , "--name" , cname , busyboxImage )
464+ defer DelContainerForceMultyTime (c , cname )
465+ res .Assert (c , icmd .Success )
449466
450467 output := command .PouchRun ("inspect" , cname ).Stdout ()
451468 result := []types.ContainerJSON {}
0 commit comments