From 16a03869c020fe017c565069912693d87348fea7 Mon Sep 17 00:00:00 2001 From: James Page Date: Fri, 30 Oct 2015 14:49:18 +0900 Subject: [PATCH 1/3] Add tox support --- .bzrignore | 2 ++ .testr.conf | 8 ++++++ hooks/nova_compute_utils.py | 9 +++--- requirements.txt | 8 ++++++ test-requirements.txt | 7 +++++ tox.ini | 30 ++++++++++++++++++++ unit_tests/test_actions_openstack_upgrade.py | 2 +- unit_tests/test_nova_compute_utils.py | 2 +- 8 files changed, 62 insertions(+), 6 deletions(-) create mode 100644 .testr.conf create mode 100644 requirements.txt create mode 100644 test-requirements.txt create mode 100644 tox.ini diff --git a/.bzrignore b/.bzrignore index 421e2bda..e046ea55 100644 --- a/.bzrignore +++ b/.bzrignore @@ -1,3 +1,5 @@ bin .coverage +.tox +.testrepository tags diff --git a/.testr.conf b/.testr.conf new file mode 100644 index 00000000..801646bb --- /dev/null +++ b/.testr.conf @@ -0,0 +1,8 @@ +[DEFAULT] +test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \ + OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \ + OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-60} \ + ${PYTHON:-python} -m subunit.run discover -t ./ ./unit_tests $LISTOPT $IDOPTION + +test_id_option=--load-list $IDFILE +test_list_option=--list diff --git a/hooks/nova_compute_utils.py b/hooks/nova_compute_utils.py index 032dbc00..e3beb462 100644 --- a/hooks/nova_compute_utils.py +++ b/hooks/nova_compute_utils.py @@ -299,8 +299,9 @@ def resource_map(): conf = neutron_plugin_attribute(plugin, 'config', net_manager) svcs = neutron_plugin_attribute(plugin, 'services', net_manager) - ctxts = (neutron_plugin_attribute(plugin, 'contexts', net_manager) - or []) + ctxts = (neutron_plugin_attribute(plugin, + 'contexts', net_manager) or + []) resource_map[conf] = {} resource_map[conf]['services'] = svcs resource_map[conf]['contexts'] = ctxts @@ -373,8 +374,8 @@ def determine_packages(): if (net_manager in ['flatmanager', 'flatdhcpmanager'] and config('multi-host').lower() == 'yes'): packages.extend(['nova-api', 'nova-network']) - elif (net_manager in ['quantum', 'neutron'] - and neutron_plugin_legacy_mode()): + elif (net_manager in ['quantum', 'neutron'] and + neutron_plugin_legacy_mode()): plugin = neutron_plugin() pkg_lists = neutron_plugin_attribute(plugin, 'packages', net_manager) for pkg_list in pkg_lists: diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..4e02d4bb --- /dev/null +++ b/requirements.txt @@ -0,0 +1,8 @@ +PyYAML>=3.10 +simplejson>=3.3.1 +netifaces>=0.8 +netaddr>=0.7.10 +Jinja2>=2.7.2 +six>=1.5.2 +dnspython +psutil diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 00000000..ff4fb63b --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1,7 @@ +testtools +coverage +mock +flake8==2.1.0 +# No version required +charm-tools +os-testr diff --git a/tox.ini b/tox.ini new file mode 100644 index 00000000..6bdf5757 --- /dev/null +++ b/tox.ini @@ -0,0 +1,30 @@ +[tox] +# Default to current LTS +envlist = lint,py27 +skipsdist = True + +[testenv] +setenv = VIRTUAL_ENV={envdir} + PYTHONHASHSEED=0 +install_command = + pip install --allow-unverified python-apt {opts} {packages} +commands = ostestr {posargs} + +[testenv:py27] +basepython = python2.7 +deps = -r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt + +[testenv:lint] +basepython = python2.7 +deps = -r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt +commands = flake8 {posargs} hooks unit_tests tests + charm proof + +[testenv:venv] +commands = {posargs} + +[flake8] +ignore = E402,E226 +exclude = hooks/charmhelpers diff --git a/unit_tests/test_actions_openstack_upgrade.py b/unit_tests/test_actions_openstack_upgrade.py index 5c295b0a..43237e50 100644 --- a/unit_tests/test_actions_openstack_upgrade.py +++ b/unit_tests/test_actions_openstack_upgrade.py @@ -49,7 +49,7 @@ class TestNovaComputeUpgradeActions(CharmTestCase): @patch('charmhelpers.contrib.openstack.utils.git_install_requested') # noqa @patch('charmhelpers.contrib.openstack.utils.openstack_upgrade_available') # noqa @patch('charmhelpers.contrib.openstack.utils.juju_log') - def test_openstack_upgrade_false(self, log, upgrade_avail, git_requested, + def test_openstack_upgrade_false(self, log, upgrade_avail, git_requested, action_set, config): git_requested.return_value = False diff --git a/unit_tests/test_nova_compute_utils.py b/unit_tests/test_nova_compute_utils.py index e367df28..92dbefe6 100644 --- a/unit_tests/test_nova_compute_utils.py +++ b/unit_tests/test_nova_compute_utils.py @@ -326,7 +326,7 @@ class NovaComputeUtilsTests(CharmTestCase): call(authkey_root + '0'), call(authkey_root + '1'), call(authkey_root + '2') - ] + ] self.assertEquals(sorted(self.relation_get.call_args_list), sorted(expected_relations)) From 5b95fe369a833356a42845cc2bfcb98b5d506124 Mon Sep 17 00:00:00 2001 From: James Page Date: Fri, 30 Oct 2015 15:00:35 +0900 Subject: [PATCH 2/3] Align requirements with upstream OpenStack as part of migration --- requirements.txt | 19 +++++++++++-------- test-requirements.txt | 13 +++++++------ 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/requirements.txt b/requirements.txt index 4e02d4bb..426002dc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,11 @@ -PyYAML>=3.10 -simplejson>=3.3.1 -netifaces>=0.8 -netaddr>=0.7.10 -Jinja2>=2.7.2 -six>=1.5.2 -dnspython -psutil +# The order of packages is significant, because pip processes them in the order +# of appearance. Changing the order has an impact on the overall integration +# process, which may cause wedges in the gate later. +PyYAML>=3.1.0 +simplejson>=2.2.0 +netifaces>=0.10.4 +netaddr>=0.7.12,!=0.7.16 +Jinja2>=2.6 # BSD License (3 clause) +six>=1.9.0 +dnspython>=1.12.0 +psutil>=1.1.1,<2.0.0 diff --git a/test-requirements.txt b/test-requirements.txt index ff4fb63b..3af44d73 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,7 +1,8 @@ -testtools -coverage -mock -flake8==2.1.0 -# No version required +# The order of packages is significant, because pip processes them in the order +# of appearance. Changing the order has an impact on the overall integration +# process, which may cause wedges in the gate later. +coverage>=3.6 +mock>=1.2 +flake8>=2.2.4,<=2.4.1 +os-testr>=0.4.1 charm-tools -os-testr From f7af5a9e72d98e2925da37b40e791d0bb2098163 Mon Sep 17 00:00:00 2001 From: James Page Date: Fri, 30 Oct 2015 15:01:09 +0900 Subject: [PATCH 3/3] Drop comment --- tox.ini | 1 - 1 file changed, 1 deletion(-) diff --git a/tox.ini b/tox.ini index 6bdf5757..4e328e48 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,4 @@ [tox] -# Default to current LTS envlist = lint,py27 skipsdist = True