Skip to content

Commit

Permalink
test: detect broken podman
Browse files Browse the repository at this point in the history
Improved podman detection so we fail fast if current installation does
not pass `podman info` minimal test. This should save time running
tests on systems what are not properly configured.

Skips will happen only on platforms that are known not to support
podman, but on those supporting it, tests will fail.
  • Loading branch information
ssbarnea committed Jan 5, 2020
1 parent b21671f commit e1137ba
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion molecule/test/functional/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def skip_test(request, driver_name):
msg_tmpl = "Skipped '{}' not supported"
support_checks_map = {
'docker': supports_docker,
'podman': lambda: min_ansible("2.8.6") and platform.system() != 'Darwin',
'podman': supports_podman,
'delegated': lambda: True,
}
try:
Expand Down Expand Up @@ -253,11 +253,16 @@ def get_docker_executable():
return distutils.spawn.find_executable('docker')


def get_podman_executable():
return distutils.spawn.find_executable('podman')


def get_virtualbox_executable():
return distutils.spawn.find_executable('VBoxManage')


@pytest.helpers.register
@util.lru_cache
def supports_docker():
docker = get_docker_executable()
if docker:
Expand All @@ -277,6 +282,30 @@ def supports_docker():
return True


@pytest.helpers.register
@util.lru_cache
def supports_podman():
# Returns true if podman is supported and working
# Returns false if podman in not supported
# Calls pytest.fail if podman appears to be broken
if min_ansible("2.8.6") and platform.system() != 'Darwin':
podman = get_podman_executable()
if podman:
result = util.run([podman, "info"], stdout=PIPE, universal_newlines=True)
if result.returncode != 0:
LOG.error(
"Error %s returned from `podman info`: %s",
result.returncode,
result.stdout,
)
pytest.fail(
"Cannot run podman tests with a broken podman installation."
)
return False
return True
return False


def min_ansible(version):
"""Ensure current Ansible is newer than a given a minimal one."""
try:
Expand Down

0 comments on commit e1137ba

Please sign in to comment.