Merge "FUPs: ReportClient traffic series"

This commit is contained in:
Zuul 2019-02-04 20:02:57 +00:00 committed by Gerrit Code Review
commit 02e9e45924
2 changed files with 27 additions and 27 deletions

View File

@ -259,8 +259,8 @@ class SchedulerReportClient(object):
# timer dict, so nothing to clear.
return
# get_provider_uuids returns UUIDs in top-down order, so the first one
# is the root; and .remove() is recursive.
# get_provider_uuids_in_tree returns UUIDs in top-down order, so the
# first one is the root; and .remove() is recursive.
self._provider_tree.remove(uuids[0])
for uuid in uuids:
self._association_refresh_time.pop(uuid, None)
@ -758,8 +758,8 @@ class SchedulerReportClient(object):
def _refresh_associations(self, context, rp_uuid, force=False,
refresh_sharing=True):
"""Refresh aggregates, traits, and (optionally) aggregate-associated
sharing providers for the specified resource provider uuid.
"""Refresh inventories, aggregates, traits, and (optionally) aggregate-
associated sharing providers for the specified resource provider uuid.
Only refresh if there has been no refresh during the lifetime of
this process, CONF.compute.resource_provider_association_refresh
@ -821,11 +821,11 @@ class SchedulerReportClient(object):
self._provider_tree.new_root(
rp['name'], rp['uuid'],
generation=rp['generation'])
# Now we have to (populate or) refresh that guy's traits,
# aggregates, and inventories (but not *his* aggregate-
# associated providers). No need to override force=True for
# newly- added providers - the missing timestamp will
# always trigger them to refresh.
# Now we have to (populate or) refresh that provider's
# traits, aggregates, and inventories (but not *its*
# aggregate-associated providers). No need to override
# force=True for newly-added providers - the missing
# timestamp will always trigger them to refresh.
self._refresh_associations(context, rp['uuid'],
force=force,
refresh_sharing=False)
@ -1051,7 +1051,7 @@ class SchedulerReportClient(object):
url = '/resource_providers/%s/traits' % rp_uuid
# NOTE(efried): Don't use the DELETE API when traits is empty, because
# that guy doesn't return content, and we need to update the cached
# that method doesn't return content, and we need to update the cached
# provider tree with the new generation.
traits = list(traits) if traits else []
generation = self._provider_tree.data(rp_uuid).generation

View File

@ -2873,7 +2873,7 @@ class TestAssociations(SchedulerReportClientTestCase):
'nova.scheduler.client.report.SchedulerReportClient.'
'_get_sharing_providers')).mock
def assert_things_were_called(self, uuid, sharing=True):
def assert_getters_were_called(self, uuid, sharing=True):
self.mock_get_inv.assert_called_once_with(self.context, uuid)
self.mock_get_aggs.assert_called_once_with(self.context, uuid)
self.mock_get_traits.assert_called_once_with(self.context, uuid)
@ -2893,7 +2893,7 @@ class TestAssociations(SchedulerReportClientTestCase):
self.client._provider_tree.has_traits(uuid, ['CUSTOM_SILVER']))
self.assertEqual(43, self.client._provider_tree.data(uuid).generation)
def assert_things_not_called(self, timer_entry=None):
def assert_getters_not_called(self, timer_entry=None):
self.mock_get_inv.assert_not_called()
self.mock_get_aggs.assert_not_called()
self.mock_get_traits.assert_not_called()
@ -2903,7 +2903,7 @@ class TestAssociations(SchedulerReportClientTestCase):
else:
self.assertIn(timer_entry, self.client._association_refresh_time)
def reset_things(self):
def reset_getter_mocks(self):
self.mock_get_inv.reset_mock()
self.mock_get_aggs.reset_mock()
self.mock_get_traits.reset_mock()
@ -2915,7 +2915,7 @@ class TestAssociations(SchedulerReportClientTestCase):
# Seed the provider tree so _refresh_associations finds the provider
self.client._provider_tree.new_root('compute', uuid, generation=1)
self.client._refresh_associations(self.context, uuid)
self.assert_things_were_called(uuid)
self.assert_getters_were_called(uuid)
def test_refresh_associations_no_refresh_sharing(self):
"""Test refresh_sharing=False."""
@ -2924,7 +2924,7 @@ class TestAssociations(SchedulerReportClientTestCase):
self.client._provider_tree.new_root('compute', uuid, generation=1)
self.client._refresh_associations(self.context, uuid,
refresh_sharing=False)
self.assert_things_were_called(uuid, sharing=False)
self.assert_getters_were_called(uuid, sharing=False)
@mock.patch('nova.scheduler.client.report.SchedulerReportClient.'
'_associations_stale')
@ -2935,7 +2935,7 @@ class TestAssociations(SchedulerReportClientTestCase):
mock_stale.return_value = False
uuid = uuids.compute_node
self.client._refresh_associations(self.context, uuid)
self.assert_things_not_called()
self.assert_getters_not_called()
@mock.patch.object(report.LOG, 'debug')
def test_refresh_associations_time(self, log_mock):
@ -2947,7 +2947,7 @@ class TestAssociations(SchedulerReportClientTestCase):
# Called a first time because association_refresh_time is empty.
now = time.time()
self.client._refresh_associations(self.context, uuid)
self.assert_things_were_called(uuid)
self.assert_getters_were_called(uuid)
log_mock.assert_has_calls([
mock.call('Refreshing inventories for resource provider %s', uuid),
mock.call('Updating ProviderTree inventory for provider %s from '
@ -2960,20 +2960,20 @@ class TestAssociations(SchedulerReportClientTestCase):
])
# Clear call count.
self.reset_things()
self.reset_getter_mocks()
with mock.patch('time.time') as mock_future:
# Not called a second time because not enough time has passed.
mock_future.return_value = (now +
CONF.compute.resource_provider_association_refresh / 2)
self.client._refresh_associations(self.context, uuid)
self.assert_things_not_called(timer_entry=uuid)
self.assert_getters_not_called(timer_entry=uuid)
# Called because time has passed.
mock_future.return_value = (now +
CONF.compute.resource_provider_association_refresh + 1)
self.client._refresh_associations(self.context, uuid)
self.assert_things_were_called(uuid)
self.assert_getters_were_called(uuid)
def test_refresh_associations_disabled(self):
"""Test that refresh associations can be disabled."""
@ -2985,31 +2985,31 @@ class TestAssociations(SchedulerReportClientTestCase):
# Called a first time because association_refresh_time is empty.
now = time.time()
self.client._refresh_associations(self.context, uuid)
self.assert_things_were_called(uuid)
self.assert_getters_were_called(uuid)
# Clear call count.
self.reset_things()
self.reset_getter_mocks()
with mock.patch('time.time') as mock_future:
# A lot of time passes
mock_future.return_value = now + 10000000000000
self.client._refresh_associations(self.context, uuid)
self.assert_things_not_called(timer_entry=uuid)
self.assert_getters_not_called(timer_entry=uuid)
self.reset_things()
self.reset_getter_mocks()
# Forever passes
mock_future.return_value = float('inf')
self.client._refresh_associations(self.context, uuid)
self.assert_things_not_called(timer_entry=uuid)
self.assert_getters_not_called(timer_entry=uuid)
self.reset_things()
self.reset_getter_mocks()
# Even if no time passes, clearing the counter triggers refresh
mock_future.return_value = now
del self.client._association_refresh_time[uuid]
self.client._refresh_associations(self.context, uuid)
self.assert_things_were_called(uuid)
self.assert_getters_were_called(uuid)
class TestAllocations(SchedulerReportClientTestCase):