@@ -49,17 +49,13 @@ var _ = Describe("Podman checkpoint", func() {
4949 Skip (fmt .Sprintf ("check CRIU version error: %v" , err ))
5050 }
5151
52- session := podmanTest .Podman ([]string {"network" , "create" })
53- session .WaitWithDefaultTimeout ()
54- Expect (session ).Should (ExitCleanly ())
52+ session := podmanTest .PodmanExitCleanly ("network" , "create" )
5553 netname = session .OutputToString ()
5654 })
5755
5856 AfterEach (func () {
5957 if netname != "" {
60- session := podmanTest .Podman ([]string {"network" , "rm" , "-f" , netname })
61- session .WaitWithDefaultTimeout ()
62- Expect (session ).Should (ExitCleanly ())
58+ podmanTest .PodmanExitCleanly ("network" , "rm" , "-f" , netname )
6359 }
6460 })
6561
@@ -77,41 +73,32 @@ var _ = Describe("Podman checkpoint", func() {
7773
7874 It ("podman checkpoint a running container by id" , func () {
7975 localRunString := getRunString ([]string {ALPINE , "top" })
80- session := podmanTest .Podman (localRunString )
81- session .WaitWithDefaultTimeout ()
82- Expect (session ).Should (ExitCleanly ())
76+ session := podmanTest .PodmanExitCleanly (localRunString ... )
8377 cid := session .OutputToString ()
8478
8579 // Check if none of the checkpoint/restore specific information is displayed
8680 // for newly started containers.
87- inspect := podmanTest .Podman ([]string {"inspect" , cid })
88- inspect .WaitWithDefaultTimeout ()
89- Expect (inspect ).Should (ExitCleanly ())
81+ inspect := podmanTest .PodmanExitCleanly ("inspect" , cid )
9082 inspectOut := inspect .InspectContainerToJSON ()
9183 Expect (inspectOut [0 ].State .Checkpointed ).To (BeFalse (), ".State.Checkpointed" )
9284 Expect (inspectOut [0 ].State .Restored ).To (BeFalse (), ".State.Restored" )
9385 Expect (inspectOut [0 ].State ).To (HaveField ("CheckpointPath" , "" ))
9486 Expect (inspectOut [0 ].State ).To (HaveField ("CheckpointLog" , "" ))
9587 Expect (inspectOut [0 ].State ).To (HaveField ("RestoreLog" , "" ))
9688
97- result := podmanTest .Podman ([] string {
89+ result := podmanTest .PodmanExitCleanly (
9890 "container" ,
9991 "checkpoint" ,
10092 "--keep" ,
10193 cid ,
102- })
103- result .WaitWithDefaultTimeout ()
104-
105- Expect (result ).Should (ExitCleanly ())
94+ )
10695 Expect (result .OutputToString ()).To (Equal (cid ))
10796 Expect (podmanTest .NumberOfContainersRunning ()).To (Equal (0 ))
10897 Expect (podmanTest .GetContainerStatus ()).To (ContainSubstring ("Exited" ))
10998
11099 // For a checkpointed container we expect the checkpoint related information
111100 // to be populated.
112- inspect = podmanTest .Podman ([]string {"inspect" , cid })
113- inspect .WaitWithDefaultTimeout ()
114- Expect (inspect ).Should (ExitCleanly ())
101+ inspect = podmanTest .PodmanExitCleanly ("inspect" , cid )
115102 inspectOut = inspect .InspectContainerToJSON ()
116103 Expect (inspectOut [0 ].State .Checkpointed ).To (BeTrue (), ".State.Checkpointed" )
117104 Expect (inspectOut [0 ].State .Restored ).To (BeFalse (), ".State.Restored" )
@@ -124,22 +111,17 @@ var _ = Describe("Podman checkpoint", func() {
124111 result .WaitWithDefaultTimeout ()
125112 Expect (result ).Should (ExitWithError (125 , "--publish can only be used with image or --import" ))
126113
127- result = podmanTest .Podman ([] string {
114+ result = podmanTest .PodmanExitCleanly (
128115 "container" ,
129116 "restore" ,
130117 "--keep" ,
131118 cid ,
132- })
133- result .WaitWithDefaultTimeout ()
134-
135- Expect (result ).Should (ExitCleanly ())
119+ )
136120 Expect (result .OutputToString ()).To (Equal (cid ))
137121 Expect (podmanTest .NumberOfContainersRunning ()).To (Equal (1 ))
138122 Expect (podmanTest .GetContainerStatus ()).To (ContainSubstring ("Up" ))
139123
140- inspect = podmanTest .Podman ([]string {"inspect" , cid })
141- inspect .WaitWithDefaultTimeout ()
142- Expect (inspect ).Should (ExitCleanly ())
124+ inspect = podmanTest .PodmanExitCleanly ("inspect" , cid )
143125 inspectOut = inspect .InspectContainerToJSON ()
144126 Expect (inspectOut [0 ].State .Restored ).To (BeTrue (), ".State.Restored" )
145127 Expect (inspectOut [0 ].State .Checkpointed ).To (BeFalse (), ".State.Checkpointed" )
@@ -150,21 +132,17 @@ var _ = Describe("Podman checkpoint", func() {
150132 podmanTest .StopContainer (cid )
151133 Expect (podmanTest .NumberOfContainersRunning ()).To (Equal (0 ))
152134
153- result = podmanTest .Podman ([] string {
135+ podmanTest .PodmanExitCleanly (
154136 "container" ,
155137 "start" ,
156138 cid ,
157- })
158- result .WaitWithDefaultTimeout ()
139+ )
159140
160- Expect (result ).Should (ExitCleanly ())
161141 Expect (podmanTest .NumberOfContainersRunning ()).To (Equal (1 ))
162142
163143 // Stopping and starting the container should remove all checkpoint
164144 // related information from inspect again.
165- inspect = podmanTest .Podman ([]string {"inspect" , cid })
166- inspect .WaitWithDefaultTimeout ()
167- Expect (inspect ).Should (ExitCleanly ())
145+ inspect = podmanTest .PodmanExitCleanly ("inspect" , cid )
168146 inspectOut = inspect .InspectContainerToJSON ()
169147 Expect (inspectOut [0 ].State .Checkpointed ).To (BeFalse (), ".State.Checkpointed" )
170148 Expect (inspectOut [0 ].State .Restored ).To (BeFalse (), ".State.Restored" )
@@ -337,17 +315,13 @@ var _ = Describe("Podman checkpoint", func() {
337315
338316 It ("podman checkpoint container with established tcp connections" , func () {
339317 localRunString := getRunString ([]string {REDIS_IMAGE })
340- session := podmanTest .Podman (localRunString )
341- session .WaitWithDefaultTimeout ()
342- Expect (session ).Should (ExitCleanly ())
318+ session := podmanTest .PodmanExitCleanly (localRunString ... )
343319 cid := session .OutputToString ()
344320 if ! WaitContainerReady (podmanTest , cid , "Ready to accept connections" , 20 , 1 ) {
345321 Fail ("Container failed to get ready" )
346322 }
347323
348- IP := podmanTest .Podman ([]string {"inspect" , cid , fmt .Sprintf ("--format={{(index .NetworkSettings.Networks \" %s\" ).IPAddress}}" , netname )})
349- IP .WaitWithDefaultTimeout ()
350- Expect (IP ).Should (ExitCleanly ())
324+ IP := podmanTest .PodmanExitCleanly ("inspect" , cid , fmt .Sprintf ("--format={{(index .NetworkSettings.Networks \" %s\" ).IPAddress}}" , netname ))
351325
352326 // Open a network connection to the redis server
353327 conn , err := net .DialTimeout ("tcp4" , IP .OutputToString ()+ ":6379" , time .Duration (3 )* time .Second )
@@ -364,52 +338,37 @@ var _ = Describe("Podman checkpoint", func() {
364338 Expect (podmanTest .GetContainerStatus ()).To (ContainSubstring ("Up" ))
365339
366340 // Now it should work thanks to "--tcp-established"
367- result = podmanTest .Podman ([]string {"container" , "checkpoint" , cid , "--tcp-established" })
368- result .WaitWithDefaultTimeout ()
341+ podmanTest .PodmanExitCleanly ("container" , "checkpoint" , cid , "--tcp-established" )
369342
370- Expect (result ).Should (ExitCleanly ())
371343 Expect (podmanTest .NumberOfContainersRunning ()).To (Equal (0 ))
372344 Expect (podmanTest .GetContainerStatus ()).To (ContainSubstring ("Exited" ))
373345
374346 // Restore should fail as the checkpoint image contains established TCP connections
375347 result = podmanTest .Podman ([]string {"container" , "restore" , cid })
376348 result .WaitWithDefaultTimeout ()
377349
378- // default message when using crun
379- expectStderr := "crun: CRIU restoring failed -52. Please check CRIU logfile"
350+ // Some older versions print "CRIU restoring failed: -52" while others
351+ // "Error: crun: (00.054135) Error (criu/cgroup.c:1998): cg: cgroupd: recv req error: No such file or directory: OCI runtime attempted to invoke a command that was not found"
352+ expectStderr := "cg: cgroupd: recv req error|CRIU restoring failed: -52"
380353 if podmanTest .OCIRuntime == "runc" {
381354 expectStderr = "runc: criu failed: type NOTIFY errno 0"
382355 }
383- if ! IsRemote () {
384- // This part is only seen with podman local, never remote
385- expectStderr = "OCI runtime error: " + expectStderr
386- }
387- Expect (result ).Should (ExitWithError (125 , expectStderr ))
356+ Expect (result ).Should (ExitWithErrorRegex (125 , expectStderr ))
388357 Expect (podmanTest .NumberOfContainersRunning ()).To (Equal (0 ))
389358 Expect (podmanTest .GetContainerStatus ()).To (ContainSubstring ("Exited" ))
390359
391360 // Now it should work thanks to "--tcp-established"
392- result = podmanTest .Podman ([]string {"container" , "restore" , cid , "--tcp-established" })
393- result .WaitWithDefaultTimeout ()
394-
395- Expect (result ).Should (ExitCleanly ())
361+ podmanTest .PodmanExitCleanly ("container" , "restore" , cid , "--tcp-established" )
396362 Expect (podmanTest .NumberOfContainersRunning ()).To (Equal (1 ))
397363 Expect (podmanTest .GetContainerStatus ()).To (ContainSubstring ("Up" ))
398364
399- result = podmanTest .Podman ([]string {"rm" , "-t" , "0" , "-fa" })
400- result .WaitWithDefaultTimeout ()
401- Expect (result ).Should (ExitCleanly ())
402- Expect (podmanTest .NumberOfContainersRunning ()).To (Equal (0 ))
403-
404365 conn .Close ()
405366 })
406367
407368 It ("podman restore container with tcp-close" , func () {
408369 // Start a container with redis (which listens on tcp port)
409370 localRunString := getRunString ([]string {REDIS_IMAGE })
410- session := podmanTest .Podman (localRunString )
411- session .WaitWithDefaultTimeout ()
412- Expect (session ).Should (ExitCleanly ())
371+ session := podmanTest .PodmanExitCleanly (localRunString ... )
413372 cid := session .OutputToString ()
414373 if ! WaitContainerReady (podmanTest , cid , "Ready to accept connections" , 20 , 1 ) {
415374 Fail ("Container failed to get ready" )
@@ -432,16 +391,13 @@ var _ = Describe("Podman checkpoint", func() {
432391 result := podmanTest .Podman ([]string {"container" , "restore" , cid })
433392 result .WaitWithDefaultTimeout ()
434393
435- // default message when using crun
436- expectStderr := "crun: CRIU restoring failed -52. Please check CRIU logfile"
394+ // Some older versions print "CRIU restoring failed: -52" while others
395+ // "Error: crun: (00.054135) Error (criu/cgroup.c:1998): cg: cgroupd: recv req error: No such file or directory: OCI runtime attempted to invoke a command that was not found"
396+ expectStderr := "cg: cgroupd: recv req error|CRIU restoring failed: -52"
437397 if podmanTest .OCIRuntime == "runc" {
438398 expectStderr = "runc: criu failed: type NOTIFY errno 0"
439399 }
440- if ! IsRemote () {
441- // This part is only seen with podman local, never remote
442- expectStderr = "OCI runtime error: " + expectStderr
443- }
444- Expect (result ).Should (ExitWithError (125 , expectStderr ))
400+ Expect (result ).Should (ExitWithErrorRegex (125 , expectStderr ))
445401 Expect (podmanTest .NumberOfContainersRunning ()).To (Equal (0 ))
446402 Expect (podmanTest .GetContainerStatus ()).To (ContainSubstring ("Exited" ))
447403
0 commit comments