summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2018-04-10 22:24:41 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2018-05-07 21:18:04 +0900
commit2dbca9e29a6813f2df53261ffaa59b9439c13fdd (patch)
tree8303b71da5741ffb592bc74738b6548d078a0253 /test
parent756cc9162afb675dd7ca159b6f07a6d5b927bcc1 (diff)
use sorted single master table for route server setup
https://github.com/osrg/gobgp/issues/1249 The IN policy was removed. The modification by the IMPORT policy are visible to all route server peers. This saves some dozens bytes memory per a path. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'test')
-rw-r--r--test/scenario_test/route_server_ipv4_v6_test.py4
-rw-r--r--test/scenario_test/route_server_policy_grpc_test.py245
-rw-r--r--test/scenario_test/route_server_policy_test.py293
-rw-r--r--test/scenario_test/route_server_softreset_test.py2
4 files changed, 2 insertions, 542 deletions
diff --git a/test/scenario_test/route_server_ipv4_v6_test.py b/test/scenario_test/route_server_ipv4_v6_test.py
index 07f77e4a..ce17e18c 100644
--- a/test/scenario_test/route_server_ipv4_v6_test.py
+++ b/test/scenario_test/route_server_ipv4_v6_test.py
@@ -143,7 +143,7 @@ class GoBGPIPv6Test(unittest.TestCase):
def test_04_add_in_policy_to_reject_all(self):
for q in self.gobgp.peers.itervalues():
- self.gobgp.local('gobgp neighbor {0} policy in set default reject'.format(q['neigh_addr'].split('/')[0]))
+ self.gobgp.local('gobgp neighbor {0} policy import set default reject'.format(q['neigh_addr'].split('/')[0]))
def test_05_check_ipv4_peer_rib(self):
self.check_gobgp_local_rib(self.ipv4s, 'ipv4')
@@ -159,12 +159,10 @@ class GoBGPIPv6Test(unittest.TestCase):
def test_08_check_rib(self):
for q in self.ipv4s.itervalues():
- self.assertTrue(all(p['filtered'] for p in self.gobgp.get_adj_rib_in(q)))
self.assertTrue(len(self.gobgp.get_adj_rib_out(q)) == 0)
self.assertTrue(len(q.get_global_rib()) == len(q.routes))
for q in self.ipv6s.itervalues():
- self.assertTrue(all(p['filtered'] for p in self.gobgp.get_adj_rib_in(q, rf='ipv6')))
self.assertTrue(len(self.gobgp.get_adj_rib_out(q, rf='ipv6')) == 0)
self.assertTrue(len(q.get_global_rib(rf='ipv6')) == len(q.routes))
diff --git a/test/scenario_test/route_server_policy_grpc_test.py b/test/scenario_test/route_server_policy_grpc_test.py
index 41114d11..63ec6558 100644
--- a/test/scenario_test/route_server_policy_grpc_test.py
+++ b/test/scenario_test/route_server_policy_grpc_test.py
@@ -2120,205 +2120,6 @@ class ExportPolicyMedSub(object):
@register_scenario
-class InPolicyReject(object):
- """
- No.31 in-policy reject test
- ----------------
- e1 ->r1(community=65100:10) -> x | -> q1-rib -> | -> r2 --> q1
- r2(192.168.10.0/24) -> o | |
- | -> q2-rib -> | -> r2 --> q2
- ----------------
- """
- @staticmethod
- def boot(env):
- lookup_scenario('ImportPolicy').boot(env)
-
- @staticmethod
- def setup(env):
- g1 = env.g1
- e1 = env.e1
- q1 = env.q1
- q2 = env.q2
-
- g1.local('gobgp policy community add cs0 65100:10')
- g1.local('gobgp policy statement st0 add condition community cs0')
- g1.local('gobgp policy statement st0 add action reject')
- g1.local('gobgp policy add policy0 st0')
- g1.local('gobgp neighbor {0} policy in add policy0'.format(g1.peers[e1]['neigh_addr'].split('/')[0]))
-
- e1.add_route('192.168.100.0/24', community=['65100:10'])
- e1.add_route('192.168.10.0/24')
-
- for c in [e1, q1, q2]:
- g1.wait_for(BGP_FSM_ESTABLISHED, c)
-
- @staticmethod
- def check(env):
- g1 = env.g1
- e1 = env.e1
- q1 = env.q1
- q2 = env.q2
- wait_for(lambda: len(g1.get_adj_rib_in(e1)) == 2)
- wait_for(lambda: len(g1.get_local_rib(q1)) == 1)
- wait_for(lambda: len(g1.get_adj_rib_out(q1)) == 1)
- wait_for(lambda: len(q1.get_global_rib()) == 1)
- wait_for(lambda: len(g1.get_local_rib(q2)) == 1)
- wait_for(lambda: len(g1.get_adj_rib_out(q2)) == 1)
- wait_for(lambda: len(q2.get_global_rib()) == 1)
-
- @staticmethod
- def executor(env):
- lookup_scenario("InPolicyReject").boot(env)
- lookup_scenario("InPolicyReject").setup(env)
- lookup_scenario("InPolicyReject").check(env)
-
-
-@register_scenario
-class InPolicyAccept(object):
- """
- No.32 in-policy accept test
- ----------------
- e1 ->r1(community=65100:10) -> x | -> q1-rib -> | -> r2 --> q1
- r2(192.168.10.0/24) -> o | |
- | -> q2-rib -> | -> r2 --> q2
- ----------------
- """
- @staticmethod
- def boot(env):
- lookup_scenario('ImportPolicy').boot(env)
-
- @staticmethod
- def setup(env):
- g1 = env.g1
- e1 = env.e1
- q1 = env.q1
- q2 = env.q2
-
- g1.local('gobgp policy community add cs0 65100:10')
- g1.local('gobgp policy statement st0 add condition community cs0')
- g1.local('gobgp policy statement st0 add action accept')
- g1.local('gobgp policy add policy0 st0')
- g1.local('gobgp neighbor {0} policy in add policy0 default reject'.format(g1.peers[e1]['neigh_addr'].split('/')[0]))
-
- e1.add_route('192.168.100.0/24', community=['65100:10'])
- e1.add_route('192.168.10.0/24')
-
- for c in [e1, q1, q2]:
- g1.wait_for(BGP_FSM_ESTABLISHED, c)
-
- @staticmethod
- def check(env):
- lookup_scenario('InPolicyReject').check(env)
-
- @staticmethod
- def executor(env):
- lookup_scenario("InPolicyAccept").boot(env)
- lookup_scenario("InPolicyAccept").setup(env)
- lookup_scenario("InPolicyAccept").check(env)
-
-
-@register_scenario
-class InPolicyUpdate(object):
- """
- No.35 in-policy update test
- r1:192.168.2.0
- r2:192.168.20.0
- r3:192.168.200.0
- -------------------------------------
- | q1 |
- e1 ->(r1,r2,r3)-> | ->(r1)-> rib ->(r1)-> adj-rib-out | ->(r1)-> q1
- | |
- | q2 |
- | ->(r1)-> rib ->(r1)-> adj-rib-out | ->(r1)-> q2
- -------------------------------------
- |
- update distribute policy
- |
- V
- -------------------------------------------
- | q1 |
- e1 ->(r1,r2,r3)-> | ->(r1,r2)-> rib ->(r1,r2)-> adj-rib-out | ->(r1,r2)-> q1
- | |
- | q2 |
- | ->(r1,r3)-> rib ->(r1,r3)-> adj-rib-out | ->(r1,r3)-> q2
- -------------------------------------------
- """
- @staticmethod
- def boot(env):
- lookup_scenario('ImportPolicy').boot(env)
-
- @staticmethod
- def setup(env):
- g1 = env.g1
- e1 = env.e1
- q1 = env.q1
- q2 = env.q2
-
- g1.local('gobgp policy prefix add ps0 192.168.20.0/24')
- g1.local('gobgp policy prefix add ps0 192.168.200.0/24')
- g1.local('gobgp policy neighbor add ns0 {0}'.format(g1.peers[e1]['neigh_addr'].split('/')[0]))
- g1.local('gobgp policy statement st0 add condition prefix ps0')
- g1.local('gobgp policy statement st0 add condition neighbor ns0')
- g1.local('gobgp policy statement st0 add action reject')
- g1.local('gobgp policy add policy0 st0')
- g1.local('gobgp neighbor {0} policy in add policy0'.format(g1.peers[e1]['neigh_addr'].split('/')[0]))
-
- e1.add_route('192.168.2.0/24')
- e1.add_route('192.168.20.0/24')
- e1.add_route('192.168.200.0/24')
-
- for c in [e1, q1, q2]:
- g1.wait_for(BGP_FSM_ESTABLISHED, c)
-
- @staticmethod
- def check(env):
- g1 = env.g1
- e1 = env.e1
- q1 = env.q1
- q2 = env.q2
- wait_for(lambda: len(g1.get_adj_rib_in(e1)) == 3)
- wait_for(lambda: len(g1.get_local_rib(q1)) == 1)
- wait_for(lambda: len(g1.get_adj_rib_out(q1)) == 1)
- wait_for(lambda: len(q1.get_global_rib()) == 1)
- wait_for(lambda: len(g1.get_local_rib(q2)) == 1)
- wait_for(lambda: len(g1.get_adj_rib_out(q2)) == 1)
- wait_for(lambda: len(q2.get_global_rib()) == 1)
-
- @staticmethod
- def setup2(env):
- g1 = env.g1
- e1 = env.e1
- # q1 = env.q1
- # q2 = env.q2
- g1.clear_policy()
-
- g1.local('gobgp policy prefix del ps0 192.168.200.0/24')
- g1.softreset(e1)
-
- @staticmethod
- def check2(env):
- g1 = env.g1
- e1 = env.e1
- q1 = env.q1
- q2 = env.q2
- wait_for(lambda: len(g1.get_adj_rib_in(e1)) == 3)
- wait_for(lambda: len(g1.get_local_rib(q1)) == 2)
- wait_for(lambda: len(g1.get_adj_rib_out(q1)) == 2)
- wait_for(lambda: len(q1.get_global_rib()) == 2)
- wait_for(lambda: len(g1.get_local_rib(q2)) == 2)
- wait_for(lambda: len(g1.get_adj_rib_out(q2)) == 2)
- wait_for(lambda: len(q2.get_global_rib()) == 2)
-
- @staticmethod
- def executor(env):
- lookup_scenario("InPolicyUpdate").boot(env)
- lookup_scenario("InPolicyUpdate").setup(env)
- lookup_scenario("InPolicyUpdate").check(env)
- lookup_scenario("InPolicyUpdate").setup2(env)
- lookup_scenario("InPolicyUpdate").check2(env)
-
-
-@register_scenario
class ExportPolicyAsPathPrepend(object):
"""
No.37 aspath prepend action export
@@ -2623,52 +2424,6 @@ class ImportPolicyExCommunityTargetCondition(object):
lookup_scenario("ImportPolicyExCommunityTargetCondition").check(env)
-@register_scenario
-class InPolicyPrefixCondition(object):
- """
- No.42 prefix only condition accept in
- -----------------
- e1 ->r1(192.168.100.0/24) -> o | -> q1-rib -> | -> r2 --> q1
- r2(192.168.10.0/24) -> x | |
- | -> q2-rib -> | -> r2 --> q2
- -----------------
- """
- @staticmethod
- def boot(env):
- lookup_scenario('ImportPolicy').boot(env)
-
- @staticmethod
- def setup(env):
- g1 = env.g1
- e1 = env.e1
- q1 = env.q1
- q2 = env.q2
-
- g1.local('gobgp policy prefix add ps0 192.168.10.0/24')
- g1.local('gobgp policy statement st0 add condition prefix ps0')
- g1.local('gobgp policy statement st0 add action reject')
- g1.local('gobgp policy add policy0 st0')
- g1.local('gobgp neighbor {0} policy in add policy0'.format(g1.peers[e1]['neigh_addr'].split('/')[0]))
-
- # this will be blocked
- e1.add_route('192.168.100.0/24')
- # this will pass
- e1.add_route('192.168.10.0/24')
-
- for c in [e1, q1, q2]:
- g1.wait_for(BGP_FSM_ESTABLISHED, c)
-
- @staticmethod
- def check(env):
- lookup_scenario('InPolicyReject').check(env)
-
- @staticmethod
- def executor(env):
- lookup_scenario("InPolicyPrefixCondition").boot(env)
- lookup_scenario("InPolicyPrefixCondition").setup(env)
- lookup_scenario("InPolicyPrefixCondition").check(env)
-
-
def ext_community_exists(path, extcomm):
typ = extcomm.split(':')[0]
value = ':'.join(extcomm.split(':')[1:])
diff --git a/test/scenario_test/route_server_policy_test.py b/test/scenario_test/route_server_policy_test.py
index bc3637aa..3c6297d4 100644
--- a/test/scenario_test/route_server_policy_test.py
+++ b/test/scenario_test/route_server_policy_test.py
@@ -2317,245 +2317,6 @@ class ExportPolicyMedSub(object):
@register_scenario
-class InPolicyReject(object):
- """
- No.31 in-policy reject test
- ----------------
- e1 ->r1(community=65100:10) -> x | -> q1-rib -> | -> r2 --> q1
- r2(192.168.10.0/24) -> o | |
- | -> q2-rib -> | -> r2 --> q2
- ----------------
- """
- @staticmethod
- def boot(env):
- lookup_scenario('ImportPolicy').boot(env)
-
- @staticmethod
- def setup(env):
- g1 = env.g1
- e1 = env.e1
- q1 = env.q1
- q2 = env.q2
- cs0 = {'community-sets': [{'community-set-name': 'cs0', 'community-list': ['65100:10']}]}
-
- g1.set_bgp_defined_set(cs0)
-
- st0 = {'name': 'st0',
- 'conditions': {'bgp-conditions': {'match-community-set': {'community-set': 'cs0'}}},
- 'actions': {'route-disposition': 'reject-route'}}
-
- policy = {'name': 'policy0',
- 'statements': [st0]}
- g1.add_policy(policy, e1, 'in')
-
- e1.add_route('192.168.100.0/24', community=['65100:10'])
- e1.add_route('192.168.10.0/24')
-
- for c in [e1, q1, q2]:
- g1.wait_for(BGP_FSM_ESTABLISHED, c)
-
- @staticmethod
- def check(env):
- g1 = env.g1
- e1 = env.e1
- q1 = env.q1
- q2 = env.q2
- wait_for(lambda: len(g1.get_adj_rib_in(e1)) == 2)
- wait_for(lambda: len(g1.get_local_rib(q1)) == 1)
- wait_for(lambda: len(g1.get_adj_rib_out(q1)) == 1)
- wait_for(lambda: len(q1.get_global_rib()) == 1)
- wait_for(lambda: len(g1.get_local_rib(q2)) == 1)
- wait_for(lambda: len(g1.get_adj_rib_out(q2)) == 1)
- wait_for(lambda: len(q2.get_global_rib()) == 1)
-
- @staticmethod
- def executor(env):
- lookup_scenario("InPolicyReject").boot(env)
- lookup_scenario("InPolicyReject").setup(env)
- lookup_scenario("InPolicyReject").check(env)
-
-
-@register_scenario
-class InPolicyAccept(object):
- """
- No.32 in-policy accept test
- ----------------
- e1 ->r1(community=65100:10) -> x | -> q1-rib -> | -> r2 --> q1
- r2(192.168.10.0/24) -> o | |
- | -> q2-rib -> | -> r2 --> q2
- ----------------
- """
- @staticmethod
- def boot(env):
- lookup_scenario('ImportPolicy').boot(env)
-
- @staticmethod
- def setup(env):
- g1 = env.g1
- e1 = env.e1
- q1 = env.q1
- q2 = env.q2
- cs0 = {'community-sets': [{'community-set-name': 'cs0', 'community-list': ['65100:10']}]}
-
- g1.set_bgp_defined_set(cs0)
-
- st0 = {'name': 'st0',
- 'conditions': {'bgp-conditions': {'match-community-set': {'community-set': 'cs0'}}},
- 'actions': {'route-disposition': 'accept-route'}}
-
- policy = {'name': 'policy0',
- 'statements': [st0]}
- g1.add_policy(policy, e1, 'in', 'reject')
-
- e1.add_route('192.168.100.0/24', community=['65100:10'])
- e1.add_route('192.168.10.0/24')
-
- for c in [e1, q1, q2]:
- g1.wait_for(BGP_FSM_ESTABLISHED, c)
-
- @staticmethod
- def check(env):
- lookup_scenario('InPolicyReject').check(env)
-
- @staticmethod
- def executor(env):
- lookup_scenario("InPolicyAccept").boot(env)
- lookup_scenario("InPolicyAccept").setup(env)
- lookup_scenario("InPolicyAccept").check(env)
-
-
-@register_scenario
-class InPolicyUpdate(object):
- """
- No.35 in-policy update test
- r1:192.168.2.0
- r2:192.168.20.0
- r3:192.168.200.0
- -------------------------------------
- | q1 |
- e1 ->(r1,r2,r3)-> | ->(r1)-> rib ->(r1)-> adj-rib-out | ->(r1)-> q1
- | |
- | q2 |
- | ->(r1)-> rib ->(r1)-> adj-rib-out | ->(r1)-> q2
- -------------------------------------
- |
- update distribute policy
- |
- V
- -------------------------------------------
- | q1 |
- e1 ->(r1,r2,r3)-> | ->(r1,r2)-> rib ->(r1,r2)-> adj-rib-out | ->(r1,r2)-> q1
- | |
- | q2 |
- | ->(r1,r3)-> rib ->(r1,r3)-> adj-rib-out | ->(r1,r3)-> q2
- -------------------------------------------
- """
- @staticmethod
- def boot(env):
- lookup_scenario('ImportPolicy').boot(env)
-
- @staticmethod
- def setup(env):
- g1 = env.g1
- e1 = env.e1
- q1 = env.q1
- q2 = env.q2
-
- p0 = {'ip-prefix': '192.168.20.0/24'}
- p1 = {'ip-prefix': '192.168.200.0/24'}
-
- ps0 = {'prefix-set-name': 'ps0',
- 'prefix-list': [p0, p1]}
- g1.set_prefix_set(ps0)
-
- ns0 = {'neighbor-set-name': 'ns0',
- 'neighbor-info-list': [g1.peers[e1]['neigh_addr'].split('/')[0]]}
- g1.set_neighbor_set(ns0)
-
- st0 = {'name': 'st0',
- 'conditions': {
- 'match-prefix-set': {'prefix-set': ps0['prefix-set-name']},
- 'match-neighbor-set': {'neighbor-set': ns0['neighbor-set-name']}},
- 'actions': {'route-disposition': 'reject-route'}}
-
- policy = {'name': 'policy0',
- 'statements': [st0]}
- g1.add_policy(policy, e1, 'in')
-
- e1.add_route('192.168.2.0/24')
- e1.add_route('192.168.20.0/24')
- e1.add_route('192.168.200.0/24')
-
- for c in [e1, q1, q2]:
- g1.wait_for(BGP_FSM_ESTABLISHED, c)
-
- @staticmethod
- def check(env):
- g1 = env.g1
- e1 = env.e1
- q1 = env.q1
- q2 = env.q2
- wait_for(lambda: len(g1.get_adj_rib_in(e1)) == 3)
- wait_for(lambda: len(g1.get_local_rib(q1)) == 1)
- wait_for(lambda: len(g1.get_adj_rib_out(q1)) == 1)
- wait_for(lambda: len(q1.get_global_rib()) == 1)
- wait_for(lambda: len(g1.get_local_rib(q2)) == 1)
- wait_for(lambda: len(g1.get_adj_rib_out(q2)) == 1)
- wait_for(lambda: len(q2.get_global_rib()) == 1)
-
- @staticmethod
- def setup2(env):
- g1 = env.g1
- e1 = env.e1
- # q1 = env.q1
- # q2 = env.q2
- g1.clear_policy()
-
- p0 = {'ip-prefix': '192.168.20.0/24'}
-
- ps0 = {'prefix-set-name': 'ps0',
- 'prefix-list': [p0]}
- g1.set_prefix_set(ps0)
-
- ns0 = {'neighbor-set-name': 'ns0',
- 'neighbor-info-list': [g1.peers[e1]['neigh_addr'].split('/')[0]]}
- g1.set_neighbor_set(ns0)
-
- st0 = {'name': 'st0',
- 'conditions': {
- 'match-prefix-set': {'prefix-set': ps0['prefix-set-name']},
- 'match-neighbor-set': {'neighbor-set': ns0['neighbor-set-name']}},
- 'actions': {'route-disposition': 'reject-route'}}
-
- policy = {'name': 'policy0',
- 'statements': [st0]}
- g1.add_policy(policy, e1, 'in')
- g1.softreset(e1)
-
- @staticmethod
- def check2(env):
- g1 = env.g1
- e1 = env.e1
- q1 = env.q1
- q2 = env.q2
- wait_for(lambda: len(g1.get_adj_rib_in(e1)) == 3)
- wait_for(lambda: len(g1.get_local_rib(q1)) == 2)
- wait_for(lambda: len(g1.get_adj_rib_out(q1)) == 2)
- wait_for(lambda: len(q1.get_global_rib()) == 2)
- wait_for(lambda: len(g1.get_local_rib(q2)) == 2)
- wait_for(lambda: len(g1.get_adj_rib_out(q2)) == 2)
- wait_for(lambda: len(q2.get_global_rib()) == 2)
-
- @staticmethod
- def executor(env):
- lookup_scenario("InPolicyUpdate").boot(env)
- lookup_scenario("InPolicyUpdate").setup(env)
- lookup_scenario("InPolicyUpdate").check(env)
- lookup_scenario("InPolicyUpdate").setup2(env)
- lookup_scenario("InPolicyUpdate").check2(env)
-
-
-@register_scenario
class ExportPolicyAsPathPrepend(object):
"""
No.37 aspath prepend action export
@@ -2898,60 +2659,6 @@ class ImportPolicyExCommunityTargetCondition(object):
lookup_scenario("ImportPolicyExCommunityTargetCondition").check(env)
-@register_scenario
-class InPolicyPrefixCondition(object):
- """
- No.42 prefix only condition accept in
- -----------------
- e1 ->r1(192.168.100.0/24) -> o | -> q1-rib -> | -> r2 --> q1
- r2(192.168.10.0/24) -> x | |
- | -> q2-rib -> | -> r2 --> q2
- -----------------
- """
- @staticmethod
- def boot(env):
- lookup_scenario('ImportPolicy').boot(env)
-
- @staticmethod
- def setup(env):
- g1 = env.g1
- e1 = env.e1
- q1 = env.q1
- q2 = env.q2
-
- p0 = {'ip-prefix': '192.168.10.0/24'}
-
- ps0 = {'prefix-set-name': 'ps0',
- 'prefix-list': [p0]}
- g1.set_prefix_set(ps0)
-
- st0 = {'name': 'st0',
- 'conditions': {'match-prefix-set': {'prefix-set': ps0['prefix-set-name']}},
- 'actions': {'route-disposition': 'reject-route'}}
-
- policy = {'name': 'policy0',
- 'statements': [st0]}
- g1.add_policy(policy, e1, 'in')
-
- # this will be blocked
- e1.add_route('192.168.100.0/24')
- # this will pass
- e1.add_route('192.168.10.0/24')
-
- for c in [e1, q1, q2]:
- g1.wait_for(BGP_FSM_ESTABLISHED, c)
-
- @staticmethod
- def check(env):
- lookup_scenario('InPolicyReject').check(env)
-
- @staticmethod
- def executor(env):
- lookup_scenario("InPolicyPrefixCondition").boot(env)
- lookup_scenario("InPolicyPrefixCondition").setup(env)
- lookup_scenario("InPolicyPrefixCondition").check(env)
-
-
def ext_community_exists(path, extcomm):
typ = extcomm.split(':')[0]
value = ':'.join(extcomm.split(':')[1:])
diff --git a/test/scenario_test/route_server_softreset_test.py b/test/scenario_test/route_server_softreset_test.py
index ad608837..23f646eb 100644
--- a/test/scenario_test/route_server_softreset_test.py
+++ b/test/scenario_test/route_server_softreset_test.py
@@ -88,7 +88,7 @@ class GoBGPTestBase(unittest.TestCase):
pol0 = {'name': 'pol0', 'statements': [st0]}
- _filename = g1.add_policy(pol0, g3, 'in', 'reject')
+ _filename = g1.add_policy(pol0, g3, 'import', 'reject')
g3.add_route('10.0.10.0/24')
g3.add_route('10.0.20.0/24')