def tearDown(self): """Runs after each test method to finalize/tear down test environment.""" try: self.mox.UnsetStubs() self.stubs.UnsetAll() self.stubs.SmartUnsetAll() self.mox.VerifyAll() # NOTE(vish): Clean up any ips associated during the test. ctxt = context.get_admin_context() db.fixed_ip_disassociate_all_by_timeout(ctxt, FLAGS.host, self.start) db.network_disassociate_all(ctxt) rpc.Consumer.attach_to_eventlet = self.originalAttach for x in self.injected: try: x.stop() except AssertionError: pass if FLAGS.fake_rabbit: fakerabbit.reset_all() db.security_group_destroy_all(ctxt) super(TestCase, self).tearDown() finally: self.reset_flags()
def test_fixed_ip_disassociate_all_by_timeout_multi_host(self): now = timeutils.utcnow() ctxt = context.get_admin_context() self._timeout_test(ctxt, now, True) result = db.fixed_ip_disassociate_all_by_timeout(ctxt, 'foo', now) self.assertEqual(result, 1) result = db.fixed_ip_disassociate_all_by_timeout(ctxt, 'bar', now) self.assertEqual(result, 0)
def test_fixed_ip_disassociate_all_by_timeout_multi_host(self): now = utils.utcnow() ctxt = context.get_admin_context() self._timeout_test(ctxt, now, True) result = db.fixed_ip_disassociate_all_by_timeout(ctxt, 'foo', now) self.assertEqual(result, 1) result = db.fixed_ip_disassociate_all_by_timeout(ctxt, 'bar', now) self.assertEqual(result, 0)
def test_fixed_ip_disassociate_all_by_timeout_single_host(self): now = utils.utcnow() ctxt = context.get_admin_context() self._timeout_test(ctxt, now, False) result = db.fixed_ip_disassociate_all_by_timeout(ctxt, "foo", now) self.assertEqual(result, 0) result = db.fixed_ip_disassociate_all_by_timeout(ctxt, "bar", now) self.assertEqual(result, 1)
def _disassociate_all_by_timeout(cls, context, host, time_str): time = timeutils.parse_isotime(time_str) return db.fixed_ip_disassociate_all_by_timeout(context, host, time)