0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-12-22 09:41:54 +00:00

Flock test: ospf-base stub

This commit is contained in:
Maria Matejka 2024-07-24 21:04:28 +02:00
parent a804a30139
commit 2e4da8e329
6 changed files with 827 additions and 10 deletions

View File

@ -0,0 +1,739 @@
tables:
master4:
networks:
192.0.2.0/28:
routes:
- args: '* I (150/10) [192.0.2.2]'
dest: unicast
nexthop:
- iface: ve31
ospf_metric1: '10'
ospf_router_id: 192.0.2.2
preference: '150'
proto: ospf4
source: OSPF
192.0.2.16/28:
routes:
- args: '* I (150/10) [192.0.2.2]'
dest: unicast
nexthop:
- iface: ve12
ospf_metric1: '10'
ospf_router_id: 192.0.2.2
preference: '150'
proto: ospf4
source: OSPF
192.0.2.32/28:
routes:
- args: '* I (150/20) [192.0.2.18]'
dest: unicast
nexthop:
- iface: ve31 weight 1
nexthop: 192.0.2.1
- iface: ve12 weight 1
nexthop: 192.0.2.18
ospf_metric1: '20'
ospf_router_id: 192.0.2.18
preference: '150'
proto: ospf4
source: OSPF
192.0.2.96/28:
routes:
- args: '* I (150/20) [192.0.2.1]'
dest: unicast
nexthop:
- iface: ve31
nexthop: 192.0.2.1
ospf_metric1: '20'
ospf_router_id: 192.0.2.1
preference: '150'
proto: ospf4
source: OSPF
master5:
networks: {}
master6:
networks:
2001:db8:0:1::/64:
routes:
- args: '* I (150/10) [192.0.2.2]'
dest: unicast
nexthop:
- iface: ve12
ospf_metric1: '10'
ospf_router_id: 192.0.2.2
preference: '150'
proto: ospf6
source: OSPF
2001:db8:0:2::/64:
routes:
- args: '* I (150/20) [192.0.2.18]'
dest: unicast
nexthop:
- iface: ve12 weight 1
nexthop: fe80::5c38:8eff:fe25:1d68
- iface: ve31 weight 1
nexthop: fe80::ac55:22ff:fe32:3610
ospf_metric1: '20'
ospf_router_id: 192.0.2.18
preference: '150'
proto: ospf6
source: OSPF
2001:db8:0:6::/64:
routes:
- args: '* I (150/20) [192.0.2.1]'
dest: unicast
nexthop:
- iface: ve31
nexthop: fe80::ac55:22ff:fe32:3610
ospf_metric1: '20'
ospf_router_id: 192.0.2.1
preference: '150'
proto: ospf6
source: OSPF
2001:db8::/64:
routes:
- args: '* I (150/10) [192.0.2.2]'
dest: unicast
nexthop:
- iface: ve31
ospf_metric1: '10'
ospf_router_id: 192.0.2.2
preference: '150'
proto: ospf6
source: OSPF
---
tables:
master4:
networks:
192.0.2.0/28:
routes:
- args: '* I (150/20) [192.0.2.2]'
dest: unicast
nexthop:
- iface: ve12 weight 1
nexthop: 192.0.2.17
- iface: ve23 weight 1
nexthop: 192.0.2.34
ospf_metric1: '20'
ospf_router_id: 192.0.2.2
preference: '150'
proto: ospf4
source: OSPF
192.0.2.16/28:
routes:
- args: '* I (150/10) [192.0.2.18]'
dest: unicast
nexthop:
- iface: ve12
ospf_metric1: '10'
ospf_router_id: 192.0.2.18
preference: '150'
proto: ospf4
source: OSPF
192.0.2.32/28:
routes:
- args: '* I (150/10) [192.0.2.18]'
dest: unicast
nexthop:
- iface: ve23
ospf_metric1: '10'
ospf_router_id: 192.0.2.18
preference: '150'
proto: ospf4
source: OSPF
192.0.2.96/28:
routes:
- args: '* I (150/20) [192.0.2.1]'
dest: unicast
nexthop:
- iface: ve23
nexthop: 192.0.2.34
ospf_metric1: '20'
ospf_router_id: 192.0.2.1
preference: '150'
proto: ospf4
source: OSPF
master5:
networks: {}
master6:
networks:
2001:db8:0:1::/64:
routes:
- args: '* I (150/10) [192.0.2.18]'
dest: unicast
nexthop:
- iface: ve12
ospf_metric1: '10'
ospf_router_id: 192.0.2.18
preference: '150'
proto: ospf6
source: OSPF
2001:db8:0:2::/64:
routes:
- args: '* I (150/10) [192.0.2.18]'
dest: unicast
nexthop:
- iface: ve23
ospf_metric1: '10'
ospf_router_id: 192.0.2.18
preference: '150'
proto: ospf6
source: OSPF
2001:db8:0:6::/64:
routes:
- args: '* I (150/20) [192.0.2.1]'
dest: unicast
nexthop:
- iface: ve23
nexthop: fe80::7cda:1aff:feae:9831
ospf_metric1: '20'
ospf_router_id: 192.0.2.1
preference: '150'
proto: ospf6
source: OSPF
2001:db8::/64:
routes:
- args: '* I (150/20) [192.0.2.2]'
dest: unicast
nexthop:
- iface: ve12 weight 1
nexthop: fe80::4cfd:f0ff:fe23:167
- iface: ve23 weight 1
nexthop: fe80::7cda:1aff:feae:9831
ospf_metric1: '20'
ospf_router_id: 192.0.2.2
preference: '150'
proto: ospf6
source: OSPF
---
tables:
master4:
networks:
192.0.2.0/28:
routes:
- args: '* I (150/10) [192.0.2.1]'
dest: unicast
nexthop:
- iface: ve31
ospf_metric1: '10'
ospf_router_id: 192.0.2.1
preference: '150'
proto: ospf4
source: OSPF
192.0.2.16/28:
routes:
- args: '* I (150/20) [192.0.2.18]'
dest: unicast
nexthop:
- iface: ve31 weight 1
nexthop: 192.0.2.2
- iface: ve23 weight 1
nexthop: 192.0.2.33
ospf_metric1: '20'
ospf_router_id: 192.0.2.18
preference: '150'
proto: ospf4
source: OSPF
192.0.2.32/28:
routes:
- args: '* I (150/10) [192.0.2.1]'
dest: unicast
nexthop:
- iface: ve23
ospf_metric1: '10'
ospf_router_id: 192.0.2.1
preference: '150'
proto: ospf4
source: OSPF
192.0.2.96/28:
routes:
- args: '* I (150/10) [192.0.2.1]'
dest: unicast
nexthop:
- iface: multi
ospf_metric1: '10'
ospf_router_id: 192.0.2.1
preference: '150'
proto: ospf4
source: OSPF
master5:
networks: {}
master6:
networks:
2001:db8:0:1::/64:
routes:
- args: '* I (150/20) [192.0.2.18]'
dest: unicast
nexthop:
- iface: ve31 weight 1
nexthop: fe80::5c82:ccff:fe47:46df
- iface: ve23 weight 1
nexthop: fe80::8c41:8bff:fe8f:9446
ospf_metric1: '20'
ospf_router_id: 192.0.2.18
preference: '150'
proto: ospf6
source: OSPF
2001:db8:0:2::/64:
routes:
- args: '* I (150/10) [192.0.2.1]'
dest: unicast
nexthop:
- iface: ve23
ospf_metric1: '10'
ospf_router_id: 192.0.2.1
preference: '150'
proto: ospf6
source: OSPF
2001:db8:0:6::/64:
routes:
- args: '* I (150/10) [192.0.2.1]'
dest: unicast
nexthop:
- iface: multi
ospf_metric1: '10'
ospf_router_id: 192.0.2.1
preference: '150'
proto: ospf6
source: OSPF
2001:db8::/64:
routes:
- args: '* I (150/10) [192.0.2.1]'
dest: unicast
nexthop:
- iface: ve31
ospf_metric1: '10'
ospf_router_id: 192.0.2.1
preference: '150'
proto: ospf6
source: OSPF
---
tables:
master4:
networks:
192.0.2.96/28:
routes:
- args: '* I (150/10) [192.0.2.98]'
dest: unicast
nexthop:
- iface: multi
ospf_metric1: '10'
ospf_router_id: 192.0.2.98
preference: '150'
proto: ospf4
source: OSPF
master5:
networks: {}
master6:
networks:
2001:db8:0:6::/64:
routes:
- args: '* I (150/10) [192.0.2.98]'
dest: unicast
nexthop:
- iface: multi
ospf_metric1: '10'
ospf_router_id: 192.0.2.98
preference: '150'
proto: ospf6
source: OSPF
---
tables:
master4:
networks:
192.0.2.48/28:
routes:
- args: '* I (150/10) [192.0.2.49]'
dest: unicast
nexthop:
- iface: ve57
ospf_metric1: '10'
ospf_router_id: 192.0.2.49
preference: '150'
proto: ospf4
source: OSPF
192.0.2.64/28:
routes:
- args: '* I (150/20) [192.0.2.50]'
dest: unicast
nexthop:
- iface: ve57
nexthop: 192.0.2.50
ospf_metric1: '20'
ospf_router_id: 192.0.2.50
preference: '150'
proto: ospf4
source: OSPF
192.0.2.80/28:
routes:
- args: '* I (150/30) [192.0.2.66]'
dest: unicast
nexthop:
- iface: ve57
nexthop: 192.0.2.50
ospf_metric1: '30'
ospf_router_id: 192.0.2.66
preference: '150'
proto: ospf4
source: OSPF
192.0.2.96/28:
routes:
- args: '* I (150/10) [192.0.2.49]'
dest: unicast
nexthop:
- iface: multi
ospf_metric1: '10'
ospf_router_id: 192.0.2.49
preference: '150'
proto: ospf4
source: OSPF
master5:
networks: {}
master6:
networks:
2001:db8:0:3::/64:
routes:
- args: '* I (150/10) [192.0.2.49]'
dest: unicast
nexthop:
- iface: ve57
ospf_metric1: '10'
ospf_router_id: 192.0.2.49
preference: '150'
proto: ospf6
source: OSPF
2001:db8:0:4::/64:
routes:
- args: '* I (150/20) [192.0.2.50]'
dest: unicast
nexthop:
- iface: ve57
nexthop: fe80::9c97:afff:fe62:f695
ospf_metric1: '20'
ospf_router_id: 192.0.2.50
preference: '150'
proto: ospf6
source: OSPF
2001:db8:0:5::/64:
routes:
- args: '* I (150/30) [192.0.2.66]'
dest: unicast
nexthop:
- iface: ve57
nexthop: fe80::9c97:afff:fe62:f695
ospf_metric1: '30'
ospf_router_id: 192.0.2.66
preference: '150'
proto: ospf6
source: OSPF
2001:db8:0:6::/64:
routes:
- args: '* I (150/10) [192.0.2.49]'
dest: unicast
nexthop:
- iface: multi
ospf_metric1: '10'
ospf_router_id: 192.0.2.49
preference: '150'
proto: ospf6
source: OSPF
---
tables:
master4:
networks:
192.0.2.48/28:
routes:
- args: '* I (150/30) [192.0.2.50]'
dest: unicast
nexthop:
- iface: ve86
nexthop: 192.0.2.81
ospf_metric1: '30'
ospf_router_id: 192.0.2.50
preference: '150'
proto: ospf4
source: OSPF
192.0.2.64/28:
routes:
- args: '* I (150/20) [192.0.2.66]'
dest: unicast
nexthop:
- iface: ve86
nexthop: 192.0.2.81
ospf_metric1: '20'
ospf_router_id: 192.0.2.66
preference: '150'
proto: ospf4
source: OSPF
192.0.2.80/28:
routes:
- args: '* I (150/10) [192.0.2.82]'
dest: unicast
nexthop:
- iface: ve86
ospf_metric1: '10'
ospf_router_id: 192.0.2.82
preference: '150'
proto: ospf4
source: OSPF
192.0.2.96/28:
routes:
- args: '* I (150/10) [192.0.2.82]'
dest: unicast
nexthop:
- iface: multi
ospf_metric1: '10'
ospf_router_id: 192.0.2.82
preference: '150'
proto: ospf4
source: OSPF
master5:
networks: {}
master6:
networks:
2001:db8:0:3::/64:
routes:
- args: '* I (150/30) [192.0.2.50]'
dest: unicast
nexthop:
- iface: ve86
nexthop: fe80::6cc9:f2ff:feb9:754f
ospf_metric1: '30'
ospf_router_id: 192.0.2.50
preference: '150'
proto: ospf6
source: OSPF
2001:db8:0:4::/64:
routes:
- args: '* I (150/20) [192.0.2.66]'
dest: unicast
nexthop:
- iface: ve86
nexthop: fe80::6cc9:f2ff:feb9:754f
ospf_metric1: '20'
ospf_router_id: 192.0.2.66
preference: '150'
proto: ospf6
source: OSPF
2001:db8:0:5::/64:
routes:
- args: '* I (150/10) [192.0.2.82]'
dest: unicast
nexthop:
- iface: ve86
ospf_metric1: '10'
ospf_router_id: 192.0.2.82
preference: '150'
proto: ospf6
source: OSPF
2001:db8:0:6::/64:
routes:
- args: '* I (150/10) [192.0.2.82]'
dest: unicast
nexthop:
- iface: multi
ospf_metric1: '10'
ospf_router_id: 192.0.2.82
preference: '150'
proto: ospf6
source: OSPF
---
tables:
master4:
networks:
192.0.2.48/28:
routes:
- args: '* I (150/10) [192.0.2.50]'
dest: unicast
nexthop:
- iface: ve57
ospf_metric1: '10'
ospf_router_id: 192.0.2.50
preference: '150'
proto: ospf4
source: OSPF
192.0.2.64/28:
routes:
- args: '* I (150/10) [192.0.2.50]'
dest: unicast
nexthop:
- iface: ve78
ospf_metric1: '10'
ospf_router_id: 192.0.2.50
preference: '150'
proto: ospf4
source: OSPF
192.0.2.80/28:
routes:
- args: '* I (150/20) [192.0.2.66]'
dest: unicast
nexthop:
- iface: ve78
nexthop: 192.0.2.66
ospf_metric1: '20'
ospf_router_id: 192.0.2.66
preference: '150'
proto: ospf4
source: OSPF
192.0.2.96/28:
routes:
- args: '* I (150/20) [192.0.2.49]'
dest: unicast
nexthop:
- iface: ve57
nexthop: 192.0.2.49
ospf_metric1: '20'
ospf_router_id: 192.0.2.49
preference: '150'
proto: ospf4
source: OSPF
master5:
networks: {}
master6:
networks:
2001:db8:0:3::/64:
routes:
- args: '* I (150/10) [192.0.2.50]'
dest: unicast
nexthop:
- iface: ve57
ospf_metric1: '10'
ospf_router_id: 192.0.2.50
preference: '150'
proto: ospf6
source: OSPF
2001:db8:0:4::/64:
routes:
- args: '* I (150/10) [192.0.2.50]'
dest: unicast
nexthop:
- iface: ve78
ospf_metric1: '10'
ospf_router_id: 192.0.2.50
preference: '150'
proto: ospf6
source: OSPF
2001:db8:0:5::/64:
routes:
- args: '* I (150/20) [192.0.2.66]'
dest: unicast
nexthop:
- iface: ve78
nexthop: fe80::8c67:1aff:fe6f:1193
ospf_metric1: '20'
ospf_router_id: 192.0.2.66
preference: '150'
proto: ospf6
source: OSPF
2001:db8:0:6::/64:
routes:
- args: '* I (150/20) [192.0.2.49]'
dest: unicast
nexthop:
- iface: ve57
nexthop: fe80::2c33:44ff:fe0f:454b
ospf_metric1: '20'
ospf_router_id: 192.0.2.49
preference: '150'
proto: ospf6
source: OSPF
---
tables:
master4:
networks:
192.0.2.48/28:
routes:
- args: '* I (150/20) [192.0.2.50]'
dest: unicast
nexthop:
- iface: ve78
nexthop: 192.0.2.65
ospf_metric1: '20'
ospf_router_id: 192.0.2.50
preference: '150'
proto: ospf4
source: OSPF
192.0.2.64/28:
routes:
- args: '* I (150/10) [192.0.2.66]'
dest: unicast
nexthop:
- iface: ve78
ospf_metric1: '10'
ospf_router_id: 192.0.2.66
preference: '150'
proto: ospf4
source: OSPF
192.0.2.80/28:
routes:
- args: '* I (150/10) [192.0.2.66]'
dest: unicast
nexthop:
- iface: ve86
ospf_metric1: '10'
ospf_router_id: 192.0.2.66
preference: '150'
proto: ospf4
source: OSPF
192.0.2.96/28:
routes:
- args: '* I (150/20) [192.0.2.82]'
dest: unicast
nexthop:
- iface: ve86
nexthop: 192.0.2.82
ospf_metric1: '20'
ospf_router_id: 192.0.2.82
preference: '150'
proto: ospf4
source: OSPF
master5:
networks: {}
master6:
networks:
2001:db8:0:3::/64:
routes:
- args: '* I (150/20) [192.0.2.50]'
dest: unicast
nexthop:
- iface: ve78
nexthop: fe80::ac21:71ff:fea9:abe
ospf_metric1: '20'
ospf_router_id: 192.0.2.50
preference: '150'
proto: ospf6
source: OSPF
2001:db8:0:4::/64:
routes:
- args: '* I (150/10) [192.0.2.66]'
dest: unicast
nexthop:
- iface: ve78
ospf_metric1: '10'
ospf_router_id: 192.0.2.66
preference: '150'
proto: ospf6
source: OSPF
2001:db8:0:5::/64:
routes:
- args: '* I (150/10) [192.0.2.66]'
dest: unicast
nexthop:
- iface: ve86
ospf_metric1: '10'
ospf_router_id: 192.0.2.66
preference: '150'
proto: ospf6
source: OSPF
2001:db8:0:6::/64:
routes:
- args: '* I (150/20) [192.0.2.82]'
dest: unicast
nexthop:
- iface: ve86
nexthop: fe80::5cf4:d5ff:fe79:c89
ospf_metric1: '20'
ospf_router_id: 192.0.2.82
preference: '150'
proto: ospf6
source: OSPF

View File

@ -0,0 +1,27 @@
log "{{ m.logs[0].name }}" all;
ipv4 table master4;
ipv4 table master5;
ipv6 table master6;
protocol device {}
{% for v in (4,6) %}
protocol kernel kernel{{ v }} {
ipv{{v}} { table master{{v}}; export all; };
}
protocol ospf v{{(v//2)}} ospf{{v}} {
ipv{{v}} { table master{{v}}; import all; export all; };
area 0 {
interface "ve*" {
hello 2;
type ptp;
};
interface "multi" {
hello 2;
type bcast;
};
};
}
{% endfor %}

36
flock/ospf-base/test.py Normal file
View File

@ -0,0 +1,36 @@
#!/usr/bin/python3
import asyncio
from python.BIRD.Test import Test, BIRDInstance
from python.BIRD.LogChecker import LogExpectedStub
class ThisTest(Test):
async def prepare(self):
# Set epoch
# Prepare machines and links
await self.machines(
*[ f"m{n}" for n in range(1,9) ],
t=BIRDInstance,
)
for m in self.machine_index.values():
m.conf = "template.conf"
m.default_log_checker.expected += [
LogExpectedStub(f"{m.logprefix} <INFO> Chosen router ID .*")
]
await asyncio.gather(*[
self.link("ve31", "m3", "m1"),
self.link("ve12", "m1", "m2"),
self.link("ve23", "m2", "m3"),
self.link("ve57", "m5", "m7"),
self.link("ve78", "m7", "m8"),
self.link("ve86", "m8", "m6"),
self.link("multi", "m3", "m4", "m5", "m6"),
])
async def test(self):
# Startup check
await self.route_dump(30, "startup")

View File

@ -120,6 +120,15 @@ class NextHopParser(CLIParser):
def exit(self):
self.parent.result["nexthop"].append(self.result)
@subparser(RouteParser)
class DevNextHopParser(CLIParser):
entryRegex = re.compile("\\s+dev ([^:]*)")
def enter(self, groups):
self.iface ,= groups
def exit(self):
self.parent.result["nexthop"].append({ "iface": self.iface })
@subparser(RouteParser)
class AttributeParser(CLIParser):
entryRegex = re.compile("\\s+([a-zA-Z_.0-9]+): (.*)$")

View File

@ -157,11 +157,18 @@ class BIRDInstance(CLI):
self.default_log_checker.expected += exp
async with asyncio.timeout(5):
await asyncio.gather(
coro,
*[ e.done for e in exp ]
)
main_task = asyncio.create_task(coro)
try:
async with asyncio.timeout(5):
await asyncio.gather(
main_task,
*[ e.done for e in exp ]
)
except TimeoutError as e:
for e in exp:
if not e.done.done():
print(f"Not done: {e}: {e.pattern}")
for e in exp:
self.default_log_checker.expected.remove(e)
@ -234,6 +241,7 @@ class Test:
self.name = name
self.hypervisor = Hypervisor(name)
self.machine_index = {}
self.link_index = {}
self.mode = mode
self._started = None
self._starting = False
@ -299,7 +307,7 @@ class Test:
raise Exception("Link with no machines? HOW?!")
case 1:
raise NotImplementedError("dummy link")
case 2:
case _:
linfo = await self.hcom("link", name, {
"machines": { m: { "name": name } for m in machines },
"ipv6": str(next(self.ipv6_pxgen)),
@ -309,11 +317,9 @@ class Test:
for i in ("ipv4", "ipv6"):
linfo[m][i] = ipaddress.ip_interface(linfo[m][i])
self.link_index[name] = linfo
return linfo
case _:
raise NotImplementedError("virtual bridge")
async def start(self):
return await asyncio.gather(*[ v.start(test=self) for v in self.machine_index.values() ])

@ -1 +1 @@
Subproject commit c531877af0fb833747696ecce3dc9d5111930644
Subproject commit 8a733f18b122470e092915013e2b2cec1cb2baec