From f0e4a810fff9abeb98a06dec39438fd10be95f31 Mon Sep 17 00:00:00 2001 From: Flavio Percoco Date: Thu, 13 Nov 2014 15:43:00 +0100 Subject: [PATCH] Correctly stop functional servers When running integration tests, the test suite starts real zaqar servers. The tearDown class was not stopping those servers correctly, which made the test suite re-use server instances when that was not necessary, causing other tests to fail. Change-Id: Ie701a8a609f8661c3607890c4b1b37ab110b155b Closes-bug: #1383604 --- zaqar/tests/functional/base.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/zaqar/tests/functional/base.py b/zaqar/tests/functional/base.py index 82c565785..2e370eb8f 100644 --- a/zaqar/tests/functional/base.py +++ b/zaqar/tests/functional/base.py @@ -48,6 +48,7 @@ class FunctionalTestBase(testing.TestBase): server = None server_class = None + config_file = None def setUp(self): super(FunctionalTestBase, self).setUp() @@ -60,7 +61,8 @@ class FunctionalTestBase(testing.TestBase): if not self.cfg.run_tests: self.skipTest("Functional tests disabled") - self.mconf = self.load_conf(self.cfg.zaqar.config) + self.mconf = self.load_conf(self.config_file or + self.cfg.zaqar.config) validator = validation.Validator(self.mconf) self.limits = validator._limits_conf @@ -78,6 +80,7 @@ class FunctionalTestBase(testing.TestBase): if not (self.server and self.server.is_alive()): self.server = self.server_class() self.server.start(self.mconf) + self.addCleanup(self.server.process.terminate) self.client = http.Client() else: @@ -99,11 +102,6 @@ class FunctionalTestBase(testing.TestBase): self.client.set_headers(self.headers) - @classmethod - def tearDownClass(cls): - if cls.server: - cls.server.process.terminate() - def assertIsSubset(self, required_values, actual_values): """Checks if a list is subset of another. @@ -281,7 +279,6 @@ class ZaqarAdminServer(Server): def get_target(self, conf): conf.admin_mode = True server = bootstrap.Bootstrap(conf) - conf.admin_mode = False return server.run