mirror of
https://github.com/optim-enterprises-bv/openlan-cgw.git
synced 2025-11-02 11:17:47 +00:00
Added cleanup for each test case
This commit is contained in:
@@ -67,9 +67,18 @@ def test_context():
|
|||||||
|
|
||||||
ctx.device_sim.disconnect()
|
ctx.device_sim.disconnect()
|
||||||
|
|
||||||
# Let's make sure we destroy default group after we're done with tests.
|
# Let's make sure we destroy all groups after we're done with tests.
|
||||||
if ctx.kafka_producer.is_connected():
|
if ctx.kafka_producer.is_connected():
|
||||||
|
# 1. Destroy default group
|
||||||
ctx.kafka_producer.handle_single_group_delete(ctx.default_kafka_group())
|
ctx.kafka_producer.handle_single_group_delete(ctx.default_kafka_group())
|
||||||
|
# 2. Get all groups from Redis or PostgeSQL
|
||||||
|
groups_list = ctx.psql_client.get_all_infrastructure_groups()
|
||||||
|
|
||||||
|
if groups_list != None:
|
||||||
|
# 3. Interate over groups
|
||||||
|
for group in groups_list:
|
||||||
|
# 4. Send group_del request
|
||||||
|
ctx.kafka_producer.handle_single_group_delete(str(group[0]))
|
||||||
|
|
||||||
# We have to clear any messages after done working with kafka
|
# We have to clear any messages after done working with kafka
|
||||||
if ctx.kafka_consumer.is_connected():
|
if ctx.kafka_consumer.is_connected():
|
||||||
|
|||||||
@@ -84,6 +84,15 @@ class PostgreSQLClient:
|
|||||||
|
|
||||||
return group_info
|
return group_info
|
||||||
|
|
||||||
|
def get_all_infrastructure_groups(self) -> List[Tuple[int, int, int]]:
|
||||||
|
"""Fetch group record by group id."""
|
||||||
|
group_list = list()
|
||||||
|
|
||||||
|
self.execute_query(f"select * from infrastructure_groups;")
|
||||||
|
group_list = self.fetchall()
|
||||||
|
|
||||||
|
return group_list
|
||||||
|
|
||||||
def get_infra(self, mac: str) -> Tuple[str, int]:
|
def get_infra(self, mac: str) -> Tuple[str, int]:
|
||||||
"""Fetch group record by infra mac."""
|
"""Fetch group record by infra mac."""
|
||||||
infra_info = None
|
infra_info = None
|
||||||
|
|||||||
Reference in New Issue
Block a user