Merge "Implements vcpus counter"
This commit is contained in:
commit
ffa4f93c9c
@ -58,4 +58,14 @@ class InstanceNotifications(plugin.NotificationBase):
|
||||
timestamp=message['timestamp'],
|
||||
duration=0,
|
||||
resource_metadata={}),
|
||||
counter.Counter(source='?',
|
||||
name='vcpus',
|
||||
type='absolute',
|
||||
volume=message['payload']['vcpus'],
|
||||
user_id=message['payload']['user_id'],
|
||||
project_id=message['payload']['tenant_id'],
|
||||
resource_id=message['payload']['instance_id'],
|
||||
timestamp=message['timestamp'],
|
||||
duration=0,
|
||||
resource_metadata={}),
|
||||
]
|
||||
|
@ -191,7 +191,7 @@ class TestNotifications(unittest.TestCase):
|
||||
ic = notifications.InstanceNotifications()
|
||||
counters = ic.process_notification(INSTANCE_CREATE_END)
|
||||
|
||||
self.assertEqual(len(counters), 2)
|
||||
self.assertEqual(len(counters), 3)
|
||||
|
||||
self.assertEqual(counters[0].name, 'instance')
|
||||
self.assertEqual(counters[0].volume, 1)
|
||||
@ -199,18 +199,23 @@ class TestNotifications(unittest.TestCase):
|
||||
self.assertEqual(counters[1].name, 'memory')
|
||||
self.assertEqual(counters[1].volume, INSTANCE_CREATE_END['payload']['memory_mb'])
|
||||
|
||||
self.assertEqual(counters[2].name, 'vcpus')
|
||||
self.assertEqual(counters[2].volume, INSTANCE_CREATE_END['payload']['vcpus'])
|
||||
|
||||
|
||||
def test_instance_exists(self):
|
||||
ic = notifications.InstanceNotifications()
|
||||
counters = ic.process_notification(INSTANCE_EXISTS)
|
||||
self.assertEqual(len(counters), 2)
|
||||
self.assertEqual(len(counters), 3)
|
||||
self.assertEqual(counters[0].name, 'instance')
|
||||
self.assertEqual(counters[1].name, 'memory')
|
||||
self.assertEqual(counters[2].name, 'vcpus')
|
||||
|
||||
|
||||
def test_instance_delete(self):
|
||||
ic = notifications.InstanceNotifications()
|
||||
counters = ic.process_notification(INSTANCE_DELETE_START)
|
||||
self.assertEqual(len(counters), 2)
|
||||
self.assertEqual(len(counters), 3)
|
||||
self.assertEqual(counters[0].name, 'instance')
|
||||
self.assertEqual(counters[1].name, 'memory')
|
||||
self.assertEqual(counters[2].name, 'vcpus')
|
||||
|
Loading…
Reference in New Issue
Block a user