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

test: detect broken podman #2483

Merged
merged 1 commit into from
Jan 5, 2020
Merged
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
30 changes: 29 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,29 @@ 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
podman = get_podman_executable()
if not min_ansible("2.8.6") or platform.system() == 'Darwin' or not podman:
return False

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


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