From 82928825fd2db43a0694bf07f34fac828335a630 Mon Sep 17 00:00:00 2001 From: Frode Nordahl Date: Fri, 17 Apr 2020 14:20:42 +0200 Subject: [PATCH 1/2] Move NGW QoS test back to the NGW test class Commit 55fc718f981f22cb7a555de993960841d8d5196a moved a QoS data plane test from Neutron Gateway tests to the Neutron API tests. This was probably done because the Neutron API charm gate was doing end to end tests for all deployment topologies. On the back of splitting out the data plane tests from Neutron API gate to the respective data plane charms we need to move this test back where it belongs. Apparantly the Neutron Open vSwitch test class have its own variant of this test already that will be executed by the neutron-openvswitch charm gate. --- zaza/openstack/charm_tests/neutron/tests.py | 68 +++++++++------------ 1 file changed, 29 insertions(+), 39 deletions(-) diff --git a/zaza/openstack/charm_tests/neutron/tests.py b/zaza/openstack/charm_tests/neutron/tests.py index cfbb32b..6d3dfc7 100644 --- a/zaza/openstack/charm_tests/neutron/tests.py +++ b/zaza/openstack/charm_tests/neutron/tests.py @@ -115,6 +115,35 @@ class NeutronGatewayTest(NeutronPluginApiSharedTests): _APP_NAME = 'neutron-gateway' + def test_401_enable_qos(self): + """Check qos settings set via neutron-api charm.""" + if (self.current_os_release >= + openstack_utils.get_os_release('trusty_mitaka')): + logging.info('running qos check') + + with self.config_change( + {'enable-qos': 'False'}, + {'enable-qos': 'True'}, + application_name="neutron-api"): + + self._validate_openvswitch_agent_qos() + + @tenacity.retry(wait=tenacity.wait_exponential(min=5, max=60)) + def _validate_openvswitch_agent_qos(self): + """Validate that the qos extension is enabled in the ovs agent.""" + # obtain the dhcp agent to identify the neutron-gateway host + dhcp_agent = self.neutron_client.list_agents( + binary='neutron-dhcp-agent')['agents'][0] + neutron_gw_host = dhcp_agent['host'] + logging.debug('neutron gw host: {}'.format(neutron_gw_host)) + + # check extensions on the ovs agent to validate qos + ovs_agent = self.neutron_client.list_agents( + binary='neutron-openvswitch-agent', + host=neutron_gw_host)['agents'][0] + + self.assertIn('qos', ovs_agent['configurations']['extensions']) + @unittest.expectedFailure def test_800_ovs_bridges_are_managed_by_us(self): """Checking OVS bridges' external-id. @@ -291,29 +320,6 @@ class NeutronCreateNetworkTest(test_utils.OpenStackBaseTest): class NeutronApiTest(NeutronCreateNetworkTest): """Test basic Neutron API Charm functionality.""" - def test_401_enable_qos(self): - """Check qos settings set via neutron-api charm.""" - if (self.current_os_release >= - openstack_utils.get_os_release('trusty_mitaka')): - logging.info('running qos check') - - dhcp_agents = self.neutron_client.list_agents( - binary='neutron-dhcp-agent')['agents'] - if not dhcp_agents: - ovn_agents = self.neutron_client.list_agents( - binary='ovn-controller')['agents'] - if ovn_agents: - raise unittest.SkipTest( - "QoS tests are currently not supported on OVN " - "deployments") - - with self.config_change( - {'enable-qos': 'False'}, - {'enable-qos': 'True'}, - application_name="neutron-api"): - - self._validate_openvswitch_agent_qos() - def test_900_restart_on_config_change(self): """Checking restart happens on config change. @@ -367,22 +373,6 @@ class NeutronApiTest(NeutronCreateNetworkTest): pgrep_full=pgrep_full): logging.info("Testing pause resume") - @tenacity.retry(wait=tenacity.wait_exponential(min=5, max=60)) - def _validate_openvswitch_agent_qos(self): - """Validate that the qos extension is enabled in the ovs agent.""" - # obtain the dhcp agent to identify the neutron-gateway host - dhcp_agent = self.neutron_client.list_agents( - binary='neutron-dhcp-agent')['agents'][0] - neutron_gw_host = dhcp_agent['host'] - logging.debug('neutron gw host: {}'.format(neutron_gw_host)) - - # check extensions on the ovs agent to validate qos - ovs_agent = self.neutron_client.list_agents( - binary='neutron-openvswitch-agent', - host=neutron_gw_host)['agents'][0] - - self.assertIn('qos', ovs_agent['configurations']['extensions']) - class SecurityTest(test_utils.OpenStackBaseTest): """Neutron Security Tests.""" From e93fa0b57145b9bf459e5292562e67213569363f Mon Sep 17 00:00:00 2001 From: Frode Nordahl Date: Fri, 17 Apr 2020 15:26:41 +0200 Subject: [PATCH 2/2] neutron/policyd: Use ``create_network`` for test At present the neutron policyd test assumes a network visible to the demo user has already been created at the time of the test being executed. This may not always be the case, so let's manage the resource we use for the test. --- zaza/openstack/charm_tests/policyd/tests.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/zaza/openstack/charm_tests/policyd/tests.py b/zaza/openstack/charm_tests/policyd/tests.py index 360736d..2845781 100644 --- a/zaza/openstack/charm_tests/policyd/tests.py +++ b/zaza/openstack/charm_tests/policyd/tests.py @@ -514,7 +514,7 @@ class KeystoneTests(BasePolicydSpecialization): class NeutronApiTests(BasePolicydSpecialization): """Test the policyd override using the neutron client.""" - _rule = {'rule.yaml': "{'get_network': '!'}"} + _rule = {'rule.yaml': "{'create_network': '!'}"} @classmethod def setUpClass(cls, application_name=None): @@ -541,13 +541,16 @@ class NeutronApiTests(BasePolicydSpecialization): neutron_client = openstack_utils.get_neutron_session_client( self.get_keystone_session_demo_user(ip)) try: - # If we are allowed to list networks, this will return something. - # if the policyd override is present, then no error is generated, - # but no networks are returned. - networks = neutron_client.list_networks() - logging.debug("networks: {}".format(networks)) - if len(networks['networks']) == 0: - raise PolicydOperationFailedException() + # If we are allowed to create networks, this will return something. + # if the policyd override is present, an exception will be raised + created_network = neutron_client.create_network( + { + 'network': { + 'name': 'zaza-policyd-test', + }, + }) + logging.debug("networks: {}".format(created_network)) + neutron_client.delete_network(created_network['network']['id']) except Exception: raise PolicydOperationFailedException()