Record metrics in a separate etcd record
This commit is contained in:
parent
56c5bab017
commit
42ebb0a6c3
2 changed files with 55 additions and 25 deletions
|
@ -6,7 +6,7 @@ import uuid
|
|||
import os
|
||||
|
||||
from trollius import coroutine, get_event_loop, From, Future, Return
|
||||
from mock import Mock, ANY
|
||||
from mock import Mock, ANY, call
|
||||
|
||||
from buildman.manager.executor import BuilderExecutor, ExecutorException
|
||||
from buildman.manager.ephemeral import (EphemeralBuilderManager, EtcdAction,
|
||||
|
@ -179,10 +179,11 @@ class TestEphemeralLifecycle(EphemeralBuilderTestCase):
|
|||
self.assertTrue(is_scheduled)
|
||||
self.assertEqual(self.test_executor.start_builder.call_count, 1)
|
||||
|
||||
# Ensure the job and realm were added to etcd.
|
||||
# Ensure the job and realm and metric were added to etcd.
|
||||
self.assertEqual(self.etcd_client_mock.write.call_args_list[0][0][0], self.mock_job_key)
|
||||
self.assertTrue(self.etcd_client_mock.write.call_args_list[1][0][0].find('realm/') == 0)
|
||||
realm_data = json.loads(self.etcd_client_mock.write.call_args_list[1][0][1])
|
||||
self.assertTrue(self.etcd_client_mock.write.call_args_list[1][0][0].find('metric/') == 0)
|
||||
self.assertTrue(self.etcd_client_mock.write.call_args_list[2][0][0].find('realm/') == 0)
|
||||
realm_data = json.loads(self.etcd_client_mock.write.call_args_list[2][0][1])
|
||||
realm_data['realm'] = REALM_ID
|
||||
|
||||
# Right now the job is not registered with any managers because etcd has not accepted the job
|
||||
|
@ -212,9 +213,11 @@ class TestEphemeralLifecycle(EphemeralBuilderTestCase):
|
|||
|
||||
# Take the job ourselves
|
||||
yield From(self.manager.build_component_ready(test_component))
|
||||
read_calls = [call('building/', recursive=True), call(os.path.join('metric/', REALM_ID))]
|
||||
self.etcd_client_mock.read.assert_has_calls(read_calls)
|
||||
|
||||
self.etcd_client_mock.read.assert_called_with(os.path.join('realm/', REALM_ID))
|
||||
self.etcd_client_mock.delete.assert_called_once_with(os.path.join('realm/', REALM_ID))
|
||||
delete_calls = [call('building/', recursive=True), call(os.path.join('metric/', REALM_ID))]
|
||||
self.etcd_client_mock.read.assert_has_calls(delete_calls)
|
||||
self.etcd_client_mock.delete.reset_mock()
|
||||
|
||||
self.assertIsNotNone(self.manager._build_uuid_to_info.get(BUILD_UUID))
|
||||
|
@ -224,7 +227,7 @@ class TestEphemeralLifecycle(EphemeralBuilderTestCase):
|
|||
|
||||
# Ensure that the executor kills the job.
|
||||
self.assertEqual(self.test_executor.stop_builder.call_count, 1)
|
||||
self.etcd_client_mock.delete.assert_called_once_with(self.mock_job_key)
|
||||
self.etcd_client_mock.delete.assert_has_calls([call(self.mock_job_key)])
|
||||
|
||||
# Ensure the build information is cleaned up.
|
||||
self.assertIsNone(self.manager._build_uuid_to_info.get(BUILD_UUID))
|
||||
|
|
Reference in a new issue