Skip to content

Commit

Permalink
podman: skip tests with unsupported versions
Browse files Browse the repository at this point in the history
Podman tests would fail with older version of podman due to missing
cp command.

Now we also check the version and skip the tests if installed version
is too old.
  • Loading branch information
ssbarnea committed Jan 5, 2020
1 parent 17323ef commit 0f9a03a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -362,5 +362,7 @@ before_install:
script:
# keep it like this to first create env and later to run again with tests
# in order to avoid regressions to run twice on the same environment.
- podman version
- docker version
- tox --notest
- tox
20 changes: 20 additions & 0 deletions molecule/test/functional/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@
# DEALINGS IN THE SOFTWARE.

import distutils.spawn
from distutils.version import LooseVersion
import os
import pkg_resources
import platform
import shutil
import subprocess

import pexpect
import pytest
Expand All @@ -38,6 +40,9 @@
LOG = logger.get_logger(__name__)

IS_TRAVIS = os.getenv('TRAVIS') and os.getenv('CI')
# requires >=1.5.1 due to missing cp command, we tested with 1.4.2-stable3 and
# it failed, see https://bugzilla.redhat.com/show_bug.cgi?id=1759713
MIN_PODMAN_VERSION = "1.5.1"


@pytest.fixture(scope="session", autouse=True)
Expand Down Expand Up @@ -302,6 +307,21 @@ def supports_podman():
pytest.fail("Cannot run podman tests with a broken podman installation.")
return False

# checks for minimal version of podman
cmd = ["podman", "version", "-f", "{{.Version}}"]
podman_version = util.check_output(
cmd, stderr=subprocess.STDOUT, universal_newlines=True
)
# We need to use the outdated LooseVersion because podman versioning
# is not PEP-440 compliant, example '1.4.2-stable3' which should evaluate
# as newer than '1.4.2'
if LooseVersion(podman_version) < LooseVersion(MIN_PODMAN_VERSION):
pytest.skip(
"Podman driver requires version >={}, and you have {}".format(
MIN_PODMAN_VERSION, podman_version
)
)

return True


Expand Down

0 comments on commit 0f9a03a

Please sign in to comment.