Commit 363f4bba authored by Xavier Thompson's avatar Xavier Thompson Committed by Thomas Gambier

software/kvm: Properly cleanup server subprocesses

without this cleanup, the software integration tests of KVM were stuck
forever because unittest was waiting for the subprocess to stop.
parent 5fcc4234
Pipeline #29232 failed with stage
in 0 seconds
...@@ -870,7 +870,7 @@ class FakeImageServerMixin(KvmMixin): ...@@ -870,7 +870,7 @@ class FakeImageServerMixin(KvmMixin):
os.chdir(cls.image_source_directory) os.chdir(cls.image_source_directory)
try: try:
cls.server_process = multiprocessing.Process( cls.server_process = multiprocessing.Process(
target=server.serve_forever, name='FakeImageHttpServer') target=server.serve_forever, name='FakeImageHttpServer', daemon=True)
cls.server_process.start() cls.server_process.start()
server.socket.close() server.socket.close()
finally: finally:
...@@ -931,8 +931,12 @@ class TestBootImageUrlList(InstanceTestCase, FakeImageServerMixin): ...@@ -931,8 +931,12 @@ class TestBootImageUrlList(InstanceTestCase, FakeImageServerMixin):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
cls.startImageHttpServer() try:
super().setUpClass() cls.startImageHttpServer()
super().setUpClass()
except BaseException:
cls.stopImageHttpServer()
raise
@classmethod @classmethod
def tearDownClass(cls): def tearDownClass(cls):
...@@ -2269,7 +2273,7 @@ class TestInstanceHttpServer(InstanceTestCase, KvmMixin): ...@@ -2269,7 +2273,7 @@ class TestInstanceHttpServer(InstanceTestCase, KvmMixin):
os.chdir(cls.http_directory) os.chdir(cls.http_directory)
try: try:
cls.server_process = multiprocessing.Process( cls.server_process = multiprocessing.Process(
target=server.serve_forever, name='HttpServer') target=server.serve_forever, name='HttpServer', daemon=True)
cls.server_process.start() cls.server_process.start()
finally: finally:
os.chdir(old_dir) os.chdir(old_dir)
...@@ -2288,8 +2292,12 @@ class TestInstanceHttpServer(InstanceTestCase, KvmMixin): ...@@ -2288,8 +2292,12 @@ class TestInstanceHttpServer(InstanceTestCase, KvmMixin):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
cls.startHttpServer() try:
super().setUpClass() cls.startHttpServer()
super().setUpClass()
except BaseException:
cls.stopHttpServer()
raise
@classmethod @classmethod
def tearDownClass(cls): def tearDownClass(cls):
......
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