Skip to content

Commit

Permalink
Merge pull request openstack-charmers#235 from openstack-charmers/mov…
Browse files Browse the repository at this point in the history
…e-qos-test-back

Move NGW QoS test back to the NGW test class
  • Loading branch information
dshcherb authored Apr 24, 2020
2 parents 53bd932 + e93fa0b commit ab4d47d
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 47 deletions.
68 changes: 29 additions & 39 deletions zaza/openstack/charm_tests/neutron/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,35 @@ def setUpClass(cls):

_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.
Expand Down Expand Up @@ -291,29 +320,6 @@ def test_400_create_network(self):
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.
Expand Down Expand Up @@ -367,22 +373,6 @@ def test_901_pause_resume(self):
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."""
Expand Down
19 changes: 11 additions & 8 deletions zaza/openstack/charm_tests/policyd/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ def get_client_and_attempt_operation(self, ip):
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):
Expand All @@ -541,13 +541,16 @@ def get_client_and_attempt_operation(self, ip):
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()

Expand Down

0 comments on commit ab4d47d

Please sign in to comment.