diff --git a/stacklight_tests/helpers/helpers.py b/stacklight_tests/helpers/helpers.py index ca52456..103cc1b 100644 --- a/stacklight_tests/helpers/helpers.py +++ b/stacklight_tests/helpers/helpers.py @@ -174,3 +174,13 @@ class PluginHelper(object): if wait_become_online: self.fuel_web.wait_nodes_get_online_state(nodes[1:]) + + def uninstall_plugin(self, plugin_name, plugin_version, exit_code=0, + msg=None): + msg = msg or "Plugin {0} deletion failed: exit code is {1}" + with self.env.d_env.get_admin_remote() as remote: + exec_res = remote.execute("fuel plugins --remove" + " {0}=={1}".format(plugin_name, + plugin_version)) + asserts.assert_equal(exit_code, exec_res['exit_code'], + msg.format(plugin_name, exit_code)) diff --git a/stacklight_tests/lma_infrastructure_alerting/api.py b/stacklight_tests/lma_infrastructure_alerting/api.py new file mode 100644 index 0000000..3d26ed6 --- /dev/null +++ b/stacklight_tests/lma_infrastructure_alerting/api.py @@ -0,0 +1,43 @@ +# 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 import logger + +from stacklight_tests import base_test +from stacklight_tests.lma_infrastructure_alerting import( + plugin_settings as infra_alerting_plugin_settings) + + +class InfraAlertingPluginApi(base_test.PluginApi): + def get_plugin_settings(self): + return infra_alerting_plugin_settings + + def prepare_plugin(self): + self.helpers.prepare_plugin(self.settings.plugin_path) + + def activate_plugin(self): + self.helpers.activate_plugin( + self.settings.name, self.settings.version, self.settings.options) + + def get_plugin_vip(self): + return self.helpers.get_plugin_vip(self.settings.vip_name) + + def check_plugin_online(self): + lma_alerting_vip = self.get_plugin_vip() + + logger.info("Check that the Nagios server is running") + self.checkers.check_http_get_response( + "http://{0}:{1}@{2}:8001".format( + self.settings.nagios_user, self.settings.nagios_password, + lma_alerting_vip)) diff --git a/stacklight_tests/lma_infrastructure_alerting/plugin_settings.py b/stacklight_tests/lma_infrastructure_alerting/plugin_settings.py new file mode 100644 index 0000000..df1077c --- /dev/null +++ b/stacklight_tests/lma_infrastructure_alerting/plugin_settings.py @@ -0,0 +1,34 @@ +# 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 stacklight_tests import settings + +name = 'lma_infrastructure_alerting' +version = '0.10.0' +role_name = ['infrastructure_alerting'] +vip_name = 'infrastructure_alerting_mgmt_vip' +plugin_path = settings.LMA_INFRA_ALERTING_PLUGIN_PATH + +nagios_user = 'nagiosadmin' +nagios_password = 'r00tme' +send_to = 'root@localhost' +send_from = 'nagios@localhost' +smtp_host = '127.0.0.1' + +options = { + 'nagios_password/value': nagios_password, + 'send_to/value': send_to, + 'send_from/value': send_from, + 'smtp_host/value': smtp_host, +} diff --git a/stacklight_tests/lma_infrastructure_alerting/test_smoke_bvt.py b/stacklight_tests/lma_infrastructure_alerting/test_smoke_bvt.py new file mode 100644 index 0000000..23d7ebc --- /dev/null +++ b/stacklight_tests/lma_infrastructure_alerting/test_smoke_bvt.py @@ -0,0 +1,195 @@ +# 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 proboscis import test + +from fuelweb_test.helpers.decorators import log_snapshot_after_test +from fuelweb_test import logger +from fuelweb_test.tests import base_test_case + +from stacklight_tests.lma_infrastructure_alerting import api + + +@test(groups=["plugins"]) +class TestLMAInfraAlertingPlugin(api.InfraAlertingPluginApi): + """Class for testing the LMA Infrastructure Alerting plugin.""" + + @test(depends_on=[base_test_case.SetupEnvironment.prepare_slaves_3], + groups=["install_lma_infrastructure_alerting", "install", + "lma_infrastructure_alerting ", "smoke"]) + @log_snapshot_after_test + def install_lma_infrastructure_alerting_plugin(self): + """Install LMA Infrastructure Alerting plugin and check it exists + + Scenario: + 1. Upload plugin to the master node + 2. Install plugin + 3. Create cluster + 4. Check that plugin exists + + Duration 20m + """ + self.env.revert_snapshot("ready_with_3_slaves") + + self.prepare_plugin() + + self.create_cluster() + + self.activate_plugin() + + @test(depends_on=[base_test_case.SetupEnvironment.prepare_slaves_3], + groups=["deploy_lma_infrastructure_alerting", "deploy", + "lma_infrastructure_alerting", "smoke"]) + @log_snapshot_after_test + def deploy_lma_infrastructure_alerting(self): + """Deploy a cluster with the LMA Infrastructure Alerting plugin + + Scenario: + 1. Upload plugin to the master node + 2. Install plugin + 3. Create cluster + 4. Add 1 node with controller role + 5. Add 1 node with compute role + 6. Add 1 node with lma infrastructure alerting role + 7. Deploy the cluster + 8. Check that plugin is working + 9. Run OSTF + + Duration 60m + Snapshot deploy_lma_alerting_plugin + """ + + self.check_run('deploy_lma_alerting_plugin') + + self.env.revert_snapshot("ready_with_3_slaves") + + self.prepare_plugin() + + self.create_cluster() + + self.activate_plugin() + + self.helpers.deploy_cluster( + { + 'slave-01': ['controller'], + 'slave-02': ['compute'], + 'slave-03': self.settings.role_name + } + ) + + self.check_plugin_online() + + self.helpers.run_ostf() + + logger.info('Making environment snapshot' + ' deploy_lma_infrastructure_alerting') + self.env.make_snapshot("deploy_lma_infrastructure_alerting", + is_make=True) + + @test(depends_on=[base_test_case.SetupEnvironment.prepare_slaves_9], + groups=["deploy_ha_lma_infrastructure_alerting", "deploy", + "deploy_ha", "lma_infrastructure_alerting", "smoke"]) + @log_snapshot_after_test + def deploy_ha_lma_infrastructure_alerting(self): + """Deploy a cluster with the LMA Infrastructure Alerting plugin + + Scenario: + 1. Upload plugin to the master node + 2. Install plugin + 3. Create cluster + 4. Add 3 nodes with controller role + 5. Add 1 node with compute and cinder roles + 6. Add 3 nodes with lma infrastructure alerting roles + 7. Deploy the cluster + 8. Check that plugin is working + 9. Run OSTF + + Duration 60m + Snapshot deploy_lma_alerting_plugin_ha + """ + + self.check_run('deploy_ha_lma_infrastructure_alerting') + + self.env.revert_snapshot("ready_with_9_slaves") + + self.prepare_plugin() + + self.create_cluster() + + self.activate_plugin() + + self.helpers.deploy_cluster( + { + 'slave-01': ['controller'], + 'slave-02': ['controller'], + 'slave-03': ['controller'], + 'slave-04': ['compute', 'cinder'], + 'slave-05': self.settings.role_name, + 'slave-06': self.settings.role_name, + 'slave-07': self.settings.role_name + } + ) + + self.check_plugin_online() + + self.helpers.run_ostf() + + logger.info('Making environment snapshot ' + 'deploy_ha_lma_infrastructure_alerting') + self.env.make_snapshot("deploy_ha_lma_infrastructure_alerting", + is_make=True) + + @test(depends_on=[deploy_ha_lma_infrastructure_alerting], + groups=["uninstall_deployed_lma_infrastructure_alerting", + "uninstall", "lma_infrastructure_alerting", "smoke"]) + @log_snapshot_after_test + def uninstall_deployed_lma_infrastructure_alerting(self): + """Uninstall the plugin with deployed environment + + Scenario: + 1. Try to remove the plugins using the Fuel CLI + 2. Remove the environment. + 3. Remove the plugins. + + Duration 20m + """ + self.env.revert_snapshot("deploy_lma_infrastructure_alerting") + + self.helpers.uninstall_plugin(self.settings.name, + self.settings.version, 1, + 'Plugin deletion must not be permitted' + ' while it\'s active in deployed in env') + + self.fuel_web.delete_env_wait(self.helpers.cluster_id) + self.helpers.uninstall_plugin(self.settings.name, + self.settings.version) + + @test(depends_on=[base_test_case.SetupEnvironment.prepare_slaves_3], + groups=["uninstall_lma_infrastructure_alerting", "uninstall", + "lma_infrastructure_alerting", "smoke"]) + @log_snapshot_after_test + def uninstall_lma_infrastructure_alerting(self): + """Uninstall the plugins + + Scenario: + 1. Install plugin. + 2. Remove the plugins. + + Duration 5m + """ + self.env.revert_snapshot("ready_with_3_slaves") + + self.prepare_plugin() + + self.helpers.uninstall_plugin(self.settings.name, + self.settings.version) diff --git a/stacklight_tests/run_tests.py b/stacklight_tests/run_tests.py index 9a23003..005030b 100644 --- a/stacklight_tests/run_tests.py +++ b/stacklight_tests/run_tests.py @@ -47,6 +47,9 @@ def import_tests(): from stacklight_tests.influxdb_grafana import test_system # noqa from stacklight_tests.lma_collector import test_smoke_bvt # noqa + from stacklight_tests.lma_infrastructure_alerting import ( # noqa + test_smoke_bvt) # noqa + def run_tests(): from proboscis import TestProgram # noqa