From e3fab555ccc84f886cd8c5078fbf58bf6b47bbb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Lal?= Date: Wed, 17 Mar 2021 18:52:10 +0100 Subject: [PATCH] Add tests for neutron-openvswitch and neutron-gateway charms (#523) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add support for running NeutronOvsVsctlTest against any charm and not only charm-neutron-gateway. * Add new test case for charm-neutron-gateway and charm-neutron-openvswitch to verify correct handling of conflicting ext-port and data-port configurations. Signed-off-by: Przemysław Lal --- zaza/openstack/charm_tests/neutron/tests.py | 55 ++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/zaza/openstack/charm_tests/neutron/tests.py b/zaza/openstack/charm_tests/neutron/tests.py index bebe3b6..70def89 100644 --- a/zaza/openstack/charm_tests/neutron/tests.py +++ b/zaza/openstack/charm_tests/neutron/tests.py @@ -592,6 +592,58 @@ class NeutronOpenvSwitchTest(NeutronPluginApiSharedTests): logging.info('Testing pause resume') +class NeutronBridgePortMappingTest(NeutronPluginApiSharedTests): + """Test correct handling of network-bridge-port mapping functionality.""" + + def test_600_conflict_data_ext_ports(self): + """Verify proper handling of conflict between data-port and ext-port. + + Configuring ext-port and data-port at the same time should make the + charm to enter "blocked" state. After unsetting ext-port charm should + be active again. + """ + if self.application_name not in ["neutron-gateway", + "neutron-openvswitch"]: + logging.debug("Skipping test, charm under test is not " + "neutron-gateway or neutron-openvswitch") + return + + current_data_port = zaza.model.get_application_config( + self.application_name).get("data-port").get("value", "") + current_ext_port = zaza.model.get_application_config( + self.application_name).get("ext-port").get("value", "") + logging.debug("Current data-port: '{}'".format(current_data_port)) + logging.debug("Current data-port: '{}'".format(current_ext_port)) + + test_config = zaza.charm_lifecycle.utils.get_charm_config( + fatal=False) + current_state = test_config.get("target_deploy_status", {}) + blocked_state = copy.deepcopy(current_state) + blocked_state[self.application_name] = { + "workload-status": "blocked", + "workload-status-message": + "ext-port set when data-port set: see config.yaml"} + + logging.info("Setting conflicting ext-port and data-port options") + zaza.model.set_application_config( + self.application_name, {"data-port": "br-phynet43:eth43", + "ext-port": "br-phynet43:eth43"}) + zaza.model.wait_for_application_states(states=blocked_state) + + # unset ext-port and wait for app state to return to active + logging.info("Unsetting conflicting ext-port option") + zaza.model.set_application_config( + self.application_name, {"ext-port": ""}) + zaza.model.wait_for_application_states(states=current_state) + + # restore original config + zaza.model.set_application_config( + self.application_name, {'data-port': current_data_port, + 'ext-port': current_ext_port}) + zaza.model.wait_for_application_states(states=current_state) + logging.info('OK') + + class NeutronOvsVsctlTest(NeutronPluginApiSharedTests): """Test 'ovs-vsctl'-related functionality on Neutron charms.""" @@ -610,7 +662,8 @@ class NeutronOvsVsctlTest(NeutronPluginApiSharedTests): unit.name, bridge_name ) + ' is marked as managed by us' ) - expected_external_id = 'charm-neutron-gateway=managed' + expected_external_id = 'charm-{}=managed'.format( + self.application_name) actual_external_id = zaza.model.run_on_unit( unit.entity_id, 'ovs-vsctl br-get-external-id {}'.format(bridge_name),