From: git-harry Date: Mon, 31 Mar 2014 12:59:56 +0000 (+0100) Subject: Fixes HostTestCase failures due to slow test run X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=4465cd20b42c0db0efd405b57d9dc141bf6ed918;p=openstack-build%2Fcinder-build.git Fixes HostTestCase failures due to slow test run Status check in _list_hosts() fails if tests take longer than the service_down_time. Stubbing utcnow() guarantees that status check passes for tests. Change-Id: I188443730ce077a8117812f1089db36ece184e7a Closes-Bug: 1292643 --- diff --git a/cinder/tests/api/contrib/test_hosts.py b/cinder/tests/api/contrib/test_hosts.py index 7f8c542b5..f43dec3ee 100644 --- a/cinder/tests/api/contrib/test_hosts.py +++ b/cinder/tests/api/contrib/test_hosts.py @@ -28,7 +28,7 @@ from cinder import test LOG = logging.getLogger(__name__) created_time = datetime.datetime(2012, 11, 14, 1, 20, 41, 95099) -curr_time = timeutils.utcnow() +curr_time = datetime.datetime(2013, 7, 3, 0, 0, 1) SERVICE_LIST = [ {'created_at': created_time, 'updated_at': curr_time, @@ -58,6 +58,10 @@ LIST_RESPONSE = [{'service-status': 'available', 'service': 'cinder-volume', 'host_name': 'test.host.1', 'last-update': curr_time}] +def stub_utcnow(): + return datetime.datetime(2013, 7, 3, 0, 0, 2) + + def stub_service_get_all(self, req): return SERVICE_LIST @@ -81,6 +85,7 @@ class HostTestCase(test.TestCase): self.req = FakeRequest() self.stubs.Set(db, 'service_get_all', stub_service_get_all) + self.stubs.Set(timeutils, 'utcnow', stub_utcnow) def _test_host_update(self, host, key, val, expected_value): body = {key: val}