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
This commit is contained in:
Joe Gordon
2013-07-25 22:05:05 -07:00
parent 88f414ecc8
commit 045f75ff0e
2 changed files with 8 additions and 6 deletions

View File

@@ -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)

View File

@@ -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)