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

Flock tests: Adding necessary cleanup routines

This commit is contained in:
Maria Matejka 2024-07-12 19:03:17 +02:00
parent d84d2d64cd
commit db8d849756
2 changed files with 23 additions and 2 deletions

View File

@ -83,8 +83,9 @@ async def main():
]))
await asyncio.sleep(5)
await t.cleanup()
for q in (t.dest, t.src):
for f in ("bird", "birdc", "bird.conf", "bird.log"):
for f in ("bird.conf", "bird.log"):
(q.workdir / f).unlink()
await h.control_socket.send_cmd("stop", True)

View File

@ -58,6 +58,10 @@ class BIRDBinDir:
b.write(v)
(target / bn).chmod(self.mod[bn])
def cleanup(self, target):
for bn in self.files:
(target / bn).unlink()
default_bindir = BIRDBinDir.get("..")
class BIRDInstance(CLI):
@ -75,6 +79,9 @@ class BIRDInstance(CLI):
self.bindir.copy(self.workdir)
async def cleanup(self):
self.bindir.cleanup(self.workdir)
class Test:
ipv6_prefix = ipaddress.ip_network("2001:db8::/32")
ipv4_prefix = ipaddress.ip_network("192.0.2.0/24")
@ -87,6 +94,7 @@ class Test:
def __init__(self, name):
self.name = name
self.hypervisor = Hypervisor(name)
self.machine_index = {}
self._started = asyncio.Future()
self._starting = False
@ -111,12 +119,16 @@ class Test:
return await self.hypervisor.control_socket.send_cmd_early(*args)
async def machines(self, *names, t: type):
for n in names:
if n in self.machine_index:
raise Exception(f"Machine {n} duplicate")
info = await asyncio.gather(*[
self.hcom("machine", name, { "type": "minimalist" })
for name in names
])
return [
inst = [
t(mach=Machine.new(
name=n,
hypervisor=self.hypervisor,
@ -124,6 +136,11 @@ class Test:
)) for n,i in zip(names, info)
]
for n,i in zip(names, inst):
self.machine_index[n] = i
return inst
async def link(self, name, *machines):
match len(machines):
case 0:
@ -144,3 +161,6 @@ class Test:
case _:
raise NotImplementedError("virtual bridge")
async def cleanup(self):
await asyncio.gather(*[ v.cleanup() for v in self.machine_index.values() ])