0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2025-01-03 07:31:54 +00:00

Flock test: Cleanup of development remnants.

TODO next phase: implement show-route parsing in Python,
output dumping and checking

After that, make this behave like an actual test.
This commit is contained in:
Maria Matejka 2024-07-12 22:01:55 +02:00
parent d544213200
commit 369962bdbc
2 changed files with 24 additions and 37 deletions

View File

@ -4,7 +4,20 @@ import asyncio
from python.BIRD.Test import Test, BIRDInstance from python.BIRD.Test import Test, BIRDInstance
class ThisTest(Test): class ThisTest(Test):
async def start(self): async def route_dump(self, timeout=None):
if timeout is not None:
await asyncio.sleep(timeout)
print(*[
f["out"].decode()
for f in await asyncio.gather(*[
where.show_route()
for where in (self.src, self.dest)
])
])
async def run(self):
# Prepare machines and links
self.src, self.dest = await self.machines( self.src, self.dest = await self.machines(
"src", "dest", "src", "dest",
t=BIRDInstance, t=BIRDInstance,
@ -13,41 +26,14 @@ class ThisTest(Test):
"L": await self.link("L", "src", "dest") "L": await self.link("L", "src", "dest")
} }
await super().start() # Start machines and links
await self.start()
async def run(t): # Partial test
await t.start() await self.route_dump(5)
h = t.hypervisor
print(t.links, t.src, t.dest)
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"): for p in ("p170", "p180", "p190", "p200"):
await t.src.enable(p) await self.src.enable(p)
await asyncio.sleep(1) await self.route_dump(1)
shr = await asyncio.gather(*[ await self.cleanup()
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)
]))
await t.cleanup()
await h.control_socket.send_cmd("stop", True)

View File

@ -188,6 +188,7 @@ class Test:
async def cleanup(self): async def cleanup(self):
await asyncio.gather(*[ v.cleanup() for v in self.machine_index.values() ]) await asyncio.gather(*[ v.cleanup() for v in self.machine_index.values() ])
await self.hcom("stop", True)
if __name__ == "__main__": if __name__ == "__main__":
@ -196,8 +197,8 @@ if __name__ == "__main__":
p = (pathlib.Path(__file__).parent.parent.parent / "flock" / name).absolute() p = (pathlib.Path(__file__).parent.parent.parent / "flock" / name).absolute()
sys.path.insert(0, str(p)) sys.path.insert(0, str(p))
if "MAKEFLAGS" in os.environ: # if "MAKEFLAGS" in os.environ:
print(os.environ["MAKEFLAGS"]) # print(os.environ["MAKEFLAGS"])
import test import test