From 6ed82b106c164560a4cbeddd39ed8a6a8d77d89d Mon Sep 17 00:00:00 2001 From: Alistair Coles Date: Fri, 26 Feb 2021 15:30:26 +0000 Subject: [PATCH] Run garbage collector during probe test setUp DatabaseBrokers cache opened connections. If a probe test instantiates a DatabaseBroker, or any other class that in turn instantiates a DatabaseBroker, such as a ContainerSharder, then connections may hold db files open until the DatabaseBroker is garbage collected. This can cause subsequent probe tests to fail during their setUp() because resetswift is unable to unmount device directories while db files are open. A call to gc.collect() is added during setUp() to ensure db files are closed before resetswift() is called. Closes-Bug: 1917050 Change-Id: Ifda4407c9ecff4c636fe07e013c3ebcebd0df018 --- test/probe/common.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/probe/common.py b/test/probe/common.py index 667e0245bb..4dd62fb372 100644 --- a/test/probe/common.py +++ b/test/probe/common.py @@ -16,6 +16,7 @@ from __future__ import print_function import errno +import gc import json import os from subprocess import Popen, PIPE @@ -371,6 +372,10 @@ class ProbeTest(unittest.TestCase): self.configs['proxy-server'] = conf def setUp(self): + # previous test may have left DatabaseBroker instances in garbage with + # open connections to db files which will prevent unmounting devices in + # resetswift, so collect garbage now + gc.collect() resetswift() kill_orphans() self._load_rings_and_configs()