blob: 46c2c785fbd5e31fe07b4454d36d02d9eb0314ab [file] [log] [blame]
Slawek Kaplonski8dd49aa2019-04-16 14:47:07 +02001# Copyright (c) 2015 Ericsson.
2# All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
15
16import tempest.api.network.base as test
17from tempest.common import utils
18from tempest import config
19from tempest.lib.common.utils import data_utils
Vasyl Saienko4e3ff4f2021-02-26 23:54:47 +020020from tempest.lib.common.utils import test_utils
Slawek Kaplonski8dd49aa2019-04-16 14:47:07 +020021
22from neutron_tempest_plugin.bgpvpn.services import bgpvpn_client
23
24CONF = config.CONF
25
26
27class BaseBgpvpnTest(test.BaseNetworkTest):
28 """Base class for the Bgpvpn tests that use the Tempest Neutron REST client
29
30 """
31
32 credentials = ['primary', 'admin', 'alt']
33 bgpvpn_client = None
34 bgpvpn_admin_client = None
35 bgpvpn_alt_client = None
36
37 @classmethod
Slawek Kaplonski8dd49aa2019-04-16 14:47:07 +020038 def resource_setup(cls):
39 cls.route_distinguishers = []
40 cls.bgpvpns = []
41 cls.bgpvpn_client = bgpvpn_client.BgpvpnClient(
42 cls.os_primary.auth_provider,
43 CONF.network.catalog_type,
44 CONF.network.region or CONF.identity.region,
45 endpoint_type=CONF.network.endpoint_type,
46 build_interval=CONF.network.build_interval,
47 build_timeout=CONF.network.build_timeout,
48 **cls.os_primary.default_params)
49 cls.bgpvpn_admin_client = bgpvpn_client.BgpvpnClient(
50 cls.os_admin.auth_provider,
51 CONF.network.catalog_type,
52 CONF.network.region or CONF.identity.region,
53 endpoint_type=CONF.network.endpoint_type,
54 build_interval=CONF.network.build_interval,
55 build_timeout=CONF.network.build_timeout,
56 **cls.os_admin.default_params)
57 cls.bgpvpn_alt_client = bgpvpn_client.BgpvpnClient(
58 cls.os_alt.auth_provider,
59 CONF.network.catalog_type,
60 CONF.network.region or CONF.identity.region,
61 endpoint_type=CONF.network.endpoint_type,
62 build_interval=CONF.network.build_interval,
63 build_timeout=CONF.network.build_timeout,
64 **cls.os_alt.default_params)
65 super(BaseBgpvpnTest, cls).resource_setup()
66
67 @classmethod
68 def skip_checks(cls):
69 super(BaseBgpvpnTest, cls).skip_checks()
Slawek Kaplonskia7bb1612019-07-17 15:34:46 +020070 msg = None
Slawek Kaplonski8dd49aa2019-04-16 14:47:07 +020071 if not utils.is_extension_enabled('bgpvpn', 'network'):
72 msg = "Bgpvpn extension not enabled."
Slawek Kaplonskia7bb1612019-07-17 15:34:46 +020073 elif not CONF.bgpvpn.run_bgpvpn_tests:
74 msg = ("Running of bgpvpn related tests is disabled in "
75 "plugin configuration.")
76 if msg:
Slawek Kaplonski8dd49aa2019-04-16 14:47:07 +020077 raise cls.skipException(msg)
78
79 def create_bgpvpn(self, client, **kwargs):
80 if 'name' not in kwargs:
81 kwargs['name'] = data_utils.rand_name('test-bgpvpn-')
82
83 body = client.create_bgpvpn(**kwargs)
84 bgpvpn = body['bgpvpn']
Vasyl Saienko4e3ff4f2021-02-26 23:54:47 +020085 self.addCleanup(test_utils.call_and_ignore_notfound_exc,
86 self.bgpvpn_admin_client.delete_bgpvpn, bgpvpn['id'])
Slawek Kaplonski8dd49aa2019-04-16 14:47:07 +020087 return bgpvpn
88
89 def delete_bgpvpn(self, client, bgpvpn):
90 client.delete_bgpvpn(bgpvpn['id'])