summaryrefslogtreecommitdiff
path: root/ceilometer/tests
diff options
context:
space:
mode:
authorPedro Henrique <phpm13@gmail.com>2022-09-05 12:09:19 -0300
committerPedro Henrique <phpm13@gmail.com>2022-09-16 12:53:30 -0300
commit090a0eb6d09d495fdb665aa5d8ab0f8f169f3514 (patch)
tree8f4ae0ccd295baf48361d3349cad75581a050a05 /ceilometer/tests
parent4bcc346164bd70922fdb4c79b1d1be99579f21bc (diff)
downloadceilometer-090a0eb6d09d495fdb665aa5d8ab0f8f169f3514.tar.gz
Add support to namespaces on dynamic pollsters
Problem description =================== The hardcoded pollsters are defined by namespaces, so they are instantied based on the namespaces provided to the 'AgentManager'. The dynamic pollsters, on the other hand, are always instantied, independent of the provided namespaces. Proposal ======== To allow operators to define in which namespaces the dynamic pollster will be deployed, we propose to add a new configuration 'namespaces' in the dynamic pollsters yaml configuration. This configuration will support a single entry or a list of the namespaces that the pollster must be instantiated. Change-Id: I39ba0c3dd312a0601e02f8cfcab7a44e585a8a7f
Diffstat (limited to 'ceilometer/tests')
-rw-r--r--ceilometer/tests/unit/polling/test_manager.py70
1 files changed, 70 insertions, 0 deletions
diff --git a/ceilometer/tests/unit/polling/test_manager.py b/ceilometer/tests/unit/polling/test_manager.py
index e805b9be..c9a1e1e1 100644
--- a/ceilometer/tests/unit/polling/test_manager.py
+++ b/ceilometer/tests/unit/polling/test_manager.py
@@ -422,6 +422,76 @@ class TestPollingAgent(BaseAgent):
self.assertIn(60, polling_tasks.keys())
self.assertNotIn(10, polling_tasks.keys())
+ @mock.patch('glob.glob')
+ @mock.patch('ceilometer.declarative.load_definitions')
+ def test_setup_polling_dynamic_pollster_namespace(self, load_mock,
+ glob_mock):
+ glob_mock.return_value = ['test.yml']
+ load_mock.return_value = [{
+ 'name': "test.dynamic.pollster",
+ 'namespaces': "dynamic",
+ 'sample_type': 'gauge',
+ 'unit': 'test',
+ 'endpoint_type': 'test',
+ 'url_path': 'test',
+ 'value_attribute': 'test'
+ }, {
+ 'name': "test.compute.central.pollster",
+ 'sample_type': 'gauge',
+ 'namespaces': ["compute", "central"],
+ 'unit': 'test',
+ 'endpoint_type': 'test',
+ 'url_path': 'test',
+ 'value_attribute': 'test'
+ }, {
+ 'name': "test.compute.pollster",
+ 'namespaces': ["compute"],
+ 'sample_type': 'gauge',
+ 'unit': 'test',
+ 'endpoint_type': 'test',
+ 'url_path': 'test',
+ 'value_attribute': 'test'
+ }, {
+ 'name': "test.central.pollster",
+ 'sample_type': 'gauge',
+ 'unit': 'test',
+ 'endpoint_type': 'test',
+ 'url_path': 'test',
+ 'value_attribute': 'test'
+ }]
+ mgr = manager.AgentManager(0, self.CONF, namespaces=['dynamic'])
+ self.assertEqual(len(mgr.extensions), 1)
+ self.assertEqual(
+ mgr.extensions[0].definitions.configurations['name'],
+ 'test.dynamic.pollster')
+
+ mgr = manager.AgentManager(0, self.CONF)
+ self.assertEqual(
+ mgr.extensions[-3].definitions.configurations['name'],
+ 'test.compute.central.pollster')
+ self.assertEqual(
+ mgr.extensions[-2].definitions.configurations['name'],
+ 'test.compute.pollster')
+ self.assertEqual(
+ mgr.extensions[-1].definitions.configurations['name'],
+ 'test.central.pollster')
+
+ mgr = manager.AgentManager(0, self.CONF, namespaces=['compute'])
+ self.assertEqual(
+ mgr.extensions[-2].definitions.configurations['name'],
+ 'test.compute.central.pollster')
+ self.assertEqual(
+ mgr.extensions[-1].definitions.configurations['name'],
+ 'test.compute.pollster')
+
+ mgr = manager.AgentManager(0, self.CONF, ['central'])
+ self.assertEqual(
+ mgr.extensions[-2].definitions.configurations['name'],
+ 'test.compute.central.pollster')
+ self.assertEqual(
+ mgr.extensions[-1].definitions.configurations['name'],
+ 'test.central.pollster')
+
def test_setup_polling_task_same_interval(self):
self.polling_cfg['sources'].append({
'name': 'test_polling_1',