diff options
author | Satoshi Fujimoto <satoshi.fujimoto7@gmail.com> | 2017-05-09 16:09:48 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2017-05-12 09:46:54 +0900 |
commit | 8597ef851b398e16f127c2f821235b496e4375d0 (patch) | |
tree | 0bea5f2c031005739fc3d132514e3b97c56c3bac | |
parent | f8654b67c7a959a43199a7d4ac5ffdbb72619e6c (diff) |
utils/test_bgp: Add unit tests for IPv6 Flow Spec
Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | ryu/tests/unit/services/protocols/bgp/utils/test_bgp.py | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/ryu/tests/unit/services/protocols/bgp/utils/test_bgp.py b/ryu/tests/unit/services/protocols/bgp/utils/test_bgp.py index 25ecd05f..121239f6 100644 --- a/ryu/tests/unit/services/protocols/bgp/utils/test_bgp.py +++ b/ryu/tests/unit/services/protocols/bgp/utils/test_bgp.py @@ -28,6 +28,7 @@ from ryu.lib.packet.bgp import ( from ryu.services.protocols.bgp.core import BgpCoreError from ryu.services.protocols.bgp.utils.bgp import create_v4flowspec_actions +from ryu.services.protocols.bgp.utils.bgp import create_v6flowspec_actions LOG = logging.getLogger(__name__) @@ -83,3 +84,49 @@ class Test_Utils_BGP(unittest.TestCase): } expected_communities = [] self._test_create_v4flowspec_actions(actions, expected_communities) + + def _test_create_v6flowspec_actions(self, actions, expected_communities): + communities = create_v6flowspec_actions(actions) + expected_communities.sort(key=lambda x: x.subtype) + communities.sort(key=lambda x: x.subtype) + eq_(str(expected_communities), str(communities)) + + def test_create_v6flowspec_actions_all_actions(self): + actions = { + 'traffic_rate': { + 'as_number': 0, + 'rate_info': 100.0, + }, + 'traffic_action': { + 'action': 3, + }, + 'redirect': { + 'as_number': 10, + 'local_administrator': 10, + }, + 'traffic_marking': { + 'dscp': 24, + } + } + expected_communities = [ + BGPFlowSpecTrafficRateCommunity(as_number=0, rate_info=100.0), + BGPFlowSpecTrafficActionCommunity(action=3), + BGPFlowSpecRedirectCommunity(as_number=10, local_administrator=10), + BGPFlowSpecTrafficMarkingCommunity(dscp=24), + ] + self._test_create_v6flowspec_actions(actions, expected_communities) + + def test_create_v6flowspec_actions_without_actions(self): + actions = None + expected_communities = [] + self._test_create_v6flowspec_actions(actions, expected_communities) + + @raises(ValueError) + def test_create_v6flowspec_actions_not_exist_actions(self): + actions = { + 'traffic_test': { + 'test': 10, + }, + } + expected_communities = [] + self._test_create_v6flowspec_actions(actions, expected_communities) |