Fix bw_usage_update issue with conductor
During a rebase, the tests for the conductor's implementation of bw_usage_*() were lost. This caused some later changes to go untested, and thus, introduce errors. This patch: 1. Fixes the calling order of bw_usage_get() from LocalAPI 2. Fixes the test used to determine if an update should be performed 3. Fixes the RPC API version number that should have been bumped 4. Adds the tests Yikes. Change-Id: I87c8ad19002d7cc420dc15f6ae21c6bfcbb0ee53
This commit is contained in:
parent
8e9bdd77c8
commit
07848e761a
|
@ -66,7 +66,7 @@ class LocalAPI(object):
|
|||
return self._manager.aggregate_host_delete(context, aggregate, host)
|
||||
|
||||
def bw_usage_get(self, context, uuid, start_period, mac):
|
||||
return self._manager.bw_usage_update(context, uuid, start_period, mac)
|
||||
return self._manager.bw_usage_update(context, uuid, mac, start_period)
|
||||
|
||||
def bw_usage_update(self, context, uuid, mac, start_period,
|
||||
bw_in, bw_out, last_ctr_in, last_ctr_out,
|
||||
|
|
|
@ -41,7 +41,7 @@ datetime_fields = ['launched_at', 'terminated_at']
|
|||
class ConductorManager(manager.SchedulerDependentManager):
|
||||
"""Mission: TBD"""
|
||||
|
||||
RPC_API_VERSION = '1.4'
|
||||
RPC_API_VERSION = '1.5'
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(ConductorManager, self).__init__(service_name='conductor',
|
||||
|
@ -94,7 +94,7 @@ class ConductorManager(manager.SchedulerDependentManager):
|
|||
bw_in=None, bw_out=None,
|
||||
last_ctr_in=None, last_ctr_out=None,
|
||||
last_refreshed=None):
|
||||
if all((None, bw_in, bw_out, last_ctr_in, last_ctr_out)):
|
||||
if [bw_in, bw_out, last_ctr_in, last_ctr_out].count(None) != 4:
|
||||
self.db.bw_usage_update(context, uuid, mac, start_period,
|
||||
bw_in, bw_out, last_ctr_in, last_ctr_out,
|
||||
last_refreshed)
|
||||
|
|
|
@ -154,6 +154,20 @@ class ConductorTestCase(BaseTestCase):
|
|||
|
||||
db.aggregate_delete(self.context.elevated(), aggregate_ref['id'])
|
||||
|
||||
def test_bw_usage_update(self):
|
||||
self.mox.StubOutWithMock(db, 'bw_usage_update')
|
||||
self.mox.StubOutWithMock(db, 'bw_usage_get')
|
||||
|
||||
update_args = (self.context, 'uuid', 'mac', 0, 10, 20, 5, 10, 20)
|
||||
get_args = (self.context, 'uuid', 0, 'mac')
|
||||
|
||||
db.bw_usage_update(*update_args)
|
||||
db.bw_usage_get(*get_args).AndReturn('foo')
|
||||
|
||||
self.mox.ReplayAll()
|
||||
result = self.conductor.bw_usage_update(*update_args)
|
||||
self.assertEqual(result, 'foo')
|
||||
|
||||
|
||||
class ConductorRPCAPITestCase(ConductorTestCase):
|
||||
"""Conductor RPC API Tests"""
|
||||
|
@ -177,6 +191,18 @@ class ConductorLocalAPITestCase(ConductorTestCase):
|
|||
return self.conductor.instance_update(self.context, instance_uuid,
|
||||
**updates)
|
||||
|
||||
def test_bw_usage_get(self):
|
||||
self.mox.StubOutWithMock(db, 'bw_usage_update')
|
||||
self.mox.StubOutWithMock(db, 'bw_usage_get')
|
||||
|
||||
get_args = (self.context, 'uuid', 0, 'mac')
|
||||
|
||||
db.bw_usage_get(*get_args).AndReturn('foo')
|
||||
|
||||
self.mox.ReplayAll()
|
||||
result = self.conductor.bw_usage_get(*get_args)
|
||||
self.assertEqual(result, 'foo')
|
||||
|
||||
|
||||
class ConductorAPITestCase(ConductorLocalAPITestCase):
|
||||
"""Conductor API Tests"""
|
||||
|
|
Loading…
Reference in New Issue