def setUp(self): super(AuditPeriodTest, self).setUp() #a fairly random time to test with self.test_time = datetime.datetime(second=23, minute=12, hour=8, day=5, month=3, year=2012) utils.set_time_override(override_time=self.test_time)
def test_get_zone_capabilities_expired_host(self): zm = zone_manager.ZoneManager() expiry_time = (FLAGS.periodic_interval * 3) + 1 # Service capabilities stale zm.update_service_capabilities("svc1", "host1", dict(a=1, b=2)) time_future = utils.utcnow() + datetime.timedelta(seconds=expiry_time) utils.set_time_override(time_future) caps = zm.get_zone_capabilities(None) self.assertEquals(caps, {}) utils.clear_time_override()
def test_host_service_caps_stale_all_stale_services(self): zm = zone_manager.ZoneManager() expiry_time = (FLAGS.periodic_interval * 3) + 1 # Both services became stale zm.update_service_capabilities("svc1", "host1", dict(a=1, b=2)) zm.update_service_capabilities("svc2", "host1", dict(a=3, b=4)) time_future = utils.utcnow() + datetime.timedelta(seconds=expiry_time) utils.set_time_override(time_future) self.assertTrue(zm.host_service_caps_stale("host1", "svc1")) self.assertTrue(zm.host_service_caps_stale("host1", "svc2")) utils.clear_time_override()
def test_get_zone_capabilities_all_stale_host_services(self): zm = zone_manager.ZoneManager() expiry_time = (FLAGS.periodic_interval * 3) + 1 # All the host services become stale zm.update_service_capabilities("svc1", "host1", dict(a=1, b=2)) zm.update_service_capabilities("svc1", "host2", dict(a=3, b=4)) zm.update_service_capabilities("svc2", "host1", dict(a=5, b=6)) zm.update_service_capabilities("svc2", "host2", dict(a=7, b=8)) time_future = utils.utcnow() + datetime.timedelta(seconds=expiry_time) utils.set_time_override(time_future) caps = zm.get_zone_capabilities(None) self.assertEquals(caps, {})
def setUp(self): # pylint: disable=C0103 super(LockoutTestCase, self).setUp() utils.set_time_override() self.lockout = ec2.Lockout(conditional_forbid)