summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/lib/base.py25
-rw-r--r--test/lib/gobgp.py38
-rw-r--r--test/lib/quagga.py7
-rw-r--r--test/scenario_test/bgp_router_test.py6
-rw-r--r--test/scenario_test/route_server_policy_test.py153
-rw-r--r--test/scenario_test/route_server_test.py9
6 files changed, 82 insertions, 156 deletions
diff --git a/test/lib/base.py b/test/lib/base.py
index d92f7b9a..d64afdae 100644
--- a/test/lib/base.py
+++ b/test/lib/base.py
@@ -323,21 +323,32 @@ class BGPContainer(Container):
self.create_config()
self.reload_config()
+ def add_policy(self, policy, peer, typ, default='accept', reload_config=True):
+ self.set_default_policy(peer, typ, default)
+ self.define_policy(policy)
+ self.assign_policy(peer, policy, typ)
+ if self.is_running and reload_config:
+ self.create_config()
+ self.reload_config()
+
def set_default_policy(self, peer, typ, default):
- if typ in ['in', 'import', 'export'] and default in ['reject', 'accept']:
+ if typ in ['in', 'out', 'import', 'export'] and default in ['reject', 'accept']:
if 'default-policy' not in self.peers[peer]:
self.peers[peer]['default-policy'] = {}
self.peers[peer]['default-policy'][typ] = default
else:
raise Exception('wrong type or default')
- def add_policy(self, policy, peer=None, reload_config=True):
+ def define_policy(self, policy):
self.policies[policy['name']] = policy
- if peer in self.peers:
- self.peers[peer]['policies'][policy['name']] = policy
- if self.is_running and reload_config:
- self.create_config()
- self.reload_config()
+
+ def assign_policy(self, peer, policy, typ):
+ if peer not in self.peers:
+ raise Exception('peer {0} not found'.format(peer.name))
+ name = policy['name']
+ if name not in self.policies:
+ raise Exception('policy {0} not found'.format(name))
+ self.peers[peer]['policies'][typ] = policy
def get_local_rib(self, peer, rf):
raise Exception('implement get_local_rib() method')
diff --git a/test/lib/gobgp.py b/test/lib/gobgp.py
index 0ae2d71b..5b7a847e 100644
--- a/test/lib/gobgp.py
+++ b/test/lib/gobgp.py
@@ -281,27 +281,11 @@ class GoBGPContainer(BGPContainer):
n['route-reflector'] = {'config' : {'route-reflector-client': True,
'route-reflector-cluster-id': clusterId}}
- f = lambda typ: [p for p in info['policies'].itervalues() if p['type'] == typ]
- import_policies = f('import')
- export_policies = f('export')
- in_policies = f('in')
- f = lambda typ: [p['default'] for p in info['policies'].itervalues() if p['type'] == typ and 'default' in p]
- default_import_policy = f('import')
- default_export_policy = f('export')
- default_in_policy = f('in')
-
- if len(import_policies) + len(export_policies) + len(in_policies) + len(default_import_policy) \
- + len(default_export_policy) + len(default_in_policy) > 0:
+ if len(info.get('default-policy', [])) + len(info.get('policies', [])) > 0:
n['apply-policy'] = {'config': {}}
- if len(import_policies) > 0:
- n['apply-policy']['config']['import-policy-list'] = [p['name'] for p in import_policies]
-
- if len(export_policies) > 0:
- n['apply-policy']['config']['export-policy-list'] = [p['name'] for p in export_policies]
-
- if len(in_policies) > 0:
- n['apply-policy']['config']['in-policy-list'] = [p['name'] for p in in_policies]
+ for typ, p in info.get('policies', {}).iteritems():
+ n['apply-policy']['config']['{0}-policy-list'.format(typ)] = [p['name']]
def f(v):
if v == 'reject':
@@ -310,20 +294,8 @@ class GoBGPContainer(BGPContainer):
return 'accept-route'
raise Exception('invalid default policy type {0}'.format(v))
- if len(default_import_policy) > 0:
- n['apply-policy']['config']['default-import-policy'] = f(default_import_policy[0])
-
- if len(default_export_policy) > 0:
- n['apply-policy']['config']['default-export-policy'] = f(default_export_policy[0])
-
- if len(default_in_policy) > 0:
- n['apply-policy']['config']['default-in-policy'] = f(default_in_policy[0])
-
- for typ in ['in', 'import', 'export']:
- if 'default-policy' in info and typ in info['default-policy']:
- if 'apply-policy' not in n:
- n['apply-policy'] = {'config': {}}
- n['apply-policy']['config']['default-{0}-policy'.format(typ)] = f(info['default-policy'][typ])
+ for typ, d in info.get('default-policy', {}).iteritems():
+ n['apply-policy']['config']['default-{0}-policy'.format(typ)] = f(d)
if 'neighbors' not in config:
config['neighbors'] = []
diff --git a/test/lib/quagga.py b/test/lib/quagga.py
index 59cf58e9..ce53a29b 100644
--- a/test/lib/quagga.py
+++ b/test/lib/quagga.py
@@ -164,10 +164,9 @@ class QuaggaBGPContainer(BGPContainer):
c << 'neighbor {0} remote-as {1}'.format(n_addr, peer.asn)
if info['is_rs_client']:
c << 'neighbor {0} route-server-client'.format(n_addr)
- for name, policy in info['policies'].iteritems():
- direction = policy['direction']
- c << 'neighbor {0} route-map {1} {2}'.format(n_addr, name,
- direction)
+ for typ, p in info['policies'].iteritems():
+ c << 'neighbor {0} route-map {1} {2}'.format(n_addr, p['name'],
+ typ)
if info['passwd']:
c << 'neighbor {0} password {1}'.format(n_addr, info['passwd'])
if info['passive']:
diff --git a/test/scenario_test/bgp_router_test.py b/test/scenario_test/bgp_router_test.py
index d5059e00..baae3841 100644
--- a/test/scenario_test/bgp_router_test.py
+++ b/test/scenario_test/bgp_router_test.py
@@ -170,15 +170,13 @@ class GoBGPTestBase(unittest.TestCase):
med200 = {'name': 'med200',
'type': 'permit',
'match': '0.0.0.0/0',
- 'direction': 'out',
'med': 200}
- q2.add_policy(med200, self.gobgp)
+ q2.add_policy(med200, self.gobgp, 'out')
med100 = {'name': 'med100',
'type': 'permit',
'match': '0.0.0.0/0',
- 'direction': 'out',
'med': 100}
- q3.add_policy(med100, self.gobgp)
+ q3.add_policy(med100, self.gobgp, 'out')
q5.add_route('10.0.6.0/24')
diff --git a/test/scenario_test/route_server_policy_test.py b/test/scenario_test/route_server_policy_test.py
index 28163796..181af895 100644
--- a/test/scenario_test/route_server_policy_test.py
+++ b/test/scenario_test/route_server_policy_test.py
@@ -117,9 +117,8 @@ class ImportPolicy(object):
'actions': {'route-disposition': {'accept-route': False}}}
policy = {'name': 'policy0',
- 'type': 'import',
'statements': [st0]}
- g1.add_policy(policy, q2)
+ g1.add_policy(policy, q2, 'import')
# this will be blocked
e1.add_route('192.168.2.0/24')
@@ -184,9 +183,8 @@ class ExportPolicy(object):
'actions': {'route-disposition': {'accept-route': False}}}
policy = {'name': 'policy0',
- 'type': 'export',
'statements': [st0]}
- g1.add_policy(policy, q2)
+ g1.add_policy(policy, q2, 'export')
# this will be blocked
e1.add_route('192.168.2.0/24')
@@ -271,9 +269,8 @@ class ImportPolicyUpdate(object):
'actions': {'route-disposition': {'accept-route': False}}}
policy = {'name': 'policy0',
- 'type': 'import',
'statements': [st0]}
- g1.add_policy(policy, q2)
+ g1.add_policy(policy, q2, 'import')
e1.add_route('192.168.2.0/24')
e1.add_route('192.168.20.0/24')
@@ -319,9 +316,8 @@ class ImportPolicyUpdate(object):
'actions': {'route-disposition': {'accept-route': False}}}
policy = {'name': 'policy0',
- 'type': 'import',
'statements': [st0]}
- g1.add_policy(policy, q2)
+ g1.add_policy(policy, q2, 'import')
g1.softreset(e1)
@staticmethod
@@ -400,9 +396,8 @@ class ExportPolicyUpdate(object):
'actions': {'route-disposition': {'accept-route': False}}}
policy = {'name': 'policy0',
- 'type': 'export',
'statements': [st0]}
- g1.add_policy(policy, q2)
+ g1.add_policy(policy, q2, 'export')
e1.add_route('192.168.2.0/24')
e1.add_route('192.168.20.0/24')
@@ -448,9 +443,8 @@ class ExportPolicyUpdate(object):
'actions': {'route-disposition': {'accept-route': False}}}
policy = {'name': 'policy0',
- 'type': 'export',
'statements': [st0]}
- g1.add_policy(policy, q2)
+ g1.add_policy(policy, q2, 'export')
# we need hard reset to flush q2's local rib
g1.reset(e1)
@@ -545,9 +539,8 @@ class ImportPolicyIPV6(object):
'actions': {'route-disposition': {'accept-route': False}}}
policy = {'name': 'policy0',
- 'type': 'import',
'statements': [st0]}
- g1.add_policy(policy, q2)
+ g1.add_policy(policy, q2, 'import')
# this will be blocked
e1.add_route('2001::/64', rf='ipv6')
@@ -615,9 +608,8 @@ class ExportPolicyIPV6(object):
'actions': {'route-disposition': {'accept-route': False}}}
policy = {'name': 'policy0',
- 'type': 'export',
'statements': [st0]}
- g1.add_policy(policy, q2)
+ g1.add_policy(policy, q2, 'export')
# this will be blocked
e1.add_route('2001::/64', rf='ipv6')
@@ -698,9 +690,8 @@ class ImportPolicyIPV6Update(object):
'actions': {'route-disposition': {'accept-route': False}}}
policy = {'name': 'policy0',
- 'type': 'import',
'statements': [st0]}
- g1.add_policy(policy, q2)
+ g1.add_policy(policy, q2, 'import')
e1.add_route('2001:0:10:2::/64', rf='ipv6')
e1.add_route('2001:0:10:20::/64', rf='ipv6')
@@ -743,9 +734,8 @@ class ImportPolicyIPV6Update(object):
'route-disposition': {'accept-route': False}}}
policy = {'name': 'policy0',
- 'type': 'import',
'statements': [st0]}
- g1.add_policy(policy, q2)
+ g1.add_policy(policy, q2, 'import')
g1.softreset(e1, rf='ipv6')
@staticmethod
@@ -821,9 +811,8 @@ class ExportPolicyIPv6Update(object):
'actions': {'route-disposition': {'accept-route': False}}}
policy = {'name': 'policy0',
- 'type': 'export',
'statements': [st0]}
- g1.add_policy(policy, q2)
+ g1.add_policy(policy, q2, 'export')
e1.add_route('2001:0:10:2::/64', rf='ipv6')
e1.add_route('2001:0:10:20::/64', rf='ipv6')
@@ -865,9 +854,8 @@ class ExportPolicyIPv6Update(object):
'actions': {'route-disposition': {'accept-route': False}}}
policy = {'name': 'policy0',
- 'type': 'export',
'statements': [st0]}
- g1.add_policy(policy, q2)
+ g1.add_policy(policy, q2, 'export')
g1.reset(e1)
for c in [e1, q1, q2]:
@@ -917,9 +905,8 @@ class ImportPolicyAsPathLengthCondition(object):
'actions': {'route-disposition': {'accept-route': False}}}
policy = {'name': 'policy0',
- 'type': 'import',
'statements': [st0]}
- g1.add_policy(policy, q2)
+ g1.add_policy(policy, q2, 'import')
# this will be blocked
e1.add_route('192.168.100.0/24', aspath=range(e1.asn, e1.asn-10, -1))
@@ -978,9 +965,8 @@ class ImportPolicyAsPathCondition(object):
'actions': {'route-disposition': {'accept-route': False}}}
policy = {'name': 'policy0',
- 'type': 'import',
'statements': [st0]}
- g1.add_policy(policy, q2)
+ g1.add_policy(policy, q2, 'import')
# this will be blocked
e1.add_route('192.168.100.0/24', aspath=range(e1.asn, e1.asn-10, -1))
@@ -1031,9 +1017,8 @@ class ImportPolicyAsPathAnyCondition(object):
'actions': {'route-disposition': {'accept-route': False}}}
policy = {'name': 'policy0',
- 'type': 'import',
'statements': [st0]}
- g1.add_policy(policy, q2)
+ g1.add_policy(policy, q2, 'import')
# this will be blocked
e1.add_route('192.168.100.0/24', aspath=[65000, 65098, 65010])
@@ -1084,9 +1069,8 @@ class ImportPolicyAsPathOriginCondition(object):
'actions': {'route-disposition': {'accept-route': False}}}
policy = {'name': 'policy0',
- 'type': 'import',
'statements': [st0]}
- g1.add_policy(policy, q2)
+ g1.add_policy(policy, q2, 'import')
# this will be blocked
e1.add_route('192.168.100.0/24', aspath=[65000, 65098, 65090])
@@ -1137,9 +1121,8 @@ class ImportPolicyAsPathOnlyCondition(object):
'actions': {'route-disposition': {'accept-route': False}}}
policy = {'name': 'policy0',
- 'type': 'import',
'statements': [st0]}
- g1.add_policy(policy, q2)
+ g1.add_policy(policy, q2, 'import')
# this will be blocked
e1.add_route('192.168.100.0/24', aspath=[65100])
@@ -1192,9 +1175,8 @@ class ImportPolicyAsPathMismatchCondition(object):
'actions': {'route-disposition': {'accept-route': False}}}
policy = {'name': 'policy0',
- 'type': 'import',
'statements': [st0]}
- g1.add_policy(policy, q2)
+ g1.add_policy(policy, q2, 'import')
# this will be blocked
e1.add_route('192.168.100.0/24', aspath=[65100, 65090])
@@ -1253,9 +1235,8 @@ class ImportPolicyCommunityCondition(object):
'actions': {'route-disposition': {'accept-route': False}}}
policy = {'name': 'policy0',
- 'type': 'import',
'statements': [st0]}
- g1.add_policy(policy, q2)
+ g1.add_policy(policy, q2, 'import')
# this will be blocked
e1.add_route('192.168.100.0/24', community=['65100:10'])
@@ -1307,9 +1288,8 @@ class ImportPolicyCommunityRegexp(object):
'actions': {'route-disposition': {'accept-route': False}}}
policy = {'name': 'policy0',
- 'type': 'import',
'statements': [st0]}
- g1.add_policy(policy, q2)
+ g1.add_policy(policy, q2, 'import')
# this will be blocked
e1.add_route('192.168.100.0/24', community=['65100:10'])
@@ -1371,9 +1351,8 @@ class ImportPolicyCommunityAction(object):
'set-community-method': {'communities-list': ['65100:20']}}}}}
policy = {'name': 'policy0',
- 'type': 'import',
'statements': [st0]}
- g1.add_policy(policy, q2)
+ g1.add_policy(policy, q2, 'import')
e1.add_route('192.168.100.0/24', community=['65100:10'])
@@ -1446,9 +1425,8 @@ class ImportPolicyCommunityReplace(object):
'set-community-method': {'communities-list': ['65100:20']}}}}}
policy = {'name': 'policy0',
- 'type': 'import',
'statements': [st0]}
- g1.add_policy(policy, q2)
+ g1.add_policy(policy, q2, 'import')
e1.add_route('192.168.100.0/24', community=['65100:10'])
@@ -1513,9 +1491,8 @@ class ImportPolicyCommunityRemove(object):
'set-community-method': {'communities-list': ['65100:10', '65100:20']}}}}}
policy = {'name': 'policy0',
- 'type': 'import',
'statements': [st0]}
- g1.add_policy(policy, q2)
+ g1.add_policy(policy, q2, 'import')
e1.add_route('192.168.100.0/24', community=['65100:10'])
e1.add_route('192.168.110.0/24', community=['65100:10', '65100:20'])
@@ -1598,9 +1575,8 @@ class ImportPolicyCommunityNull(object):
'set-community-method': {'communities-list': []}}}}}
policy = {'name': 'policy0',
- 'type': 'import',
'statements': [st0]}
- g1.add_policy(policy, q2)
+ g1.add_policy(policy, q2, 'import')
e1.add_route('192.168.100.0/24', community=['65100:10'])
e1.add_route('192.168.110.0/24', community=['65100:10', '65100:20'])
@@ -1673,9 +1649,8 @@ class ExportPolicyCommunityAdd(object):
'set-community-method': {'communities-list': ['65100:20']}}}}}
policy = {'name': 'policy0',
- 'type': 'export',
'statements': [st0]}
- g1.add_policy(policy, q2)
+ g1.add_policy(policy, q2, 'export')
e1.add_route('192.168.100.0/24', community=['65100:10'])
@@ -1747,9 +1722,8 @@ class ExportPolicyCommunityReplace(object):
'set-community-method': {'communities-list': ['65100:20']}}}}}
policy = {'name': 'policy0',
- 'type': 'export',
'statements': [st0]}
- g1.add_policy(policy, q2)
+ g1.add_policy(policy, q2, 'export')
e1.add_route('192.168.100.0/24', community=['65100:10'])
@@ -1821,9 +1795,8 @@ class ExportPolicyCommunityRemove(object):
'set-community-method': {'communities-list': ['65100:20', '65100:30']}}}}}
policy = {'name': 'policy0',
- 'type': 'export',
'statements': [st0]}
- g1.add_policy(policy, q2)
+ g1.add_policy(policy, q2, 'export')
e1.add_route('192.168.100.0/24', community=['65100:10', '65100:20', '65100:30'])
@@ -1898,9 +1871,8 @@ class ExportPolicyCommunityNull(object):
'set-community-method': {'communities-list': []}}}}}
policy = {'name': 'policy0',
- 'type': 'export',
'statements': [st0]}
- g1.add_policy(policy, q2)
+ g1.add_policy(policy, q2, 'export')
e1.add_route('192.168.100.0/24', community=['65100:10', '65100:20', '65100:30'])
@@ -1976,9 +1948,8 @@ class ImportPolicyMedReplace(object):
'bgp-actions': {'set-med': '100'}}}
policy = {'name': 'policy0',
- 'type': 'import',
'statements': [st0]}
- g1.add_policy(policy, q2)
+ g1.add_policy(policy, q2, 'import')
e1.add_route('192.168.100.0/24', med=300)
@@ -2038,9 +2009,8 @@ class ImportPolicyMedAdd(object):
'bgp-actions': {'set-med': '+100'}}}
policy = {'name': 'policy0',
- 'type': 'import',
'statements': [st0]}
- g1.add_policy(policy, q2)
+ g1.add_policy(policy, q2, 'import')
e1.add_route('192.168.100.0/24', med=300)
@@ -2100,9 +2070,8 @@ class ImportPolicyMedSub(object):
'bgp-actions': {'set-med': '-100'}}}
policy = {'name': 'policy0',
- 'type': 'import',
'statements': [st0]}
- g1.add_policy(policy, q2)
+ g1.add_policy(policy, q2, 'import')
e1.add_route('192.168.100.0/24', med=300)
@@ -2162,9 +2131,8 @@ class ExportPolicyMedReplace(object):
'bgp-actions': {'set-med': '100'}}}
policy = {'name': 'policy0',
- 'type': 'export',
'statements': [st0]}
- g1.add_policy(policy, q2)
+ g1.add_policy(policy, q2, 'export')
e1.add_route('192.168.100.0/24', med=300)
@@ -2224,9 +2192,8 @@ class ExportPolicyMedAdd(object):
'bgp-actions': {'set-med': '+100'}}}
policy = {'name': 'policy0',
- 'type': 'export',
'statements': [st0]}
- g1.add_policy(policy, q2)
+ g1.add_policy(policy, q2, 'export')
e1.add_route('192.168.100.0/24', med=300)
@@ -2286,9 +2253,8 @@ class ExportPolicyMedSub(object):
'bgp-actions': {'set-med': '-100'}}}
policy = {'name': 'policy0',
- 'type': 'export',
'statements': [st0]}
- g1.add_policy(policy, q2)
+ g1.add_policy(policy, q2, 'export')
e1.add_route('192.168.100.0/24', med=300)
@@ -2351,9 +2317,8 @@ class InPolicyReject(object):
'actions': {'route-disposition': {'accept-route': False}}}
policy = {'name': 'policy0',
- 'type': 'in',
'statements': [st0]}
- g1.add_policy(policy, e1)
+ 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')
@@ -2411,10 +2376,8 @@ class InPolicyAccept(object):
'actions':{'route-disposition': {'accept-route': True}}}
policy = {'name': 'policy0',
- 'type': 'in',
- 'statements': [st0],
- 'default': 'reject'}
- g1.add_policy(policy, e1)
+ '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')
@@ -2488,9 +2451,8 @@ class InPolicyUpdate(object):
'actions': {'route-disposition': {'accept-route': False}}}
policy = {'name': 'policy0',
- 'type': 'in',
'statements': [st0]}
- g1.add_policy(policy, e1)
+ g1.add_policy(policy, e1, 'in')
e1.add_route('192.168.2.0/24')
e1.add_route('192.168.20.0/24')
@@ -2537,9 +2499,8 @@ class InPolicyUpdate(object):
'actions': {'route-disposition': {'accept-route': False}}}
policy = {'name': 'policy0',
- 'type': 'in',
'statements': [st0]}
- g1.add_policy(policy, e1)
+ g1.add_policy(policy, e1, 'in')
g1.softreset(e1)
@staticmethod
@@ -2599,9 +2560,8 @@ class ExportPolicyAsPathPrepend(object):
'bgp-actions': {'set-as-path-prepend': {'repeat-n': 5, 'as': "65005"}}}}
policy = {'name': 'policy0',
- 'type': 'export',
'statements': [st0]}
- g1.add_policy(policy, q2)
+ g1.add_policy(policy, q2, 'export')
e1.add_route('192.168.20.0/24')
e1.add_route('192.168.200.0/24')
@@ -2687,9 +2647,8 @@ class ImportPolicyAsPathPrependLastAS(object):
'bgp-actions': {'set-as-path-prepend': {'repeat-n': 5, 'as': "last-as"}}}}
policy = {'name': 'policy0',
- 'type': 'import',
'statements': [st0]}
- g1.add_policy(policy, q2)
+ g1.add_policy(policy, q2, 'import')
e1.add_route('192.168.20.0/24')
e1.add_route('192.168.200.0/24')
@@ -2765,9 +2724,8 @@ class ExportPolicyAsPathPrependLastAS(object):
'bgp-actions': {'set-as-path-prepend': {'repeat-n': 5, 'as': "last-as"}}}}
policy = {'name': 'policy0',
- 'type': 'export',
'statements': [st0]}
- g1.add_policy(policy, q2)
+ g1.add_policy(policy, q2, 'export')
e1.add_route('192.168.20.0/24')
e1.add_route('192.168.200.0/24')
@@ -2840,9 +2798,8 @@ class ImportPolicyExCommunityOriginCondition(object):
'actions': {'route-disposition': {'accept-route': False}}}
policy = {'name': 'policy0',
- 'type': 'import',
'statements': [st0]}
- g1.add_policy(policy, q2)
+ g1.add_policy(policy, q2, 'import')
e1.add_route('192.168.20.0/24', extendedcommunity='origin:{0}:200'.format((65001 << 16) + 65100))
e1.add_route('192.168.200.0/24', extendedcommunity='origin:{0}:100'.format((65001 << 16) + 65200))
@@ -2892,9 +2849,8 @@ class ImportPolicyExCommunityTargetCondition(object):
'actions': {'route-disposition': {'accept-route': False}}}
policy = {'name': 'policy0',
- 'type': 'import',
'statements': [st0]}
- g1.add_policy(policy, q2)
+ g1.add_policy(policy, q2, 'import')
e1.add_route('192.168.20.0/24', extendedcommunity='target:65010:320')
e1.add_route('192.168.200.0/24', extendedcommunity='target:55000:320')
@@ -2946,9 +2902,8 @@ class InPolicyPrefixCondition(object):
'actions': {'route-disposition': {'accept-route': False}}}
policy = {'name': 'policy0',
- 'type': 'in',
'statements': [st0]}
- g1.add_policy(policy, e1)
+ g1.add_policy(policy, e1, 'in')
# this will be blocked
e1.add_route('192.168.100.0/24')
@@ -3029,9 +2984,8 @@ class ImportPolicyExCommunityAdd(object):
}
policy = {'name': 'policy0',
- 'type': 'import',
'statements': [st0]}
- g1.add_policy(policy, q2)
+ g1.add_policy(policy, q2, 'import')
e1.add_route('192.168.10.0/24')
@@ -3110,9 +3064,8 @@ class ImportPolicyExCommunityAdd2(object):
}
policy = {'name': 'policy0',
- 'type': 'import',
'statements': [st0]}
- g1.add_policy(policy, q2)
+ g1.add_policy(policy, q2, 'import')
e1.add_route('192.168.10.0/24', extendedcommunity='target:65000:1')
@@ -3196,9 +3149,8 @@ class ImportPolicyExCommunityMultipleAdd(object):
}
policy = {'name': 'policy0',
- 'type': 'import',
'statements': [st0]}
- g1.add_policy(policy, q2)
+ g1.add_policy(policy, q2, 'import')
e1.add_route('192.168.10.0/24')
@@ -3282,9 +3234,8 @@ class ExportPolicyExCommunityAdd(object):
}
policy = {'name': 'policy0',
- 'type': 'export',
'statements': [st0]}
- g1.add_policy(policy, q2)
+ g1.add_policy(policy, q2, 'export')
e1.add_route('192.168.10.0/24')
@@ -3370,9 +3321,8 @@ class InPolicyUpdate2(object):
'actions': {'route-disposition': {'accept-route': False}}}
policy = {'name': 'policy0',
- 'type': 'in',
'statements': [st0]}
- g1.add_policy(policy, e1)
+ g1.add_policy(policy, e1, 'in')
e1.add_route('192.168.2.0/24')
e1.add_route('192.168.20.0/24')
@@ -3420,9 +3370,8 @@ class InPolicyUpdate2(object):
'actions': {'route-disposition': {'accept-route': False}}}
policy = {'name': 'policy0',
- 'type': 'in',
'statements': [st0]}
- g1.add_policy(policy, e1)
+ g1.add_policy(policy, e1, 'in')
g1.softreset(e1)
@staticmethod
diff --git a/test/scenario_test/route_server_test.py b/test/scenario_test/route_server_test.py
index 3c8f9356..afe350af 100644
--- a/test/scenario_test/route_server_test.py
+++ b/test/scenario_test/route_server_test.py
@@ -189,17 +189,15 @@ class GoBGPTestBase(unittest.TestCase):
med200 = {'name': 'med200',
'type': 'permit',
'match': '0.0.0.0/0',
- 'direction': 'out',
'med': 200,
'priority': 10}
- q2.add_policy(med200, self.gobgp)
+ q2.add_policy(med200, self.gobgp, 'out')
med100 = {'name': 'med100',
'type': 'permit',
'match': '0.0.0.0/0',
- 'direction': 'out',
'med': 100,
'priority': 10}
- q3.add_policy(med100, self.gobgp)
+ q3.add_policy(med100, self.gobgp, 'out')
q5.add_route('10.0.6.0/24')
@@ -231,10 +229,9 @@ class GoBGPTestBase(unittest.TestCase):
med300 = {'name': 'med300',
'type': 'permit',
'match': '0.0.0.0/0',
- 'direction': 'out',
'med': 300,
'priority': 5}
- q3.add_policy(med300, self.gobgp)
+ q3.add_policy(med300, self.gobgp, 'out')
time.sleep(self.wait_per_retry)