Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support > 1 image in systemd_in_container test #753

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions config_defaults/subtests/docker_cli/systemd_in_container.ini
Original file line number Diff line number Diff line change
@@ -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 = fedora:latest,centos:latest
23 changes: 20 additions & 3 deletions subtests/docker_cli/systemd_in_container/systemd_in_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,49 @@

from os.path import join
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


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:
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, counting starts at 1
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 = get_as_list(config.get('fqins_to_test', ''))
if fqins_to_test:
systemd_in_container.iterations = len(fqins_to_test) + 1 # default image