summaryrefslogtreecommitdiffhomepage
path: root/test/scenario_test
diff options
context:
space:
mode:
Diffstat (limited to 'test/scenario_test')
-rw-r--r--test/scenario_test/route_server_malformed_test.py836
-rw-r--r--test/scenario_test/route_server_policy_grpc_test.py540
-rw-r--r--test/scenario_test/route_server_policy_test.py535
-rwxr-xr-xtest/scenario_test/run_all_tests.sh6
4 files changed, 1288 insertions, 629 deletions
diff --git a/test/scenario_test/route_server_malformed_test.py b/test/scenario_test/route_server_malformed_test.py
index 9bf92708..511797fc 100644
--- a/test/scenario_test/route_server_malformed_test.py
+++ b/test/scenario_test/route_server_malformed_test.py
@@ -23,21 +23,26 @@ import sys
import os
import time
import nose
+import inspect
+from nose.tools import *
from noseplugin import OptionParser, parser_option
-scenarios = {}
+counter = 1
+_SCENARIOS = {}
-def scenario(idx):
- def wrapped(f):
- if idx not in scenarios:
- scenarios[idx] = {}
- if f.__name__ in scenarios[idx]:
- raise Exception('scenario index {0}. already exists'.format(idx))
+def register_scenario(cls):
+ global counter
+ _SCENARIOS[counter] = cls
+ counter += 1
- scenarios[idx][f.__name__] = f
- return wrapped
+
+def lookup_scenario(name):
+ for value in _SCENARIOS.values():
+ if value.__name__ == name:
+ return value
+ return None
def wait_for(f, timeout=120):
@@ -53,348 +58,438 @@ def wait_for(f, timeout=120):
raise Exception('timeout')
-"""
- No.1 malformaed mp-reach-nlri
-"""
-@scenario(1)
-def boot(env):
- gobgp_ctn_image_name = env.parser_option.gobgp_image
- log_level = env.parser_option.gobgp_log_level
- g1 = GoBGPContainer(name='g1', asn=65000, router_id='192.168.0.1',
- ctn_image_name=gobgp_ctn_image_name,
- log_level=log_level)
- e1 = ExaBGPContainer(name='e1', asn=65001, router_id='192.168.0.2')
- e2 = ExaBGPContainer(name='e2', asn=65001, router_id='192.168.0.2')
-
- ctns = [g1, e1, e2]
- initial_wait_time = max(ctn.run() for ctn in ctns)
- time.sleep(initial_wait_time)
-
- for q in [e1, e2]:
- g1.add_peer(q, is_rs_client=True)
- q.add_peer(g1)
-
- env.g1 = g1
- env.e1 = e1
- env.e2 = e2
-
-@scenario(1)
-def setup(env):
- g1 = env.g1
- e1 = env.e1
- e2 = env.e2
- for c in [e1, e2]:
- g1.wait_for(BGP_FSM_ESTABLISHED, c)
-
- # advertise malformed MP_REACH_NLRI
- e1.add_route('10.7.0.17/32', attribute='0x0e 0x60 0x11223344')
-
-@scenario(1)
-def check(env):
- g1 = env.g1
- e1 = env.e1
- e2 = env.e2
- def f():
- for line in e1.log().split('\n'):
- if 'UPDATE message error / Attribute Flags Error / 0x600E0411223344' in line:
- return True
- return False
- wait_for(f)
- # check e2 is still established
- g1.wait_for(BGP_FSM_ESTABLISHED, e2)
-
-"""
- No.2 malformaed mp-unreach-nlri
-"""
-@scenario(2)
-def boot(env):
- scenarios[1]['boot'](env)
-
-@scenario(2)
-def setup(env):
- g1 = env.g1
- e1 = env.e1
- e2 = env.e2
- for c in [e1, e2]:
- g1.wait_for(BGP_FSM_ESTABLISHED, c)
-
- # advertise malformed MP_UNREACH_NLRI
- e1.add_route('10.7.0.17/32', attribute='0x0f 0x60 0x11223344')
-
-@scenario(2)
-def check(env):
- g1 = env.g1
- e1 = env.e1
- e2 = env.e2
- def f():
- for line in e1.log().split('\n'):
- if 'UPDATE message error / Attribute Flags Error / 0x600F0411223344' in line:
- return True
- return False
- wait_for(f)
- # check e2 is still established
- g1.wait_for(BGP_FSM_ESTABLISHED, e2)
-
-"""
- No.3 malformaed as-path
-"""
-@scenario(3)
-def boot(env):
- scenarios[1]['boot'](env)
-
-@scenario(3)
-def setup(env):
- g1 = env.g1
- e1 = env.e1
- e2 = env.e2
- for c in [e1, e2]:
- g1.wait_for(BGP_FSM_ESTABLISHED, c)
-
- # advertise malformed AS_PATH
- # Send the attribute to the length and number of aspath is inconsistent
- # Attribute Type 0x02 (AS_PATH)
- # Attribute Flag 0x40 (well-known transitive)
- # Attribute Value 0x02020000ffdc (
- # segment type = 02
- # segment length = 02 -> # correct value = 01
- # as number = 65500 )
- e1.add_route('10.7.0.17/32', attribute='0x02 0x60 0x11223344')
-
-@scenario(3)
-def check(env):
- g1 = env.g1
- e1 = env.e1
- e2 = env.e2
- def f():
- for line in e1.log().split('\n'):
- if 'UPDATE message error / Attribute Flags Error / 0x60020411223344' in line:
- return True
- return False
- wait_for(f)
- # check e2 is still established
- g1.wait_for(BGP_FSM_ESTABLISHED, e2)
-
-"""
- No.4 malformaed as4-path
-"""
-@scenario(4)
-def boot(env):
- scenarios[1]['boot'](env)
-
-@scenario(4)
-def setup(env):
- g1 = env.g1
- e1 = env.e1
- e2 = env.e2
- for c in [e1, e2]:
- g1.wait_for(BGP_FSM_ESTABLISHED, c)
-
- # advertise malformed AS4_PATH
- e1.add_route('10.7.0.17/32', attribute='0x11 0x60 0x11223344')
-
-@scenario(4)
-def check(env):
- g1 = env.g1
- e1 = env.e1
- e2 = env.e2
- def f():
- for line in e1.log().split('\n'):
- if 'UPDATE message error / Attribute Flags Error / 0x60110411223344' in line:
- return True
- return False
- wait_for(f)
- # check e2 is still established
- g1.wait_for(BGP_FSM_ESTABLISHED, e2)
-
-"""
- No.5 malformaed nexthop
-"""
-@scenario(5)
-def boot(env):
- scenarios[1]['boot'](env)
-
-@scenario(5)
-def setup(env):
- g1 = env.g1
- e1 = env.e1
- e2 = env.e2
- for c in [e1, e2]:
- g1.wait_for(BGP_FSM_ESTABLISHED, c)
-
- # advertise malformed NEXT_HOP
- # 0x0e: MP_REACH_NLRI
- # 0x60: Optional, Transitive
- # 0x01: AFI(IPv4)
- # 0x01: SAFI(unicast)
- # 0x10: Length of Next Hop Address
- # 0xffffff00: Network address of Next Hop
- # 0x00: Reserved
- e1.add_route('10.7.0.17/32', attribute='0x0e 0x60 0x010110ffffff0000')
-
-@scenario(5)
-def check(env):
- g1 = env.g1
- e1 = env.e1
- e2 = env.e2
- def f():
- for line in e1.log().split('\n'):
- if 'UPDATE message error / Attribute Flags Error / 0x600E08010110FFFFFF0000' in line:
- return True
- return False
- wait_for(f)
- # check e2 is still established
- g1.wait_for(BGP_FSM_ESTABLISHED, e2)
-
-"""
- No.6 malformaed route family
-"""
-@scenario(6)
-def boot(env):
- scenarios[1]['boot'](env)
-
-@scenario(6)
-def setup(env):
- g1 = env.g1
- e1 = env.e1
- e2 = env.e2
- for c in [e1, e2]:
- g1.wait_for(BGP_FSM_ESTABLISHED, c)
-
- # advertise malformed ROUTE_FAMILY
- # 0x0e: MP_REACH_NLRI
- # 0x60: Optional, Transitive
- # 0x01: AFI(IPv4)
- # 0x01: SAFI(unicast)
- # 0x10: Length of Next Hop Address
- # 0xffffff00: Network address of Next Hop
- # 0x00: Reserved
- e1.add_route('10.7.0.17/32', attribute='0x0e 0x60 0x0002011020010db800000000000000000000000100')
-
-@scenario(6)
-def check(env):
- g1 = env.g1
- e1 = env.e1
- e2 = env.e2
- def f():
- for line in e1.log().split('\n'):
- if 'UPDATE message error / Attribute Flags Error / 0x600E150002011020010DB800000000000000000000000100' in line:
- return True
- return False
- wait_for(f)
- # check e2 is still established
- g1.wait_for(BGP_FSM_ESTABLISHED, e2)
-
-"""
- No.7 malformaed aspath segment length invalid
-"""
-@scenario(7)
-def boot(env):
- scenarios[1]['boot'](env)
-
-@scenario(7)
-def setup(env):
- g1 = env.g1
- e1 = env.e1
- e2 = env.e2
- for c in [e1, e2]:
- g1.wait_for(BGP_FSM_ESTABLISHED, c)
-
- # advertise malformed AS_PATH SEGMENT LENGTH
- # Send the attribute to the length and number of aspath is inconsistent
- # Attribute Type 0x02 (AS_PATH)
- # Attribute Flag 0x40 (well-known transitive)
- # Attribute Value 0x02020000ffdc (
- # segment type = 02
- # segment length = 02 -> # correct value = 01
- # as number = 65500 )
- e1.add_route('10.7.0.17/32', attribute='0x02 0x40 0x0202ffdc')
-
-@scenario(7)
-def check(env):
- g1 = env.g1
- e1 = env.e1
- e2 = env.e2
- def f():
- for line in e1.log().split('\n'):
- if 'UPDATE message error / Malformed AS_PATH / 0x4002040202FFDC' in line:
- return True
- return False
- wait_for(f)
- # check e2 is still established
- g1.wait_for(BGP_FSM_ESTABLISHED, e2)
-
-"""
- No.8 malformaed nexthop loopback addr
-"""
-@scenario(8)
-def boot(env):
- scenarios[1]['boot'](env)
-
-@scenario(8)
-def setup(env):
- g1 = env.g1
- e1 = env.e1
- e2 = env.e2
- for c in [e1, e2]:
- g1.wait_for(BGP_FSM_ESTABLISHED, c)
-
- # Malformed Invalid NEXT_HOP Attribute
- # Send the attribute of invalid nexthop
- # next-hop 127.0.0.1 -> # correct value = other than loopback and 0.0.0.0 address
- e1.add_route('10.7.0.17/32', nexthop='127.0.0.1')
-
-@scenario(8)
-def check(env):
- g1 = env.g1
- e1 = env.e1
- e2 = env.e2
- def f():
- for line in e1.log().split('\n'):
- if 'UPDATE message error / Invalid NEXT_HOP Attribute / 0x4003047F000001' in line:
- return True
- return False
- wait_for(f)
- # check e2 is still established
- g1.wait_for(BGP_FSM_ESTABLISHED, e2)
-
-"""
- No.9 malformaed origin type
-"""
-@scenario(9)
-def boot(env):
- scenarios[1]['boot'](env)
-
-@scenario(9)
-def setup(env):
- g1 = env.g1
- e1 = env.e1
- e2 = env.e2
- for c in [e1, e2]:
- g1.wait_for(BGP_FSM_ESTABLISHED, c)
-
- # Invalid ORIGIN Attribute
- # Send the attribute of origin type 4
- # Attribute Type 0x01 (Origin)
- # Attribute Flag 0x40 (well-known transitive)
- # Attribute Value 0x04 (
- # origin type = 04 -> # correct value = 01 or 02 or 03 )
- e1.add_route('10.7.0.17/32', attribute='0x1 0x40 0x04')
-
-@scenario(9)
-def check(env):
- g1 = env.g1
- e1 = env.e1
- e2 = env.e2
- def f():
- for line in e1.log().split('\n'):
- if 'UPDATE message error / Invalid ORIGIN Attribute / 0x40010104' in line:
- return True
- return False
- wait_for(f)
- # check e2 is still established
- g1.wait_for(BGP_FSM_ESTABLISHED, e2)
-
-class GoBGPTestBase(unittest.TestCase):
+@register_scenario
+class MalformedMpReachNlri(object):
+ """
+ No.1 malformaed mp-reach-nlri
+ """
+
+ @staticmethod
+ def boot(env):
+ gobgp_ctn_image_name = env.parser_option.gobgp_image
+ log_level = env.parser_option.gobgp_log_level
+ g1 = GoBGPContainer(name='g1', asn=65000, router_id='192.168.0.1',
+ ctn_image_name=gobgp_ctn_image_name,
+ log_level=log_level)
+ e1 = ExaBGPContainer(name='e1', asn=65001, router_id='192.168.0.2')
+ e2 = ExaBGPContainer(name='e2', asn=65001, router_id='192.168.0.2')
+
+ ctns = [g1, e1, e2]
+ initial_wait_time = max(ctn.run() for ctn in ctns)
+ time.sleep(initial_wait_time)
+
+ for q in [e1, e2]:
+ g1.add_peer(q, is_rs_client=True)
+ q.add_peer(g1)
+
+ env.g1 = g1
+ env.e1 = e1
+ env.e2 = e2
+
+ @staticmethod
+ def setup(env):
+ g1 = env.g1
+ e1 = env.e1
+ e2 = env.e2
+ for c in [e1, e2]:
+ g1.wait_for(BGP_FSM_ESTABLISHED, c)
+
+ # advertise malformed MP_REACH_NLRI
+ e1.add_route('10.7.0.17/32', attribute='0x0e 0x60 0x11223344')
+
+ @staticmethod
+ def check(env):
+ g1 = env.g1
+ e1 = env.e1
+ e2 = env.e2
+ def f():
+ for line in e1.log().split('\n'):
+ if 'UPDATE message error / Attribute Flags Error / 0x600E0411223344' in line:
+ return True
+ return False
+ wait_for(f)
+ # check e2 is still established
+ g1.wait_for(BGP_FSM_ESTABLISHED, e2)
+
+ @staticmethod
+ def executor(env):
+ lookup_scenario("MalformedMpReachNlri").boot(env)
+ lookup_scenario("MalformedMpReachNlri").setup(env)
+ lookup_scenario("MalformedMpReachNlri").check(env)
+
+
+@register_scenario
+class MalformedMpUnReachNlri(object):
+ """
+ No.2 malformaed mp-unreach-nlri
+ """
+
+ @staticmethod
+ def boot(env):
+ lookup_scenario("MalformedMpReachNlri").boot(env)
+
+ @staticmethod
+ def setup(env):
+ g1 = env.g1
+ e1 = env.e1
+ e2 = env.e2
+ for c in [e1, e2]:
+ g1.wait_for(BGP_FSM_ESTABLISHED, c)
+
+ # advertise malformed MP_UNREACH_NLRI
+ e1.add_route('10.7.0.17/32', attribute='0x0f 0x60 0x11223344')
+
+ @staticmethod
+ def check(env):
+ g1 = env.g1
+ e1 = env.e1
+ e2 = env.e2
+ def f():
+ for line in e1.log().split('\n'):
+ if 'UPDATE message error / Attribute Flags Error / 0x600F0411223344' in line:
+ return True
+ return False
+ wait_for(f)
+ # check e2 is still established
+ g1.wait_for(BGP_FSM_ESTABLISHED, e2)
+
+ @staticmethod
+ def executor(env):
+ lookup_scenario("MalformedMpUnReachNlri").boot(env)
+ lookup_scenario("MalformedMpUnReachNlri").setup(env)
+ lookup_scenario("MalformedMpUnReachNlri").check(env)
+
+
+@register_scenario
+class MalformedAsPath(object):
+ """
+ No.3 malformaed as-path
+ """
+
+ @staticmethod
+ def boot(env):
+ lookup_scenario("MalformedMpReachNlri").boot(env)
+
+ @staticmethod
+ def setup(env):
+ g1 = env.g1
+ e1 = env.e1
+ e2 = env.e2
+ for c in [e1, e2]:
+ g1.wait_for(BGP_FSM_ESTABLISHED, c)
+
+ # advertise malformed AS_PATH
+ # Send the attribute to the length and number of aspath is inconsistent
+ # Attribute Type 0x02 (AS_PATH)
+ # Attribute Flag 0x40 (well-known transitive)
+ # Attribute Value 0x02020000ffdc (
+ # segment type = 02
+ # segment length = 02 -> # correct value = 01
+ # as number = 65500 )
+ e1.add_route('10.7.0.17/32', attribute='0x02 0x60 0x11223344')
+
+ @staticmethod
+ def check(env):
+ g1 = env.g1
+ e1 = env.e1
+ e2 = env.e2
+ def f():
+ for line in e1.log().split('\n'):
+ if 'UPDATE message error / Attribute Flags Error / 0x60020411223344' in line:
+ return True
+ return False
+ wait_for(f)
+ # check e2 is still established
+ g1.wait_for(BGP_FSM_ESTABLISHED, e2)
+
+ @staticmethod
+ def executor(env):
+ lookup_scenario("MalformedAsPath").boot(env)
+ lookup_scenario("MalformedAsPath").setup(env)
+ lookup_scenario("MalformedAsPath").check(env)
+
+
+@register_scenario
+class MalformedAs4Path(object):
+ """
+ No.4 malformaed as4-path
+ """
+
+ @staticmethod
+ def boot(env):
+ lookup_scenario("MalformedMpReachNlri").boot(env)
+
+ @staticmethod
+ def setup(env):
+ g1 = env.g1
+ e1 = env.e1
+ e2 = env.e2
+ for c in [e1, e2]:
+ g1.wait_for(BGP_FSM_ESTABLISHED, c)
+
+ # advertise malformed AS4_PATH
+ e1.add_route('10.7.0.17/32', attribute='0x11 0x60 0x11223344')
+
+ @staticmethod
+ def check(env):
+ g1 = env.g1
+ e1 = env.e1
+ e2 = env.e2
+ def f():
+ for line in e1.log().split('\n'):
+ if 'UPDATE message error / Attribute Flags Error / 0x60110411223344' in line:
+ return True
+ return False
+ wait_for(f)
+ # check e2 is still established
+ g1.wait_for(BGP_FSM_ESTABLISHED, e2)
+
+ @staticmethod
+ def executor(env):
+ lookup_scenario("MalformedAs4Path").boot(env)
+ lookup_scenario("MalformedAs4Path").setup(env)
+ lookup_scenario("MalformedAs4Path").check(env)
+
+
+@register_scenario
+class MalformedNexthop(object):
+ """
+ No.5 malformaed nexthop
+ """
+
+ @staticmethod
+ def boot(env):
+ lookup_scenario("MalformedMpReachNlri").boot(env)
+
+ @staticmethod
+ def setup(env):
+ g1 = env.g1
+ e1 = env.e1
+ e2 = env.e2
+ for c in [e1, e2]:
+ g1.wait_for(BGP_FSM_ESTABLISHED, c)
+
+ # advertise malformed NEXT_HOP
+ # 0x0e: MP_REACH_NLRI
+ # 0x60: Optional, Transitive
+ # 0x01: AFI(IPv4)
+ # 0x01: SAFI(unicast)
+ # 0x10: Length of Next Hop Address
+ # 0xffffff00: Network address of Next Hop
+ # 0x00: Reserved
+ e1.add_route('10.7.0.17/32', attribute='0x0e 0x60 0x010110ffffff0000')
+
+ @staticmethod
+ def check(env):
+ g1 = env.g1
+ e1 = env.e1
+ e2 = env.e2
+ def f():
+ for line in e1.log().split('\n'):
+ if 'UPDATE message error / Attribute Flags Error / 0x600E08010110FFFFFF0000' in line:
+ return True
+ return False
+ wait_for(f)
+ # check e2 is still established
+ g1.wait_for(BGP_FSM_ESTABLISHED, e2)
+
+ @staticmethod
+ def executor(env):
+ lookup_scenario("MalformedNexthop").boot(env)
+ lookup_scenario("MalformedNexthop").setup(env)
+ lookup_scenario("MalformedNexthop").check(env)
+
+
+@register_scenario
+class MalformedRouteFamily(object):
+ """
+ No.6 malformaed route family
+ """
+
+ @staticmethod
+ def boot(env):
+ lookup_scenario("MalformedMpReachNlri").boot(env)
+
+ @staticmethod
+ def setup(env):
+ g1 = env.g1
+ e1 = env.e1
+ e2 = env.e2
+ for c in [e1, e2]:
+ g1.wait_for(BGP_FSM_ESTABLISHED, c)
+
+ # advertise malformed ROUTE_FAMILY
+ # 0x0e: MP_REACH_NLRI
+ # 0x60: Optional, Transitive
+ # 0x01: AFI(IPv4)
+ # 0x01: SAFI(unicast)
+ # 0x10: Length of Next Hop Address
+ # 0xffffff00: Network address of Next Hop
+ # 0x00: Reserved
+ e1.add_route('10.7.0.17/32', attribute='0x0e 0x60 0x0002011020010db800000000000000000000000100')
+
+ @staticmethod
+ def check(env):
+ g1 = env.g1
+ e1 = env.e1
+ e2 = env.e2
+ def f():
+ for line in e1.log().split('\n'):
+ if 'UPDATE message error / Attribute Flags Error / 0x600E150002011020010DB800000000000000000000000100' in line:
+ return True
+ return False
+ wait_for(f)
+ # check e2 is still established
+ g1.wait_for(BGP_FSM_ESTABLISHED, e2)
+
+ @staticmethod
+ def executor(env):
+ lookup_scenario("MalformedRouteFamily").boot(env)
+ lookup_scenario("MalformedRouteFamily").setup(env)
+ lookup_scenario("MalformedRouteFamily").check(env)
+
+
+@register_scenario
+class MalformedAsPathSegmentLengthInvalid(object):
+ """
+ No.7 malformaed aspath segment length invalid
+ """
+
+ @staticmethod
+ def boot(env):
+ lookup_scenario("MalformedMpReachNlri").boot(env)
+
+ @staticmethod
+ def setup(env):
+ g1 = env.g1
+ e1 = env.e1
+ e2 = env.e2
+ for c in [e1, e2]:
+ g1.wait_for(BGP_FSM_ESTABLISHED, c)
+
+ # advertise malformed AS_PATH SEGMENT LENGTH
+ # Send the attribute to the length and number of aspath is inconsistent
+ # Attribute Type 0x02 (AS_PATH)
+ # Attribute Flag 0x40 (well-known transitive)
+ # Attribute Value 0x02020000ffdc (
+ # segment type = 02
+ # segment length = 02 -> # correct value = 01
+ # as number = 65500 )
+ e1.add_route('10.7.0.17/32', attribute='0x02 0x40 0x0202ffdc')
+
+ @staticmethod
+ def check(env):
+ g1 = env.g1
+ e1 = env.e1
+ e2 = env.e2
+ def f():
+ for line in e1.log().split('\n'):
+ if 'UPDATE message error / Malformed AS_PATH / 0x4002040202FFDC' in line:
+ return True
+ return False
+ wait_for(f)
+ # check e2 is still established
+ g1.wait_for(BGP_FSM_ESTABLISHED, e2)
+
+ @staticmethod
+ def executor(env):
+ lookup_scenario("MalformedAsPathSegmentLengthInvalid").boot(env)
+ lookup_scenario("MalformedAsPathSegmentLengthInvalid").setup(env)
+ lookup_scenario("MalformedAsPathSegmentLengthInvalid").check(env)
+
+
+@register_scenario
+class MalformedNexthopLoopbackAddr(object):
+ """
+ No.8 malformaed nexthop loopback addr
+ """
+
+ @staticmethod
+ def boot(env):
+ lookup_scenario("MalformedMpReachNlri").boot(env)
+
+ @staticmethod
+ def setup(env):
+ g1 = env.g1
+ e1 = env.e1
+ e2 = env.e2
+ for c in [e1, e2]:
+ g1.wait_for(BGP_FSM_ESTABLISHED, c)
+
+ # Malformed Invalid NEXT_HOP Attribute
+ # Send the attribute of invalid nexthop
+ # next-hop 127.0.0.1 -> # correct value = other than loopback and 0.0.0.0 address
+ e1.add_route('10.7.0.17/32', nexthop='127.0.0.1')
+
+ @staticmethod
+ def check(env):
+ g1 = env.g1
+ e1 = env.e1
+ e2 = env.e2
+ def f():
+ for line in e1.log().split('\n'):
+ if 'UPDATE message error / Invalid NEXT_HOP Attribute / 0x4003047F000001' in line:
+ return True
+ return False
+ wait_for(f)
+ # check e2 is still established
+ g1.wait_for(BGP_FSM_ESTABLISHED, e2)
+
+ @staticmethod
+ def executor(env):
+ lookup_scenario("MalformedNexthopLoopbackAddr").boot(env)
+ lookup_scenario("MalformedNexthopLoopbackAddr").setup(env)
+ lookup_scenario("MalformedNexthopLoopbackAddr").check(env)
+
+
+@register_scenario
+class MalformedOriginType(object):
+ """
+ No.9 malformaed origin type
+ """
+
+ @staticmethod
+ def boot(env):
+ lookup_scenario("MalformedMpReachNlri").boot(env)
+
+ @staticmethod
+ def setup(env):
+ g1 = env.g1
+ e1 = env.e1
+ e2 = env.e2
+ for c in [e1, e2]:
+ g1.wait_for(BGP_FSM_ESTABLISHED, c)
+
+ # Invalid ORIGIN Attribute
+ # Send the attribute of origin type 4
+ # Attribute Type 0x01 (Origin)
+ # Attribute Flag 0x40 (well-known transitive)
+ # Attribute Value 0x04 (
+ # origin type = 04 -> # correct value = 01 or 02 or 03 )
+ e1.add_route('10.7.0.17/32', attribute='0x1 0x40 0x04')
+
+ @staticmethod
+ def check(env):
+ g1 = env.g1
+ e1 = env.e1
+ e2 = env.e2
+ def f():
+ for line in e1.log().split('\n'):
+ if 'UPDATE message error / Invalid ORIGIN Attribute / 0x40010104' in line:
+ return True
+ return False
+ wait_for(f)
+ # check e2 is still established
+ g1.wait_for(BGP_FSM_ESTABLISHED, e2)
+
+ @staticmethod
+ def executor(env):
+ lookup_scenario("MalformedOriginType").boot(env)
+ lookup_scenario("MalformedOriginType").setup(env)
+ lookup_scenario("MalformedOriginType").check(env)
+
+
+class TestGoBGPBase():
wait_per_retry = 5
retry_limit = 10
@@ -404,31 +499,28 @@ class GoBGPTestBase(unittest.TestCase):
idx = parser_option.test_index
base.TEST_PREFIX = parser_option.test_prefix
cls.parser_option = parser_option
-
- if idx not in scenarios:
- print 'invalid test-index. # of scenarios: {0}'.format(len(scenarios))
+ cls.executors = []
+ if idx == 0:
+ print 'unset test-index. run all test sequential'
+ for _, v in _SCENARIOS.items():
+ for k, m in inspect.getmembers(v, inspect.isfunction):
+ if k == 'executor':
+ cls.executor = m
+ cls.executors.append(cls.executor)
+ elif idx not in _SCENARIOS:
+ print 'invalid test-index. # of scenarios: {0}'.format(len(_SCENARIOS))
sys.exit(1)
-
- cls.boot = scenarios[idx]['boot']
- cls.setup = scenarios[idx]['setup']
- cls.check = scenarios[idx]['check']
- cls.setup2 = scenarios[idx]['setup2'] if 'setup2' in scenarios[idx] else None
- cls.check2 = scenarios[idx]['check2'] if 'check2' in scenarios[idx] else None
+ else:
+ for k, m in inspect.getmembers(_SCENARIOS[idx], inspect.isfunction):
+ if k == 'executor':
+ cls.executor = m
+ cls.executors.append(cls.executor)
def test(self):
+ for e in self.executors:
+ yield e
- self.boot()
-
- self.setup()
-
- self.check()
-
- if self.setup2:
- self.setup2()
-
- if self.check2:
- self.check2()
-
+
if __name__ == '__main__':
if os.geteuid() is not 0:
print "you are not root."
diff --git a/test/scenario_test/route_server_policy_grpc_test.py b/test/scenario_test/route_server_policy_grpc_test.py
index 1d3a67e7..0e108154 100644
--- a/test/scenario_test/route_server_policy_grpc_test.py
+++ b/test/scenario_test/route_server_policy_grpc_test.py
@@ -24,6 +24,7 @@ import os
import time
import nose
import inspect
+from nose.tools import *
from noseplugin import OptionParser, parser_option
@@ -124,6 +125,12 @@ class ImportPolicy(object):
wait_for(lambda: len(env.g1.get_adj_rib_out(env.q2)) == 1)
wait_for(lambda: len(env.q2.get_global_rib()) == 1)
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ImportPolicy").boot(env)
+ lookup_scenario("ImportPolicy").setup(env)
+ lookup_scenario("ImportPolicy").check(env)
+
@register_scenario
class ExportPolicy(object):
@@ -175,6 +182,12 @@ class ExportPolicy(object):
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("ExportPolicy").boot(env)
+ lookup_scenario("ExportPolicy").setup(env)
+ lookup_scenario("ExportPolicy").check(env)
+
@register_scenario
class ImportPolicyUpdate(object):
@@ -267,6 +280,14 @@ class ImportPolicyUpdate(object):
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("ImportPolicyUpdate").boot(env)
+ lookup_scenario("ImportPolicyUpdate").setup(env)
+ lookup_scenario("ImportPolicyUpdate").check(env)
+ lookup_scenario("ImportPolicyUpdate").setup2(env)
+ lookup_scenario("ImportPolicyUpdate").check2(env)
+
@register_scenario
class ExportPolicyUpdate(object):
@@ -363,6 +384,13 @@ class ExportPolicyUpdate(object):
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("ExportPolicyUpdate").boot(env)
+ lookup_scenario("ExportPolicyUpdate").setup(env)
+ lookup_scenario("ExportPolicyUpdate").check(env)
+ lookup_scenario("ExportPolicyUpdate").setup2(env)
+ lookup_scenario("ExportPolicyUpdate").check2(env)
@register_scenario
class ExportPolicyUpdateRouteRefresh(object):
@@ -421,6 +449,13 @@ class ExportPolicyUpdateRouteRefresh(object):
def check2(env):
lookup_scenario("ExportPolicyUpdate").check2(env)
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ExportPolicyUpdateRouteRefresh").boot(env)
+ lookup_scenario("ExportPolicyUpdateRouteRefresh").setup(env)
+ lookup_scenario("ExportPolicyUpdateRouteRefresh").check(env)
+ lookup_scenario("ExportPolicyUpdateRouteRefresh").setup2(env)
+ lookup_scenario("ExportPolicyUpdateRouteRefresh").check2(env)
@register_scenario
class ImportPolicyIPV6(object):
@@ -495,6 +530,12 @@ class ImportPolicyIPV6(object):
wait_for(lambda: len(env.g1.get_adj_rib_out(env.q2, rf='ipv6')) == 1)
wait_for(lambda: len(env.q2.get_global_rib(rf='ipv6')) == 1)
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ImportPolicyIPV6").boot(env)
+ lookup_scenario("ImportPolicyIPV6").setup(env)
+ lookup_scenario("ImportPolicyIPV6").check(env)
+
@register_scenario
class ExportPolicyIPV6(object):
@@ -546,6 +587,12 @@ class ExportPolicyIPV6(object):
wait_for(lambda: len(env.g1.get_adj_rib_out(env.q2, rf='ipv6')) == 1)
wait_for(lambda: len(env.q2.get_global_rib(rf='ipv6')) == 1)
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ExportPolicyIPV6").boot(env)
+ lookup_scenario("ExportPolicyIPV6").setup(env)
+ lookup_scenario("ExportPolicyIPV6").check(env)
+
@register_scenario
class ImportPolicyIPV6Update(object):
@@ -629,6 +676,14 @@ class ImportPolicyIPV6Update(object):
wait_for(lambda: len(env.g1.get_adj_rib_out(env.q2, rf='ipv6')) == 2)
wait_for(lambda: len(env.q2.get_global_rib(rf='ipv6')) == 2)
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ImportPolicyIPV6Update").boot(env)
+ lookup_scenario("ImportPolicyIPV6Update").setup(env)
+ lookup_scenario("ImportPolicyIPV6Update").check(env)
+ lookup_scenario("ImportPolicyIPV6Update").setup2(env)
+ lookup_scenario("ImportPolicyIPV6Update").check2(env)
+
@register_scenario
class ExportPolicyIPv6Update(object):
@@ -715,6 +770,14 @@ class ExportPolicyIPv6Update(object):
wait_for(lambda: len(env.g1.get_adj_rib_out(env.q2, rf='ipv6')) == 2)
wait_for(lambda: len(env.q2.get_global_rib(rf='ipv6')) == 2)
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ExportPolicyIPv6Update").boot(env)
+ lookup_scenario("ExportPolicyIPv6Update").setup(env)
+ lookup_scenario("ExportPolicyIPv6Update").check(env)
+ lookup_scenario("ExportPolicyIPv6Update").setup2(env)
+ lookup_scenario("ExportPolicyIPv6Update").check2(env)
+
@register_scenario
class ImportPolicyAsPathLengthCondition(object):
@@ -764,6 +827,12 @@ class ImportPolicyAsPathLengthCondition(object):
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("ImportPolicyAsPathLengthCondition").boot(env)
+ lookup_scenario("ImportPolicyAsPathLengthCondition").setup(env)
+ lookup_scenario("ImportPolicyAsPathLengthCondition").check(env)
+
@register_scenario
class ImportPolicyAsPathCondition(object):
@@ -806,6 +875,12 @@ class ImportPolicyAsPathCondition(object):
# same check function as previous No.1 scenario
lookup_scenario("ImportPolicy").check(env)
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ImportPolicyAsPathCondition").boot(env)
+ lookup_scenario("ImportPolicyAsPathCondition").setup(env)
+ lookup_scenario("ImportPolicyAsPathCondition").check(env)
+
@register_scenario
class ImportPolicyAsPathAnyCondition(object):
@@ -848,6 +923,12 @@ class ImportPolicyAsPathAnyCondition(object):
# same check function as previous No.1 scenario
lookup_scenario("ImportPolicy").check(env)
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ImportPolicyAsPathAnyCondition").boot(env)
+ lookup_scenario("ImportPolicyAsPathAnyCondition").setup(env)
+ lookup_scenario("ImportPolicyAsPathAnyCondition").check(env)
+
@register_scenario
class ImportPolicyAsPathOriginCondition(object):
@@ -890,6 +971,12 @@ class ImportPolicyAsPathOriginCondition(object):
# same check function as previous No.1 scenario
lookup_scenario("ImportPolicy").check(env)
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ImportPolicyAsPathOriginCondition").boot(env)
+ lookup_scenario("ImportPolicyAsPathOriginCondition").setup(env)
+ lookup_scenario("ImportPolicyAsPathOriginCondition").check(env)
+
@register_scenario
class ImportPolicyAsPathOnlyCondition(object):
@@ -932,6 +1019,12 @@ class ImportPolicyAsPathOnlyCondition(object):
# same check function as previous No.1 scenario
lookup_scenario("ImportPolicy").check(env)
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ImportPolicyAsPathOnlyCondition").boot(env)
+ lookup_scenario("ImportPolicyAsPathOnlyCondition").setup(env)
+ lookup_scenario("ImportPolicyAsPathOnlyCondition").check(env)
+
@register_scenario
class ImportPolicyAsPathMismatchCondition(object):
@@ -983,6 +1076,12 @@ class ImportPolicyAsPathMismatchCondition(object):
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("ImportPolicyAsPathMismatchCondition").boot(env)
+ lookup_scenario("ImportPolicyAsPathMismatchCondition").setup(env)
+ lookup_scenario("ImportPolicyAsPathMismatchCondition").check(env)
+
@register_scenario
class ImportPolicyCommunityCondition(object):
@@ -1026,6 +1125,12 @@ class ImportPolicyCommunityCondition(object):
def check(env):
lookup_scenario("ImportPolicy").check(env)
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ImportPolicyCommunityCondition").boot(env)
+ lookup_scenario("ImportPolicyCommunityCondition").setup(env)
+ lookup_scenario("ImportPolicyCommunityCondition").check(env)
+
@register_scenario
class ImportPolicyCommunityRegexp(object):
@@ -1066,6 +1171,12 @@ class ImportPolicyCommunityRegexp(object):
def check(env):
lookup_scenario("ImportPolicy").check(env)
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ImportPolicyCommunityRegexp").boot(env)
+ lookup_scenario("ImportPolicyCommunityRegexp").setup(env)
+ lookup_scenario("ImportPolicyCommunityRegexp").check(env)
+
def community_exists(path, com):
a, b = com.split(':')
@@ -1129,11 +1240,18 @@ class ImportPolicyCommunityAction(object):
q1 = env.q1
q2 = env.q2
path = g1.get_adj_rib_out(q1)[0]
- env.assertTrue(community_exists(path, '65100:10'))
- env.assertFalse(community_exists(path, '65100:20'))
+ assert_true(community_exists(path, '65100:10'))
+ assert_false(community_exists(path, '65100:20'))
path = g1.get_adj_rib_out(q2)[0]
- env.assertTrue(community_exists(path, '65100:10'))
- env.assertTrue(community_exists(path, '65100:20'))
+ assert_true(community_exists(path, '65100:10'))
+ assert_true(community_exists(path, '65100:20'))
+
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ImportPolicyCommunityAction").boot(env)
+ lookup_scenario("ImportPolicyCommunityAction").setup(env)
+ lookup_scenario("ImportPolicyCommunityAction").check(env)
+ lookup_scenario("ImportPolicyCommunityAction").check2(env)
@register_scenario
@@ -1184,11 +1302,18 @@ class ImportPolicyCommunityReplace(object):
q1 = env.q1
q2 = env.q2
path = g1.get_adj_rib_out(q1)[0]
- env.assertTrue(community_exists(path, '65100:10'))
- env.assertFalse(community_exists(path, '65100:20'))
+ assert_true(community_exists(path, '65100:10'))
+ assert_false(community_exists(path, '65100:20'))
path = g1.get_adj_rib_out(q2)[0]
- env.assertFalse(community_exists(path, '65100:10'))
- env.assertTrue(community_exists(path, '65100:20'))
+ assert_false(community_exists(path, '65100:10'))
+ assert_true(community_exists(path, '65100:20'))
+
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ImportPolicyCommunityReplace").boot(env)
+ lookup_scenario("ImportPolicyCommunityReplace").setup(env)
+ lookup_scenario("ImportPolicyCommunityReplace").check(env)
+ lookup_scenario("ImportPolicyCommunityReplace").check2(env)
@register_scenario
@@ -1249,18 +1374,25 @@ class ImportPolicyCommunityRemove(object):
q2 = env.q2
adj_out = g1.get_adj_rib_out(q1)
for path in adj_out:
- env.assertTrue(community_exists(path, '65100:10'))
+ assert_true(community_exists(path, '65100:10'))
if path['nlri']['prefix'] == '192.168.110.0/24':
- env.assertTrue(community_exists(path, '65100:20'))
+ assert_true(community_exists(path, '65100:20'))
if path['nlri']['prefix'] == '192.168.120.0/24':
- env.assertTrue(community_exists(path, '65100:30'))
+ assert_true(community_exists(path, '65100:30'))
adj_out = g1.get_adj_rib_out(q2)
for path in adj_out:
- env.assertFalse(community_exists(path, '65100:10'))
+ assert_false(community_exists(path, '65100:10'))
if path['nlri']['prefix'] == '192.168.110.0/24':
- env.assertFalse(community_exists(path, '65100:20'))
+ assert_false(community_exists(path, '65100:20'))
if path['nlri']['prefix'] == '192.168.120.0/24':
- env.assertTrue(community_exists(path, '65100:30'))
+ assert_true(community_exists(path, '65100:30'))
+
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ImportPolicyCommunityRemove").boot(env)
+ lookup_scenario("ImportPolicyCommunityRemove").setup(env)
+ lookup_scenario("ImportPolicyCommunityRemove").check(env)
+ lookup_scenario("ImportPolicyCommunityRemove").check2(env)
@register_scenario
@@ -1310,18 +1442,25 @@ class ImportPolicyCommunityNull(object):
q2 = env.q2
adj_out = g1.get_adj_rib_out(q1)
for path in adj_out:
- env.assertTrue(community_exists(path, '65100:10'))
+ assert_true(community_exists(path, '65100:10'))
if path['nlri']['prefix'] == '192.168.110.0/24':
- env.assertTrue(community_exists(path, '65100:20'))
+ assert_true(community_exists(path, '65100:20'))
if path['nlri']['prefix'] == '192.168.120.0/24':
- env.assertTrue(community_exists(path, '65100:30'))
+ assert_true(community_exists(path, '65100:30'))
adj_out = g1.get_adj_rib_out(q2)
for path in adj_out:
- env.assertFalse(community_exists(path, '65100:10'))
+ assert_false(community_exists(path, '65100:10'))
if path['nlri']['prefix'] == '192.168.110.0/24':
- env.assertFalse(community_exists(path, '65100:20'))
+ assert_false(community_exists(path, '65100:20'))
if path['nlri']['prefix'] == '192.168.120.0/24':
- env.assertFalse(community_exists(path, '65100:30'))
+ assert_false(community_exists(path, '65100:30'))
+
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ImportPolicyCommunityNull").boot(env)
+ lookup_scenario("ImportPolicyCommunityNull").setup(env)
+ lookup_scenario("ImportPolicyCommunityNull").check(env)
+ lookup_scenario("ImportPolicyCommunityNull").check2(env)
@register_scenario
@@ -1371,18 +1510,25 @@ class ExportPolicyCommunityAdd(object):
adj_out = g1.get_adj_rib_out(q1)
for path in adj_out:
- env.assertTrue(community_exists(path, '65100:10'))
- env.assertFalse(community_exists(path, '65100:20'))
+ assert_true(community_exists(path, '65100:10'))
+ assert_false(community_exists(path, '65100:20'))
local_rib = g1.get_local_rib(q2)
for path in local_rib[0]['paths']:
- env.assertTrue(community_exists(path, '65100:10'))
- env.assertFalse(community_exists(path, '65100:20'))
+ assert_true(community_exists(path, '65100:10'))
+ assert_false(community_exists(path, '65100:20'))
adj_out = g1.get_adj_rib_out(q2)
for path in adj_out:
- env.assertTrue(community_exists(path, '65100:10'))
- env.assertTrue(community_exists(path, '65100:20'))
+ assert_true(community_exists(path, '65100:10'))
+ assert_true(community_exists(path, '65100:20'))
+
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ExportPolicyCommunityAdd").boot(env)
+ lookup_scenario("ExportPolicyCommunityAdd").setup(env)
+ lookup_scenario("ExportPolicyCommunityAdd").check(env)
+ lookup_scenario("ExportPolicyCommunityAdd").check2(env)
@register_scenario
@@ -1432,18 +1578,25 @@ class ExportPolicyCommunityReplace(object):
adj_out = g1.get_adj_rib_out(q1)
for path in adj_out:
- env.assertTrue(community_exists(path, '65100:10'))
- env.assertFalse(community_exists(path, '65100:20'))
+ assert_true(community_exists(path, '65100:10'))
+ assert_false(community_exists(path, '65100:20'))
local_rib = g1.get_local_rib(q2)
for path in local_rib[0]['paths']:
- env.assertTrue(community_exists(path, '65100:10'))
- env.assertFalse(community_exists(path, '65100:20'))
+ assert_true(community_exists(path, '65100:10'))
+ assert_false(community_exists(path, '65100:20'))
adj_out = g1.get_adj_rib_out(q2)
for path in adj_out:
- env.assertFalse(community_exists(path, '65100:10'))
- env.assertTrue(community_exists(path, '65100:20'))
+ assert_false(community_exists(path, '65100:10'))
+ assert_true(community_exists(path, '65100:20'))
+
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ExportPolicyCommunityReplace").boot(env)
+ lookup_scenario("ExportPolicyCommunityReplace").setup(env)
+ lookup_scenario("ExportPolicyCommunityReplace").check(env)
+ lookup_scenario("ExportPolicyCommunityReplace").check2(env)
@register_scenario
@@ -1493,21 +1646,28 @@ class ExportPolicyCommunityRemove(object):
adj_out = g1.get_adj_rib_out(q1)
for path in adj_out:
- env.assertTrue(community_exists(path, '65100:10'))
- env.assertTrue(community_exists(path, '65100:20'))
- env.assertTrue(community_exists(path, '65100:30'))
+ assert_true(community_exists(path, '65100:10'))
+ assert_true(community_exists(path, '65100:20'))
+ assert_true(community_exists(path, '65100:30'))
local_rib = g1.get_local_rib(q2)
for path in local_rib[0]['paths']:
- env.assertTrue(community_exists(path, '65100:10'))
- env.assertTrue(community_exists(path, '65100:20'))
- env.assertTrue(community_exists(path, '65100:30'))
+ assert_true(community_exists(path, '65100:10'))
+ assert_true(community_exists(path, '65100:20'))
+ assert_true(community_exists(path, '65100:30'))
adj_out = g1.get_adj_rib_out(q2)
for path in adj_out:
- env.assertTrue(community_exists(path, '65100:10'))
- env.assertFalse(community_exists(path, '65100:20'))
- env.assertFalse(community_exists(path, '65100:30'))
+ assert_true(community_exists(path, '65100:10'))
+ assert_false(community_exists(path, '65100:20'))
+ assert_false(community_exists(path, '65100:30'))
+
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ExportPolicyCommunityRemove").boot(env)
+ lookup_scenario("ExportPolicyCommunityRemove").setup(env)
+ lookup_scenario("ExportPolicyCommunityRemove").check(env)
+ lookup_scenario("ExportPolicyCommunityRemove").check2(env)
@register_scenario
@@ -1557,21 +1717,29 @@ class ExportPolicyCommunityNull(object):
adj_out = g1.get_adj_rib_out(q1)
for path in adj_out:
- env.assertTrue(community_exists(path, '65100:10'))
- env.assertTrue(community_exists(path, '65100:20'))
- env.assertTrue(community_exists(path, '65100:30'))
+ assert_true(community_exists(path, '65100:10'))
+ assert_true(community_exists(path, '65100:20'))
+ assert_true(community_exists(path, '65100:30'))
local_rib = g1.get_local_rib(q2)
for path in local_rib[0]['paths']:
- env.assertTrue(community_exists(path, '65100:10'))
- env.assertTrue(community_exists(path, '65100:20'))
- env.assertTrue(community_exists(path, '65100:30'))
+ assert_true(community_exists(path, '65100:10'))
+ assert_true(community_exists(path, '65100:20'))
+ assert_true(community_exists(path, '65100:30'))
adj_out = g1.get_adj_rib_out(q2)
for path in adj_out:
- env.assertFalse(community_exists(path, '65100:10'))
- env.assertFalse(community_exists(path, '65100:20'))
- env.assertFalse(community_exists(path, '65100:30'))
+ assert_false(community_exists(path, '65100:10'))
+ assert_false(community_exists(path, '65100:20'))
+ assert_false(community_exists(path, '65100:30'))
+
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ExportPolicyCommunityNull").boot(env)
+ lookup_scenario("ExportPolicyCommunityNull").setup(env)
+ lookup_scenario("ExportPolicyCommunityNull").check(env)
+ lookup_scenario("ExportPolicyCommunityNull").check2(env)
+
def metric(path):
for a in path['attrs']:
@@ -1624,13 +1792,20 @@ class ImportPolicyMedReplace(object):
q2 = env.q2
adj_out = g1.get_adj_rib_out(q1)
- env.assertTrue(metric(adj_out[0]) == 300)
+ assert_true(metric(adj_out[0]) == 300)
local_rib = g1.get_local_rib(q2)
- env.assertTrue(metric(local_rib[0]['paths'][0]) == 100)
+ assert_true(metric(local_rib[0]['paths'][0]) == 100)
adj_out = g1.get_adj_rib_out(q2)
- env.assertTrue(metric(adj_out[0]) == 100)
+ assert_true(metric(adj_out[0]) == 100)
+
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ImportPolicyMedReplace").boot(env)
+ lookup_scenario("ImportPolicyMedReplace").setup(env)
+ lookup_scenario("ImportPolicyMedReplace").check(env)
+ lookup_scenario("ImportPolicyMedReplace").check2(env)
@register_scenario
@@ -1677,13 +1852,20 @@ class ImportPolicyMedAdd(object):
q2 = env.q2
adj_out = g1.get_adj_rib_out(q1)
- env.assertTrue(metric(adj_out[0]) == 300)
+ assert_true(metric(adj_out[0]) == 300)
local_rib = g1.get_local_rib(q2)
- env.assertTrue(metric(local_rib[0]['paths'][0]) == 400)
+ assert_true(metric(local_rib[0]['paths'][0]) == 400)
adj_out = g1.get_adj_rib_out(q2)
- env.assertTrue(metric(adj_out[0]) == 400)
+ assert_true(metric(adj_out[0]) == 400)
+
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ImportPolicyMedAdd").boot(env)
+ lookup_scenario("ImportPolicyMedAdd").setup(env)
+ lookup_scenario("ImportPolicyMedAdd").check(env)
+ lookup_scenario("ImportPolicyMedAdd").check2(env)
@register_scenario
@@ -1730,13 +1912,20 @@ class ImportPolicyMedSub(object):
q2 = env.q2
adj_out = g1.get_adj_rib_out(q1)
- env.assertTrue(metric(adj_out[0]) == 300)
+ assert_true(metric(adj_out[0]) == 300)
local_rib = g1.get_local_rib(q2)
- env.assertTrue(metric(local_rib[0]['paths'][0]) == 200)
+ assert_true(metric(local_rib[0]['paths'][0]) == 200)
adj_out = g1.get_adj_rib_out(q2)
- env.assertTrue(metric(adj_out[0]) == 200)
+ assert_true(metric(adj_out[0]) == 200)
+
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ImportPolicyMedSub").boot(env)
+ lookup_scenario("ImportPolicyMedSub").setup(env)
+ lookup_scenario("ImportPolicyMedSub").check(env)
+ lookup_scenario("ImportPolicyMedSub").check2(env)
@register_scenario
@@ -1783,13 +1972,20 @@ class ExportPolicyMedReplace(object):
q2 = env.q2
adj_out = g1.get_adj_rib_out(q1)
- env.assertTrue(metric(adj_out[0]) == 300)
+ assert_true(metric(adj_out[0]) == 300)
local_rib = g1.get_local_rib(q2)
- env.assertTrue(metric(local_rib[0]['paths'][0]) == 300)
+ assert_true(metric(local_rib[0]['paths'][0]) == 300)
adj_out = g1.get_adj_rib_out(q2)
- env.assertTrue(metric(adj_out[0]) == 100)
+ assert_true(metric(adj_out[0]) == 100)
+
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ExportPolicyMedReplace").boot(env)
+ lookup_scenario("ExportPolicyMedReplace").setup(env)
+ lookup_scenario("ExportPolicyMedReplace").check(env)
+ lookup_scenario("ExportPolicyMedReplace").check2(env)
@register_scenario
@@ -1836,13 +2032,20 @@ class ExportPolicyMedAdd(object):
q2 = env.q2
adj_out = g1.get_adj_rib_out(q1)
- env.assertTrue(metric(adj_out[0]) == 300)
+ assert_true(metric(adj_out[0]) == 300)
local_rib = g1.get_local_rib(q2)
- env.assertTrue(metric(local_rib[0]['paths'][0]) == 300)
+ assert_true(metric(local_rib[0]['paths'][0]) == 300)
adj_out = g1.get_adj_rib_out(q2)
- env.assertTrue(metric(adj_out[0]) == 400)
+ assert_true(metric(adj_out[0]) == 400)
+
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ExportPolicyMedAdd").boot(env)
+ lookup_scenario("ExportPolicyMedAdd").setup(env)
+ lookup_scenario("ExportPolicyMedAdd").check(env)
+ lookup_scenario("ExportPolicyMedAdd").check2(env)
@register_scenario
@@ -1889,13 +2092,20 @@ class ExportPolicyMedSub(object):
q2 = env.q2
adj_out = g1.get_adj_rib_out(q1)
- env.assertTrue(metric(adj_out[0]) == 300)
+ assert_true(metric(adj_out[0]) == 300)
local_rib = g1.get_local_rib(q2)
- env.assertTrue(metric(local_rib[0]['paths'][0]) == 300)
+ assert_true(metric(local_rib[0]['paths'][0]) == 300)
adj_out = g1.get_adj_rib_out(q2)
- env.assertTrue(metric(adj_out[0]) == 200)
+ assert_true(metric(adj_out[0]) == 200)
+
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ExportPolicyMedSub").boot(env)
+ lookup_scenario("ExportPolicyMedSub").setup(env)
+ lookup_scenario("ExportPolicyMedSub").check(env)
+ lookup_scenario("ExportPolicyMedSub").check2(env)
@register_scenario
@@ -1945,6 +2155,12 @@ class InPolicyReject(object):
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):
@@ -1983,6 +2199,12 @@ class InPolicyAccept(object):
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):
@@ -2076,6 +2298,14 @@ class InPolicyUpdate(object):
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):
@@ -2134,19 +2364,26 @@ class ExportPolicyAsPathPrepend(object):
q2 = env.q2
path = g1.get_adj_rib_out(q1, prefix='192.168.20.0/24')[0]
- env.assertTrue(path['aspath'] == [e1.asn])
+ assert_true(path['aspath'] == [e1.asn])
path = g1.get_adj_rib_out(q1, prefix='192.168.200.0/24')[0]
- env.assertTrue(path['aspath'] == [e1.asn])
+ assert_true(path['aspath'] == [e1.asn])
path = g1.get_local_rib(q2, prefix='192.168.20.0/24')[0]['paths'][0]
- env.assertTrue(path['aspath'] == [e1.asn])
+ assert_true(path['aspath'] == [e1.asn])
path = g1.get_adj_rib_out(q2, prefix='192.168.20.0/24')[0]
- env.assertTrue(path['aspath'] == [65005]*5 + [e1.asn])
+ assert_true(path['aspath'] == [65005]*5 + [e1.asn])
path = g1.get_adj_rib_out(q2, prefix='192.168.200.0/24')[0]
- env.assertTrue(path['aspath'] == [e1.asn])
+ assert_true(path['aspath'] == [e1.asn])
+
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ExportPolicyAsPathPrepend").boot(env)
+ lookup_scenario("ExportPolicyAsPathPrepend").setup(env)
+ lookup_scenario("ExportPolicyAsPathPrepend").check(env)
+ lookup_scenario("ExportPolicyAsPathPrepend").check2(env)
@register_scenario
@@ -2196,19 +2433,26 @@ class ImportPolicyAsPathPrependLastAS(object):
q2 = env.q2
path = g1.get_adj_rib_out(q1, prefix='192.168.20.0/24')[0]
- env.assertTrue(path['aspath'] == [e1.asn])
+ assert_true(path['aspath'] == [e1.asn])
path = g1.get_adj_rib_out(q1, prefix='192.168.200.0/24')[0]
- env.assertTrue(path['aspath'] == [e1.asn])
+ assert_true(path['aspath'] == [e1.asn])
path = g1.get_local_rib(q2, prefix='192.168.20.0/24')[0]['paths'][0]
- env.assertTrue(path['aspath'] == [e1.asn]*5 + [e1.asn])
+ assert_true(path['aspath'] == [e1.asn]*5 + [e1.asn])
path = g1.get_adj_rib_out(q2, prefix='192.168.20.0/24')[0]
- env.assertTrue(path['aspath'] == [e1.asn]*5 + [e1.asn])
+ assert_true(path['aspath'] == [e1.asn]*5 + [e1.asn])
path = g1.get_adj_rib_out(q2, prefix='192.168.200.0/24')[0]
- env.assertTrue(path['aspath'] == [e1.asn])
+ assert_true(path['aspath'] == [e1.asn])
+
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ImportPolicyAsPathPrependLastAS").boot(env)
+ lookup_scenario("ImportPolicyAsPathPrependLastAS").setup(env)
+ lookup_scenario("ImportPolicyAsPathPrependLastAS").check(env)
+ lookup_scenario("ImportPolicyAsPathPrependLastAS").check2(env)
@register_scenario
@@ -2258,19 +2502,26 @@ class ExportPolicyAsPathPrependLastAS(object):
q2 = env.q2
path = g1.get_adj_rib_out(q1, prefix='192.168.20.0/24')[0]
- env.assertTrue(path['aspath'] == [e1.asn])
+ assert_true(path['aspath'] == [e1.asn])
path = g1.get_adj_rib_out(q1, prefix='192.168.200.0/24')[0]
- env.assertTrue(path['aspath'] == [e1.asn])
+ assert_true(path['aspath'] == [e1.asn])
path = g1.get_local_rib(q2, prefix='192.168.20.0/24')[0]['paths'][0]
- env.assertTrue(path['aspath'] == [e1.asn])
+ assert_true(path['aspath'] == [e1.asn])
path = g1.get_adj_rib_out(q2, prefix='192.168.20.0/24')[0]
- env.assertTrue(path['aspath'] == [e1.asn]*5 + [e1.asn])
+ assert_true(path['aspath'] == [e1.asn]*5 + [e1.asn])
path = g1.get_adj_rib_out(q2, prefix='192.168.200.0/24')[0]
- env.assertTrue(path['aspath'] == [e1.asn])
+ assert_true(path['aspath'] == [e1.asn])
+
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ExportPolicyAsPathPrependLastAS").boot(env)
+ lookup_scenario("ExportPolicyAsPathPrependLastAS").setup(env)
+ lookup_scenario("ExportPolicyAsPathPrependLastAS").check(env)
+ lookup_scenario("ExportPolicyAsPathPrependLastAS").check2(env)
@register_scenario
@@ -2310,6 +2561,12 @@ class ImportPolicyExCommunityOriginCondition(object):
def check(env):
lookup_scenario("ImportPolicy").check(env)
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ImportPolicyExCommunityOriginCondition").boot(env)
+ lookup_scenario("ImportPolicyExCommunityOriginCondition").setup(env)
+ lookup_scenario("ImportPolicyExCommunityOriginCondition").check(env)
+
@register_scenario
class ImportPolicyExCommunityTargetCondition(object):
@@ -2348,6 +2605,12 @@ class ImportPolicyExCommunityTargetCondition(object):
def check(env):
lookup_scenario("ImportPolicy").check(env)
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ImportPolicyExCommunityTargetCondition").boot(env)
+ lookup_scenario("ImportPolicyExCommunityTargetCondition").setup(env)
+ lookup_scenario("ImportPolicyExCommunityTargetCondition").check(env)
+
@register_scenario
class InPolicyPrefixCondition(object):
@@ -2388,6 +2651,12 @@ class InPolicyPrefixCondition(object):
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]
@@ -2445,10 +2714,16 @@ class ImportPolicyExCommunityAdd(object):
q1 = env.q1
q2 = env.q2
path = g1.get_adj_rib_out(q1)[0]
- env.assertFalse(ext_community_exists(path, 'RT:65000:1'))
+ assert_false(ext_community_exists(path, 'RT:65000:1'))
path = g1.get_adj_rib_out(q2)[0]
- env.assertTrue(ext_community_exists(path, 'RT:65000:1'))
+ assert_true(ext_community_exists(path, 'RT:65000:1'))
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ImportPolicyExCommunityAdd").boot(env)
+ lookup_scenario("ImportPolicyExCommunityAdd").setup(env)
+ lookup_scenario("ImportPolicyExCommunityAdd").check(env)
+ lookup_scenario("ImportPolicyExCommunityAdd").check2(env)
@register_scenario
class ImportPolicyExCommunityAdd2(object):
@@ -2495,14 +2770,21 @@ class ImportPolicyExCommunityAdd2(object):
q1 = env.q1
q2 = env.q2
path = g1.get_adj_rib_out(q1)[0]
- env.assertTrue(ext_community_exists(path, 'RT:65000:1'))
- env.assertFalse(ext_community_exists(path, 'RT:65100:100'))
+ assert_true(ext_community_exists(path, 'RT:65000:1'))
+ assert_false(ext_community_exists(path, 'RT:65100:100'))
path = g1.get_local_rib(q2)[0]['paths'][0]
- env.assertTrue(ext_community_exists(path, 'RT:65000:1'))
- env.assertTrue(ext_community_exists(path, 'RT:65100:100'))
+ assert_true(ext_community_exists(path, 'RT:65000:1'))
+ assert_true(ext_community_exists(path, 'RT:65100:100'))
path = g1.get_adj_rib_out(q2)[0]
- env.assertTrue(ext_community_exists(path, 'RT:65000:1'))
- env.assertTrue(ext_community_exists(path, 'RT:65100:100'))
+ assert_true(ext_community_exists(path, 'RT:65000:1'))
+ assert_true(ext_community_exists(path, 'RT:65100:100'))
+
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ImportPolicyExCommunityAdd2").boot(env)
+ lookup_scenario("ImportPolicyExCommunityAdd2").setup(env)
+ lookup_scenario("ImportPolicyExCommunityAdd2").check(env)
+ lookup_scenario("ImportPolicyExCommunityAdd2").check2(env)
@register_scenario
@@ -2550,14 +2832,21 @@ class ImportPolicyExCommunityMultipleAdd(object):
q1 = env.q1
q2 = env.q2
path = g1.get_adj_rib_out(q1)[0]
- env.assertFalse(ext_community_exists(path, 'RT:65100:100'))
- env.assertFalse(ext_community_exists(path, 'RT:100:100'))
+ assert_false(ext_community_exists(path, 'RT:65100:100'))
+ assert_false(ext_community_exists(path, 'RT:100:100'))
path = g1.get_local_rib(q2)[0]['paths'][0]
- env.assertTrue(ext_community_exists(path, 'RT:65100:100'))
- env.assertTrue(ext_community_exists(path, 'RT:100:100'))
+ assert_true(ext_community_exists(path, 'RT:65100:100'))
+ assert_true(ext_community_exists(path, 'RT:100:100'))
path = g1.get_adj_rib_out(q2)[0]
- env.assertTrue(ext_community_exists(path, 'RT:65100:100'))
- env.assertTrue(ext_community_exists(path, 'RT:100:100'))
+ assert_true(ext_community_exists(path, 'RT:65100:100'))
+ assert_true(ext_community_exists(path, 'RT:100:100'))
+
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ImportPolicyExCommunityMultipleAdd").boot(env)
+ lookup_scenario("ImportPolicyExCommunityMultipleAdd").setup(env)
+ lookup_scenario("ImportPolicyExCommunityMultipleAdd").check(env)
+ lookup_scenario("ImportPolicyExCommunityMultipleAdd").check2(env)
@register_scenario
@@ -2605,14 +2894,21 @@ class ExportPolicyExCommunityAdd(object):
q1 = env.q1
q2 = env.q2
path = g1.get_adj_rib_out(q1)[0]
- env.assertFalse(ext_community_exists(path, 'RT:65000:1'))
+ assert_false(ext_community_exists(path, 'RT:65000:1'))
path = g1.get_local_rib(q2)[0]['paths'][0]
- env.assertFalse(ext_community_exists(path, 'RT:65000:1'))
+ assert_false(ext_community_exists(path, 'RT:65000:1'))
path = g1.get_adj_rib_out(q2)[0]
- env.assertTrue(ext_community_exists(path, 'RT:65000:1'))
+ assert_true(ext_community_exists(path, 'RT:65000:1'))
+
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ExportPolicyExCommunityAdd").boot(env)
+ lookup_scenario("ExportPolicyExCommunityAdd").setup(env)
+ lookup_scenario("ExportPolicyExCommunityAdd").check(env)
+ lookup_scenario("ExportPolicyExCommunityAdd").check2(env)
-class GoBGPTestBase(unittest.TestCase):
+class TestGoBGPBase():
wait_per_retry = 5
retry_limit = 10
@@ -2622,37 +2918,27 @@ class GoBGPTestBase(unittest.TestCase):
idx = parser_option.test_index
base.TEST_PREFIX = parser_option.test_prefix
cls.parser_option = parser_option
-
- if idx not in _SCENARIOS:
+ cls.executors = []
+ if idx == 0:
+ print 'unset test-index. run all test sequential'
+ for _, v in _SCENARIOS.items():
+ for k, m in inspect.getmembers(v, inspect.isfunction):
+ if k == 'executor':
+ cls.executor = m
+ cls.executors.append(cls.executor)
+ elif idx not in _SCENARIOS:
print 'invalid test-index. # of scenarios: {0}'.format(len(_SCENARIOS))
sys.exit(1)
-
- cls.setup2 = None
- cls.check2 = None
- for k, m in inspect.getmembers(_SCENARIOS[idx], inspect.isfunction):
- if k == 'boot':
- cls.boot = m
- elif k == 'setup':
- cls.setup = m
- elif k == 'check':
- cls.check = m
- elif k == 'setup2':
- cls.setup2 = m
- elif k == 'check2':
- cls.check2 = m
+ else:
+ for k, m in inspect.getmembers(_SCENARIOS[idx], inspect.isfunction):
+ if k == 'executor':
+ cls.executor = m
+ cls.executors.append(cls.executor)
def test(self):
- self.boot()
-
- self.setup()
-
- self.check()
-
- if self.setup2:
- self.setup2()
+ for e in self.executors:
+ yield e
- if self.check2:
- self.check2()
if __name__ == '__main__':
if os.geteuid() is not 0:
diff --git a/test/scenario_test/route_server_policy_test.py b/test/scenario_test/route_server_policy_test.py
index 1eb31f62..b2a4bc29 100644
--- a/test/scenario_test/route_server_policy_test.py
+++ b/test/scenario_test/route_server_policy_test.py
@@ -24,6 +24,7 @@ import os
import time
import nose
import inspect
+from nose.tools import *
from noseplugin import OptionParser, parser_option
@@ -139,6 +140,12 @@ class ImportPolicy(object):
wait_for(lambda: len(env.g1.get_adj_rib_out(env.q2)) == 1)
wait_for(lambda: len(env.q2.get_global_rib()) == 1)
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ImportPolicy").boot(env)
+ lookup_scenario("ImportPolicy").setup(env)
+ lookup_scenario("ImportPolicy").check(env)
+
@register_scenario
class ExportPolicy(object):
@@ -205,6 +212,12 @@ class ExportPolicy(object):
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("ExportPolicy").boot(env)
+ lookup_scenario("ExportPolicy").setup(env)
+ lookup_scenario("ExportPolicy").check(env)
+
@register_scenario
class ImportPolicyUpdate(object):
@@ -332,6 +345,14 @@ class ImportPolicyUpdate(object):
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("ImportPolicyUpdate").boot(env)
+ lookup_scenario("ImportPolicyUpdate").setup(env)
+ lookup_scenario("ImportPolicyUpdate").check(env)
+ lookup_scenario("ImportPolicyUpdate").setup2(env)
+ lookup_scenario("ImportPolicyUpdate").check2(env)
+
@register_scenario
class ExportPolicyUpdate(object):
@@ -462,6 +483,14 @@ class ExportPolicyUpdate(object):
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("ExportPolicyUpdate").boot(env)
+ lookup_scenario("ExportPolicyUpdate").setup(env)
+ lookup_scenario("ExportPolicyUpdate").check(env)
+ lookup_scenario("ExportPolicyUpdate").setup2(env)
+ lookup_scenario("ExportPolicyUpdate").check2(env)
+
@register_scenario
class ImportPolicyIPV6(object):
@@ -551,6 +580,12 @@ class ImportPolicyIPV6(object):
wait_for(lambda: len(env.g1.get_adj_rib_out(env.q2, rf='ipv6')) == 1)
wait_for(lambda: len(env.q2.get_global_rib(rf='ipv6')) == 1)
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ImportPolicyIPV6").boot(env)
+ lookup_scenario("ImportPolicyIPV6").setup(env)
+ lookup_scenario("ImportPolicyIPV6").check(env)
+
@register_scenario
class ExportPolicyIPV6(object):
@@ -617,6 +652,12 @@ class ExportPolicyIPV6(object):
wait_for(lambda: len(env.g1.get_adj_rib_out(env.q2, rf='ipv6')) == 1)
wait_for(lambda: len(env.q2.get_global_rib(rf='ipv6')) == 1)
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ExportPolicyIPV6").boot(env)
+ lookup_scenario("ExportPolicyIPV6").setup(env)
+ lookup_scenario("ExportPolicyIPV6").check(env)
+
@register_scenario
class ImportPolicyIPV6Update(object):
@@ -736,6 +777,14 @@ class ImportPolicyIPV6Update(object):
wait_for(lambda: len(env.g1.get_adj_rib_out(env.q2, rf='ipv6')) == 2)
wait_for(lambda: len(env.q2.get_global_rib(rf='ipv6')) == 2)
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ImportPolicyIPV6Update").boot(env)
+ lookup_scenario("ImportPolicyIPV6Update").setup(env)
+ lookup_scenario("ImportPolicyIPV6Update").check(env)
+ lookup_scenario("ImportPolicyIPV6Update").setup2(env)
+ lookup_scenario("ImportPolicyIPV6Update").check2(env)
+
@register_scenario
class ExportPolicyIPv6Update(object):
@@ -857,6 +906,14 @@ class ExportPolicyIPv6Update(object):
wait_for(lambda: len(env.g1.get_adj_rib_out(env.q2, rf='ipv6')) == 2)
wait_for(lambda: len(env.q2.get_global_rib(rf='ipv6')) == 2)
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ExportPolicyIPv6Update").boot(env)
+ lookup_scenario("ExportPolicyIPv6Update").setup(env)
+ lookup_scenario("ExportPolicyIPv6Update").check(env)
+ lookup_scenario("ExportPolicyIPv6Update").setup2(env)
+ lookup_scenario("ExportPolicyIPv6Update").check2(env)
+
@register_scenario
class ImportPolicyAsPathLengthCondition(object):
@@ -909,6 +966,12 @@ class ImportPolicyAsPathLengthCondition(object):
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("ImportPolicyAsPathLengthCondition").boot(env)
+ lookup_scenario("ImportPolicyAsPathLengthCondition").setup(env)
+ lookup_scenario("ImportPolicyAsPathLengthCondition").check(env)
+
@register_scenario
class ImportPolicyAsPathCondition(object):
@@ -956,6 +1019,12 @@ class ImportPolicyAsPathCondition(object):
# same check function as previous No.1 scenario
lookup_scenario("ImportPolicy").check(env)
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ImportPolicyAsPathCondition").boot(env)
+ lookup_scenario("ImportPolicyAsPathCondition").setup(env)
+ lookup_scenario("ImportPolicyAsPathCondition").check(env)
+
@register_scenario
class ImportPolicyAsPathAnyCondition(object):
@@ -1003,6 +1072,12 @@ class ImportPolicyAsPathAnyCondition(object):
# same check function as previous No.1 scenario
lookup_scenario("ImportPolicy").check(env)
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ImportPolicyAsPathAnyCondition").boot(env)
+ lookup_scenario("ImportPolicyAsPathAnyCondition").setup(env)
+ lookup_scenario("ImportPolicyAsPathAnyCondition").check(env)
+
@register_scenario
class ImportPolicyAsPathOriginCondition(object):
@@ -1050,6 +1125,12 @@ class ImportPolicyAsPathOriginCondition(object):
# same check function as previous No.1 scenario
lookup_scenario("ImportPolicy").check(env)
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ImportPolicyAsPathOriginCondition").boot(env)
+ lookup_scenario("ImportPolicyAsPathOriginCondition").setup(env)
+ lookup_scenario("ImportPolicyAsPathOriginCondition").check(env)
+
@register_scenario
class ImportPolicyAsPathOnlyCondition(object):
@@ -1097,6 +1178,12 @@ class ImportPolicyAsPathOnlyCondition(object):
# same check function as previous No.1 scenario
lookup_scenario("ImportPolicy").check(env)
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ImportPolicyAsPathOnlyCondition").boot(env)
+ lookup_scenario("ImportPolicyAsPathOnlyCondition").setup(env)
+ lookup_scenario("ImportPolicyAsPathOnlyCondition").check(env)
+
@register_scenario
class ImportPolicyAsPathMismatchCondition(object):
@@ -1155,6 +1242,12 @@ class ImportPolicyAsPathMismatchCondition(object):
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("ImportPolicyAsPathMismatchCondition").boot(env)
+ lookup_scenario("ImportPolicyAsPathMismatchCondition").setup(env)
+ lookup_scenario("ImportPolicyAsPathMismatchCondition").check(env)
+
@register_scenario
class ImportPolicyCommunityCondition(object):
@@ -1204,6 +1297,12 @@ class ImportPolicyCommunityCondition(object):
def check(env):
lookup_scenario("ImportPolicy").check(env)
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ImportPolicyCommunityCondition").boot(env)
+ lookup_scenario("ImportPolicyCommunityCondition").setup(env)
+ lookup_scenario("ImportPolicyCommunityCondition").check(env)
+
@register_scenario
class ImportPolicyCommunityRegexp(object):
@@ -1250,6 +1349,12 @@ class ImportPolicyCommunityRegexp(object):
def check(env):
lookup_scenario("ImportPolicy").check(env)
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ImportPolicyCommunityRegexp").boot(env)
+ lookup_scenario("ImportPolicyCommunityRegexp").setup(env)
+ lookup_scenario("ImportPolicyCommunityRegexp").check(env)
+
def community_exists(path, com):
a, b = com.split(':')
@@ -1320,11 +1425,18 @@ class ImportPolicyCommunityAction(object):
q1 = env.q1
q2 = env.q2
path = g1.get_adj_rib_out(q1)[0]
- env.assertTrue(community_exists(path, '65100:10'))
- env.assertFalse(community_exists(path, '65100:20'))
+ assert_true(community_exists(path, '65100:10'))
+ assert_false(community_exists(path, '65100:20'))
path = g1.get_adj_rib_out(q2)[0]
- env.assertTrue(community_exists(path, '65100:10'))
- env.assertTrue(community_exists(path, '65100:20'))
+ assert_true(community_exists(path, '65100:10'))
+ assert_true(community_exists(path, '65100:20'))
+
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ImportPolicyCommunityAction").boot(env)
+ lookup_scenario("ImportPolicyCommunityAction").setup(env)
+ lookup_scenario("ImportPolicyCommunityAction").check(env)
+ lookup_scenario("ImportPolicyCommunityAction").check2(env)
@register_scenario
@@ -1381,11 +1493,18 @@ class ImportPolicyCommunityReplace(object):
q1 = env.q1
q2 = env.q2
path = g1.get_adj_rib_out(q1)[0]
- env.assertTrue(community_exists(path, '65100:10'))
- env.assertFalse(community_exists(path, '65100:20'))
+ assert_true(community_exists(path, '65100:10'))
+ assert_false(community_exists(path, '65100:20'))
path = g1.get_adj_rib_out(q2)[0]
- env.assertFalse(community_exists(path, '65100:10'))
- env.assertTrue(community_exists(path, '65100:20'))
+ assert_false(community_exists(path, '65100:10'))
+ assert_true(community_exists(path, '65100:20'))
+
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ImportPolicyCommunityReplace").boot(env)
+ lookup_scenario("ImportPolicyCommunityReplace").setup(env)
+ lookup_scenario("ImportPolicyCommunityReplace").check(env)
+ lookup_scenario("ImportPolicyCommunityReplace").check2(env)
@register_scenario
@@ -1452,18 +1571,25 @@ class ImportPolicyCommunityRemove(object):
q2 = env.q2
adj_out = g1.get_adj_rib_out(q1)
for path in adj_out:
- env.assertTrue(community_exists(path, '65100:10'))
+ assert_true(community_exists(path, '65100:10'))
if path['nlri']['prefix'] == '192.168.110.0/24':
- env.assertTrue(community_exists(path, '65100:20'))
+ assert_true(community_exists(path, '65100:20'))
if path['nlri']['prefix'] == '192.168.120.0/24':
- env.assertTrue(community_exists(path, '65100:30'))
+ assert_true(community_exists(path, '65100:30'))
adj_out = g1.get_adj_rib_out(q2)
for path in adj_out:
- env.assertFalse(community_exists(path, '65100:10'))
+ assert_false(community_exists(path, '65100:10'))
if path['nlri']['prefix'] == '192.168.110.0/24':
- env.assertFalse(community_exists(path, '65100:20'))
+ assert_false(community_exists(path, '65100:20'))
if path['nlri']['prefix'] == '192.168.120.0/24':
- env.assertTrue(community_exists(path, '65100:30'))
+ assert_true(community_exists(path, '65100:30'))
+
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ImportPolicyCommunityRemove").boot(env)
+ lookup_scenario("ImportPolicyCommunityRemove").setup(env)
+ lookup_scenario("ImportPolicyCommunityRemove").check(env)
+ lookup_scenario("ImportPolicyCommunityRemove").check2(env)
@register_scenario
@@ -1520,18 +1646,25 @@ class ImportPolicyCommunityNull(object):
q2 = env.q2
adj_out = g1.get_adj_rib_out(q1)
for path in adj_out:
- env.assertTrue(community_exists(path, '65100:10'))
+ assert_true(community_exists(path, '65100:10'))
if path['nlri']['prefix'] == '192.168.110.0/24':
- env.assertTrue(community_exists(path, '65100:20'))
+ assert_true(community_exists(path, '65100:20'))
if path['nlri']['prefix'] == '192.168.120.0/24':
- env.assertTrue(community_exists(path, '65100:30'))
+ assert_true(community_exists(path, '65100:30'))
adj_out = g1.get_adj_rib_out(q2)
for path in adj_out:
- env.assertFalse(community_exists(path, '65100:10'))
+ assert_false(community_exists(path, '65100:10'))
if path['nlri']['prefix'] == '192.168.110.0/24':
- env.assertFalse(community_exists(path, '65100:20'))
+ assert_false(community_exists(path, '65100:20'))
if path['nlri']['prefix'] == '192.168.120.0/24':
- env.assertFalse(community_exists(path, '65100:30'))
+ assert_false(community_exists(path, '65100:30'))
+
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ImportPolicyCommunityNull").boot(env)
+ lookup_scenario("ImportPolicyCommunityNull").setup(env)
+ lookup_scenario("ImportPolicyCommunityNull").check(env)
+ lookup_scenario("ImportPolicyCommunityNull").check2(env)
@register_scenario
@@ -1587,18 +1720,25 @@ class ExportPolicyCommunityAdd(object):
adj_out = g1.get_adj_rib_out(q1)
for path in adj_out:
- env.assertTrue(community_exists(path, '65100:10'))
- env.assertFalse(community_exists(path, '65100:20'))
+ assert_true(community_exists(path, '65100:10'))
+ assert_false(community_exists(path, '65100:20'))
local_rib = g1.get_local_rib(q2)
for path in local_rib[0]['paths']:
- env.assertTrue(community_exists(path, '65100:10'))
- env.assertFalse(community_exists(path, '65100:20'))
+ assert_true(community_exists(path, '65100:10'))
+ assert_false(community_exists(path, '65100:20'))
adj_out = g1.get_adj_rib_out(q2)
for path in adj_out:
- env.assertTrue(community_exists(path, '65100:10'))
- env.assertTrue(community_exists(path, '65100:20'))
+ assert_true(community_exists(path, '65100:10'))
+ assert_true(community_exists(path, '65100:20'))
+
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ExportPolicyCommunityAdd").boot(env)
+ lookup_scenario("ExportPolicyCommunityAdd").setup(env)
+ lookup_scenario("ExportPolicyCommunityAdd").check(env)
+ lookup_scenario("ExportPolicyCommunityAdd").check2(env)
@register_scenario
@@ -1654,18 +1794,25 @@ class ExportPolicyCommunityReplace(object):
adj_out = g1.get_adj_rib_out(q1)
for path in adj_out:
- env.assertTrue(community_exists(path, '65100:10'))
- env.assertFalse(community_exists(path, '65100:20'))
+ assert_true(community_exists(path, '65100:10'))
+ assert_false(community_exists(path, '65100:20'))
local_rib = g1.get_local_rib(q2)
for path in local_rib[0]['paths']:
- env.assertTrue(community_exists(path, '65100:10'))
- env.assertFalse(community_exists(path, '65100:20'))
+ assert_true(community_exists(path, '65100:10'))
+ assert_false(community_exists(path, '65100:20'))
adj_out = g1.get_adj_rib_out(q2)
for path in adj_out:
- env.assertFalse(community_exists(path, '65100:10'))
- env.assertTrue(community_exists(path, '65100:20'))
+ assert_false(community_exists(path, '65100:10'))
+ assert_true(community_exists(path, '65100:20'))
+
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ExportPolicyCommunityReplace").boot(env)
+ lookup_scenario("ExportPolicyCommunityReplace").setup(env)
+ lookup_scenario("ExportPolicyCommunityReplace").check(env)
+ lookup_scenario("ExportPolicyCommunityReplace").check2(env)
@register_scenario
@@ -1721,21 +1868,28 @@ class ExportPolicyCommunityRemove(object):
adj_out = g1.get_adj_rib_out(q1)
for path in adj_out:
- env.assertTrue(community_exists(path, '65100:10'))
- env.assertTrue(community_exists(path, '65100:20'))
- env.assertTrue(community_exists(path, '65100:30'))
+ assert_true(community_exists(path, '65100:10'))
+ assert_true(community_exists(path, '65100:20'))
+ assert_true(community_exists(path, '65100:30'))
local_rib = g1.get_local_rib(q2)
for path in local_rib[0]['paths']:
- env.assertTrue(community_exists(path, '65100:10'))
- env.assertTrue(community_exists(path, '65100:20'))
- env.assertTrue(community_exists(path, '65100:30'))
+ assert_true(community_exists(path, '65100:10'))
+ assert_true(community_exists(path, '65100:20'))
+ assert_true(community_exists(path, '65100:30'))
adj_out = g1.get_adj_rib_out(q2)
for path in adj_out:
- env.assertTrue(community_exists(path, '65100:10'))
- env.assertFalse(community_exists(path, '65100:20'))
- env.assertFalse(community_exists(path, '65100:30'))
+ assert_true(community_exists(path, '65100:10'))
+ assert_false(community_exists(path, '65100:20'))
+ assert_false(community_exists(path, '65100:30'))
+
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ExportPolicyCommunityRemove").boot(env)
+ lookup_scenario("ExportPolicyCommunityRemove").setup(env)
+ lookup_scenario("ExportPolicyCommunityRemove").check(env)
+ lookup_scenario("ExportPolicyCommunityRemove").check2(env)
@register_scenario
@@ -1791,21 +1945,29 @@ class ExportPolicyCommunityNull(object):
adj_out = g1.get_adj_rib_out(q1)
for path in adj_out:
- env.assertTrue(community_exists(path, '65100:10'))
- env.assertTrue(community_exists(path, '65100:20'))
- env.assertTrue(community_exists(path, '65100:30'))
+ assert_true(community_exists(path, '65100:10'))
+ assert_true(community_exists(path, '65100:20'))
+ assert_true(community_exists(path, '65100:30'))
local_rib = g1.get_local_rib(q2)
for path in local_rib[0]['paths']:
- env.assertTrue(community_exists(path, '65100:10'))
- env.assertTrue(community_exists(path, '65100:20'))
- env.assertTrue(community_exists(path, '65100:30'))
+ assert_true(community_exists(path, '65100:10'))
+ assert_true(community_exists(path, '65100:20'))
+ assert_true(community_exists(path, '65100:30'))
adj_out = g1.get_adj_rib_out(q2)
for path in adj_out:
- env.assertFalse(community_exists(path, '65100:10'))
- env.assertFalse(community_exists(path, '65100:20'))
- env.assertFalse(community_exists(path, '65100:30'))
+ assert_false(community_exists(path, '65100:10'))
+ assert_false(community_exists(path, '65100:20'))
+ assert_false(community_exists(path, '65100:30'))
+
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ExportPolicyCommunityNull").boot(env)
+ lookup_scenario("ExportPolicyCommunityNull").setup(env)
+ lookup_scenario("ExportPolicyCommunityNull").check(env)
+ lookup_scenario("ExportPolicyCommunityNull").check2(env)
+
def metric(path):
for a in path['attrs']:
@@ -1860,13 +2022,20 @@ class ImportPolicyMedReplace(object):
q2 = env.q2
adj_out = g1.get_adj_rib_out(q1)
- env.assertTrue(metric(adj_out[0]) == 300)
+ assert_true(metric(adj_out[0]) == 300)
local_rib = g1.get_local_rib(q2)
- env.assertTrue(metric(local_rib[0]['paths'][0]) == 100)
+ assert_true(metric(local_rib[0]['paths'][0]) == 100)
adj_out = g1.get_adj_rib_out(q2)
- env.assertTrue(metric(adj_out[0]) == 100)
+ assert_true(metric(adj_out[0]) == 100)
+
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ImportPolicyMedReplace").boot(env)
+ lookup_scenario("ImportPolicyMedReplace").setup(env)
+ lookup_scenario("ImportPolicyMedReplace").check(env)
+ lookup_scenario("ImportPolicyMedReplace").check2(env)
@register_scenario
@@ -1915,13 +2084,20 @@ class ImportPolicyMedAdd(object):
q2 = env.q2
adj_out = g1.get_adj_rib_out(q1)
- env.assertTrue(metric(adj_out[0]) == 300)
+ assert_true(metric(adj_out[0]) == 300)
local_rib = g1.get_local_rib(q2)
- env.assertTrue(metric(local_rib[0]['paths'][0]) == 400)
+ assert_true(metric(local_rib[0]['paths'][0]) == 400)
adj_out = g1.get_adj_rib_out(q2)
- env.assertTrue(metric(adj_out[0]) == 400)
+ assert_true(metric(adj_out[0]) == 400)
+
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ImportPolicyMedAdd").boot(env)
+ lookup_scenario("ImportPolicyMedAdd").setup(env)
+ lookup_scenario("ImportPolicyMedAdd").check(env)
+ lookup_scenario("ImportPolicyMedAdd").check2(env)
@register_scenario
@@ -1970,13 +2146,20 @@ class ImportPolicyMedSub(object):
q2 = env.q2
adj_out = g1.get_adj_rib_out(q1)
- env.assertTrue(metric(adj_out[0]) == 300)
+ assert_true(metric(adj_out[0]) == 300)
local_rib = g1.get_local_rib(q2)
- env.assertTrue(metric(local_rib[0]['paths'][0]) == 200)
+ assert_true(metric(local_rib[0]['paths'][0]) == 200)
adj_out = g1.get_adj_rib_out(q2)
- env.assertTrue(metric(adj_out[0]) == 200)
+ assert_true(metric(adj_out[0]) == 200)
+
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ImportPolicyMedSub").boot(env)
+ lookup_scenario("ImportPolicyMedSub").setup(env)
+ lookup_scenario("ImportPolicyMedSub").check(env)
+ lookup_scenario("ImportPolicyMedSub").check2(env)
@register_scenario
@@ -2025,13 +2208,20 @@ class ExportPolicyMedReplace(object):
q2 = env.q2
adj_out = g1.get_adj_rib_out(q1)
- env.assertTrue(metric(adj_out[0]) == 300)
+ assert_true(metric(adj_out[0]) == 300)
local_rib = g1.get_local_rib(q2)
- env.assertTrue(metric(local_rib[0]['paths'][0]) == 300)
+ assert_true(metric(local_rib[0]['paths'][0]) == 300)
adj_out = g1.get_adj_rib_out(q2)
- env.assertTrue(metric(adj_out[0]) == 100)
+ assert_true(metric(adj_out[0]) == 100)
+
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ExportPolicyMedReplace").boot(env)
+ lookup_scenario("ExportPolicyMedReplace").setup(env)
+ lookup_scenario("ExportPolicyMedReplace").check(env)
+ lookup_scenario("ExportPolicyMedReplace").check2(env)
@register_scenario
@@ -2080,13 +2270,20 @@ class ExportPolicyMedAdd(object):
q2 = env.q2
adj_out = g1.get_adj_rib_out(q1)
- env.assertTrue(metric(adj_out[0]) == 300)
+ assert_true(metric(adj_out[0]) == 300)
local_rib = g1.get_local_rib(q2)
- env.assertTrue(metric(local_rib[0]['paths'][0]) == 300)
+ assert_true(metric(local_rib[0]['paths'][0]) == 300)
adj_out = g1.get_adj_rib_out(q2)
- env.assertTrue(metric(adj_out[0]) == 400)
+ assert_true(metric(adj_out[0]) == 400)
+
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ExportPolicyMedAdd").boot(env)
+ lookup_scenario("ExportPolicyMedAdd").setup(env)
+ lookup_scenario("ExportPolicyMedAdd").check(env)
+ lookup_scenario("ExportPolicyMedAdd").check2(env)
@register_scenario
@@ -2135,13 +2332,20 @@ class ExportPolicyMedSub(object):
q2 = env.q2
adj_out = g1.get_adj_rib_out(q1)
- env.assertTrue(metric(adj_out[0]) == 300)
+ assert_true(metric(adj_out[0]) == 300)
local_rib = g1.get_local_rib(q2)
- env.assertTrue(metric(local_rib[0]['paths'][0]) == 300)
+ assert_true(metric(local_rib[0]['paths'][0]) == 300)
adj_out = g1.get_adj_rib_out(q2)
- env.assertTrue(metric(adj_out[0]) == 200)
+ assert_true(metric(adj_out[0]) == 200)
+
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ExportPolicyMedSub").boot(env)
+ lookup_scenario("ExportPolicyMedSub").setup(env)
+ lookup_scenario("ExportPolicyMedSub").check(env)
+ lookup_scenario("ExportPolicyMedSub").check2(env)
@register_scenario
@@ -2197,6 +2401,12 @@ class InPolicyReject(object):
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):
@@ -2242,6 +2452,12 @@ class InPolicyAccept(object):
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):
@@ -2370,6 +2586,14 @@ class InPolicyUpdate(object):
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):
@@ -2437,19 +2661,26 @@ class ExportPolicyAsPathPrepend(object):
q2 = env.q2
path = g1.get_adj_rib_out(q1, prefix='192.168.20.0/24')[0]
- env.assertTrue(path['aspath'] == [e1.asn])
+ assert_true(path['aspath'] == [e1.asn])
path = g1.get_adj_rib_out(q1, prefix='192.168.200.0/24')[0]
- env.assertTrue(path['aspath'] == [e1.asn])
+ assert_true(path['aspath'] == [e1.asn])
path = g1.get_local_rib(q2, prefix='192.168.20.0/24')[0]['paths'][0]
- env.assertTrue(path['aspath'] == [e1.asn])
+ assert_true(path['aspath'] == [e1.asn])
path = g1.get_adj_rib_out(q2, prefix='192.168.20.0/24')[0]
- env.assertTrue(path['aspath'] == [65005]*5 + [e1.asn])
+ assert_true(path['aspath'] == [65005]*5 + [e1.asn])
path = g1.get_adj_rib_out(q2, prefix='192.168.200.0/24')[0]
- env.assertTrue(path['aspath'] == [e1.asn])
+ assert_true(path['aspath'] == [e1.asn])
+
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ExportPolicyAsPathPrepend").boot(env)
+ lookup_scenario("ExportPolicyAsPathPrepend").setup(env)
+ lookup_scenario("ExportPolicyAsPathPrepend").check(env)
+ lookup_scenario("ExportPolicyAsPathPrepend").check2(env)
@register_scenario
@@ -2508,19 +2739,26 @@ class ImportPolicyAsPathPrependLastAS(object):
q2 = env.q2
path = g1.get_adj_rib_out(q1, prefix='192.168.20.0/24')[0]
- env.assertTrue(path['aspath'] == [e1.asn])
+ assert_true(path['aspath'] == [e1.asn])
path = g1.get_adj_rib_out(q1, prefix='192.168.200.0/24')[0]
- env.assertTrue(path['aspath'] == [e1.asn])
+ assert_true(path['aspath'] == [e1.asn])
path = g1.get_local_rib(q2, prefix='192.168.20.0/24')[0]['paths'][0]
- env.assertTrue(path['aspath'] == [e1.asn]*5 + [e1.asn])
+ assert_true(path['aspath'] == [e1.asn]*5 + [e1.asn])
path = g1.get_adj_rib_out(q2, prefix='192.168.20.0/24')[0]
- env.assertTrue(path['aspath'] == [e1.asn]*5 + [e1.asn])
+ assert_true(path['aspath'] == [e1.asn]*5 + [e1.asn])
path = g1.get_adj_rib_out(q2, prefix='192.168.200.0/24')[0]
- env.assertTrue(path['aspath'] == [e1.asn])
+ assert_true(path['aspath'] == [e1.asn])
+
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ImportPolicyAsPathPrependLastAS").boot(env)
+ lookup_scenario("ImportPolicyAsPathPrependLastAS").setup(env)
+ lookup_scenario("ImportPolicyAsPathPrependLastAS").check(env)
+ lookup_scenario("ImportPolicyAsPathPrependLastAS").check2(env)
@register_scenario
@@ -2579,19 +2817,26 @@ class ExportPolicyAsPathPrependLastAS(object):
q2 = env.q2
path = g1.get_adj_rib_out(q1, prefix='192.168.20.0/24')[0]
- env.assertTrue(path['aspath'] == [e1.asn])
+ assert_true(path['aspath'] == [e1.asn])
path = g1.get_adj_rib_out(q1, prefix='192.168.200.0/24')[0]
- env.assertTrue(path['aspath'] == [e1.asn])
+ assert_true(path['aspath'] == [e1.asn])
path = g1.get_local_rib(q2, prefix='192.168.20.0/24')[0]['paths'][0]
- env.assertTrue(path['aspath'] == [e1.asn])
+ assert_true(path['aspath'] == [e1.asn])
path = g1.get_adj_rib_out(q2, prefix='192.168.20.0/24')[0]
- env.assertTrue(path['aspath'] == [e1.asn]*5 + [e1.asn])
+ assert_true(path['aspath'] == [e1.asn]*5 + [e1.asn])
path = g1.get_adj_rib_out(q2, prefix='192.168.200.0/24')[0]
- env.assertTrue(path['aspath'] == [e1.asn])
+ assert_true(path['aspath'] == [e1.asn])
+
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ExportPolicyAsPathPrependLastAS").boot(env)
+ lookup_scenario("ExportPolicyAsPathPrependLastAS").setup(env)
+ lookup_scenario("ExportPolicyAsPathPrependLastAS").check(env)
+ lookup_scenario("ExportPolicyAsPathPrependLastAS").check2(env)
@register_scenario
@@ -2639,6 +2884,12 @@ class ImportPolicyExCommunityOriginCondition(object):
def check(env):
lookup_scenario("ImportPolicy").check(env)
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ImportPolicyExCommunityOriginCondition").boot(env)
+ lookup_scenario("ImportPolicyExCommunityOriginCondition").setup(env)
+ lookup_scenario("ImportPolicyExCommunityOriginCondition").check(env)
+
@register_scenario
class ImportPolicyExCommunityTargetCondition(object):
@@ -2685,6 +2936,12 @@ class ImportPolicyExCommunityTargetCondition(object):
def check(env):
lookup_scenario("ImportPolicy").check(env)
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ImportPolicyExCommunityTargetCondition").boot(env)
+ lookup_scenario("ImportPolicyExCommunityTargetCondition").setup(env)
+ lookup_scenario("ImportPolicyExCommunityTargetCondition").check(env)
+
@register_scenario
class InPolicyPrefixCondition(object):
@@ -2735,6 +2992,12 @@ class InPolicyPrefixCondition(object):
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]
@@ -2816,9 +3079,16 @@ class ImportPolicyExCommunityAdd(object):
q1 = env.q1
q2 = env.q2
path = g1.get_adj_rib_out(q1)[0]
- env.assertFalse(ext_community_exists(path, 'RT:65000:1'))
+ assert_false(ext_community_exists(path, 'RT:65000:1'))
path = g1.get_adj_rib_out(q2)[0]
- env.assertTrue(ext_community_exists(path, 'RT:65000:1'))
+ assert_true(ext_community_exists(path, 'RT:65000:1'))
+
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ImportPolicyExCommunityAdd").boot(env)
+ lookup_scenario("ImportPolicyExCommunityAdd").setup(env)
+ lookup_scenario("ImportPolicyExCommunityAdd").check(env)
+ lookup_scenario("ImportPolicyExCommunityAdd").check2(env)
@register_scenario
@@ -2890,14 +3160,21 @@ class ImportPolicyExCommunityAdd2(object):
q1 = env.q1
q2 = env.q2
path = g1.get_adj_rib_out(q1)[0]
- env.assertTrue(ext_community_exists(path, 'RT:65000:1'))
- env.assertFalse(ext_community_exists(path, 'RT:65100:100'))
+ assert_true(ext_community_exists(path, 'RT:65000:1'))
+ assert_false(ext_community_exists(path, 'RT:65100:100'))
path = g1.get_local_rib(q2)[0]['paths'][0]
- env.assertTrue(ext_community_exists(path, 'RT:65000:1'))
- env.assertTrue(ext_community_exists(path, 'RT:65100:100'))
+ assert_true(ext_community_exists(path, 'RT:65000:1'))
+ assert_true(ext_community_exists(path, 'RT:65100:100'))
path = g1.get_adj_rib_out(q2)[0]
- env.assertTrue(ext_community_exists(path, 'RT:65000:1'))
- env.assertTrue(ext_community_exists(path, 'RT:65100:100'))
+ assert_true(ext_community_exists(path, 'RT:65000:1'))
+ assert_true(ext_community_exists(path, 'RT:65100:100'))
+
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ImportPolicyExCommunityAdd2").boot(env)
+ lookup_scenario("ImportPolicyExCommunityAdd2").setup(env)
+ lookup_scenario("ImportPolicyExCommunityAdd2").check(env)
+ lookup_scenario("ImportPolicyExCommunityAdd2").check2(env)
@register_scenario
@@ -2969,14 +3246,21 @@ class ImportPolicyExCommunityMultipleAdd(object):
q1 = env.q1
q2 = env.q2
path = g1.get_adj_rib_out(q1)[0]
- env.assertFalse(ext_community_exists(path, 'RT:65100:100'))
- env.assertFalse(ext_community_exists(path, 'RT:100:100'))
+ assert_false(ext_community_exists(path, 'RT:65100:100'))
+ assert_false(ext_community_exists(path, 'RT:100:100'))
path = g1.get_local_rib(q2)[0]['paths'][0]
- env.assertTrue(ext_community_exists(path, 'RT:65100:100'))
- env.assertTrue(ext_community_exists(path, 'RT:100:100'))
+ assert_true(ext_community_exists(path, 'RT:65100:100'))
+ assert_true(ext_community_exists(path, 'RT:100:100'))
path = g1.get_adj_rib_out(q2)[0]
- env.assertTrue(ext_community_exists(path, 'RT:65100:100'))
- env.assertTrue(ext_community_exists(path, 'RT:100:100'))
+ assert_true(ext_community_exists(path, 'RT:65100:100'))
+ assert_true(ext_community_exists(path, 'RT:100:100'))
+
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ImportPolicyExCommunityMultipleAdd").boot(env)
+ lookup_scenario("ImportPolicyExCommunityMultipleAdd").setup(env)
+ lookup_scenario("ImportPolicyExCommunityMultipleAdd").check(env)
+ lookup_scenario("ImportPolicyExCommunityMultipleAdd").check2(env)
@register_scenario
@@ -3048,14 +3332,21 @@ class ExportPolicyExCommunityAdd(object):
q1 = env.q1
q2 = env.q2
path = g1.get_adj_rib_out(q1)[0]
- env.assertFalse(ext_community_exists(path, 'RT:65000:1'))
+ assert_false(ext_community_exists(path, 'RT:65000:1'))
path = g1.get_local_rib(q2)[0]['paths'][0]
- env.assertFalse(ext_community_exists(path, 'RT:65000:1'))
+ assert_false(ext_community_exists(path, 'RT:65000:1'))
path = g1.get_adj_rib_out(q2)[0]
- env.assertTrue(ext_community_exists(path, 'RT:65000:1'))
+ assert_true(ext_community_exists(path, 'RT:65000:1'))
+
+ @staticmethod
+ def executor(env):
+ lookup_scenario("ExportPolicyExCommunityAdd").boot(env)
+ lookup_scenario("ExportPolicyExCommunityAdd").setup(env)
+ lookup_scenario("ExportPolicyExCommunityAdd").check(env)
+ lookup_scenario("ExportPolicyExCommunityAdd").check2(env)
-class GoBGPTestBase(unittest.TestCase):
+class TestGoBGPBase():
wait_per_retry = 5
retry_limit = 10
@@ -3065,37 +3356,27 @@ class GoBGPTestBase(unittest.TestCase):
idx = parser_option.test_index
base.TEST_PREFIX = parser_option.test_prefix
cls.parser_option = parser_option
-
- if idx not in _SCENARIOS:
+ cls.executors = []
+ if idx == 0:
+ print 'unset test-index. run all test sequential'
+ for _, v in _SCENARIOS.items():
+ for k, m in inspect.getmembers(v, inspect.isfunction):
+ if k == 'executor':
+ cls.executor = m
+ cls.executors.append(cls.executor)
+ elif idx not in _SCENARIOS:
print 'invalid test-index. # of scenarios: {0}'.format(len(_SCENARIOS))
sys.exit(1)
-
- cls.setup2 = None
- cls.check2 = None
- for k, m in inspect.getmembers(_SCENARIOS[idx], inspect.isfunction):
- if k == 'boot':
- cls.boot = m
- elif k == 'setup':
- cls.setup = m
- elif k == 'check':
- cls.check = m
- elif k == 'setup2':
- cls.setup2 = m
- elif k == 'check2':
- cls.check2 = m
+ else:
+ for k, m in inspect.getmembers(_SCENARIOS[idx], inspect.isfunction):
+ if k == 'executor':
+ cls.executor = m
+ cls.executors.append(cls.executor)
def test(self):
- self.boot()
-
- self.setup()
-
- self.check()
-
- if self.setup2:
- self.setup2()
+ for e in self.executors:
+ yield e
- if self.check2:
- self.check2()
if __name__ == '__main__':
if os.geteuid() is not 0:
diff --git a/test/scenario_test/run_all_tests.sh b/test/scenario_test/run_all_tests.sh
index 4cf584b7..4a6e7aff 100755
--- a/test/scenario_test/run_all_tests.sh
+++ b/test/scenario_test/run_all_tests.sh
@@ -68,7 +68,7 @@ sudo -E PYTHONPATH=$GOBGP/test python global_policy_test.py --gobgp-image $GOBGP
PIDS=("${PIDS[@]}" $!)
# route server malformed message test
-NUM=$(sudo -E PYTHONPATH=$GOBGP/test python route_server_malformed_test.py -s 2> /dev/null | awk '/invalid/{print $NF}')
+NUM=$(sudo -E PYTHONPATH=$GOBGP/test python route_server_malformed_test.py --test-index -1 -s 2> /dev/null | awk '/invalid/{print $NF}')
PARALLEL_NUM=10
for (( i = 1; i < $(( $NUM + 1)); ++i ))
do
@@ -86,7 +86,7 @@ do
done
# route server policy test
-NUM=$(sudo -E PYTHONPATH=$GOBGP/test python route_server_policy_test.py -s 2> /dev/null | awk '/invalid/{print $NF}')
+NUM=$(sudo -E PYTHONPATH=$GOBGP/test python route_server_policy_test.py --test-index -1 -s 2> /dev/null | awk '/invalid/{print $NF}')
PARALLEL_NUM=25
for (( i = 0; i < $(( NUM / PARALLEL_NUM + 1)); ++i ))
do
@@ -112,7 +112,7 @@ do
done
# route server policy grpc test
-NUM=$(sudo -E PYTHONPATH=$GOBGP/test python route_server_policy_grpc_test.py -s 2> /dev/null | awk '/invalid/{print $NF}')
+NUM=$(sudo -E PYTHONPATH=$GOBGP/test python route_server_policy_grpc_test.py --test-index -1 -s 2> /dev/null | awk '/invalid/{print $NF}')
PARALLEL_NUM=25
for (( i = 0; i < $(( NUM / PARALLEL_NUM + 1)); ++i ))
do