From 045f75ff0e50e3afccdebbba5f506fa4a5cc703f Mon Sep 17 00:00:00 2001 From: Joe Gordon Date: Thu, 25 Jul 2013 22:05:05 -0700 Subject: [PATCH] Remove sleep from service group db and mc tests Before servicegroup.test_db_servicegroup and test_mc_servicegroup used eventlet to put the test to sleep and waited for the service to run its periodic _report_state instead of using timeutils and explicitly calling _report_state. By switching to a timeutils fixture The following tests, are removed from the list of top 10 lowest tests: nova.tests.servicegroup.test_db_servicegroup.DBServiceGroupTestCase.test_DB_driver nova.tests.servicegroup.test_mc_servicegroup.MemcachedServiceGroupTestCase.test_memcached_driver Change-Id: I091a9975cc7e4fccb26700359d1e3b5c165034d3 --- nova/tests/servicegroup/test_db_servicegroup.py | 7 ++++--- nova/tests/servicegroup/test_mc_servicegroup.py | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/nova/tests/servicegroup/test_db_servicegroup.py b/nova/tests/servicegroup/test_db_servicegroup.py index a7ab3ff6f2..43b6c5d112 100644 --- a/nova/tests/servicegroup/test_db_servicegroup.py +++ b/nova/tests/servicegroup/test_db_servicegroup.py @@ -14,7 +14,6 @@ import datetime -import eventlet import fixtures from nova import context @@ -68,14 +67,16 @@ class DBServiceGroupTestCase(test.TestCase): self._binary) self.assertTrue(self.servicegroup_api.service_is_up(service_ref)) - eventlet.sleep(self.down_time + 1) + self.useFixture(test.TimeOverride()) + timeutils.advance_time_seconds(self.down_time + 1) + self.servicegroup_api._driver._report_state(serv) service_ref = db.service_get_by_args(self._ctx, self._host, self._binary) self.assertTrue(self.servicegroup_api.service_is_up(service_ref)) serv.stop() - eventlet.sleep(self.down_time + 1) + timeutils.advance_time_seconds(self.down_time + 1) service_ref = db.service_get_by_args(self._ctx, self._host, self._binary) diff --git a/nova/tests/servicegroup/test_mc_servicegroup.py b/nova/tests/servicegroup/test_mc_servicegroup.py index 9f27ecc31f..5e7922f4dd 100644 --- a/nova/tests/servicegroup/test_mc_servicegroup.py +++ b/nova/tests/servicegroup/test_mc_servicegroup.py @@ -15,7 +15,6 @@ # License for the specific language governing permissions and limitations # under the License. -import eventlet import fixtures from nova import context @@ -73,14 +72,16 @@ class MemcachedServiceGroupTestCase(test.TestCase): time=self.down_time) self.assertTrue(self.servicegroup_api.service_is_up(service_ref)) - eventlet.sleep(self.down_time + 1) + self.useFixture(test.TimeOverride()) + timeutils.advance_time_seconds(self.down_time + 1) + self.servicegroup_api._driver._report_state(serv) service_ref = db.service_get_by_args(self._ctx, self._host, self._binary) self.assertTrue(self.servicegroup_api.service_is_up(service_ref)) serv.stop() - eventlet.sleep(self.down_time + 1) + timeutils.advance_time_seconds(self.down_time + 1) service_ref = db.service_get_by_args(self._ctx, self._host, self._binary)