From 42f3d0bdbda3c54c0d3490e0f407e7dbb8f574ca Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Fri, 11 Jan 2013 11:56:09 -0500 Subject: Make pinging conductor a part of conductor API. This patch moves the loop that pings the conductor over rpc until it responds to be a part of the conductor API. This will allow it to be used elsewhere in the code as needed. Part of bp no-db-compute. Change-Id: Ie027adef4a3af3059b4ab586e927c93ae1a86fe9 --- nova/tests/compute/test_compute.py | 15 --------------- nova/tests/conductor/test_conductor.py | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 15 deletions(-) (limited to 'nova/tests') diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py index bf619bbec..23df703be 100644 --- a/nova/tests/compute/test_compute.py +++ b/nova/tests/compute/test_compute.py @@ -3121,21 +3121,6 @@ class ComputeTestCase(BaseTestCase): instance = self._create_fake_instance(params) self.compute._instance_update(self.context, instance['uuid']) - def test_startup_conductor_ping(self): - timeouts = [] - calls = dict(count=0) - - def fake_ping(context, message, timeout): - timeouts.append(timeout) - calls['count'] += 1 - if calls['count'] < 15: - raise rpc_common.Timeout("fake") - - self.stubs.Set(self.compute.conductor_api, 'ping', fake_ping) - self.compute._get_instances_at_startup(self.context) - self.assertEqual(timeouts.count(10), 10) - self.assertTrue(None in timeouts) - def test_destroy_evacuated_instances(self): fake_context = context.get_admin_context() diff --git a/nova/tests/conductor/test_conductor.py b/nova/tests/conductor/test_conductor.py index ffe09c95e..7986fc583 100644 --- a/nova/tests/conductor/test_conductor.py +++ b/nova/tests/conductor/test_conductor.py @@ -650,6 +650,23 @@ class ConductorAPITestCase(_BaseTestCase, test.TestCase): def test_service_get_all_compute_by_host(self): self._test_stubbed('service_get_all_compute_by_host', 'host') + def test_ping(self): + timeouts = [] + calls = dict(count=0) + + def fake_ping(_self, context, message, timeout): + timeouts.append(timeout) + calls['count'] += 1 + if calls['count'] < 15: + raise rpc_common.Timeout("fake") + + self.stubs.Set(conductor_api.API, 'ping', fake_ping) + + self.conductor.wait_until_ready(self.context) + + self.assertEqual(timeouts.count(10), 10) + self.assertTrue(None in timeouts) + class ConductorLocalAPITestCase(ConductorAPITestCase): """Conductor LocalAPI Tests.""" @@ -667,6 +684,10 @@ class ConductorLocalAPITestCase(ConductorAPITestCase): self.assertRaises(KeyError, self._do_update, instance['uuid'], foo='bar') + def test_ping(self): + # Override test in ConductorAPITestCase + pass + class ConductorImportTest(test.TestCase): def test_import_conductor_local(self): -- cgit