Merge "Add bvt tests for toolchain"

This commit is contained in:
Jenkins 2016-05-25 12:37:38 +00:00 committed by Gerrit Code Review
commit d3f1fabf3a
21 changed files with 300 additions and 118 deletions

View File

@ -63,21 +63,6 @@ class PluginApi(object):
'slave-09': self.settings.role_name,
}
def create_cluster(self, name=None, settings=None):
"""Create a cluster.
:param name: name of the cluster (default: class's name).
:type name: str
:param settings: optional dict containing the cluster's configuration.
:type settings: dict
:returns: the cluster's id
:rtype: str
"""
return self.env.fuel_web.create_cluster(
name=self.__class__.__name__,
settings=settings,
mode='ha_compact')
@abc.abstractmethod
def get_plugin_settings(self):
"""Return a dict with the default plugin's settings.

View File

@ -26,9 +26,11 @@ class ElasticsearchPluginApi(base_test.PluginApi):
def prepare_plugin(self):
self.helpers.prepare_plugin(self.settings.plugin_path)
def activate_plugin(self):
def activate_plugin(self, options=None):
if options is None:
options = self.settings.default_options
self.helpers.activate_plugin(
self.settings.name, self.settings.version, self.settings.options)
self.settings.name, self.settings.version, options)
def get_plugin_vip(self):
return self.helpers.get_plugin_vip(self.settings.vip_name)
@ -40,12 +42,12 @@ class ElasticsearchPluginApi(base_test.PluginApi):
return "http://{}:9200/".format(self.get_plugin_vip())
def check_plugin_online(self):
logger.debug("Check that Elasticsearch is ready")
logger.info("Check that Elasticsearch is ready")
msg = "Elasticsearch responded with {0}, expected {1}"
self.checkers.check_http_get_response(
self.get_elasticsearch_url(), msg=msg)
logger.debug("Check that Kibana is running")
logger.info("Check that Kibana is running")
msg = "Kibana responded with {0}, expected {1}"
self.checkers.check_http_get_response(self.get_kibana_url(), msg=msg)

View File

@ -22,4 +22,5 @@ vip_name = 'es_vip_mgmt'
plugin_path = settings.ELASTICSEARCH_KIBANA_PLUGIN_PATH
version = helpers.get_plugin_version(plugin_path)
options = {}
default_options = {}
toolchain_options = {}

View File

@ -41,7 +41,7 @@ class TestElasticsearchPlugin(api.ElasticsearchPluginApi):
self.prepare_plugin()
self.create_cluster()
self.helpers.create_cluster(name=self.__class__.__name__)
self.activate_plugin()
@ -71,7 +71,7 @@ class TestElasticsearchPlugin(api.ElasticsearchPluginApi):
self.prepare_plugin()
self.create_cluster()
self.helpers.create_cluster(name=self.__class__.__name__)
self.activate_plugin()
@ -109,7 +109,7 @@ class TestElasticsearchPlugin(api.ElasticsearchPluginApi):
self.prepare_plugin()
self.create_cluster()
self.helpers.create_cluster(name=self.__class__.__name__)
self.activate_plugin()

View File

@ -92,6 +92,23 @@ class PluginHelper(object):
self.fuel_web.client.list_cluster_nodes(self.cluster_id)
if node["status"] == "ready"]
def create_cluster(self, name=None, settings=None):
"""Create a cluster.
:param name: name of the cluster.
:type name: str
:param settings: optional dict containing the cluster's configuration.
:type settings: dict
:returns: the cluster's id
:rtype: str
"""
if not name:
name = self.__class__.__name__
return self.env.fuel_web.create_cluster(
name=name,
settings=settings,
mode='ha_compact')
def deploy_cluster(self, nodes_roles):
"""Method to deploy cluster with provided node roles."""
self.fuel_web.update_nodes(self.cluster_id, nodes_roles)

View File

@ -28,9 +28,11 @@ class InfluxdbPluginApi(base_test.PluginApi):
def prepare_plugin(self):
self.helpers.prepare_plugin(self.settings.plugin_path)
def activate_plugin(self):
def activate_plugin(self, options=None):
if options is None:
options = self.settings.default_options
self.helpers.activate_plugin(
self.settings.name, self.settings.version, self.settings.options)
self.settings.name, self.settings.version, options)
def get_plugin_vip(self):
return self.helpers.get_plugin_vip(self.settings.vip_name)
@ -53,37 +55,37 @@ class InfluxdbPluginApi(base_test.PluginApi):
params={"db": db, "u": user, "p": password, "q": query})
def check_plugin_online(self):
logger.debug("Check that the InfluxDB server replies to ping requests")
logger.info("Check that the InfluxDB server replies to ping requests")
self.checkers.check_http_get_response(
url=self.get_influxdb_url('ping'),
expected_code=204)
logger.debug("Check that the InfluxDB API requires authentication")
logger.info("Check that the InfluxDB API requires authentication")
self.do_influxdb_query("show measurements",
user=plugin_settings.influxdb_user,
password='rogue', expected_code=401)
logger.debug("Check that the InfluxDB user is authorized")
logger.info("Check that the InfluxDB user is authorized")
self.do_influxdb_query("show measurements")
logger.debug("Check that the InfluxDB user doesn't have admin rights")
logger.info("Check that the InfluxDB user doesn't have admin rights")
self.do_influxdb_query("show servers", expected_code=401)
logger.debug("Check that the InfluxDB root user has admin rights")
logger.info("Check that the InfluxDB root user has admin rights")
self.do_influxdb_query("show servers",
user=plugin_settings.influxdb_rootuser,
password=plugin_settings.influxdb_rootpass)
logger.debug("Check that the Grafana UI server is running")
logger.info("Check that the Grafana UI server is running")
self.checkers.check_http_get_response(
self.get_grafana_url('login'))
logger.debug("Check that the Grafana user is authorized")
logger.info("Check that the Grafana user is authorized")
self.checkers.check_http_get_response(
self.get_grafana_url('api/org'),
auth=(plugin_settings.grafana_user, plugin_settings.grafana_pass))
logger.debug("Check that the Grafana API requires authentication")
logger.info("Check that the Grafana API requires authentication")
self.checkers.check_http_get_response(
self.get_grafana_url('api/org'),
auth=(plugin_settings.grafana_user, 'rogue'), expected_code=401)

View File

@ -36,7 +36,7 @@ mysql_dbname = 'grafanalma'
mysql_user = 'grafanalma'
mysql_pass = 'mysqlpass'
options = {
default_options = {
'influxdb_rootpass/value': influxdb_rootpass,
'influxdb_username/value': influxdb_user,
'influxdb_userpass/value': influxdb_pass,
@ -47,3 +47,5 @@ options = {
'mysql_username/value': mysql_user,
'mysql_password/value': mysql_pass,
}
toolchain_options = default_options

View File

@ -41,7 +41,7 @@ class TestInfluxdbPlugin(api.InfluxdbPluginApi):
self.prepare_plugin()
self.create_cluster()
self.helpers.create_cluster(name=self.__class__.__name__)
self.activate_plugin()
@ -71,7 +71,7 @@ class TestInfluxdbPlugin(api.InfluxdbPluginApi):
self.prepare_plugin()
self.create_cluster()
self.helpers.create_cluster(name=self.__class__.__name__)
self.activate_plugin()
@ -109,7 +109,7 @@ class TestInfluxdbPlugin(api.InfluxdbPluginApi):
self.prepare_plugin()
self.create_cluster()
self.helpers.create_cluster(name=self.__class__.__name__)
self.activate_plugin()

View File

@ -24,9 +24,11 @@ class LMACollectorPluginApi(base_test.PluginApi):
def prepare_plugin(self):
self.helpers.prepare_plugin(self.settings.plugin_path)
def activate_plugin(self):
def activate_plugin(self, options=None):
if options is None:
options = self.settings.default_options
self.helpers.activate_plugin(
self.settings.name, self.settings.version, self.settings.options)
self.settings.name, self.settings.version, options)
def get_plugin_vip(self):
pass

View File

@ -22,7 +22,7 @@ role_name = [] # NOTE(rpromyshlennikov): there is no role name
plugin_path = settings.LMA_COLLECTOR_PLUGIN_PATH
version = helpers.get_plugin_version(plugin_path)
options = {
default_options = {
'environment_label/value': 'deploy_lma_toolchain',
'elasticsearch_mode/value': 'remote',
'influxdb_mode/value': 'remote',
@ -30,3 +30,10 @@ options = {
'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'
}

View File

@ -40,7 +40,7 @@ class TestLMACollectorPlugin(api.LMACollectorPluginApi):
self.prepare_plugin()
self.create_cluster()
self.helpers.create_cluster(name=self.__class__.__name__)
self.activate_plugin()
@ -70,7 +70,7 @@ class TestLMACollectorPlugin(api.LMACollectorPluginApi):
self.prepare_plugin()
self.create_cluster()
self.helpers.create_cluster(name=self.__class__.__name__)
self.activate_plugin()

View File

@ -31,9 +31,11 @@ class InfraAlertingPluginApi(base_test.PluginApi):
def prepare_plugin(self):
self.helpers.prepare_plugin(self.settings.plugin_path)
def activate_plugin(self):
def activate_plugin(self, options=None):
if options is None:
options = self.settings.default_options
self.helpers.activate_plugin(
self.settings.name, self.settings.version, self.settings.options)
self.settings.name, self.settings.version, options)
def get_plugin_vip(self):
return self.helpers.get_plugin_vip(self.settings.vip_name)

View File

@ -27,9 +27,11 @@ send_to = 'root@localhost'
send_from = 'nagios@localhost'
smtp_host = '127.0.0.1'
options = {
default_options = {
'nagios_password/value': nagios_password,
'send_to/value': send_to,
'send_from/value': send_from,
'smtp_host/value': smtp_host,
}
toolchain_options = default_options

View File

@ -41,7 +41,7 @@ class TestLMAInfraAlertingPlugin(api.InfraAlertingPluginApi):
self.prepare_plugin()
self.create_cluster()
self.helpers.create_cluster(name=self.__class__.__name__)
self.activate_plugin()
@ -73,7 +73,7 @@ class TestLMAInfraAlertingPlugin(api.InfraAlertingPluginApi):
self.prepare_plugin()
self.create_cluster()
self.helpers.create_cluster(name=self.__class__.__name__)
self.activate_plugin()
@ -121,7 +121,7 @@ class TestLMAInfraAlertingPlugin(api.InfraAlertingPluginApi):
self.prepare_plugin()
self.create_cluster()
self.helpers.create_cluster(name=self.__class__.__name__)
self.activate_plugin()

View File

@ -193,7 +193,7 @@ class TestLMAInfraAlertingPluginSystem(api.InfraAlertingPluginApi):
self.helpers.fuel_createmirror()
self.create_cluster()
self.helpers.create_cluster(name=self.__class__.__name__)
self.activate_plugin()

View File

@ -47,11 +47,11 @@ def import_tests():
from stacklight_tests.influxdb_grafana import test_smoke_bvt # noqa
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)
from stacklight_tests.lma_infrastructure_alerting import ( # noqa
test_system)
from stacklight_tests.toolchain import test_smoke_bvt # noqa
def run_tests():

View File

@ -0,0 +1,62 @@
# 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 fuelweb_test.tests import base_test_case
from stacklight_tests.elasticsearch_kibana import api as elasticsearch_api
from stacklight_tests.helpers import checkers
from stacklight_tests.helpers import helpers
from stacklight_tests.helpers import remote_ops
from stacklight_tests.helpers import ui_tester
from stacklight_tests.influxdb_grafana import api as influx_api
from stacklight_tests.lma_collector import api as collector_api
from stacklight_tests.lma_infrastructure_alerting import (
api as infrastructure_alerting_api)
from stacklight_tests.toolchain import toolchain_settings
class ToolchainApi(object):
def __init__(self):
self.test = base_test_case.TestBasic()
self.env = self.test.env
self.settings = toolchain_settings
self.helpers = helpers.PluginHelper(self.env)
self.checkers = checkers
self.remote_ops = remote_ops
self.ui_tester = ui_tester
self.plugins = [
elasticsearch_api.ElasticsearchPluginApi(),
influx_api.InfluxdbPluginApi(),
collector_api.LMACollectorPluginApi(),
infrastructure_alerting_api.InfraAlertingPluginApi()]
def __getattr__(self, item):
return getattr(self.test, item)
def prepare_plugins(self):
for plugin in self.plugins:
plugin.prepare_plugin()
def activate_plugins(self):
msg = "Activate {} plugin"
for plugin in self.plugins:
logger.info(msg.format(plugin.get_plugin_settings().name))
plugin.activate_plugin(
options=plugin.get_plugin_settings().toolchain_options)
def check_plugins_online(self):
msg = "Check {} plugin"
for plugin in self.plugins:
logger.info(msg.format(plugin.get_plugin_settings().name))
plugin.check_plugin_online()

View File

@ -1,42 +0,0 @@
# 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 base_test
from stacklight_tests.influxdb_grafana import api as influx_grafana_api
from stacklight_tests.lma_collector import api as lma_collector_api
class ToolchainApi(base_test.PluginApi):
def __init__(self):
super(ToolchainApi, self).__init__()
self.plugins = [influx_grafana_api.InfluxdbPluginApi(),
lma_collector_api.LMACollectorPluginApi()]
def get_plugin_settings(self):
pass
def prepare_plugin(self):
for plugin in self.plugins:
plugin.prepare_plugin()
def activate_plugin(self):
for plugin in self.plugins:
plugin.activate_plugin()
def get_plugin_vip(self):
pass
def check_plugin_online(self):
for plugin in self.plugins:
plugin.check_plugin_online()

View File

@ -1,26 +0,0 @@
# 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.influxdb_grafana import (
plugin_settings as influxdb_grafana_settings)
from stacklight_tests.lma_collector import (
plugin_settings as lma_collector_settings)
name = 'toolchain'
version = '0.9.0'
role_name = list(set(
influxdb_grafana_settings.role_name +
lma_collector_settings.role_name
))

View File

@ -0,0 +1,120 @@
# 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.toolchain import api
@test(groups=["plugins"])
class TestToolchain(api.ToolchainApi):
"""Class for smoke testing the LMA Toolchain plugins."""
@test(depends_on_groups=['prepare_slaves_3'],
groups=["install_toolchain", "install", "toolchain", "smoke"])
@log_snapshot_after_test
def install_toolchain(self):
"""Install the LMA Toolchain plugins and check it exists
Scenario:
1. Upload the LMA Toolchain plugins to the master node
2. Install the plugins
3. Create a cluster
4. Check that the plugins can be enabled
Duration 20m
"""
self.env.revert_snapshot("ready_with_3_slaves")
self.prepare_plugins()
self.helpers.create_cluster(name=self.__class__.__name__)
self.activate_plugins()
@test(depends_on_groups=['prepare_slaves_3'],
groups=["deploy_toolchain", "deploy", "toolchain", "smoke"])
@log_snapshot_after_test
def deploy_toolchain(self):
"""Deploy a cluster with the LMA Toolchain plugins
Scenario:
1. Upload the LMA Toolchain plugins to the master node
2. Install the plugins
3. Create the cluster
4. Add 1 node with controller role
5. Add 1 node with compute and cinder roles
6. Add 1 node with plugin roles
7. Deploy the cluster
8. Check that LMA Toolchain plugins are running
9. Run OSTF
Duration 60m
Snapshot deploy_toolchain
"""
self.check_run("deploy_toolchain")
self.env.revert_snapshot("ready_with_3_slaves")
self.prepare_plugins()
self.helpers.create_cluster(name=self.__class__.__name__)
self.activate_plugins()
self.helpers.deploy_cluster(self.settings.base_nodes)
self.check_plugins_online()
self.helpers.run_ostf()
self.env.make_snapshot("deploy_toolchain", is_make=True)
@test(depends_on_groups=['prepare_slaves_9'],
groups=["deploy_ha_toolchain", "deploy", "deploy_ha", "toolchain",
"smoke"])
@log_snapshot_after_test
def deploy_ha_toolchain(self):
"""Deploy a cluster with the LMA Toolchain plugins in HA mode
Scenario:
1. Upload the LMA Toolchain plugins to the master node
2. Install the plugins
3. Create the cluster
4. Add 3 nodes with controller role
5. Add 3 nodes with compute and cinder roles
6. Add 3 nodes with plugin roles
7. Deploy the cluster
8. Check that LMA Toolchain plugins are running
9. Run OSTF
Duration 120m
Snapshot deploy_ha_toolchain
"""
self.check_run("deploy_ha_toolchain")
self.env.revert_snapshot("ready_with_9_slaves")
self.prepare_plugins()
self.helpers.create_cluster(name=self.__class__.__name__)
self.activate_plugins()
self.helpers.deploy_cluster(self.settings.full_ha_nodes)
self.check_plugins_online()
self.helpers.run_ostf()
self.env.make_snapshot("deploy_ha_toolchain", is_make=True)

View File

@ -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 stacklight_tests.elasticsearch_kibana import (
plugin_settings as elasticsearch_settings)
from stacklight_tests.influxdb_grafana import (
plugin_settings as influxdb_settings)
from stacklight_tests.lma_collector import (
plugin_settings as collector_settings)
from stacklight_tests.lma_infrastructure_alerting import (
plugin_settings as infrastructure_alerting_settings)
name = 'toolchain'
stacklight_roles = (elasticsearch_settings.role_name +
influxdb_settings.role_name +
collector_settings.role_name +
infrastructure_alerting_settings.role_name)
base_nodes = {
'slave-01': ['controller'],
'slave-02': ['compute', 'cinder'],
'slave-03': stacklight_roles
}
full_ha_nodes = {
'slave-01': ['controller'],
'slave-02': ['controller'],
'slave-03': ['controller'],
'slave-04': ['compute', 'cinder'],
'slave-05': ['compute', 'cinder'],
'slave-06': ['compute', 'cinder'],
'slave-07': stacklight_roles,
'slave-08': stacklight_roles,
'slave-09': stacklight_roles
}