From 87bf960ea9b3fe09fbf5be239ffddcd73f17c5e9 Mon Sep 17 00:00:00 2001 From: Chris Evich Date: Wed, 16 Aug 2017 14:22:56 -0400 Subject: [PATCH 1/6] Support > 1 image in systemd_in_container test For images based on the base-image, it's useful to confirm they retain support for running systemd. Enable this (optionally) by iterating over an CSV list of FQINs from the test configuration. This way failure of the test against any one image doesn't impact testing of the others. Signed-off-by: Chris Evich --- .../docker_cli/systemd_in_container.ini | 5 +++++ .../systemd_in_container.py | 22 ++++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 config_defaults/subtests/docker_cli/systemd_in_container.ini diff --git a/config_defaults/subtests/docker_cli/systemd_in_container.ini b/config_defaults/subtests/docker_cli/systemd_in_container.ini new file mode 100644 index 000000000..ea63b4f51 --- /dev/null +++ b/config_defaults/subtests/docker_cli/systemd_in_container.ini @@ -0,0 +1,5 @@ +[docker_cli/systemd_in_container] + +#: When non-empty, a CSV list of additional images to run this test against. +#: *N/B:* The default test image is always exercized. +fqins_to_test = diff --git a/subtests/docker_cli/systemd_in_container/systemd_in_container.py b/subtests/docker_cli/systemd_in_container/systemd_in_container.py index a84602734..60690ad28 100644 --- a/subtests/docker_cli/systemd_in_container/systemd_in_container.py +++ b/subtests/docker_cli/systemd_in_container/systemd_in_container.py @@ -19,6 +19,7 @@ from os.path import join from autotest.client.utils import run +from dockertest.config import get_as_list from dockertest import subtest from dockertest.images import DockerImages from dockertest.output.validate import mustpass @@ -27,24 +28,39 @@ class systemd_in_container(subtest.Subtest): + # Execute this many times, with #0 being the default test image + iterations = 1 + def initialize(self): # See Prerequisites (above) DockerVersion().require_server("1.12") self.stuff['result'] = None self.stuff['di'] = DockerImages(self) + self.stuff['fqins'] = [self.stuff['di'].default_image] + if self.iterations > 1: + fqins_to_test += get_as_list(fqins_to_test) super(systemd_in_container, self).initialize() def run_once(self): super(systemd_in_container, self).run_once() + # First item is always the default test image + fqin = self.stuff['fqins'][self.iteration - 1] + # Assumes script exits non-zero on test-failure and # cleans up any/all containers/images it created result = run("%s %s" % (join(self.bindir, 'test.sh'), - self.stuff['di'].default_image), + fqin), ignore_status=True) self.logdebug(str(result)) self.stuff['result'] = result - def postprocess(self): - super(systemd_in_container, self).postprocess() + def postprocess_iteration(self): + super(systemd_in_container, self).postprocess_iteration() mustpass(self.stuff['result']) + +# A little bit of magic to configure the class when fqins_to_test is set +config = Config()['docker_cli/systemd_in_container'] +fqins_to_test = config.get('fqins_to_test') +if fqins_to_test and get_as_list(fqins_to_test): + systemd_in_container.iterations = len(get_as_list(fqins_to_test)) + 1 From 4ac4fd7adc6972850edebfcc3daede56f3ff72e9 Mon Sep 17 00:00:00 2001 From: Chris Evich Date: Wed, 16 Aug 2017 14:27:04 -0400 Subject: [PATCH 2/6] FUDGING FOR CI: DO NOT MERGE --- config_defaults/subtests/docker_cli/systemd_in_container.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config_defaults/subtests/docker_cli/systemd_in_container.ini b/config_defaults/subtests/docker_cli/systemd_in_container.ini index ea63b4f51..b151166f0 100644 --- a/config_defaults/subtests/docker_cli/systemd_in_container.ini +++ b/config_defaults/subtests/docker_cli/systemd_in_container.ini @@ -2,4 +2,4 @@ #: When non-empty, a CSV list of additional images to run this test against. #: *N/B:* The default test image is always exercized. -fqins_to_test = +fqins_to_test = fedora:latest,centos:latest From 735fe9fffe0a5329148f73e98b90c88f0fe06222 Mon Sep 17 00:00:00 2001 From: Chris Evich Date: Fri, 18 Aug 2017 18:32:21 -0400 Subject: [PATCH 3/6] fixup! Support > 1 image in systemd_in_container test --- subtests/docker_cli/systemd_in_container/systemd_in_container.py | 1 + 1 file changed, 1 insertion(+) diff --git a/subtests/docker_cli/systemd_in_container/systemd_in_container.py b/subtests/docker_cli/systemd_in_container/systemd_in_container.py index 60690ad28..016c0f05f 100644 --- a/subtests/docker_cli/systemd_in_container/systemd_in_container.py +++ b/subtests/docker_cli/systemd_in_container/systemd_in_container.py @@ -21,6 +21,7 @@ from autotest.client.utils import run from dockertest.config import get_as_list from dockertest import subtest +from dockertest.config import Config from dockertest.images import DockerImages from dockertest.output.validate import mustpass from dockertest.output.dockerversion import DockerVersion From 2034f8de932c0ef81dc09d1fac6edf8f6d8e1722 Mon Sep 17 00:00:00 2001 From: Chris Evich Date: Fri, 18 Aug 2017 18:32:21 -0400 Subject: [PATCH 4/6] fixup! Support > 1 image in systemd_in_container test --- .../systemd_in_container/systemd_in_container.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/subtests/docker_cli/systemd_in_container/systemd_in_container.py b/subtests/docker_cli/systemd_in_container/systemd_in_container.py index 016c0f05f..0fe7d266d 100644 --- a/subtests/docker_cli/systemd_in_container/systemd_in_container.py +++ b/subtests/docker_cli/systemd_in_container/systemd_in_container.py @@ -39,12 +39,12 @@ def initialize(self): self.stuff['di'] = DockerImages(self) self.stuff['fqins'] = [self.stuff['di'].default_image] if self.iterations > 1: - fqins_to_test += get_as_list(fqins_to_test) + self.stuff['fqins'] += get_as_list(config.get('fqins_to_test','')) super(systemd_in_container, self).initialize() def run_once(self): super(systemd_in_container, self).run_once() - # First item is always the default test image + # First item is always the default test image, counting starts at 1 fqin = self.stuff['fqins'][self.iteration - 1] # Assumes script exits non-zero on test-failure and @@ -62,6 +62,7 @@ def postprocess_iteration(self): # A little bit of magic to configure the class when fqins_to_test is set config = Config()['docker_cli/systemd_in_container'] -fqins_to_test = config.get('fqins_to_test') -if fqins_to_test and get_as_list(fqins_to_test): - systemd_in_container.iterations = len(get_as_list(fqins_to_test)) + 1 +fqins_to_test = get_as_list(config.get('fqins_to_test','')) +if fqins_to_test: + systemd_in_container.fqins_to_test + systemd_in_container.iterations = len(fqins_to_test) + 1 # default image From 7312e1838a148f2cb69e549d7cf5e0cdb5cdf031 Mon Sep 17 00:00:00 2001 From: Chris Evich Date: Fri, 18 Aug 2017 18:32:21 -0400 Subject: [PATCH 5/6] fixup! Support > 1 image in systemd_in_container test --- .../docker_cli/systemd_in_container/systemd_in_container.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/subtests/docker_cli/systemd_in_container/systemd_in_container.py b/subtests/docker_cli/systemd_in_container/systemd_in_container.py index 0fe7d266d..aeb5770eb 100644 --- a/subtests/docker_cli/systemd_in_container/systemd_in_container.py +++ b/subtests/docker_cli/systemd_in_container/systemd_in_container.py @@ -39,7 +39,7 @@ def initialize(self): self.stuff['di'] = DockerImages(self) self.stuff['fqins'] = [self.stuff['di'].default_image] if self.iterations > 1: - self.stuff['fqins'] += get_as_list(config.get('fqins_to_test','')) + self.stuff['fqins'] += get_as_list(config.get('fqins_to_test','')) super(systemd_in_container, self).initialize() def run_once(self): @@ -64,5 +64,4 @@ def postprocess_iteration(self): config = Config()['docker_cli/systemd_in_container'] fqins_to_test = get_as_list(config.get('fqins_to_test','')) if fqins_to_test: - systemd_in_container.fqins_to_test systemd_in_container.iterations = len(fqins_to_test) + 1 # default image From 193044a889e9d59bd0b17224c96380850ba1ba83 Mon Sep 17 00:00:00 2001 From: Chris Evich Date: Fri, 18 Aug 2017 18:32:21 -0400 Subject: [PATCH 6/6] fixup! Support > 1 image in systemd_in_container test --- .../docker_cli/systemd_in_container/systemd_in_container.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/subtests/docker_cli/systemd_in_container/systemd_in_container.py b/subtests/docker_cli/systemd_in_container/systemd_in_container.py index aeb5770eb..176acbc85 100644 --- a/subtests/docker_cli/systemd_in_container/systemd_in_container.py +++ b/subtests/docker_cli/systemd_in_container/systemd_in_container.py @@ -39,7 +39,7 @@ def initialize(self): self.stuff['di'] = DockerImages(self) self.stuff['fqins'] = [self.stuff['di'].default_image] if self.iterations > 1: - self.stuff['fqins'] += get_as_list(config.get('fqins_to_test','')) + self.stuff['fqins'] += get_as_list(config.get('fqins_to_test', '')) super(systemd_in_container, self).initialize() def run_once(self): @@ -62,6 +62,6 @@ def postprocess_iteration(self): # A little bit of magic to configure the class when fqins_to_test is set config = Config()['docker_cli/systemd_in_container'] -fqins_to_test = get_as_list(config.get('fqins_to_test','')) +fqins_to_test = get_as_list(config.get('fqins_to_test', '')) if fqins_to_test: systemd_in_container.iterations = len(fqins_to_test) + 1 # default image