From 786711e179d318394051c148c7944796a208992f Mon Sep 17 00:00:00 2001 From: Andrey Kurilin Date: Mon, 16 Oct 2017 18:00:07 +0300 Subject: [PATCH] [ci] Split legacy-rally-dsvm-cli job * Use empty deployment For functional tests we should not rely on existing deployment, it is not needed, so we stop doing it and use just empty deployment * Move functional tests under separate `tox-functional` job Change-Id: I1eda2d455cbf0479ae8aeb54ef32ab21d9ccdeb1 --- .../check_samples/test_certification_task.py | 7 +++- tests/check_samples/test_task_samples.py | 2 +- tests/check_samples/utils.py | 32 +++++++++++++++++++ tests/functional/test_cli_deployment.py | 2 +- tests/functional/utils.py | 11 ++----- tox.ini | 2 +- 6 files changed, 44 insertions(+), 12 deletions(-) create mode 100644 tests/check_samples/utils.py diff --git a/tests/check_samples/test_certification_task.py b/tests/check_samples/test_certification_task.py index 272889ca..3c9b3411 100644 --- a/tests/check_samples/test_certification_task.py +++ b/tests/check_samples/test_certification_task.py @@ -19,12 +19,17 @@ import traceback import unittest import rally as rally_m -from tests.functional import utils +from tests.check_samples import utils class TestPreCreatedTasks(unittest.TestCase): + def test_check_success(self): + rally = utils.Rally() + rally("deployment check") + def test_task_samples_is_valid(self): + rally = utils.Rally() full_path = os.path.join( os.path.dirname(rally_m.__file__), os.pardir, "tasks", "openstack") diff --git a/tests/check_samples/test_task_samples.py b/tests/check_samples/test_task_samples.py index 444ef30e..f7934985 100644 --- a/tests/check_samples/test_task_samples.py +++ b/tests/check_samples/test_task_samples.py @@ -30,7 +30,7 @@ from rally.common import broker from rally.common import yamlutils as yaml from rally import plugins from rally.plugins.openstack.context.keystone import users -from tests.functional import utils +from tests.check_samples import utils class TestTaskSamples(unittest.TestCase): diff --git a/tests/check_samples/utils.py b/tests/check_samples/utils.py new file mode 100644 index 00000000..baf34213 --- /dev/null +++ b/tests/check_samples/utils.py @@ -0,0 +1,32 @@ +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import os +import subprocess + +from tests.functional import utils + + +DEPLOYMENT_FILE = "/tmp/rally_functests_main_deployment.json" + + +class Rally(utils.Rally): + + def __init__(self, force_new_db=False): + self._DEPLOYMENT_CREATE_ARGS = " --file %s" % DEPLOYMENT_FILE + if not os.path.exists(DEPLOYMENT_FILE): + subprocess.call(["rally", "--log-file", "/dev/null", + "deployment", "config"], + stdout=open(DEPLOYMENT_FILE, "w")) + super(Rally, self).__init__(force_new_db=force_new_db) diff --git a/tests/functional/test_cli_deployment.py b/tests/functional/test_cli_deployment.py index b30efb45..8d49d853 100644 --- a/tests/functional/test_cli_deployment.py +++ b/tests/functional/test_cli_deployment.py @@ -67,7 +67,7 @@ class DeploymentTestCase(unittest.TestCase): def test_check_success(self): rally = utils.Rally() - self.assertTrue(rally("deployment check")) + rally("deployment check") def test_check_fail(self): rally = utils.Rally() diff --git a/tests/functional/utils.py b/tests/functional/utils.py index 6927a79f..13a3f5e8 100644 --- a/tests/functional/utils.py +++ b/tests/functional/utils.py @@ -26,8 +26,6 @@ import tempfile from oslo_utils import encodeutils from six.moves import configparser -DEPLOYMENT_FILE = "/tmp/rally_functests_main_deployment.json" - class RallyCliError(Exception): @@ -72,12 +70,9 @@ class Rally(object): output = rally("deployment list") """ + _DEPLOYMENT_CREATE_ARGS = "" - def __init__(self, fake=False, force_new_db=False): - if not os.path.exists(DEPLOYMENT_FILE): - subprocess.call(["rally", "--log-file", "/dev/null", - "deployment", "config"], - stdout=open(DEPLOYMENT_FILE, "w")) + def __init__(self, force_new_db=False): # NOTE(sskripnick): we should change home dir to avoid races # and do not touch any user files in ~/.rally @@ -119,7 +114,7 @@ class Rally(object): self.reports_root = os.environ.get("REPORTS_ROOT", "rally-cli-output-files") self._created_files = [] - self("deployment create --file %s --name MAIN" % DEPLOYMENT_FILE, + self("deployment create --name MAIN%s" % self._DEPLOYMENT_CREATE_ARGS, write_report=False) def __del__(self): diff --git a/tox.ini b/tox.ini index 1aba3fe2..28af1e87 100644 --- a/tox.ini +++ b/tox.ini @@ -57,7 +57,7 @@ commands = oslo_debug_helper -t tests {posargs} sitepackages = True commands = find . -type f -name "*.pyc" -delete - {toxinidir}/tests/ci/rally_cli_job.sh + python {toxinidir}/tests/ci/pytest_launcher.py tests/check_samples --posargs={posargs} [testenv:functional] sitepackages = True