backing up
[vsorcdistro/.git] / ryu / build / lib.linux-armv7l-2.7 / ryu / tests / integrated / bgp / test_basic.py
1 # Copyright (C) 2016 Nippon Telegraph and Telephone Corporation.
2 # Copyright (C) 2016 Fumihiko Kakuma <kakuma at valinux co jp>
3 #
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
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,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13 # implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 from __future__ import absolute_import
18
19 import time
20
21 from ryu.tests.integrated.common import docker_base as ctn_base
22 from . import base
23
24
25 class BgpSpeakerBasicTest(base.BgpSpeakerTestBase):
26     def setUp(self):
27         super(BgpSpeakerBasicTest, self).setUp()
28         self.r1.stop_ryubgp(retry=True)
29         self.r1.start_ryubgp(retry=True)
30
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:
36                 break
37             time.sleep(1)
38         self.assertEqual(neighbor_state, ctn_base.BGP_FSM_ESTABLISHED)
39
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:
45                 break
46             time.sleep(1)
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'])