From 526a8b590ea6dec7c3e9797461963a50afc3a1dc Mon Sep 17 00:00:00 2001 From: vgusev Date: Thu, 5 May 2016 18:11:15 +0300 Subject: [PATCH] Add bvt tests for elasticsearch_kibana Added basic classes and structure for tests. Change-Id: I4759bf9f4da4178cb85f0c4c83ed2d6adbfee1dc --- stacklight_tests/elasticsearch_kibana/api.py | 46 +++++++ .../elasticsearch_kibana/plugin_settings.py | 25 ++++ .../elasticsearch_kibana/test_smoke_bvt.py | 125 ++++++++++++++++++ stacklight_tests/run_tests.py | 1 + 4 files changed, 197 insertions(+) create mode 100644 stacklight_tests/elasticsearch_kibana/api.py create mode 100644 stacklight_tests/elasticsearch_kibana/plugin_settings.py create mode 100644 stacklight_tests/elasticsearch_kibana/test_smoke_bvt.py diff --git a/stacklight_tests/elasticsearch_kibana/api.py b/stacklight_tests/elasticsearch_kibana/api.py new file mode 100644 index 0000000..a39ac3b --- /dev/null +++ b/stacklight_tests/elasticsearch_kibana/api.py @@ -0,0 +1,46 @@ +# 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.elasticsearch_kibana import plugin_settings + + +class ElasticsearchPluginApi(base_test.PluginApi): + def get_plugin_settings(self): + return 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): + es_server_ip = self.get_plugin_vip() + + logger.debug("Check that Elasticsearch is ready") + msg = "Elasticsearch responded with {0}, expected {1}" + self.checkers.check_http_get_response( + self.settings.elasticsearch_url.format(es_server_ip), msg=msg) + + logger.debug("Check that Kibana is running") + msg = "Kibana responded with {0}, expected {1}" + self.checkers.check_http_get_response( + self.settings.kibana_url.format(es_server_ip), msg=msg) diff --git a/stacklight_tests/elasticsearch_kibana/plugin_settings.py b/stacklight_tests/elasticsearch_kibana/plugin_settings.py new file mode 100644 index 0000000..5cf6d84 --- /dev/null +++ b/stacklight_tests/elasticsearch_kibana/plugin_settings.py @@ -0,0 +1,25 @@ +# 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 = 'elasticsearch_kibana' +version = '0.9.0' +role_name = ['elasticsearch_kibana'] +vip_name = 'es_vip_mgmt' +plugin_path = settings.ELASTICSEARCH_KIBANA_PLUGIN_PATH + +elasticsearch_url = "http://{}:9200/" +kibana_url = "http://{}/" diff --git a/stacklight_tests/elasticsearch_kibana/test_smoke_bvt.py b/stacklight_tests/elasticsearch_kibana/test_smoke_bvt.py new file mode 100644 index 0000000..50f51db --- /dev/null +++ b/stacklight_tests/elasticsearch_kibana/test_smoke_bvt.py @@ -0,0 +1,125 @@ +# 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 fuelweb_test.tests import base_test_case +from proboscis import test + +from stacklight_tests.elasticsearch_kibana import api + + +@test(groups=["plugins"]) +class TestElasticsearchPlugin(api.ElasticsearchPluginApi): + """Class for smoke testing the Elasticsearch-Kibana plugin.""" + + @test(depends_on=[base_test_case.SetupEnvironment.prepare_slaves_3], + groups=["install_elasticsearch_kibana", "install", + "elasticsearch_kibana", "smoke"]) + @log_snapshot_after_test + def install_elasticsearch_kibana_plugin(self): + """Install Elasticsearch-Kibana 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_elasticsearch_kibana", "deploy", + "elasticsearch_kibana", "smoke"]) + @log_snapshot_after_test + def deploy_elasticsearch_kibana_plugin(self): + """Deploy a cluster with the Elasticsearch-Kibana 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 and cinder roles + 6. Add 1 node with elasticsearch_kibana role + 7. Deploy the cluster + 8. Check that plugin is working + 9. Run OSTF + + Duration 60m + Snapshot deploy_elasticsearch_kibana_plugin + """ + self.check_run("deploy_elasticsearch_kibana_plugin") + self.env.revert_snapshot("ready_with_3_slaves") + + self.prepare_plugin() + + self.create_cluster() + + self.activate_plugin() + + self.helpers.deploy_cluster(self.base_nodes) + + self.check_plugin_online() + + self.helpers.run_ostf() + + self.env.make_snapshot("deploy_elasticsearch_kibana_plugin", + is_make=True) + + @test(depends_on=[base_test_case.SetupEnvironment.prepare_slaves_9], + groups=["deploy_ha_elasticsearch_kibana", "deploy", "deploy_ha" + "elasticsearch_kibana", "smoke"]) + @log_snapshot_after_test + def deploy_ha_elasticsearch_kibana_plugin(self): + """Deploy a cluster with the Elasticsearch-Kibana plugin in HA mode + + Scenario: + 1. Upload plugin to the master node + 2. Install plugin + 3. Create cluster + 4. Add 3 nodes with controller role + 5. Add 3 nodes with compute and cinder roles + 6. Add 3 nodes with elasticsearch_kibana role + 7. Deploy the cluster + 8. Check that plugin is working + 9. Run OSTF + + Duration 120m + Snapshot deploy_ha_elasticsearch_kibana_plugin + """ + self.check_run("deploy_ha_elasticsearch_kibana_plugin") + self.env.revert_snapshot("ready_with_9_slaves") + + self.prepare_plugin() + + self.create_cluster() + + self.activate_plugin() + + self.helpers.deploy_cluster(self.full_ha_nodes) + + self.check_plugin_online() + + self.helpers.run_ostf() + + self.env.make_snapshot("deploy_ha_elasticsearch_kibana_plugin", + is_make=True) diff --git a/stacklight_tests/run_tests.py b/stacklight_tests/run_tests.py index 11c0d31..9a23003 100644 --- a/stacklight_tests/run_tests.py +++ b/stacklight_tests/run_tests.py @@ -41,6 +41,7 @@ class CloseSSHConnectionsPlugin(plugins.Plugin): def import_tests(): + from stacklight_tests.elasticsearch_kibana import test_smoke_bvt # noqa from stacklight_tests.influxdb_grafana import test_destructive # noqa from stacklight_tests.influxdb_grafana import test_smoke_bvt # noqa from stacklight_tests.influxdb_grafana import test_system # noqa