Merge "Add post-deployment tests"

This commit is contained in:
Jenkins 2016-06-02 14:57:49 +00:00 committed by Gerrit Code Review
commit 63651c9f6e
4 changed files with 172 additions and 5 deletions

View File

@ -13,6 +13,12 @@ System
.. automodule:: stacklight_tests.toolchain.test_system
:members:
Post-installation
=================
.. automodule:: stacklight_tests.toolchain.test_post_install
:members:
Detached plugins
================

View File

@ -99,14 +99,34 @@ class PluginHelper(object):
"""
if options is None:
options = {}
msg = "Plugin {name} ({version}) couldn't be enabled.".format(
name=name,
version=version)
msg = "Plugin {0} isn't found.".format(name)
asserts.assert_true(
self.fuel_web.check_plugin_exists(self.cluster_id, name),
msg)
self.fuel_web.update_plugin_settings(
self.cluster_id, name, version, options)
logger.info("Updating settings for plugin {0} ({1}): {2}".format(
name, version, options))
nailgun_client = self.fuel_web.client
attributes = nailgun_client.get_cluster_attributes(self.cluster_id)
attributes = attributes['editable'][name]
plugin_data = None
for item in attributes['metadata']['versions']:
if item['metadata']['plugin_version'] == version:
plugin_data = item
break
asserts.assert_is_not_none(
plugin_data, "Plugin {0} ({1}) is not found".format(name, version))
attributes['metadata']['enabled'] = True
for option, value in options.items():
path = option.split("/")
for p in path[:-1]:
plugin_settings = plugin_data[p]
plugin_settings[path[-1]] = value
nailgun_client.update_cluster_attributes(self.cluster_id, {
"editable": {name: attributes}
})
def get_plugin_vip(self, vip_name):
"""Get plugin IP."""
@ -354,3 +374,40 @@ class PluginHelper(object):
"Executing {cmd} command.".format(cmd=cmd))
with self.env.d_env.get_admin_remote() as remote:
remote.check_call(cmd)
def run_tasks(self, nodes, tasks=None, start=None, end=None,
timeout=10 * 60):
"""Run a set of tasks on nodes and wait for completion.
The list of tasks is provided using the 'tasks' parameter and it can
also be specified using the 'start' and/or 'end' parameters. In the
latter case, the method will compute the exact set of tasks to be
executed.
:param nodes: list of nodes that should run the tasks
:type nodes: list
:param tasks: list of tasks to run.
:param tasks: list
:param start: the task from where to start the deployment.
:param start: str
:param end: the task where to end the deployment.
:param end: str
:param timeout: number of seconds to wait for the tasks completion
(default: 600).
:param timeout: int
"""
nailgun_client = self.fuel_web.client
task_ids = []
if tasks is not None:
task_ids += tasks
if start is not None or end is not None:
task_ids += [
t["id"] for t in nailgun_client.get_end_deployment_tasks(
self.cluster_id, end=end or '', start=start or '')]
node_ids = ",".join([str(node["id"]) for node in nodes])
logger.info("Running tasks {0} for nodes {1}".format(
",".join(task_ids), node_ids))
result = nailgun_client.put_deployment_tasks_for_cluster(
self.cluster_id, data=task_ids, node_id=node_ids)
self.fuel_web.assert_task_success(result, timeout=timeout)

View File

@ -53,6 +53,7 @@ def import_tests():
from stacklight_tests.lma_infrastructure_alerting import ( # noqa
test_system)
from stacklight_tests.toolchain import test_detached_plugins # noqa
from stacklight_tests.toolchain import test_post_install # noqa
from stacklight_tests.toolchain import test_smoke_bvt # noqa
from stacklight_tests.toolchain import test_system # noqa

View File

@ -0,0 +1,103 @@
# 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
from stacklight_tests.toolchain import toolchain_settings as settings
@test(groups=["plugins"])
class TestToolchainPostInstallation(api.ToolchainApi):
"""Class for testing that the LMA Toolchain plugins can be installed in an
existing environment.
"""
@test(depends_on_groups=['prepare_slaves_5'],
groups=["deploy_environment_without_toolchain", "deploy",
"toolchain", "post_installation"])
@log_snapshot_after_test
def deploy_environment_without_toolchain(self):
"""Deploy a cluster without the LMA Toolchain plugins.
Scenario:
1. Create the cluster
2. Add 1 node with the controller role
3. Add 1 node with the compute and cinder roles
4. Deploy the cluster
5. Run OSTF
Duration 60m
Snapshot deploy_environment_without_toolchain
"""
self.check_run("deploy_environment_without_toolchain")
self.env.revert_snapshot("ready_with_5_slaves")
self.helpers.create_cluster(name=self.__class__.__name__)
self.helpers.deploy_cluster({
'slave-01': ['controller'],
'slave-02': ['compute', 'cinder'],
})
self.helpers.run_ostf()
self.env.make_snapshot("deploy_environment_without_toolchain",
is_make=True)
@test(depends_on=[deploy_environment_without_toolchain],
groups=["deploy_toolchain_in_existing_environment", "deploy",
"toolchain", "detached_plugins"])
@log_snapshot_after_test
def deploy_toolchain_in_existing_environment(self):
"""Deploy the LMA Toolchain plugins in an existing environment.
Scenario:
1. Upload the plugins to the master node
2. Install the plugins
3. Configure the plugins
4. Add 3 nodes with the plugin roles
5. Deploy the cluster
6. Check that LMA Toolchain plugins are running
7. Run OSTF
Duration 60m
Snapshot deploy_toolchain_in_existing_environment
"""
self.check_run("deploy_toolchain_in_existing_environment")
existing_nodes = self.helpers.get_all_ready_nodes()
self.prepare_plugins()
self.activate_plugins()
self.helpers.deploy_cluster({
'slave-03': settings.stacklight_roles,
'slave-04': settings.stacklight_roles,
'slave-05': settings.stacklight_roles
})
# The 'hiera' and post-deployment tasks have to be re-executed
# "manually" for the existing nodes
self.helpers.run_tasks(existing_nodes, tasks=['hiera'],
start="post_deployment_start", timeout=20 * 60)
self.check_plugins_online()
self.helpers.run_ostf()
self.env.make_snapshot("deploy_toolchain_in_existing_environment",
is_make=True)