1 # Copyright (C) 2016 Nippon Telegraph and Telephone Corporation.
2 # Copyright (C) 2016 Fumihiko Kakuma <kakuma at valinux co jp>
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 from __future__ import absolute_import
21 from ryu.tests.integrated.common import docker_base as ctn_base
25 class BgpSpeakerBasicTest(base.BgpSpeakerTestBase):
27 super(BgpSpeakerBasicTest, self).setUp()
28 self.r1.stop_ryubgp(retry=True)
29 self.r1.start_ryubgp(retry=True)
31 def test_check_neighbor_established(self):
32 neighbor_state = ctn_base.BGP_FSM_IDLE
33 for _ in range(0, self.checktime):
34 neighbor_state = self.q1.get_neighbor_state(self.r1)
35 if neighbor_state == ctn_base.BGP_FSM_ESTABLISHED:
38 self.assertEqual(neighbor_state, ctn_base.BGP_FSM_ESTABLISHED)
40 def test_check_rib_nexthop(self):
41 neighbor_state = ctn_base.BGP_FSM_IDLE
42 for _ in range(0, self.checktime):
43 neighbor_state = self.q1.get_neighbor_state(self.r1)
44 if neighbor_state == ctn_base.BGP_FSM_ESTABLISHED:
47 self.assertEqual(neighbor_state, ctn_base.BGP_FSM_ESTABLISHED)
48 rib = self.q1.get_global_rib(prefix='10.10.0.0/28')
49 self.assertEqual(self.r1_ip, rib[0]['nexthop'])