Debian Codegraph @

neutron_tempest_plugin/neutron_dynamic_routing/scenario/basic/test_4byte_asn.py

raw symbols SCIP
1 # Licensed under the Apache License, Version 2.0 (the "License"); you may
2 # not use this file except in compliance with the License. You may obtain
3 # a copy of the License at
4 #
5 # http://www.apache.org/licenses/LICENSE-2.0
6 #
7 # Unless required by applicable law or agreed to in writing, software
8 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10 # License for the specific language governing permissions and limitations
11 # under the License.
12
13 from tempest.common import utils
14 from tempest import config
15 from tempest.lib import decorators
16
17 from neutron_tempest_plugin.neutron_dynamic_routing.scenario import base
18 from neutron_tempest_plugin.neutron_dynamic_routing.scenario\
19 import base_test_proto as test_base
20
21 from os_ken.tests.integrated.common import docker_base as ctn_base
22 from os_ken.tests.integrated.common import quagga
23
24 CONF = config.CONF
25
26
27 class BgpSpeaker4byteASNTest(test_base.BgpSpeakerProtoTestBase):
28
29 RAS_MAX = 3
30 ip_version = 4
31 public_gw = '192.168.10.1'
32 MyScope = base.Scope(name='my-scope')
33 PNet = base.Net(name='', net='172.24.6.0', mask=24,
34 cidr='172.24.6.0/24', router=None)
35 PPool = base.Pool(name='test-pool-ext', prefixlen=PNet.mask,
36 prefixes=[PNet.net + '/8'])
37 PSubNet = base.SubNet(name='', cidr=PNet.cidr, mask=PNet.mask)
38 TPool = base.Pool(name='tenant-test-pool', prefixlen=28,
39 prefixes=['10.10.0.0/16'])
40 L_AS = base.AS(asn='4200000000', router_id='192.168.0.3', adv_net='')
41 ras_l = [
42 base.AS(asn='4210000000', router_id='192.168.0.12',
43 adv_net='192.168.162.0/24'),
44 base.AS(asn='64522', router_id='192.168.0.13',
45 adv_net='192.168.163.0/24'),
46 base.AS(asn='4230000000', router_id='192.168.0.14',
47 adv_net='192.168.164.0/24')
48 ]
49
50 bgp_speaker_args = {
51 'local_as': L_AS.asn,
52 'ip_version': ip_version,
53 'name': 'my-bgp-speaker1',
54 'advertise_floating_ip_host_routes': True,
55 'advertise_tenant_networks': True
56 }
57 bgp_peer_args = [
58 {'remote_as': ras_l[0].asn,
59 'name': 'my-bgp-peer1',
60 'peer_ip': None,
61 'auth_type': 'none'},
62 {'remote_as': ras_l[1].asn,
63 'name': 'my-bgp-peer2',
64 'peer_ip': None,
65 'auth_type': 'none'},
66 {'remote_as': ras_l[2].asn,
67 'name': 'my-bgp-peer3',
68 'peer_ip': None,
69 'auth_type': 'none'}
70 ]
71
72 @classmethod
73 @utils.requires_ext(extension="bgp_4byte_asn", service="network")
74 def resource_setup(cls):
75 super(BgpSpeaker4byteASNTest, cls).resource_setup()
76
77 @classmethod
78 def resource_setup_container(cls):
79 cls.brdc = ctn_base.Bridge(name='br-docker-4byte-asn',
80 subnet='192.168.10.0/24',
81 start_ip='192.168.10.128',
82 end_ip='192.168.10.254',
83 self_ip=True,
84 fixed_ip=cls.public_gw + '/24',
85 br_type=base.BRIDGE_TYPE)
86 cls.bridges.append(cls.brdc)
87 # This is dummy container object for a dr service.
88 # This keeps data which passes to a quagga container.
89 cls.dr = ctn_base.BGPContainer(name='dummy-dr-4byte-asn',
90 asn=int(cls.L_AS.asn),
91 router_id=cls.L_AS.router_id)
92 cls.dr.set_addr_info(bridge='br-docker-4byte-asn', ipv4=cls.public_gw)
93 # quagga container
94 cls.dockerimg = ctn_base.DockerImage(baseimage=cls.baseimage)
95 cls.q_img = cls.dockerimg.create_quagga(check_exist=True)
96 cls.images.append(cls.q_img)
97 for i in range(cls.RAS_MAX):
98 qg = quagga.QuaggaBGPContainer(name='q-4byte-asn-' + str(i + 1),
99 asn=int(cls.ras_l[i].asn),
100 router_id=cls.ras_l[i].router_id,
101 ctn_image_name=cls.q_img)
102 cls.containers.append(qg)
103 cls.r_ass.append(qg)
104 qg.add_route(cls.ras_l[i].adv_net)
105 qg.run(wait=True)
106 cls.r_as_ip.append(cls.brdc.addif(qg))
107 qg.add_peer(cls.dr, bridge=cls.brdc.name,
108 peer_info={'passive': True})
109 cls.tnet_gen = cls.get_subnet(start='10.10.1.0', end='10.10.255.0',
110 step=256)
111
112 @decorators.idempotent_id('9f18c931-a59e-4a27-939b-21124995ffe2')
113 def test_check_neighbor_established(self):
114 self._test_check_neighbor_established(self.ip_version)
115
116 @decorators.idempotent_id('73466aa5-7d1d-4f9f-8fb4-4100fad2dffe')
117 def test_check_advertised_tenant_network(self):
118 self._test_check_advertised_tenant_network(self.ip_version)
119
120 @decorators.idempotent_id('c3158328-2f69-4aa2-b1b7-5a06ab58afaf')
121 def test_check_advertised_multiple_tenant_network(self):
122 self._test_check_advertised_multiple_tenant_network(self.ip_version)
123
124 @decorators.idempotent_id('212a3d82-ac50-43dc-b657-030b1133643e')
125 def test_check_neighbor_established_with_multiple_peers(self):
126 self._test_check_neighbor_established_with_multiple_peers(
127 self.ip_version)
128
129 @decorators.idempotent_id('c72411c8-ea79-495d-bdbd-a10159642676')
130 def test_check_advertised_tenant_network_with_multiple_peers(self):
131 self._test_check_advertised_tenant_network_with_multiple_peers(
132 self.ip_version)