Debian Codegraph @

neutron_tempest_plugin/neutron_dynamic_routing/scenario/basic/test_basic.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 os_ken.tests.integrated.common import docker_base as ctn_base
18 from tempest import config
19 from tempest.lib import decorators
20
21 from neutron_tempest_plugin.neutron_dynamic_routing.scenario\
22 import base as s_base
23 from neutron_tempest_plugin.neutron_dynamic_routing.scenario.basic import base
24
25 CONF = config.CONF
26
27
28 class BgpSpeakerBasicTest(base.BgpSpeakerBasicTestJSONBase):
29
30 @decorators.idempotent_id('cc615252-c6cb-4d75-a70e-608fb2c3736a')
31 def test_schedule_added_speaker(self):
32 self.bgp_peer_args[0]['peer_ip'] = self.r_as_ip[0].split('/')[0]
33 num, subnet = next(self.tnet_gen)
34 mask = '/' + str(self.TPool.prefixlen)
35 TNet = s_base.Net(name='', net=subnet, mask=self.TPool.prefixlen,
36 cidr=subnet + mask, router=None)
37 TSubNet = s_base.SubNet(name='', cidr=TNet.cidr, mask=TNet.mask)
38 MyRouter = s_base.Router(name='my-router' + str(num), gw='')
39 ext_net_id = self.create_bgp_network(
40 4, self.MyScope,
41 self.PNet, self.PPool, self.PSubNet,
42 self.TPool, [[TNet, TSubNet, MyRouter]])
43 speaker_id, peers_ids = self.create_and_add_peers_to_speaker(
44 ext_net_id,
45 self.bgp_speaker_args,
46 [self.bgp_peer_args[0]])
47 self.check_remote_as_state(self.dr, self.r_ass[0],
48 ctn_base.BGP_FSM_ESTABLISHED)
49
50 @decorators.idempotent_id('ce98c33c-0ffa-49ae-b365-da836406793b')
51 def test_unschedule_deleted_speaker(self):
52 self.bgp_peer_args[0]['peer_ip'] = self.r_as_ip[0].split('/')[0]
53 num, subnet = next(self.tnet_gen)
54 mask = '/' + str(self.TPool.prefixlen)
55 TNet = s_base.Net(name='', net=subnet, mask=self.TPool.prefixlen,
56 cidr=subnet + mask, router=None)
57 TSubNet = s_base.SubNet(name='', cidr=TNet.cidr, mask=TNet.mask)
58 MyRouter = s_base.Router(name='my-router' + str(num), gw='')
59 ext_net_id = self.create_bgp_network(
60 4, self.MyScope,
61 self.PNet, self.PPool, self.PSubNet,
62 self.TPool, [[TNet, TSubNet, MyRouter]])
63 speaker_id, peers_ids = self.create_and_add_peers_to_speaker(
64 ext_net_id,
65 self.bgp_speaker_args,
66 [self.bgp_peer_args[0]],
67 auto_delete=False)
68 self.check_remote_as_state(self.dr, self.r_ass[0],
69 ctn_base.BGP_FSM_ESTABLISHED)
70 self.delete_bgp_speaker(speaker_id)
71 self.delete_bgp_peer(peers_ids[0])
72 self.check_remote_as_state(self.dr, self.r_ass[0],
73 ctn_base.BGP_FSM_ACTIVE,
74 init_state=ctn_base.BGP_FSM_ESTABLISHED)
75
76 @decorators.idempotent_id('aa6c565c-ded3-413b-8dc9-3928b3b0e38f')
77 def test_remove_add_speaker_agent(self):
78 self.bgp_peer_args[0]['peer_ip'] = self.r_as_ip[0].split('/')[0]
79 num, subnet = next(self.tnet_gen)
80 mask = '/' + str(self.TPool.prefixlen)
81 TNet = s_base.Net(name='', net=subnet, mask=self.TPool.prefixlen,
82 cidr=subnet + mask, router=None)
83 TSubNet = s_base.SubNet(name='', cidr=TNet.cidr, mask=TNet.mask)
84 MyRouter = s_base.Router(name='my-router' + str(num), gw='')
85 ext_net_id = self.create_bgp_network(
86 4, self.MyScope,
87 self.PNet, self.PPool, self.PSubNet,
88 self.TPool, [[TNet, TSubNet, MyRouter]])
89 speaker_id, peers_ids = self.create_and_add_peers_to_speaker(
90 ext_net_id,
91 self.bgp_speaker_args,
92 [self.bgp_peer_args[0]])
93 self.check_remote_as_state(self.dr, self.r_ass[0],
94 ctn_base.BGP_FSM_ESTABLISHED)
95 agent_list = self.bgp_client.list_dragents_for_bgp_speaker(
96 speaker_id)['agents']
97 self.assertEqual(1, len(agent_list))
98 agent_id = agent_list[0]['id']
99 self.bgp_client.remove_bgp_speaker_from_dragent(agent_id, speaker_id)
100 # NOTE(tidwellr) This assertion can fail due to the fact that BGP
101 # speakers are auto-scheduled. The BGP process can quickly return to
102 # ACTIVE status before this gets asserted. Let's see how it goes with
103 # this commented out.
104 # self.check_remote_as_state(self.dr, self.r_ass[0],
105 # ctn_base.BGP_FSM_ACTIVE,
106 # init_state=ctn_base.BGP_FSM_ESTABLISHED)
107
108 # Ignore errors re-associating the BGP speaker, auto-scheduling may
109 # have already added it to an agent. The next assertion is what
110 # matters.
111 self.bgp_client.add_bgp_speaker_to_dragent(agent_id, speaker_id,
112 ignore_errors=True)
113 self.check_remote_as_state(self.dr, self.r_ass[0],
114 ctn_base.BGP_FSM_ESTABLISHED)