mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-12-22 01:31:55 +00:00
Flock test: integrated with Makefile
This commit is contained in:
parent
62145d087b
commit
d544213200
@ -76,7 +76,7 @@ cli: $(client)
|
||||
$(daemon): LIBS += $(DAEMON_LIBS)
|
||||
|
||||
# Include directories
|
||||
dirs := client conf doc filter lib nest test $(addprefix proto/,$(protocols)) @sysdep_dirs@
|
||||
dirs := client conf doc filter lib nest test flock $(addprefix proto/,$(protocols)) @sysdep_dirs@
|
||||
|
||||
# conf/Makefile declarations needed for all other modules
|
||||
conf-lex-targets := $(addprefix $(objdir)/conf/,cf-lex.o)
|
||||
|
10
flock/Makefile
Normal file
10
flock/Makefile
Normal file
@ -0,0 +1,10 @@
|
||||
flock-%:
|
||||
@python3 -m python.BIRD.Test $*
|
||||
|
||||
FLOCK_ALL := $(addprefix flock-, \
|
||||
bgp-secondary \
|
||||
)
|
||||
|
||||
flock-all: $(FLOCK_ALL)
|
||||
|
||||
.PHONY: flock-all
|
@ -1,18 +1,7 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import asyncio
|
||||
import os
|
||||
import pathlib
|
||||
import sys
|
||||
|
||||
selfpath = pathlib.Path(__file__)
|
||||
name = selfpath.parent.stem
|
||||
|
||||
sys.path.insert(0, str(selfpath.parent.parent / "lib"))
|
||||
|
||||
from BIRD.Test import Test, BIRDInstance
|
||||
|
||||
os.chdir(pathlib.Path(__file__).parent)
|
||||
from python.BIRD.Test import Test, BIRDInstance
|
||||
|
||||
class ThisTest(Test):
|
||||
async def start(self):
|
||||
@ -26,44 +15,39 @@ class ThisTest(Test):
|
||||
|
||||
await super().start()
|
||||
|
||||
async def main():
|
||||
t = ThisTest(name)
|
||||
async def run(t):
|
||||
await t.start()
|
||||
|
||||
await t.start()
|
||||
h = t.hypervisor
|
||||
|
||||
h = t.hypervisor
|
||||
print(t.links, t.src, t.dest)
|
||||
|
||||
print(t.links, t.src, t.dest)
|
||||
await asyncio.sleep(5)
|
||||
|
||||
await asyncio.sleep(5)
|
||||
|
||||
print(await asyncio.gather(*[
|
||||
where.show_route()
|
||||
for where in (t.src, t.dest)
|
||||
]))
|
||||
|
||||
await asyncio.sleep(1)
|
||||
|
||||
for p in ("p170", "p180", "p190", "p200"):
|
||||
await t.src.enable(p)
|
||||
await asyncio.sleep(1)
|
||||
|
||||
shr = await asyncio.gather(*[
|
||||
print(await asyncio.gather(*[
|
||||
where.show_route()
|
||||
for where in (t.src, t.dest)
|
||||
])
|
||||
|
||||
print(shr[0]["out"].decode(), shr[1]["out"].decode())
|
||||
]))
|
||||
|
||||
await asyncio.sleep(1)
|
||||
|
||||
print(await asyncio.gather(*[
|
||||
where.show_route()
|
||||
for where in (t.src, t.dest)
|
||||
]))
|
||||
for p in ("p170", "p180", "p190", "p200"):
|
||||
await t.src.enable(p)
|
||||
await asyncio.sleep(1)
|
||||
|
||||
await t.cleanup()
|
||||
await h.control_socket.send_cmd("stop", True)
|
||||
shr = await asyncio.gather(*[
|
||||
where.show_route()
|
||||
for where in (t.src, t.dest)
|
||||
])
|
||||
|
||||
assert(__name__ == "__main__")
|
||||
asyncio.run(main())
|
||||
print(shr[0]["out"].decode(), shr[1]["out"].decode())
|
||||
|
||||
await asyncio.sleep(1)
|
||||
|
||||
print(await asyncio.gather(*[
|
||||
where.show_route()
|
||||
for where in (t.src, t.dest)
|
||||
]))
|
||||
|
||||
await t.cleanup()
|
||||
await h.control_socket.send_cmd("stop", True)
|
||||
|
@ -1 +0,0 @@
|
||||
print("imported", __file__)
|
@ -63,7 +63,7 @@ class BIRDBinDir:
|
||||
for bn in self.files:
|
||||
(target / bn).unlink()
|
||||
|
||||
default_bindir = BIRDBinDir.get("..")
|
||||
default_bindir = BIRDBinDir.get(".")
|
||||
|
||||
class BIRDInstance(CLI):
|
||||
def __init__(self, mach: Machine, bindir=None, conf=None):
|
||||
@ -112,13 +112,16 @@ class Test:
|
||||
self.name = name
|
||||
self.hypervisor = Hypervisor(name)
|
||||
self.machine_index = {}
|
||||
self._started = asyncio.Future()
|
||||
self._started = None
|
||||
self._starting = False
|
||||
|
||||
self.ipv6_pxgen = self.ipv6_prefix.subnets(new_prefix=self.ipv6_link_pxlen)
|
||||
self.ipv4_pxgen = self.ipv4_prefix.subnets(new_prefix=self.ipv4_link_pxlen)
|
||||
|
||||
async def hcom(self, *args):
|
||||
if self._started is None:
|
||||
self._started = asyncio.Future()
|
||||
|
||||
if self._started.done():
|
||||
return await self.hypervisor.control_socket.send_cmd(*args)
|
||||
|
||||
@ -185,3 +188,18 @@ class Test:
|
||||
|
||||
async def cleanup(self):
|
||||
await asyncio.gather(*[ v.cleanup() for v in self.machine_index.values() ])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
name = sys.argv[1]
|
||||
|
||||
p = (pathlib.Path(__file__).parent.parent.parent / "flock" / name).absolute()
|
||||
sys.path.insert(0, str(p))
|
||||
|
||||
if "MAKEFLAGS" in os.environ:
|
||||
print(os.environ["MAKEFLAGS"])
|
||||
|
||||
import test
|
||||
|
||||
os.chdir(p)
|
||||
asyncio.run(test.ThisTest(name).run())
|
0
python/BIRD/__init__.py
Normal file
0
python/BIRD/__init__.py
Normal file
Loading…
Reference in New Issue
Block a user