diff options
Diffstat (limited to 'test/scenario_test/route_server_test.py')
-rw-r--r-- | test/scenario_test/route_server_test.py | 45 |
1 files changed, 27 insertions, 18 deletions
diff --git a/test/scenario_test/route_server_test.py b/test/scenario_test/route_server_test.py index 5949f615..e83812a1 100644 --- a/test/scenario_test/route_server_test.py +++ b/test/scenario_test/route_server_test.py @@ -13,17 +13,25 @@ # See the License for the specific language governing permissions and # limitations under the License. -import unittest -from fabric.api import local -from lib import base -from lib.gobgp import * -from lib.quagga import * +from __future__ import absolute_import + import sys -import os import time +import unittest + +from fabric.api import local import nose + from noseplugin import OptionParser, parser_option +from lib import base +from lib.base import ( + BGP_FSM_ACTIVE, + BGP_FSM_ESTABLISHED, +) +from lib.gobgp import GoBGPContainer +from lib.quagga import QuaggaBGPContainer + class GoBGPTestBase(unittest.TestCase): @@ -39,9 +47,10 @@ class GoBGPTestBase(unittest.TestCase): ctn_image_name=gobgp_ctn_image_name, log_level=parser_option.gobgp_log_level) - rs_clients = [QuaggaBGPContainer(name='q{0}'.format(i+1), asn=65001+i, - router_id='192.168.0.{0}'.format(i+2)) - for i in range(3)] + rs_clients = [ + QuaggaBGPContainer(name='q{0}'.format(i + 1), asn=(65001 + i), + router_id='192.168.0.{0}'.format(i + 2)) + for i in range(3)] ctns = [g1] + rs_clients q1 = rs_clients[0] q2 = rs_clients[1] @@ -50,7 +59,7 @@ class GoBGPTestBase(unittest.TestCase): # advertise a route from route-server-clients routes = [] for idx, rs_client in enumerate(rs_clients): - route = '10.0.{0}.0/24'.format(idx+1) + route = '10.0.{0}.0/24'.format(idx + 1) rs_client.add_route(route) routes.append(route) @@ -76,11 +85,11 @@ class GoBGPTestBase(unittest.TestCase): state = self.gobgp.get_neighbor_state(rs_client) self.assertEqual(state, BGP_FSM_ESTABLISHED) - if len(local_rib) < len(self.quaggas)-1: + if len(local_rib) < (len(self.quaggas) - 1): time.sleep(self.wait_per_retry) continue - self.assertTrue(len(local_rib) == (len(self.quaggas)-1)) + self.assertTrue(len(local_rib) == (len(self.quaggas) - 1)) for c in self.quaggas.itervalues(): if rs_client != c: @@ -91,7 +100,7 @@ class GoBGPTestBase(unittest.TestCase): if done: continue # should not reach here - self.assertTrue(False) + raise AssertionError def check_rs_client_rib(self): for rs_client in self.quaggas.itervalues(): @@ -115,7 +124,7 @@ class GoBGPTestBase(unittest.TestCase): if done: continue # should not reach here - self.assertTrue(False) + raise AssertionError # test each neighbor state is turned establish def test_01_neighbor_established(self): @@ -208,9 +217,9 @@ class GoBGPTestBase(unittest.TestCase): self.gobgp.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=q3) def check_nexthop(target_prefix, expected_nexthop): - done = False + is_done = False for _ in range(self.retry_limit): - if done: + if is_done: break time.sleep(self.wait_per_retry) for path in q1.get_global_rib(): @@ -220,9 +229,9 @@ class GoBGPTestBase(unittest.TestCase): n_addrs = [i[1].split('/')[0] for i in expected_nexthop.ip_addrs] if path['nexthop'] in n_addrs: - done = True + is_done = True break - return done + return is_done done = check_nexthop('10.0.6.0/24', q3) self.assertTrue(done) |