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: I55abc999f6f397b171d05fd9e9b39d833ca95e55
This commit is contained in:
Iury Gregory Melo Ferreira 2019-03-11 15:36:35 +01:00
parent 66392a90df
commit 9b881cb973
9 changed files with 59 additions and 14 deletions

View File

@ -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'):

View File

@ -140,7 +140,7 @@ class BaremetalAllocationTests(base.TestCase):
('--trait', 'foo',
'A custom trait must start with the prefix CUSTOM_'),
('--candidate-node', '', 'expected one argument'),
('--candidate-node', 'banana?', 'Expected a logical name or UUID'),
('--candidate-node', 'banana?', 'Nodes cannot be found'),
('--wait', 'meow', 'invalid int value'))
@ddt.unpack
def test_create_negative(self, argument, value, ex_text):
@ -156,5 +156,5 @@ class BaremetalAllocationTests(base.TestCase):
"""Check errors on missing resource class."""
base_cmd = 'baremetal allocation create'
self.assertRaisesRegex(exceptions.CommandFailed,
'--resource-class is required',
'--resource-class',
self.openstack, base_cmd)

View File

@ -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'),

View File

@ -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: <node>'),
('--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: <node>'),
('--property', 'prop', "Reason: can't remove non-existent object")
)
@ddt.unpack

View File

@ -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,

View File

@ -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'

View File

@ -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

View File

@ -20,11 +20,11 @@
vars:
tox_environment:
PYTHONUNBUFFERED: 'true'
tox_envlist: functional
tox_envlist: functionalpy3
devstack_plugins:
ironic: git://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

View File

@ -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