Merge pull request #235 from openstack-charmers/move-qos-test-back

Move NGW QoS test back to the NGW test class
This commit is contained in:
Dmitrii Shcherbakov
2020-04-24 10:29:04 +03:00
committed by GitHub
2 changed files with 40 additions and 47 deletions

View File

@@ -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."""

View File

@@ -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()