From 0579b36da02ff55bdb7190c6e0588093a7a845f9 Mon Sep 17 00:00:00 2001 From: Simon Pasquier Date: Tue, 31 May 2016 18:43:39 +0200 Subject: [PATCH] Fix the number of collector services for 0.10 Change-Id: Iedeaaff92ca52102a1d3d7ba49f60cb7fe1b2ba1 --- stacklight_tests/helpers/checkers.py | 11 ++--- stacklight_tests/helpers/helpers.py | 14 ------ stacklight_tests/lma_collector/api.py | 44 +++++++++++-------- .../lma_collector/plugin_settings.py | 30 +++++-------- stacklight_tests/toolchain/test_system.py | 2 +- 5 files changed, 43 insertions(+), 58 deletions(-) diff --git a/stacklight_tests/helpers/checkers.py b/stacklight_tests/helpers/checkers.py index d2f33c1..49954b9 100644 --- a/stacklight_tests/helpers/checkers.py +++ b/stacklight_tests/helpers/checkers.py @@ -38,8 +38,8 @@ def check_http_get_response(url, expected_code=200, msg=None, **kwargs): return r -def verify_services(remote, service_name, count): - """Check that a process is running on a host. +def check_process_count(remote, process, count): + """Check that the expected number of processes is running on a host. :param remote: SSH connection to the node. :type remote: SSHClient @@ -50,8 +50,9 @@ def verify_services(remote, service_name, count): :returns: list of PIDs. :rtype: list """ - msg = "{0} count not equal to {1}, received instead {2}." - pids = remote_ops.get_pids_of_process(remote, service_name) + msg = "Got {got} instances instead of {count} for process {process}." + pids = remote_ops.get_pids_of_process(remote, process) asserts.assert_equal( - len(pids), count, msg.format(service_name, count, len(pids))) + len(pids), count, + msg.format(process=process, count=count, got=len(pids))) return pids diff --git a/stacklight_tests/helpers/helpers.py b/stacklight_tests/helpers/helpers.py index 8ca6026..cdbb88b 100644 --- a/stacklight_tests/helpers/helpers.py +++ b/stacklight_tests/helpers/helpers.py @@ -336,20 +336,6 @@ class PluginHelper(object): for cmd in cmds: remote.check_call(cmd) - @staticmethod - def get_services_for_version(services_mapping, version): - """Returns processes for needed version only. - - :param services_mapping: full services mapping. - :type services_mapping: dict - :param version: plugin's version. - :type version: str - """ - def get_major_version(): - return ".".join(version.split(".")[:2]) - major_version = get_major_version() - return services_mapping[major_version] - def fuel_create_repositories(self, nodes): """Start task to setup repositories on provided nodes diff --git a/stacklight_tests/lma_collector/api.py b/stacklight_tests/lma_collector/api.py index dead67e..d132bf7 100644 --- a/stacklight_tests/lma_collector/api.py +++ b/stacklight_tests/lma_collector/api.py @@ -34,27 +34,33 @@ class LMACollectorPluginApi(base_test.PluginApi): def get_plugin_vip(self): pass - def get_services_to_check(self): - services_to_check = self.helpers.get_services_for_version( - self.settings.services_to_check, - self.settings.version) - return services_to_check - def verify_services(self): - """Check that LMA services started in the right quantity.""" - nodes = self.helpers.get_all_ready_nodes() + """Check that the correct amount of collector processes are running. + + :returns: list of process IDs indexed by node and process + :rtype: dict + """ pids = {} - services_to_check = self.get_services_to_check() - for node in nodes: - logger.info("Check {services} services on the {name} node".format( - name=node['name'], - services=', '.join(services_to_check.keys()),)) - services_pids = {} - with self.env.d_env.get_ssh_to_remote(node['ip']) as remote: - for service, count in services_to_check.items(): - services_pids[service] = ( - self.checkers.verify_services(remote, service, count)) - pids[node['name']] = services_pids + processes_count = { + "collectd": 1, + "collectdmon": 1 + } + if self.settings.version == "0.9": + processes_count["hekad"] = 1 + else: + # Starting with 0.10, there are one collector for logs and one for + # metrics + processes_count["hekad"] = 2 + for node in self.helpers.get_all_ready_nodes(): + pids[node["name"]] = {} + with self.env.d_env.get_ssh_to_remote(node["ip"]) as remote: + for process, count in processes_count.items(): + logger.info("Checking process {0} on node {1}".format( + process, node["name"] + )) + pids[node["name"]][process] = ( + self.checkers.check_process_count( + remote, process, count)) return pids def check_plugin_online(self): diff --git a/stacklight_tests/lma_collector/plugin_settings.py b/stacklight_tests/lma_collector/plugin_settings.py index 0dfbd74..dbf4fd9 100644 --- a/stacklight_tests/lma_collector/plugin_settings.py +++ b/stacklight_tests/lma_collector/plugin_settings.py @@ -16,32 +16,24 @@ from stacklight_tests.helpers import helpers from stacklight_tests import settings -name = 'lma_collector' +name = "lma_collector" role_name = [] # NOTE(rpromyshlennikov): there is no role name # because lma collector is installed on all nodes in cluster plugin_path = settings.LMA_COLLECTOR_PLUGIN_PATH version = helpers.get_plugin_version(plugin_path) default_options = { - 'environment_label/value': 'deploy_lma_toolchain', - 'elasticsearch_mode/value': 'remote', - 'influxdb_mode/value': 'remote', - 'alerting_mode/value': 'local', - 'elasticsearch_address/value': '127.0.0.1', - 'influxdb_address/value': '127.0.0.1' + "environment_label/value": "deploy_lma_toolchain", + "elasticsearch_mode/value": "remote", + "influxdb_mode/value": "remote", + "alerting_mode/value": "local", + "elasticsearch_address/value": "127.0.0.1", + "influxdb_address/value": "127.0.0.1" } toolchain_options = { - 'environment_label/value': 'deploy_lma_toolchain', - 'elasticsearch_mode/value': 'local', - 'influxdb_mode/value': 'local', - 'alerting_mode/value': 'local' -} - -services_to_check = { - "0.9": { - "hekad": 1, - "collectd": 1, - "collectdmon": 1 - }, + "environment_label/value": "deploy_lma_toolchain", + "elasticsearch_mode/value": "local", + "influxdb_mode/value": "local", + "alerting_mode/value": "local" } diff --git a/stacklight_tests/toolchain/test_system.py b/stacklight_tests/toolchain/test_system.py index e4d6d0b..f2b4799 100644 --- a/stacklight_tests/toolchain/test_system.py +++ b/stacklight_tests/toolchain/test_system.py @@ -213,7 +213,7 @@ class TestNodesToolchain(api.ToolchainApi): pids_before = self.get_pids_of_services() - # NOTE(rpromyshlennikov): fuel-createmirror cmd is depricated + # NOTE(rpromyshlennikov): fuel-createmirror cmd is deprecated # since fuel-8.0 release self.helpers.replace_ubuntu_mirror_with_mos() self.helpers.fuel_create_repositories(ready_nodes_before)