Skip to content

Commit

Permalink
fix(pytest): call stop for all instances even if stop raise exception (
Browse files Browse the repository at this point in the history
…#4339)


Signed-off-by: adi_holden <adi@dragonflydb.io>
  • Loading branch information
adiholden authored Dec 18, 2024
1 parent 682a3f6 commit 3f68028
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tests/dragonfly/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,9 +453,19 @@ def start_all(self, instances: List[DflyInstance]):

async def stop_all(self):
"""Stop all launched instances."""
exceptions = [] # To collect exceptions
for instance in self.instances:
await instance.close_clients()
instance.stop()
try:
instance.stop()
except Exception as e:
exceptions.append(e) # Collect the exception
if exceptions:
first_exception = exceptions[0]
raise Exception(
f"One or more errors occurred while stopping instances. "
f"First exception: {first_exception}"
) from first_exception

def __repr__(self) -> str:
return f"Factory({self.args})"
Expand Down

0 comments on commit 3f68028

Please sign in to comment.