Debian Codegraph @

neutron_tempest_plugin/neutron_dynamic_routing/scenario/ipv4/test_ipv4.py

raw symbols SCIP
1 # Copyright (C) 2016 VA Linux Systems Japan K.K.
2 # Copyright (C) 2016 Fumihiko Kakuma <kakuma at valinux co jp>
3 # All Rights Reserved.
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License"); you may
6 # not use this file except in compliance with the License. You may obtain
7 # a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 # License for the specific language governing permissions and limitations
15 # under the License.
16
17 from tempest import config
18 from tempest.lib import decorators
19
20 from neutron_tempest_plugin.neutron_dynamic_routing.scenario import base
21 from neutron_tempest_plugin.neutron_dynamic_routing.scenario\
22 import base_test_proto as test_base
23
24 from os_ken.tests.integrated.common import docker_base as ctn_base
25 from os_ken.tests.integrated.common import quagga
26
27 CONF = config.CONF
28
29
30 class BgpSpeakerIpv4Test(test_base.BgpSpeakerProtoTestBase):
31
32 RAS_MAX = 3
33 ip_version = 4
34 public_gw = '192.168.11.1'
35 MyScope = base.Scope(name='my-scope')
36 PNet = base.Net(name='', net='172.24.6.0', mask=24,
37 cidr='172.24.6.0/24', router=None)
38 PPool = base.Pool(name='test-pool-ext', prefixlen=PNet.mask,
39 prefixes=[PNet.net + '/8'])
40 PSubNet = base.SubNet(name='', cidr=PNet.cidr, mask=PNet.mask)
41 TPool = base.Pool(name='tenant-test-pool', prefixlen=28,
42 prefixes=['10.10.0.0/16'])
43 L_AS = base.AS(asn='64512', router_id='192.168.0.2', adv_net='')
44 ras_l = [
45 base.AS(asn='64522', router_id='192.168.0.12',
46 adv_net='192.168.162.0/24'),
47 base.AS(asn='64523', router_id='192.168.0.13',
48 adv_net='192.168.163.0/24'),
49 base.AS(asn='64524', router_id='192.168.0.14',
50 adv_net='192.168.164.0/24')
51 ]
52
53 bgp_speaker_args = {
54 'local_as': L_AS.asn,
55 'ip_version': ip_version,
56 'name': 'my-bgp-speaker1',
57 'advertise_floating_ip_host_routes': True,
58 'advertise_tenant_networks': True
59 }
60 bgp_peer_args = [
61 {'remote_as': ras_l[0].asn,
62 'name': 'my-bgp-peer1',
63 'peer_ip': None,
64 'auth_type': 'none'},
65 {'remote_as': ras_l[1].asn,
66 'name': 'my-bgp-peer2',
67 'peer_ip': None,
68 'auth_type': 'none'},
69 {'remote_as': ras_l[2].asn,
70 'name': 'my-bgp-peer3',
71 'peer_ip': None,
72 'auth_type': 'none'}
73 ]
74
75 def setUp(self):
76 super(BgpSpeakerIpv4Test, self).setUp()
77
78 @classmethod
79 def resource_setup_container(cls):
80 cls.brdc = ctn_base.Bridge(name='br-docker-ipv4',
81 subnet='192.168.11.0/24',
82 start_ip='192.168.11.128',
83 end_ip='192.168.11.254',
84 self_ip=True,
85 fixed_ip=cls.public_gw + '/24',
86 br_type=base.BRIDGE_TYPE)
87 cls.bridges.append(cls.brdc)
88 # This is dummy container object for a dr service.
89 # This keeps data which passes to a quagga container.
90 cls.dr = ctn_base.BGPContainer(name='dr', asn=int(cls.L_AS.asn),
91 router_id=cls.L_AS.router_id)
92 cls.dr.set_addr_info(bridge='br-docker-ipv4', 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' + 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('7f2acbc2-ff88-4a63-aa02-a2f9feb3f5b0')
113 def test_check_neighbor_established(self):
114 self._test_check_neighbor_established(self.ip_version)
115
116 @decorators.idempotent_id('f32245fc-aeab-4244-acfa-3af9dd662e8d')
117 def test_check_advertised_tenant_network(self):
118 self._test_check_advertised_tenant_network(self.ip_version)
119
120 @decorators.idempotent_id('a5c238de-b750-499c-aaa2-b44a057e9ed3')
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('e4961cc1-0c47-4081-a896-caaa9342ca75')
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('91971dfb-c129-4744-9fbb-ac4f9e8d56c0')
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)