Skip to content

Commit

Permalink
Add tests for neutron-openvswitch and neutron-gateway charms
Browse files Browse the repository at this point in the history
* 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 <przemyslaw.lal@canonical.com>
  • Loading branch information
przemeklal committed Mar 10, 2021
1 parent 0cbe7fe commit 734866b
Showing 1 changed file with 49 additions and 1 deletion.
50 changes: 49 additions & 1 deletion zaza/openstack/charm_tests/neutron/tests.py
Expand Up @@ -592,6 +592,53 @@ def test_901_pause_and_resume(self):
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 in ["neutron-gateway", "neutron-openvswitch"]:
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."""

Expand All @@ -610,7 +657,8 @@ def test_800_ovs_bridges_are_managed_by_us(self):
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),
Expand Down

0 comments on commit 734866b

Please sign in to comment.