From cdd4b8c046f5902f515d782fa19fbf738d376549 Mon Sep 17 00:00:00 2001 From: Iury Gregory Melo Ferreira Date: Mon, 11 Mar 2019 15:36:35 +0100 Subject: [PATCH] Run jobs under python2 and python3 -Switch functional job to run under python3 -Create a functional job to run under python2 -Create a tempest job to run under python2 -Create tox env to run functional tests under python3 -Validate if `USE_PYTHON3` is set to `True` to call the correct env for tests -Remove hardcoded path for client when running functional tests - Update tests failures to work for python2 and python3 Change-Id: I96d418f08c46add8bf61bf8d1b4e45b6083b8d84 (cherry picked from commit 9b881cb973bc2219df90c2b71e2a1d0e18dcd98a) --- ironicclient/tests/functional/base.py | 3 ++- .../test_baremetal_deploy_template_basic.py | 5 ++++- .../osc/v1/test_baremetal_node_negative.py | 14 +++++++++++--- ironicclient/tests/functional/test_chassis.py | 8 ++++---- playbooks/functional/run.yaml | 8 +++++++- tox.ini | 8 ++++++++ zuul.d/ironicclient-jobs.yaml | 19 +++++++++++++++++-- zuul.d/project.yaml | 4 ++++ 8 files changed, 57 insertions(+), 12 deletions(-) diff --git a/ironicclient/tests/functional/base.py b/ironicclient/tests/functional/base.py index 862f0528c..cb87f4831 100644 --- a/ironicclient/tests/functional/base.py +++ b/ironicclient/tests/functional/base.py @@ -37,7 +37,8 @@ class FunctionalTestBase(base.ClientTestBase): def _get_clients(self): # NOTE(aarefiev): {toxinidir} is a current working directory, so # the tox env path is {toxinidir}/.tox - cli_dir = os.path.join(os.path.abspath('.'), '.tox/functional/bin') + venv_name = os.environ.get('OS_TESTENV_NAME', 'functional') + cli_dir = os.path.join(os.path.abspath('.'), '.tox/%s/bin' % venv_name) config = self._get_config() if config.get('os_auth_url'): diff --git a/ironicclient/tests/functional/osc/v1/test_baremetal_deploy_template_basic.py b/ironicclient/tests/functional/osc/v1/test_baremetal_deploy_template_basic.py index 1fa2932f7..5a717509c 100644 --- a/ironicclient/tests/functional/osc/v1/test_baremetal_deploy_template_basic.py +++ b/ironicclient/tests/functional/osc/v1/test_baremetal_deploy_template_basic.py @@ -13,6 +13,7 @@ import json import ddt +import six from tempest.lib.common.utils import data_utils from tempest.lib import exceptions @@ -159,7 +160,9 @@ class BaremetalDeployTemplateTests(base.TestCase): @ddt.data( ('--uuid', '', 'expected one argument'), ('--uuid', '!@#$^*&%^', 'Expected a UUID'), - ('', '', 'too few arguments'), + ('', '', + 'too few arguments' if six.PY2 + else 'the following arguments are required'), ('', 'not/a/name', 'Deploy template name must be a valid trait'), ('', 'foo', 'Deploy template name must be a valid trait'), ('--steps', '', 'expected one argument'), diff --git a/ironicclient/tests/functional/osc/v1/test_baremetal_node_negative.py b/ironicclient/tests/functional/osc/v1/test_baremetal_node_negative.py index c4af8746d..22013aa3b 100644 --- a/ironicclient/tests/functional/osc/v1/test_baremetal_node_negative.py +++ b/ironicclient/tests/functional/osc/v1/test_baremetal_node_negative.py @@ -28,7 +28,9 @@ class BaremetalNodeNegativeTests(base.TestCase): self.node = self.node_create() @ddt.data( - ('', '', 'error: argument --driver is required'), + ('', '', + 'error: argument --driver is required' if six.PY2 + else 'error: the following arguments are required: --driver'), ('--driver', 'wrongdriver', 'No valid host was found. Reason: No conductor service ' 'registered which supports driver wrongdriver.') @@ -45,6 +47,8 @@ class BaremetalNodeNegativeTests(base.TestCase): """Test for baremetal node delete without node specified.""" command = 'baremetal node delete' ex_text = 'error: too few arguments' + if six.PY3: + ex_text = '' six.assertRaisesRegex(self, exceptions.CommandFailed, ex_text, self.openstack, command) @@ -56,7 +60,9 @@ class BaremetalNodeNegativeTests(base.TestCase): self.openstack, command) @ddt.data( - ('--property', '', 'error: too few arguments'), + ('--property', '', + 'error: too few arguments' if six.PY2 + else 'error: the following arguments are required: '), ('--property', 'prop', 'Attributes must be a list of PATH=VALUE') ) @ddt.unpack @@ -69,7 +75,9 @@ class BaremetalNodeNegativeTests(base.TestCase): self.openstack, command) @ddt.data( - ('--property', '', 'error: too few arguments'), + ('--property', '', + 'error: too few arguments' if six.PY2 + else 'error: the following arguments are required: '), ('--property', 'prop', "Reason: can't remove non-existent object") ) @ddt.unpack diff --git a/ironicclient/tests/functional/test_chassis.py b/ironicclient/tests/functional/test_chassis.py index 7ac944b93..67cab2677 100644 --- a/ironicclient/tests/functional/test_chassis.py +++ b/ironicclient/tests/functional/test_chassis.py @@ -132,7 +132,7 @@ class ChassisNegativeTestsIronicClient(base.FunctionalTestBase): 1) check that chassis-delete command without arguments triggers an exception """ - ex_text = r'chassis-delete: error: too few arguments' + ex_text = r'chassis-delete: error:' six.assertRaisesRegex(self, exceptions.CommandFailed, ex_text, @@ -159,7 +159,7 @@ class ChassisNegativeTestsIronicClient(base.FunctionalTestBase): 1) check that chassis-show command without arguments triggers an exception """ - ex_text = r'chassis-show: error: too few arguments' + ex_text = r'chassis-show: error:' six.assertRaisesRegex(self, exceptions.CommandFailed, ex_text, @@ -187,7 +187,7 @@ class ChassisNegativeTestsIronicClient(base.FunctionalTestBase): 2) check that chassis-update command without arguments triggers an exception """ - ex_text = r'chassis-update: error: too few arguments' + ex_text = r'chassis-update: error:' six.assertRaisesRegex(self, exceptions.CommandFailed, ex_text, @@ -203,7 +203,7 @@ class ChassisNegativeTestsIronicClient(base.FunctionalTestBase): triggers an exception """ uuid = data_utils.rand_uuid() - ex_text = r'chassis-update: error: too few arguments' + ex_text = r'chassis-update: error:' six.assertRaisesRegex(self, exceptions.CommandFailed, diff --git a/playbooks/functional/run.yaml b/playbooks/functional/run.yaml index baa830aa7..275ebc0c8 100644 --- a/playbooks/functional/run.yaml +++ b/playbooks/functional/run.yaml @@ -44,6 +44,12 @@ export IRONICCLIENT_TEST_CONFIG=$CONFIG_FILE cd $IRONICCLIENT_DIR - tox -e functional + if [[ $USE_PYTHON3 == "True" ]]; then + echo 'Running Functional Tests under Python3' + tox -e functionalpy3 + else + echo 'Running Functional Tests under Python2' + tox -e functional + fi executable: /bin/bash chdir: '/opt/stack/python-ironicclient' diff --git a/tox.ini b/tox.ini index 8e2b4d965..8eb6df918 100644 --- a/tox.ini +++ b/tox.ini @@ -56,6 +56,14 @@ commands = {posargs} passenv = * setenv = TESTS_DIR=./ironicclient/tests/functional LANGUAGE=en_US + OS_TESTENV_NAME = {envname} + +[testenv:functionalpy3] +basepython = python3 +passenv = * +setenv = TESTS_DIR=./ironicclient/tests/functional + LANGUAGE=en_US + OS_TESTENV_NAME = {envname} [testenv:docs] basepython = python3 diff --git a/zuul.d/ironicclient-jobs.yaml b/zuul.d/ironicclient-jobs.yaml index 1dde6c4e5..f08da280f 100644 --- a/zuul.d/ironicclient-jobs.yaml +++ b/zuul.d/ironicclient-jobs.yaml @@ -20,11 +20,11 @@ vars: tox_environment: PYTHONUNBUFFERED: 'true' - tox_envlist: functional + tox_envlist: functionalpy3 devstack_plugins: ironic: https://git.openstack.org/openstack/ironic devstack_localrc: - USE_PYTHON3: False + USE_PYTHON3: True EBTABLES_RACE_FIX: True IRONIC_ENABLED_NETWORK_INTERFACES: noop IRONIC_DHCP_PROVIDER: none @@ -35,6 +35,14 @@ mysql: True rabbit: True +- job: + name: ironicclient-functional-python2 + parent: ironicclient-functional + post-run: playbooks/functional/run.yaml + vars: + tox_envlist: functional + devstack_localrc: + USE_PYTHON3: False - job: name: ironicclient-tempest @@ -46,3 +54,10 @@ devstack_localrc: USE_PYTHON3: True EBTABLES_RACE_FIX: True + +- job: + name: ironicclient-tempest-python2 + parent: ironicclient-tempest + vars: + devstack_localrc: + USE_PYTHON3: False diff --git a/zuul.d/project.yaml b/zuul.d/project.yaml index f5a5f52c6..0d54bbe98 100644 --- a/zuul.d/project.yaml +++ b/zuul.d/project.yaml @@ -13,9 +13,13 @@ check: jobs: - ironicclient-functional + - ironicclient-functional-python2 - ironicclient-tempest + - ironicclient-tempest-python2 gate: queue: ironic jobs: - ironicclient-functional + - ironicclient-functional-python2 - ironicclient-tempest + - ironicclient-tempest-python2