diff --git a/.zuul.d/python-jobs.yaml b/.zuul.d/python-jobs.yaml index 6d7f9adfde..6824ae9fb5 100644 --- a/.zuul.d/python-jobs.yaml +++ b/.zuul.d/python-jobs.yaml @@ -37,6 +37,16 @@ vars: tox_env: functional +- job: + name: rally-tox-functional-py3 + parent: rally-tox-base + description: | + Run test for rally project. + + Uses tox with the ``functional-py3`` environment. + vars: + tox_env: functional-py3 + - job: name: rally-tox-self parent: rally-tox-base diff --git a/.zuul.d/zuul.yaml b/.zuul.d/zuul.yaml index 252d85c2d8..a90c193eb8 100644 --- a/.zuul.d/zuul.yaml +++ b/.zuul.d/zuul.yaml @@ -40,6 +40,7 @@ - rally-tox-py37 - rally-tox-cover - rally-tox-functional + - rally-tox-functional-py3 - rally-database-migration - rally-install-ubuntu-xenial - rally-install-ubuntu-bionic @@ -56,6 +57,7 @@ - rally-tox-py37 - rally-tox-cover - rally-tox-functional + - rally-tox-functional-py3 - rally-database-migration - rally-install-ubuntu-xenial - rally-install-ubuntu-bionic diff --git a/tests/ci/rally_functional_job.sh b/tests/ci/rally_functional_job.sh deleted file mode 100755 index 181e036eec..0000000000 --- a/tests/ci/rally_functional_job.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash - -LOCAL_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - -DB_CONNECTION="$(rally db show)" - -if [[ $DB_CONNECTION == sqlite* ]]; then - CONCURRENCY=0 -else - # in case of not sqlite db backends we cannot launch tests in parallel due - # to possible conflicts - CONCURRENCY=1 - # currently, RCI_KEEP_DB variable is used to not create new databases per - # each test - export RCI_KEEP_DB=1 -fi - - -python $LOCAL_DIR/pytest_launcher.py "tests/functional" --concurrency $CONCURRENCY --posargs=$1 diff --git a/tests/functional/test_cli_env.py b/tests/functional/test_cli_env.py index 1102706c89..fd313ba3e7 100644 --- a/tests/functional/test_cli_env.py +++ b/tests/functional/test_cli_env.py @@ -35,7 +35,7 @@ class EnvTestCase(unittest.TestCase): self.assertEqual({}, env_data["platforms"]) def _create_spec(self, spec): - f = tempfile.NamedTemporaryFile(delete=False) + f = tempfile.NamedTemporaryFile(mode="w", delete=False) def unlink(): os.unlink(f.name) diff --git a/tests/functional/test_cli_functional.py b/tests/functional/test_cli_functional.py index 2a6303ec4a..c18cca76db 100644 --- a/tests/functional/test_cli_functional.py +++ b/tests/functional/test_cli_functional.py @@ -16,18 +16,30 @@ import subprocess import unittest +import six + +from rally.utils import encodeutils + class CLITestCase(unittest.TestCase): def test_rally_cli(self): try: - output = subprocess.check_output(["rally"], - stderr=subprocess.STDOUT) + subprocess.check_output(["rally"], stderr=subprocess.STDOUT) except subprocess.CalledProcessError as e: - output = e.output - self.assertIn("too few arguments", output) + output = encodeutils.safe_decode(e.output) + else: + self.fail("It should ve non-zero exit code.") + + # NOTE(andreykurilin): we should have the same errors... + if six.PY2: + self.assertIn("too few arguments", output) + else: + self.assertIn("the following arguments are required: category", + output) def test_version_cli(self): - output = subprocess.check_output(["rally", "version"], - stderr=subprocess.STDOUT) + output = encodeutils.safe_decode( + subprocess.check_output(["rally", "version"], + stderr=subprocess.STDOUT)) self.assertIn("Rally version:", output) diff --git a/tox.ini b/tox.ini index 349a8f5a78..40c666c074 100644 --- a/tox.ini +++ b/tox.ini @@ -67,10 +67,16 @@ commands = echo "do nothing" [testenv:functional] -sitepackages = True +basepython = python2.7 commands = find . -type f -name "*.pyc" -delete - {toxinidir}/tests/ci/rally_functional_job.sh {posargs} + python {toxinidir}/tests/ci/pytest_launcher.py tests/functional --posargs={posargs} + +[testenv:functional-py3] +basepython = python3 +commands = + find . -type f -name "*.pyc" -delete + python {toxinidir}/tests/ci/pytest_launcher.py tests/functional --posargs={posargs} [testenv:cover] commands = {toxinidir}/tests/ci/cover.sh {posargs}