diff --git a/neutron/tests/contrib/gate_hook.sh b/neutron/tests/contrib/gate_hook.sh index 6c97703b420..dd850f72763 100644 --- a/neutron/tests/contrib/gate_hook.sh +++ b/neutron/tests/contrib/gate_hook.sh @@ -101,6 +101,7 @@ case $VENV in load_rc_hook trunk load_conf_hook vlan_provider load_conf_hook osprofiler + load_conf_hook availability_zone if [[ "$VENV" =~ "dsvm-scenario" ]]; then load_rc_hook ubuntu_image fi diff --git a/neutron/tests/contrib/hooks/availability_zone b/neutron/tests/contrib/hooks/availability_zone new file mode 100644 index 00000000000..7c2ca0d19e9 --- /dev/null +++ b/neutron/tests/contrib/hooks/availability_zone @@ -0,0 +1,14 @@ +[[test-config|$TEMPEST_CONFIG]] + +[neutron_plugin_options] +agent_availability_zone = nova + +[[post-config|/$NEUTRON_L3_CONF]] + +[agent] +availability_zone = nova + +[[post-config|/$NEUTRON_DHCP_CONF]] + +[agent] +availability_zone = nova diff --git a/neutron/tests/tempest/api/admin/test_agent_availability_zone.py b/neutron/tests/tempest/api/admin/test_agent_availability_zone.py new file mode 100644 index 00000000000..9f9f7fbb214 --- /dev/null +++ b/neutron/tests/tempest/api/admin/test_agent_availability_zone.py @@ -0,0 +1,53 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +from neutron_lib import constants +from tempest.lib import decorators +import testtools + +from neutron.tests.tempest.api import base +from neutron.tests.tempest import config + +AZ_SUPPORTED_AGENTS = [constants.AGENT_TYPE_DHCP, constants.AGENT_TYPE_L3] +CONF = config.CONF + + +class AgentAvailabilityZoneTestCase(base.BaseAdminNetworkTest): + + required_extensions = ['agent', 'availability_zone'] + + @classmethod + def resource_setup(cls): + super(AgentAvailabilityZoneTestCase, cls).resource_setup() + body = cls.admin_client.list_agents() + agents = body['agents'] + agents_type = [agent.get('agent_type') for agent in agents] + for az_agent in AZ_SUPPORTED_AGENTS: + if az_agent in agents_type: + return + msg = 'availability_zone supported agent not found.' + raise cls.skipException(msg) + + @decorators.idempotent_id('3ffa661e-cfcc-417d-8b63-1c5ec4a22e54') + @testtools.skipUnless(CONF.neutron_plugin_options.agent_availability_zone, + "Need a single availability_zone assumption.") + def test_agents_availability_zone(self): + """ + Test list agents availability_zone, only L3 and DHCP agent support + availability_zone, default availability_zone is "nova". + """ + body = self.admin_client.list_agents() + agents = body['agents'] + for agent in agents: + if agent.get('agent_type') in AZ_SUPPORTED_AGENTS: + self.assertEqual( + CONF.neutron_plugin_options.agent_availability_zone, + agent.get('availability_zone')) diff --git a/neutron/tests/tempest/config.py b/neutron/tests/tempest/config.py index 6830b184f19..804fece5357 100644 --- a/neutron/tests/tempest/config.py +++ b/neutron/tests/tempest/config.py @@ -34,6 +34,10 @@ NeutronPluginOptions = [ default=False, help='Image that supports features that cirros does not, like' ' Ubuntu or CentOS supporting advanced features'), + cfg.StrOpt('agent_availability_zone', + help='The availability zone for all agents in the deployment. ' + 'Configure this only when the single value is used by ' + 'all agents in the deployment.'), ] # TODO(amuller): Redo configuration options registration as part of the planned