summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIury Gregory Melo Ferreira <imelofer@redhat.com>2019-03-11 15:36:35 +0100
committerIury Gregory Melo Ferreira <imelofer@redhat.com>2019-03-15 17:43:19 +0100
commit9b881cb973bc2219df90c2b71e2a1d0e18dcd98a (patch)
treeb791399aaeedafab83be3bdeda8800af63b04eba
parent66392a90df2d61adf780f3a95a7da37d639d227c (diff)
downloadpython-ironicclient-9b881cb973bc2219df90c2b71e2a1d0e18dcd98a.tar.gz
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
-rw-r--r--ironicclient/tests/functional/base.py3
-rw-r--r--ironicclient/tests/functional/osc/v1/test_baremetal_allocation.py4
-rw-r--r--ironicclient/tests/functional/osc/v1/test_baremetal_deploy_template_basic.py5
-rw-r--r--ironicclient/tests/functional/osc/v1/test_baremetal_node_negative.py14
-rw-r--r--ironicclient/tests/functional/test_chassis.py8
-rw-r--r--playbooks/functional/run.yaml8
-rw-r--r--tox.ini8
-rw-r--r--zuul.d/ironicclient-jobs.yaml19
-rw-r--r--zuul.d/project.yaml4
9 files changed, 59 insertions, 14 deletions
diff --git a/ironicclient/tests/functional/base.py b/ironicclient/tests/functional/base.py
index 862f052..cb87f48 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_allocation.py b/ironicclient/tests/functional/osc/v1/test_baremetal_allocation.py
index d92ef7d..b7a66ad 100644
--- a/ironicclient/tests/functional/osc/v1/test_baremetal_allocation.py
+++ b/ironicclient/tests/functional/osc/v1/test_baremetal_allocation.py
@@ -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)
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 1fa2932..5a71750 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 c4af874..22013aa 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: <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
diff --git a/ironicclient/tests/functional/test_chassis.py b/ironicclient/tests/functional/test_chassis.py
index 7ac944b..67cab26 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 baa830a..275ebc0 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 eda34de..16b724e 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 12e6ced..8a98384 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: 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
diff --git a/zuul.d/project.yaml b/zuul.d/project.yaml
index f5a5f52..0d54bbe 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