mirror of
https://github.com/containers/podman.git
synced 2025-06-20 17:13:43 +08:00
Add exec after checkpoint/restore test
A container restored from a checkpoint archive used to have the root file-system mounted with a wrong (new) SELinux label. This made it, for example, impossible to use 'podman exec' on a restored container. This test tests exactly this. 'podman exec' after 'podman container restore'. Unfortunately this test does not fail, even without the patch that fixes it as the test seems to run in an environment where the SELinux label of the container root file-system is not relevant. Somehow. Signed-off-by: Adrian Reber <areber@redhat.com>
This commit is contained in:
@ -392,4 +392,43 @@ var _ = Describe("Podman checkpoint", func() {
|
||||
// Remove exported checkpoint
|
||||
os.Remove("/tmp/checkpoint.tar.gz")
|
||||
})
|
||||
|
||||
It("podman checkpoint and run exec in restored container", func() {
|
||||
// Start the container
|
||||
session := podmanTest.Podman([]string{"run", "-it", "--rm", "-d", ALPINE, "top"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session.ExitCode()).To(Equal(0))
|
||||
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1))
|
||||
cid := session.OutputToString()
|
||||
|
||||
// Checkpoint the container
|
||||
result := podmanTest.Podman([]string{"container", "checkpoint", "-l", "-e", "/tmp/checkpoint.tar.gz"})
|
||||
result.WaitWithDefaultTimeout()
|
||||
|
||||
Expect(result.ExitCode()).To(Equal(0))
|
||||
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0))
|
||||
Expect(podmanTest.NumberOfContainers()).To(Equal(0))
|
||||
|
||||
// Restore the container
|
||||
result = podmanTest.Podman([]string{"container", "restore", "-i", "/tmp/checkpoint.tar.gz"})
|
||||
result.WaitWithDefaultTimeout()
|
||||
|
||||
Expect(result.ExitCode()).To(Equal(0))
|
||||
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1))
|
||||
Expect(podmanTest.NumberOfContainers()).To(Equal(1))
|
||||
Expect(podmanTest.GetContainerStatus()).To(ContainSubstring("Up"))
|
||||
|
||||
// Exec in the container
|
||||
result = podmanTest.Podman([]string{"exec", "-l", "/bin/sh", "-c", "echo " + cid + " > /test.output"})
|
||||
result.WaitWithDefaultTimeout()
|
||||
Expect(result.ExitCode()).To(Equal(0))
|
||||
|
||||
result = podmanTest.Podman([]string{"exec", "-l", "cat", "/test.output"})
|
||||
result.WaitWithDefaultTimeout()
|
||||
Expect(result.ExitCode()).To(Equal(0))
|
||||
Expect(result.OutputToString()).To(ContainSubstring(cid))
|
||||
|
||||
// Remove exported checkpoint
|
||||
os.Remove("/tmp/checkpoint.tar.gz")
|
||||
})
|
||||
})
|
||||
|
Reference in New Issue
Block a user