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

Flock tests: cleanup on crash

This commit is contained in:
Maria Matejka 2024-07-22 10:18:41 +02:00
parent 41bd2d0cd7
commit 5eea993f60
2 changed files with 14 additions and 1 deletions

View File

@ -4,7 +4,7 @@ import asyncio
from python.BIRD.Test import Test, BIRDInstance
class ThisTest(Test):
async def run(self):
async def test(self):
# Set epoch
self.epoch = 0

View File

@ -153,6 +153,7 @@ class BIRDInstance(CLI):
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")
@ -174,6 +175,7 @@ class Test:
self.mode = mode
self._started = None
self._starting = False
self._stopped = None
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)
@ -181,6 +183,9 @@ class Test:
self.route_dump_id = 0
async def hcom(self, *args):
if self._stopped is not None:
return
if self._started is None:
self._started = asyncio.Future()
@ -250,7 +255,15 @@ class Test:
async def cleanup(self):
await asyncio.gather(*[ v.cleanup() for v in self.machine_index.values() ])
self.machine_index = {}
await self.hcom("stop", True)
self._stopped = True
async def run(self):
try:
await self.test()
finally:
await self.cleanup()
async def route_dump(self, timeout, name, full=True, machines=None, check_timeout=10, check_retry_timeout=0.5):
# Compile dump ID