From aad7743f42e559aefde37bb44622986df4e2ae98 Mon Sep 17 00:00:00 2001 From: Monsyne Dragon Date: Fri, 27 Jul 2012 19:51:32 +0000 Subject: Correct host count in instance_usage_audit_log extension. This fixes bug 1030106. Basically we were not counting disabled hosts in the total host count. Also I have refactored the get_audit_task_logs method, it's really part of the extension (only the extension uses it), so I've moved it out of nova.compute.utils into the extension itself. (the tests that exercise it already lived in the extension's tests anyway.) Change-Id: Iaf42d887b824ba0cbf6ab0ed143a4c01b37b0cb1 --- .../compute/contrib/test_instance_usage_audit_log.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'nova/tests') diff --git a/nova/tests/api/openstack/compute/contrib/test_instance_usage_audit_log.py b/nova/tests/api/openstack/compute/contrib/test_instance_usage_audit_log.py index b81052ddc..2e06897c7 100644 --- a/nova/tests/api/openstack/compute/contrib/test_instance_usage_audit_log.py +++ b/nova/tests/api/openstack/compute/contrib/test_instance_usage_audit_log.py @@ -27,8 +27,12 @@ from nova.tests.api.openstack import fakes from nova import utils -TEST_COMPUTE_SERVICES = [dict(host=name) for name in - "foo bar baz plonk".split()] +TEST_COMPUTE_SERVICES = [dict(host='foo', topic='compute'), + dict(host='bar', topic='compute'), + dict(host='baz', topic='compute'), + dict(host='plonk', topic='compute'), + dict(host='wibble', topic='bogus'), + ] begin1 = datetime.datetime(2012, 7, 4, 6, 0, 0) @@ -79,8 +83,7 @@ TEST_LOGS3 = [ ] -def fake_service_get_all_by_topic(context, topic): - assert topic == "compute" +def fake_service_get_all(context): return TEST_COMPUTE_SERVICES @@ -117,8 +120,8 @@ class InstanceUsageAuditLogTest(test.TestCase): self.stubs.Set(utils, 'last_completed_audit_period', fake_last_completed_audit_period) - self.stubs.Set(db, 'service_get_all_by_topic', - fake_service_get_all_by_topic) + self.stubs.Set(db, 'service_get_all', + fake_service_get_all) self.stubs.Set(db, 'task_log_get_all', fake_task_log_get_all) -- cgit