From 8e8544bab7cea7c401a6144071bb94cd13c46f4d Mon Sep 17 00:00:00 2001 From: Frode Nordahl Date: Sat, 2 Nov 2019 10:31:30 +0100 Subject: [PATCH] Fix ovn_present for ovn-dedicated-chassis Add missing unit test. --- .../utilities/test_zaza_utilities_openstack.py | 8 +++++++- zaza/openstack/utilities/openstack.py | 15 +++++++-------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/unit_tests/utilities/test_zaza_utilities_openstack.py b/unit_tests/utilities/test_zaza_utilities_openstack.py index 6e00ff0..4576564 100644 --- a/unit_tests/utilities/test_zaza_utilities_openstack.py +++ b/unit_tests/utilities/test_zaza_utilities_openstack.py @@ -1202,4 +1202,10 @@ class TestOpenStackUtils(ut_utils.BaseTestCase): 'neutron-api', 'enable-dvr') def test_ovn_present(self): - pass + self.patch_object(openstack_utils.model, 'get_application') + self.get_application.side_effect = [None, KeyError] + self.assertTrue(openstack_utils.ovn_present()) + self.get_application.side_effect = [KeyError, None] + self.assertTrue(openstack_utils.ovn_present()) + self.get_application.side_effect = [KeyError, KeyError] + self.assertFalse(openstack_utils.ovn_present()) diff --git a/zaza/openstack/utilities/openstack.py b/zaza/openstack/utilities/openstack.py index 22a2f27..959cb09 100644 --- a/zaza/openstack/utilities/openstack.py +++ b/zaza/openstack/utilities/openstack.py @@ -477,15 +477,14 @@ def ovn_present(): :returns: True when OVN is present, False otherwise :rtype: bool """ - try: - for name in ('ovn-chassis', 'ovn-dedicated-chassis'): + app_presence = [] + for name in ('ovn-chassis', 'ovn-dedicated-chassis'): + try: model.get_application(name) - return True - except KeyError: - return False - else: - raise RuntimeError('Unable to determine whether or not OVN is present ' - 'in deployment') + app_presence.append(True) + except KeyError: + app_presence.append(False) + return any(app_presence) BRIDGE_MAPPINGS = 'bridge-mappings'