Commit 88a73f75 authored by Jérome Perrin's avatar Jérome Perrin

testcase: improve leaked partitions detection and cleanup

- We should only try to remove leaked partitions if we detected some,
  otherwise it may produce a strange message "unable to delete leaked
  partitions".
- If some supervisor configuration is still present after partition
  deletion, they must be removed not to block next test and the current
  test must be marked failed.
parent a620b0b5
Pipeline #6386 running with stage
in 0 seconds
...@@ -442,25 +442,30 @@ class SlapOSInstanceTestCase(unittest.TestCase): ...@@ -442,25 +442,30 @@ class SlapOSInstanceTestCase(unittest.TestCase):
cls.logger.critical( cls.logger.critical(
"The following partitions were not cleaned up: %s", "The following partitions were not cleaned up: %s",
[cp.getId() for cp in leaked_partitions]) [cp.getId() for cp in leaked_partitions])
for cp in leaked_partitions: for cp in leaked_partitions:
try:
cls.slap.request(
software_release=cp.getSoftwareRelease().getURI(),
# software_type=cp.getType(), # TODO
# XXX is this really the reference ?
partition_reference=cp.getInstanceParameterDict()['instance_title'],
state="destroyed")
except:
cls.logger.exception(
"Error during request destruction of leaked partition")
try: try:
cls.slap.request( cls.slap.waitForReport(max_retry=cls.report_max_retry, debug=cls._debug)
software_release=cp.getSoftwareRelease().getURI(),
# software_type=cp.getType(), # TODO
# XXX is this really the reference ?
partition_reference=cp.getInstanceParameterDict()['instance_title'],
state="destroyed")
except: except:
cls.logger.exception( cls.logger.exception("Error during leaked partitions actual destruction")
"Error during request destruction of leaked partition")
try:
cls.slap.waitForReport(max_retry=cls.report_max_retry, debug=cls._debug)
except:
cls.logger.exception("Error during leaked partitions actual destruction")
try: try:
cls.slap.stop() cls.slap.stop()
except: except:
cls.logger.exception("Error during stop") cls.logger.exception("Error during stop")
leaked_supervisor_configs = glob.glob(
os.path.join(cls.slap.instance_directory, 'etc', 'supervisord.conf.d', '*.conf'))
if leaked_supervisor_configs:
[os.unlink(config) for config in leaked_supervisor_configs]
raise AssertionError("Test leaked supervisor configurations: %s" % leaked_supervisor_configs)
@classmethod @classmethod
def requestDefaultInstance(cls, state='started'): def requestDefaultInstance(cls, state='started'):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment