From 07e5fb8cbed222252caa74b32953fa162053ac9d Mon Sep 17 00:00:00 2001 From: Roman Prykhodchenko Date: Thu, 26 Nov 2015 11:06:51 +0100 Subject: [PATCH] Fix functional tests the patch fixes tox.ini to run functional tests properly. Since a few tests were broken, the patch fixes them as well. Change-Id: I389915775c97596c2bc36ed82799e392494d55ff Closes-bug: #1517948 --- fuelclient/tests/functional/base.py | 3 ++- fuelclient/tests/functional/v1/test_client.py | 17 ++++++++++++----- tox.ini | 11 +++++++---- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/fuelclient/tests/functional/base.py b/fuelclient/tests/functional/base.py index 349652cf..378f8407 100644 --- a/fuelclient/tests/functional/base.py +++ b/fuelclient/tests/functional/base.py @@ -45,7 +45,8 @@ class CliExectutionResult(object): class BaseTestCase(oslo_base.BaseTestCase): - nailgun_root = os.environ.get('NAILGUN_ROOT', '/tmp/fuel_web/nailgun') + nailgun_root = os.path.join(os.getenv('FUEL_WEB_ROOT', '/tmp/fuel_web/'), + 'nailgun') def setUp(self): super(BaseTestCase, self).setUp() diff --git a/fuelclient/tests/functional/v1/test_client.py b/fuelclient/tests/functional/v1/test_client.py index 27090c72..3a71bbda 100644 --- a/fuelclient/tests/functional/v1/test_client.py +++ b/fuelclient/tests/functional/v1/test_client.py @@ -43,7 +43,7 @@ class TestHandlers(base.BaseTestCase): expected_stdout = \ [( "env --create --name=TestEnv --release={0}".format(release_id), - "Environment 'TestEnv' with id=1 and was created!\n" + "Environment 'TestEnv' with id=1 was created!\n" ), ( "--env-id=1 env set --name=NewEnv", ("Following attributes are changed for " @@ -69,7 +69,7 @@ class TestHandlers(base.BaseTestCase): self.check_if_required("node {0}".format(action)) self.load_data_to_nailgun_server() - self.check_number_of_rows_in_table("node --node 9f:b7,9d:24,ab:aa", 3) + self.check_number_of_rows_in_table("node --node 9f:b6,9d:24,ab:aa", 3) def test_selected_node_provision(self): self.load_data_to_nailgun_server() @@ -162,7 +162,7 @@ class TestHandlers(base.BaseTestCase): self.check_for_stdout( "env create --name=NewEnv --release={0} --nst=tun" .format(release_id), - "Environment 'NewEnv' with id=1 and was created!\n") + "Environment 'NewEnv' with id=1 was created!\n") def test_destroy_multiple_nodes(self): self.load_data_to_nailgun_server() @@ -396,8 +396,15 @@ class TestDownloadUploadNodeAttributes(base.BaseTestCase): def test_upload_download_interfaces(self): self.load_data_to_nailgun_server() + + release_id = self.get_first_deployable_release_id() + env_create = "env create --name=test --release={0}".format(release_id) + add_node = "--env-id=1 node set --node 1 --role=controller" + cmd = "node --node-id 1 --network" - self.run_cli_commands((self.download_command(cmd), + self.run_cli_commands((env_create, + add_node, + self.download_command(cmd), self.upload_command(cmd))) def test_upload_download_disks(self): @@ -436,7 +443,7 @@ class TestDirectoryDoesntExistErrorMessages(base.BaseTestCase): def test_net_upload(self): self.check_for_stderr( - "net --upload --dir /foo/bar/baz --env 1 network", + "network --upload --dir /foo/bar/baz --env 1", "Directory '/foo/bar/baz' doesn't exist.\n", check_errors=False ) diff --git a/tox.ini b/tox.ini index cdfb2f15..8e994bcb 100644 --- a/tox.ini +++ b/tox.ini @@ -8,6 +8,7 @@ usedevelop = True install_command = pip install --allow-external -U {opts} {packages} whitelist_externals = bash oslo_debug_helper + python setenv = VIRTUAL_ENV={envdir} ARTIFACTS={toxinidir}/test_run FUELCLIENT_JUNIT=fuelclient-{envname}.xml @@ -35,14 +36,16 @@ passenv = FUEL_WEB_ROOT TEST_NAILGUN_DB deps = -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt -commands = - bash -c "TESTS_DIR={posargs:./fuelclient/tests/unit} python setup.py test --slowest" + +commands = python setup.py test --slowest --testr-args "{posargs}" [testenv:functional] +setenv = {[testenv]setenv} + OS_TEST_PATH={toxinidir}/fuelclient/tests/functional commands = bash {toxinidir}/tools/cleanup.sh bash {toxinidir}/tools/prepare_nailgun.sh - bash -c "TESTS_DIR={posargs:./fuelclient/tests/functional} python setup.py test --slowest" + python setup.py test --slowest --testr-args "{posargs}" [testenv:dbgunit] commands = oslo_debug_helper -t {toxinidir}/fuelclient/tests/unit {posargs} @@ -69,7 +72,7 @@ commands = [testenv:cover] commands = - bash -c "TESTS_DIR={posargs:./fuelclient/tests/unit} python setup.py testr --coverage" + python setup.py testr --coverage --testr-args '{posargs}' [testenv:venv] commands = {posargs:}