From 16b0bafa2f6e7c5cf1df913384bb5e5432fbe80e Mon Sep 17 00:00:00 2001 From: Vladimir Ushakov Date: Thu, 8 Sep 2016 09:34:14 +0300 Subject: [PATCH] Add zabbix destructive test. Add test_host_failover test. Add related zabbix API methods. Change-Id: I20d8c032b321ec3818f98c577d29b5025771d9a4 --- stacklight_tests/run_tests.py | 1 + stacklight_tests/zabbix/api.py | 11 +++-- stacklight_tests/zabbix/plugin_settings.py | 4 +- stacklight_tests/zabbix/test_destructive.py | 45 +++++++++++++++++++++ 4 files changed, 56 insertions(+), 5 deletions(-) create mode 100644 stacklight_tests/zabbix/test_destructive.py diff --git a/stacklight_tests/run_tests.py b/stacklight_tests/run_tests.py index 13dce73..178ec89 100644 --- a/stacklight_tests/run_tests.py +++ b/stacklight_tests/run_tests.py @@ -70,6 +70,7 @@ def import_tests(): from stacklight_tests.toolchain import test_reduced_footprint # noqa from stacklight_tests.toolchain import test_smoke_bvt # noqa from stacklight_tests.toolchain import test_system # noqa + from stacklight_tests.zabbix import test_destructive # noqa from stacklight_tests.zabbix import test_functional # noqa from stacklight_tests.zabbix import test_smoke_bvt # noqa from stacklight_tests.zabbix import test_system # noqa diff --git a/stacklight_tests/zabbix/api.py b/stacklight_tests/zabbix/api.py index 36c465b..3df9e35 100644 --- a/stacklight_tests/zabbix/api.py +++ b/stacklight_tests/zabbix/api.py @@ -114,9 +114,12 @@ class ZabbixApi(base_test.PluginApi): self.helpers.cluster_id)['vips']['zbx_vip_mgmt']['ipaddr'] def check_plugin_online(self): - controller = self.fuel_web.get_nailgun_cluster_nodes_by_roles( - self.helpers.cluster_id, ['controller'])[0] - with self.fuel_web.get_ssh_for_nailgun_node(controller) as remote: + controllers = [ + controller for controller in + self.fuel_web.get_nailgun_cluster_nodes_by_roles( + self.helpers.cluster_id, ['controller']) + if controller["online"]] + with self.fuel_web.get_ssh_for_nailgun_node(controllers[0]) as remote: remote.check_call("dpkg --get-selections | grep zabbix") response = remote.execute("crm resource status " "p_zabbix-server")["stdout"][0] @@ -164,7 +167,7 @@ class ZabbixApi(base_test.PluginApi): result = remote.check_call( "crm status | grep {} | awk '{{print $4}}'".format( self.helpers.get_vip_resource_name( - self.settings.zabbix_vip))) + self.settings.failover_vip))) return result['stdout'][0].rstrip() def get_triggers(self, params=None): diff --git a/stacklight_tests/zabbix/plugin_settings.py b/stacklight_tests/zabbix/plugin_settings.py index 3a3a09b..1e54481 100644 --- a/stacklight_tests/zabbix/plugin_settings.py +++ b/stacklight_tests/zabbix/plugin_settings.py @@ -18,7 +18,9 @@ from stacklight_tests import settings name = 'zabbix_monitoring' plugin_path = settings.ZABBIX_MONITORING_PLUGIN_PATH version = helpers.get_plugin_version(plugin_path) -zabbix_vip = 'zbx_vip_mgmt' +failover_vip = 'zbx_vip_mgmt' +# NOTE(vgusev): This parameter is required for destructive scenario +role_name = ["controller"] dependant_plugins = { 'ZABBIX_MONITORING_EMC': { 'name': 'zabbix_monitoring_emc', diff --git a/stacklight_tests/zabbix/test_destructive.py b/stacklight_tests/zabbix/test_destructive.py new file mode 100644 index 0000000..736369e --- /dev/null +++ b/stacklight_tests/zabbix/test_destructive.py @@ -0,0 +1,45 @@ +# Copyright 2016 Mirantis, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from fuelweb_test.helpers.decorators import log_snapshot_after_test +from proboscis import test + +from stacklight_tests.zabbix import api + + +@test(groups=["plugins"]) +class TestDestructiveZabbix(api.ZabbixApi): + """Class for destructive testing of Zabbix plugin.""" + + @test(depends_on_groups=["deploy_zabbix_monitoring_ha"], + groups=["test_host_failover", "zabbix", "destructive"]) + @log_snapshot_after_test + def test_host_failover(self): + """Verify that zabbix-server will be started on another + node in case of network failover. + + Scenario: + 1. Find node with active zabbix-server via crm status + 2. Shutdown the node. + 3. Check that zabbix is active on other node via crm status. + 4. Check response from zabbix via HTTP request + + Duration 15m + """ + + self.env.revert_snapshot("deploy_zabbix_monitoring_ha") + + self.check_plugin_failover() + + self.check_plugin_online()