From 86b6b74158c2a59c3ec98e313cf41e9e0dcdb336 Mon Sep 17 00:00:00 2001 From: Yaroslav Lobankov Date: Wed, 14 Sep 2016 18:44:52 +0300 Subject: [PATCH] Adding a new option CONF.network.dvr_extra_resources This patch is intended to introduce a new config option. It is called 'dvr_extra_resources'. If the option is set to True, extra resources will be provisioned to bind the router to the L3 agent. Extra resources need to be provisioned in the Liberty release or older, and are not required since the Mitaka release. We will not encounter the bug 1590049 by setting the option to False. Change-Id: Ib1a6007bbd65182743e1f1ed5819134d748e8d92 --- .../network/admin/test_l3_agent_scheduler.py | 57 ++++++++++--------- tempest/config.py | 9 +++ 2 files changed, 38 insertions(+), 28 deletions(-) diff --git a/tempest/api/network/admin/test_l3_agent_scheduler.py b/tempest/api/network/admin/test_l3_agent_scheduler.py index b2cb0039df..d2e14923cc 100644 --- a/tempest/api/network/admin/test_l3_agent_scheduler.py +++ b/tempest/api/network/admin/test_l3_agent_scheduler.py @@ -67,34 +67,35 @@ class L3AgentSchedulerTestJSON(base.BaseAdminNetworkTest): msg = "L3 Agent Scheduler enabled in conf, but L3 Agent not found" raise exceptions.InvalidConfiguration(msg) cls.router = cls.create_router(data_utils.rand_name('router')) - # NOTE(armax): If DVR is an available extension, and the created router - # is indeed a distributed one, more resources need to be provisioned - # in order to bind the router to the L3 agent. - # That said, let's preserve the existing test logic, where the extra - # query and setup steps are only required if the extension is available - # and only if the router's default type is distributed. - if test.is_extension_enabled('dvr', 'network'): - cls.is_dvr_router = cls.admin_routers_client.show_router( - cls.router['id'])['router'].get('distributed', False) - if cls.is_dvr_router: - cls.network = cls.create_network() - cls.subnet = cls.create_subnet(cls.network) - cls.port = cls.create_port(cls.network) - cls.routers_client.add_router_interface( - cls.router['id'], port_id=cls.port['id']) - # NOTE: Sometimes we have seen this test fail with dvr in, - # multinode tests, since the dhcp port is not created before - # the test gets executed and so the router is not scheduled - # on the given agent. By adding the external gateway info to - # the router, the router should be properly scheduled in the - # dvr_snat node. - # This is a temporary work around to prevent a race condition. - external_gateway_info = { - 'network_id': CONF.network.public_network_id, - 'enable_snat': True} - cls.admin_routers_client.update_router( - cls.router['id'], - external_gateway_info=external_gateway_info) + + if CONF.network.dvr_extra_resources: + # NOTE(armax): If DVR is an available extension, and the created + # router is indeed a distributed one, more resources need to be + # provisioned in order to bind the router to the L3 agent in the + # Liberty release or older, and are not required since the Mitaka + # release. + if test.is_extension_enabled('dvr', 'network'): + cls.is_dvr_router = cls.admin_routers_client.show_router( + cls.router['id'])['router'].get('distributed', False) + if cls.is_dvr_router: + cls.network = cls.create_network() + cls.subnet = cls.create_subnet(cls.network) + cls.port = cls.create_port(cls.network) + cls.routers_client.add_router_interface( + cls.router['id'], port_id=cls.port['id']) + # NOTE: Sometimes we have seen this test fail with dvr in, + # multinode tests, since the dhcp port is not created + # before the test gets executed and so the router is not + # scheduled on the given agent. By adding the external + # gateway info to the router, the router should be properly + # scheduled in the dvr_snat node. This is a temporary work + # around to prevent a race condition. + external_gateway_info = { + 'network_id': CONF.network.public_network_id, + 'enable_snat': True} + cls.admin_routers_client.update_router( + cls.router['id'], + external_gateway_info=external_gateway_info) @classmethod def resource_cleanup(cls): diff --git a/tempest/config.py b/tempest/config.py index f6c89ae9da..2ce3406e69 100644 --- a/tempest/config.py +++ b/tempest/config.py @@ -546,6 +546,15 @@ NetworkGroup = [ default=["1.0.0.0/16", "2.0.0.0/16"], help="List of ip pools" " for subnetpools creation"), + # TODO(ylobankov): Delete this option once the Liberty release is EOL. + cfg.BoolOpt('dvr_extra_resources', + default=True, + help="Whether or not to create internal network, subnet, " + "port and add network interface to distributed router " + "in L3 agent scheduler test. Extra resources need to be " + "provisioned in order to bind router to L3 agent in the " + "Liberty release or older, and are not required since " + "the Mitaka release.") ] network_feature_group = cfg.OptGroup(name='network-feature-enabled',