From 5b77ef8b9180e94d6c483d6ab1380f87ff974d02 Mon Sep 17 00:00:00 2001 From: Al Bailey Date: Wed, 9 Jan 2019 09:36:05 -0600 Subject: [PATCH] Enable python3 unit testing in zuul for nfv This does not ensure nfv is python3 compatable, but it does ensure that the current unit tests and code covered by those tests work in python3. The shell.py changes are due to a change in default values in argparse. The instance director change is because python3 uses a reference rather than a copy, for its dict keys. Story: 2003427 Task: 28818 Change-Id: Iaccc0ab5fc4e30b41df108f817612abad8ec612c Signed-off-by: Al Bailey --- .zuul.yaml | 12 ++++++++++++ nfv/nfv-client/nfv_client/shell.py | 3 +++ nfv/nfv-vim/nfv_vim/directors/_instance_director.py | 4 +++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/.zuul.yaml b/.zuul.yaml index 82f9e85b..783db39c 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -9,6 +9,7 @@ - openstack-tox-linters - nfv-tox-pep8 - nfv-tox-py27 + - nfv-tox-py35 - nfv-tox-pylint - nova-api-proxy-tox-pep8 - nova-api-proxy-tox-pylint @@ -21,6 +22,7 @@ - openstack-tox-linters - nfv-tox-pep8 - nfv-tox-py27 + - nfv-tox-py35 - nfv-tox-pylint - nova-api-proxy-tox-pep8 - nova-api-proxy-tox-pylint @@ -40,6 +42,16 @@ tox_envlist: py27 tox_extra_args: -c nfv/tox.ini +- job: + name: nfv-tox-py35 + parent: tox + description: Run py35 for nfv + required-projects: + - openstack/stx-fault + vars: + tox_envlist: py35 + tox_extra_args: -c nfv/tox.ini + - job: name: nfv-tox-pep8 parent: tox diff --git a/nfv/nfv-client/nfv_client/shell.py b/nfv/nfv-client/nfv_client/shell.py index a7a457d6..8553e118 100755 --- a/nfv/nfv-client/nfv_client/shell.py +++ b/nfv/nfv-client/nfv_client/shell.py @@ -28,6 +28,7 @@ def process_main(argv=sys.argv[1:]): # pylint: disable=dangerous-default-value parser.add_argument('--os-interface', default=None) commands = parser.add_subparsers(title='Commands', metavar='') + commands.required = True # Software Patch Commands sw_patch_parser = commands.add_parser('patch-strategy', @@ -36,6 +37,7 @@ def process_main(argv=sys.argv[1:]): # pylint: disable=dangerous-default-value sw_patch_cmds = sw_patch_parser.add_subparsers( title='Software Patch Commands', metavar='') + sw_patch_cmds.required = True sw_patch_create_strategy_cmd \ = sw_patch_cmds.add_parser('create', help='Create a strategy') @@ -99,6 +101,7 @@ def process_main(argv=sys.argv[1:]): # pylint: disable=dangerous-default-value sw_upgrade_cmds = sw_upgrade_parser.add_subparsers( title='Software Upgrade Commands', metavar='') + sw_upgrade_cmds.required = True sw_upgrade_create_strategy_cmd \ = sw_upgrade_cmds.add_parser('create', help='Create a strategy') diff --git a/nfv/nfv-vim/nfv_vim/directors/_instance_director.py b/nfv/nfv-vim/nfv_vim/directors/_instance_director.py index 71f2833f..b3caaa61 100755 --- a/nfv/nfv-vim/nfv_vim/directors/_instance_director.py +++ b/nfv/nfv-vim/nfv_vim/directors/_instance_director.py @@ -229,7 +229,9 @@ class InstanceDirector(object): instances_failed.append(instance) # Remove reboot counts for instances that recovered - reboot_tracking_instance_uuids = self._reboot_count.keys() + # Make a copy of the keys for this to work in python3 + # since _reboot_count is changing while iterating + reboot_tracking_instance_uuids = list(self._reboot_count.keys()) for instance_uuid in reboot_tracking_instance_uuids: if instance_uuid not in instance_tracking_uuids: