test_docker_compose.py: Test the port publish feature
Extend docker_test() to expose a random (8888) port to verify that doesn't
fail, and extend the docker-compose test to run the busybox httpd in the
background, expose that as port 80 and verify that /etc/resolv.conf could be
fetched by wget.
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
(cherry picked from commit 4915b692c8
)
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
This commit is contained in:
parent
1a48c70e07
commit
3adc69a086
@ -2,3 +2,6 @@ version: '3'
|
|||||||
services:
|
services:
|
||||||
busybox:
|
busybox:
|
||||||
image: "busybox:latest"
|
image: "busybox:latest"
|
||||||
|
command: httpd -f -h /etc/
|
||||||
|
ports:
|
||||||
|
- "80:80"
|
||||||
|
@ -37,13 +37,15 @@ class TestDockerCompose(infra.basetest.BRTest):
|
|||||||
|
|
||||||
def docker_test(self):
|
def docker_test(self):
|
||||||
# will download container if not available, which may take some time
|
# will download container if not available, which may take some time
|
||||||
_, exit_code = self.emulator.run('docker run --rm busybox:latest /bin/true', 120)
|
_, exit_code = self.emulator.run('docker run --rm -p 8888:8888 busybox:latest /bin/true', 120)
|
||||||
self.assertEqual(exit_code, 0)
|
self.assertEqual(exit_code, 0)
|
||||||
|
|
||||||
def docker_compose_test(self):
|
def docker_compose_test(self):
|
||||||
# will download container if not available, which may take some time
|
# will download container if not available, which may take some time
|
||||||
_, exit_code = self.emulator.run('docker-compose up', 120)
|
self.assertRunOk('docker-compose up -d', 120)
|
||||||
self.assertEqual(exit_code, 0)
|
# container may take some time to start
|
||||||
|
self.assertRunOk('while ! docker inspect root_busybox_1 2>&1 >/dev/null; do sleep 1; done', 120)
|
||||||
|
self.assertRunOk('wget http://127.0.0.1/resolv.conf', 120)
|
||||||
|
|
||||||
def test_run(self):
|
def test_run(self):
|
||||||
kernel = os.path.join(self.builddir, "images", "bzImage")
|
kernel = os.path.join(self.builddir, "images", "bzImage")
|
||||||
|
Loading…
Reference in New Issue
Block a user