mirror of
https://github.com/containers/podman.git
synced 2025-06-20 09:03:43 +08:00
Ensure test container in running state
* Save storage if tests fail Fixes #1643 Signed-off-by: Jhon Honce <jhonce@redhat.com>
This commit is contained in:
@ -6,6 +6,7 @@ from datetime import datetime, timezone
|
|||||||
from test.podman_testcase import PodmanTestCase
|
from test.podman_testcase import PodmanTestCase
|
||||||
|
|
||||||
import podman
|
import podman
|
||||||
|
from podman import FoldedString
|
||||||
|
|
||||||
|
|
||||||
class TestImages(PodmanTestCase):
|
class TestImages(PodmanTestCase):
|
||||||
@ -44,6 +45,7 @@ class TestImages(PodmanTestCase):
|
|||||||
self.assertGreaterEqual(len(actual), 2)
|
self.assertGreaterEqual(len(actual), 2)
|
||||||
self.assertIsNotNone(self.alpine_image)
|
self.assertIsNotNone(self.alpine_image)
|
||||||
|
|
||||||
|
@unittest.skip('TODO: missing buildah json file')
|
||||||
def test_build(self):
|
def test_build(self):
|
||||||
path = os.path.join(self.tmpdir, 'ctnr', 'Dockerfile')
|
path = os.path.join(self.tmpdir, 'ctnr', 'Dockerfile')
|
||||||
img, logs = self.pclient.images.build(
|
img, logs = self.pclient.images.build(
|
||||||
@ -59,12 +61,12 @@ class TestImages(PodmanTestCase):
|
|||||||
def test_create(self):
|
def test_create(self):
|
||||||
img_details = self.alpine_image.inspect()
|
img_details = self.alpine_image.inspect()
|
||||||
|
|
||||||
actual = self.alpine_image.container()
|
actual = self.alpine_image.container(command=['sleep', '1h'])
|
||||||
self.assertIsNotNone(actual)
|
self.assertIsNotNone(actual)
|
||||||
self.assertEqual(actual.status, 'configured')
|
self.assertEqual(FoldedString(actual.status), 'configured')
|
||||||
|
|
||||||
ctnr = actual.start()
|
ctnr = actual.start()
|
||||||
self.assertIn(ctnr.status, ['running', 'stopped', 'exited'])
|
self.assertEqual(FoldedString(ctnr.status), 'running')
|
||||||
|
|
||||||
ctnr_details = ctnr.inspect()
|
ctnr_details = ctnr.inspect()
|
||||||
for e in img_details.containerconfig['env']:
|
for e in img_details.containerconfig['env']:
|
||||||
|
@ -31,7 +31,9 @@ function cleanup {
|
|||||||
# aggressive cleanup as tests may crash leaving crap around
|
# aggressive cleanup as tests may crash leaving crap around
|
||||||
umount '^(shm|nsfs)'
|
umount '^(shm|nsfs)'
|
||||||
umount '\/run\/netns'
|
umount '\/run\/netns'
|
||||||
rm -r "$1"
|
if [[ $RETURNCODE -eq 0 ]]; then
|
||||||
|
rm -r "$1"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Create temporary directory for storage
|
# Create temporary directory for storage
|
||||||
|
Reference in New Issue
Block a user