mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-05-29 06:29:40 +00:00
topotests: keep srv6-locator feature fine (step2)
This commit is a part of #5853 works. This commit add new topotest to verify SRv6-manager's functionality. Following tests are performed on this topotest. - check that SRv6-locator is set correctly - check that default SRv6-function locator is set correctly - check that SRv6-function is installed as ipv6 route correctly Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
This commit is contained in:
parent
ade3eebc6a
commit
96d423f7c9
0
tests/topotests/srv6_locator/__init__.py
Normal file
0
tests/topotests/srv6_locator/__init__.py
Normal file
1
tests/topotests/srv6_locator/expected_chunks1.json
Normal file
1
tests/topotests/srv6_locator/expected_chunks1.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
[]
|
8
tests/topotests/srv6_locator/expected_chunks2.json
Normal file
8
tests/topotests/srv6_locator/expected_chunks2.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "loc1",
|
||||||
|
"chunks": [
|
||||||
|
"2001:db8:1:1::/64"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
1
tests/topotests/srv6_locator/expected_chunks3.json
Normal file
1
tests/topotests/srv6_locator/expected_chunks3.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
[]
|
6
tests/topotests/srv6_locator/expected_chunks4.json
Normal file
6
tests/topotests/srv6_locator/expected_chunks4.json
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "loc3",
|
||||||
|
"chunks": []
|
||||||
|
}
|
||||||
|
]
|
8
tests/topotests/srv6_locator/expected_chunks5.json
Normal file
8
tests/topotests/srv6_locator/expected_chunks5.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "loc3",
|
||||||
|
"chunks": [
|
||||||
|
"2001:db8:3:3::/64"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
29
tests/topotests/srv6_locator/expected_ipv6_routes.json
Normal file
29
tests/topotests/srv6_locator/expected_ipv6_routes.json
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"2001:db8:1:1:1::/80":[
|
||||||
|
{
|
||||||
|
"prefix":"2001:db8:1:1:1::/80",
|
||||||
|
"protocol":"static",
|
||||||
|
"selected":true,
|
||||||
|
"installed":true,
|
||||||
|
"nexthops":[{
|
||||||
|
"fib":true,
|
||||||
|
"active":true,
|
||||||
|
"seg6local":{ "action":"End" }
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"2001:db8:2:2:1::/80":[
|
||||||
|
{
|
||||||
|
"prefix":"2001:db8:2:2:1::/80",
|
||||||
|
"protocol":"static",
|
||||||
|
"selected":true,
|
||||||
|
"installed":true,
|
||||||
|
"nexthops":[{
|
||||||
|
"fib":true,
|
||||||
|
"active":true,
|
||||||
|
"seg6local":{ "action":"End" }
|
||||||
|
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
26
tests/topotests/srv6_locator/expected_locators1.json
Normal file
26
tests/topotests/srv6_locator/expected_locators1.json
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"locators":[
|
||||||
|
{
|
||||||
|
"name": "loc1",
|
||||||
|
"prefix": "2001:db8:1:1::/64",
|
||||||
|
"status_up": true,
|
||||||
|
"chunks": [
|
||||||
|
{
|
||||||
|
"prefix": "2001:db8:1:1::/64",
|
||||||
|
"proto": "system"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "loc2",
|
||||||
|
"prefix": "2001:db8:2:2::/64",
|
||||||
|
"status_up": true,
|
||||||
|
"chunks": [
|
||||||
|
{
|
||||||
|
"prefix": "2001:db8:2:2::/64",
|
||||||
|
"proto": "system"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
26
tests/topotests/srv6_locator/expected_locators2.json
Normal file
26
tests/topotests/srv6_locator/expected_locators2.json
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"locators":[
|
||||||
|
{
|
||||||
|
"name": "loc1",
|
||||||
|
"prefix": "2001:db8:1:1::/64",
|
||||||
|
"status_up": true,
|
||||||
|
"chunks": [
|
||||||
|
{
|
||||||
|
"prefix": "2001:db8:1:1::/64",
|
||||||
|
"proto": "sharp"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "loc2",
|
||||||
|
"prefix": "2001:db8:2:2::/64",
|
||||||
|
"status_up": true,
|
||||||
|
"chunks": [
|
||||||
|
{
|
||||||
|
"prefix": "2001:db8:2:2::/64",
|
||||||
|
"proto": "system"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
26
tests/topotests/srv6_locator/expected_locators3.json
Normal file
26
tests/topotests/srv6_locator/expected_locators3.json
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"locators":[
|
||||||
|
{
|
||||||
|
"name": "loc1",
|
||||||
|
"prefix": "2001:db8:1:1::/64",
|
||||||
|
"status_up": true,
|
||||||
|
"chunks": [
|
||||||
|
{
|
||||||
|
"prefix": "2001:db8:1:1::/64",
|
||||||
|
"proto": "system"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "loc2",
|
||||||
|
"prefix": "2001:db8:2:2::/64",
|
||||||
|
"status_up": true,
|
||||||
|
"chunks": [
|
||||||
|
{
|
||||||
|
"prefix": "2001:db8:2:2::/64",
|
||||||
|
"proto": "system"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
36
tests/topotests/srv6_locator/expected_locators4.json
Normal file
36
tests/topotests/srv6_locator/expected_locators4.json
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
{
|
||||||
|
"locators":[
|
||||||
|
{
|
||||||
|
"name": "loc1",
|
||||||
|
"prefix": "2001:db8:1:1::/64",
|
||||||
|
"status_up": true,
|
||||||
|
"chunks": [
|
||||||
|
{
|
||||||
|
"prefix": "2001:db8:1:1::/64",
|
||||||
|
"proto": "system"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "loc2",
|
||||||
|
"prefix": "2001:db8:2:2::/64",
|
||||||
|
"status_up": true,
|
||||||
|
"chunks": [
|
||||||
|
{
|
||||||
|
"prefix": "2001:db8:2:2::/64",
|
||||||
|
"proto": "system"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name":"loc3",
|
||||||
|
"status_up":false,
|
||||||
|
"chunks":[
|
||||||
|
{
|
||||||
|
"proto":"sharp"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
38
tests/topotests/srv6_locator/expected_locators5.json
Normal file
38
tests/topotests/srv6_locator/expected_locators5.json
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
{
|
||||||
|
"locators":[
|
||||||
|
{
|
||||||
|
"name": "loc1",
|
||||||
|
"prefix": "2001:db8:1:1::/64",
|
||||||
|
"status_up": true,
|
||||||
|
"chunks": [
|
||||||
|
{
|
||||||
|
"prefix": "2001:db8:1:1::/64",
|
||||||
|
"proto": "system"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "loc2",
|
||||||
|
"prefix": "2001:db8:2:2::/64",
|
||||||
|
"status_up": true,
|
||||||
|
"chunks": [
|
||||||
|
{
|
||||||
|
"prefix": "2001:db8:2:2::/64",
|
||||||
|
"proto": "system"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "loc3",
|
||||||
|
"prefix": "2001:db8:3:3::/64",
|
||||||
|
"status_up": true,
|
||||||
|
"chunks":[
|
||||||
|
{
|
||||||
|
"prefix": "2001:db8:3:3::/64",
|
||||||
|
"proto": "sharp"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
2
tests/topotests/srv6_locator/r1/setup.sh
Normal file
2
tests/topotests/srv6_locator/r1/setup.sh
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
ip link add dummy0 type dummy
|
||||||
|
ip link set dummy0 up
|
7
tests/topotests/srv6_locator/r1/sharpd.conf
Normal file
7
tests/topotests/srv6_locator/r1/sharpd.conf
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
hostname r1
|
||||||
|
!
|
||||||
|
log stdout notifications
|
||||||
|
log monitor notifications
|
||||||
|
log commands
|
||||||
|
log file sharpd.log debugging
|
||||||
|
!
|
22
tests/topotests/srv6_locator/r1/zebra.conf
Normal file
22
tests/topotests/srv6_locator/r1/zebra.conf
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
hostname r1
|
||||||
|
!
|
||||||
|
debug zebra events
|
||||||
|
debug zebra rib detailed
|
||||||
|
!
|
||||||
|
log stdout notifications
|
||||||
|
log monitor notifications
|
||||||
|
log commands
|
||||||
|
log file zebra.log debugging
|
||||||
|
!
|
||||||
|
segment-routing
|
||||||
|
srv6
|
||||||
|
locators
|
||||||
|
locator loc1
|
||||||
|
prefix 2001:db8:1:1::/64
|
||||||
|
!
|
||||||
|
locator loc2
|
||||||
|
prefix 2001:db8:2:2::/64
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
142
tests/topotests/srv6_locator/test_srv6_locator.py
Executable file
142
tests/topotests/srv6_locator/test_srv6_locator.py
Executable file
@ -0,0 +1,142 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
#
|
||||||
|
# test_srv6_manager.py
|
||||||
|
# Part of NetDEF Topology Tests
|
||||||
|
#
|
||||||
|
# Copyright (c) 2020 by
|
||||||
|
# LINE Corporation, Hiroki Shirokura <slank.dev@gmail.com>
|
||||||
|
#
|
||||||
|
# Permission to use, copy, modify, and/or distribute this software
|
||||||
|
# for any purpose with or without fee is hereby granted, provided
|
||||||
|
# that the above copyright notice and this permission notice appear
|
||||||
|
# in all copies.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS" AND NETDEF DISCLAIMS ALL WARRANTIES
|
||||||
|
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NETDEF BE LIABLE FOR
|
||||||
|
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
|
||||||
|
# DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||||
|
# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||||
|
# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||||
|
# OF THIS SOFTWARE.
|
||||||
|
#
|
||||||
|
|
||||||
|
"""
|
||||||
|
test_srv6_manager.py:
|
||||||
|
Test for SRv6 manager on zebra
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import json
|
||||||
|
import time
|
||||||
|
import pytest
|
||||||
|
import functools
|
||||||
|
|
||||||
|
CWD = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
sys.path.append(os.path.join(CWD, '../'))
|
||||||
|
|
||||||
|
# pylint: disable=C0413
|
||||||
|
from lib import topotest
|
||||||
|
from lib.topogen import Topogen, TopoRouter, get_topogen
|
||||||
|
from lib.topolog import logger
|
||||||
|
from mininet.topo import Topo
|
||||||
|
|
||||||
|
|
||||||
|
def open_json_file(filename):
|
||||||
|
try:
|
||||||
|
with open(filename, "r") as f:
|
||||||
|
return json.load(f)
|
||||||
|
except IOError:
|
||||||
|
assert False, "Could not read file {}".format(filename)
|
||||||
|
|
||||||
|
|
||||||
|
class TemplateTopo(Topo):
|
||||||
|
def build(self, *_args, **_opts):
|
||||||
|
tgen = get_topogen(self)
|
||||||
|
tgen.add_router('r1')
|
||||||
|
|
||||||
|
|
||||||
|
def setup_module(mod):
|
||||||
|
tgen = Topogen(TemplateTopo, mod.__name__)
|
||||||
|
tgen.start_topology()
|
||||||
|
router_list = tgen.routers()
|
||||||
|
for rname, router in tgen.routers().items():
|
||||||
|
router.run("/bin/bash {}/{}/setup.sh".format(CWD, rname))
|
||||||
|
router.load_config(TopoRouter.RD_ZEBRA, os.path.join(CWD, '{}/zebra.conf'.format(rname)))
|
||||||
|
router.load_config(TopoRouter.RD_BGP, os.path.join(CWD, '{}/bgpd.conf'.format(rname)))
|
||||||
|
router.load_config(TopoRouter.RD_SHARP, os.path.join(CWD, '{}/sharpd.conf'.format(rname)))
|
||||||
|
tgen.start_router()
|
||||||
|
|
||||||
|
|
||||||
|
def teardown_module(mod):
|
||||||
|
tgen = get_topogen()
|
||||||
|
tgen.stop_topology()
|
||||||
|
|
||||||
|
|
||||||
|
def test_srv6():
|
||||||
|
tgen = get_topogen()
|
||||||
|
if tgen.routers_have_failure():
|
||||||
|
pytest.skip(tgen.errors)
|
||||||
|
router = tgen.gears['r1']
|
||||||
|
|
||||||
|
def _check_srv6_locator(router, expected_locator_file):
|
||||||
|
logger.info("checking zebra locator status")
|
||||||
|
output = json.loads(router.vtysh_cmd("show segment-routing srv6 locator json"))
|
||||||
|
expected = open_json_file("{}/{}".format(CWD, expected_locator_file))
|
||||||
|
return topotest.json_cmp(output, expected)
|
||||||
|
|
||||||
|
def _check_sharpd_chunk(router, expected_chunk_file):
|
||||||
|
logger.info("checking sharpd locator chunk status")
|
||||||
|
output = json.loads(router.vtysh_cmd("show sharp segment-routing srv6"))
|
||||||
|
expected = open_json_file("{}/{}".format(CWD, expected_chunk_file))
|
||||||
|
return topotest.json_cmp(output, expected)
|
||||||
|
|
||||||
|
def check_srv6_locator(router, expected_file):
|
||||||
|
func = functools.partial(_check_srv6_locator, router, expected_file)
|
||||||
|
success, result = topotest.run_and_expect(func, None, count=5, wait=0.5)
|
||||||
|
assert result is None, 'Failed'
|
||||||
|
|
||||||
|
def check_sharpd_chunk(router, expected_file):
|
||||||
|
func = functools.partial(_check_sharpd_chunk, router, expected_file)
|
||||||
|
success, result = topotest.run_and_expect(func, None, count=5, wait=0.5)
|
||||||
|
assert result is None, 'Failed'
|
||||||
|
|
||||||
|
logger.info("Test1 for Locator Configuration")
|
||||||
|
check_srv6_locator(router, "expected_locators1.json")
|
||||||
|
check_sharpd_chunk(router, "expected_chunks1.json")
|
||||||
|
|
||||||
|
logger.info("Test2 get chunk for locator loc1")
|
||||||
|
router.vtysh_cmd("sharp srv6-manager get-locator-chunk loc1")
|
||||||
|
check_srv6_locator(router, "expected_locators2.json")
|
||||||
|
check_sharpd_chunk(router, "expected_chunks2.json")
|
||||||
|
|
||||||
|
logger.info("Test3 release chunk for locator loc1")
|
||||||
|
router.vtysh_cmd("sharp srv6-manager release-locator-chunk loc1")
|
||||||
|
check_srv6_locator(router, "expected_locators3.json")
|
||||||
|
check_sharpd_chunk(router, "expected_chunks3.json")
|
||||||
|
|
||||||
|
logger.info("Test4 get chunk for non-exist locator by zclient")
|
||||||
|
router.vtysh_cmd("sharp srv6-manager get-locator-chunk loc3")
|
||||||
|
check_srv6_locator(router, "expected_locators4.json")
|
||||||
|
check_sharpd_chunk(router, "expected_chunks4.json")
|
||||||
|
|
||||||
|
logger.info("Test5 Test for Zclient. after locator loc3 was configured")
|
||||||
|
router.vtysh_cmd(
|
||||||
|
"""
|
||||||
|
configure terminal
|
||||||
|
segment-routing
|
||||||
|
srv6
|
||||||
|
locators
|
||||||
|
locator loc3
|
||||||
|
prefix 2001:db8:3:3::/64
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
check_srv6_locator(router, "expected_locators5.json")
|
||||||
|
check_sharpd_chunk(router, "expected_chunks5.json")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
args = ["-s"] + sys.argv[1:]
|
||||||
|
sys.exit(pytest.main(args))
|
Loading…
Reference in New Issue
Block a user