Merge "Add regression test for custom hostnames"

This commit is contained in:
Jenkins 2017-04-11 07:58:37 +00:00 committed by Gerrit Code Review
commit 05049ff966
3 changed files with 130 additions and 1 deletions

View File

@ -282,13 +282,16 @@ class PluginHelper(object):
mode='ha_compact') mode='ha_compact')
return self._cluster_id return self._cluster_id
def deploy_cluster(self, nodes_roles, verify_network=False, def deploy_cluster(self, nodes_roles,
nodes_hostnames=None, verify_network=False,
update_interfaces=True, check_services=True, update_interfaces=True, check_services=True,
timeout=getattr(conf, 'DEPLOYMENT_TIMEOUT', 7800)): timeout=getattr(conf, 'DEPLOYMENT_TIMEOUT', 7800)):
"""Assign roles to nodes and deploy the cluster. """Assign roles to nodes and deploy the cluster.
:param nodes_roles: nodes to roles mapping. :param nodes_roles: nodes to roles mapping.
:type nodes_roles: dict :type nodes_roles: dict
:param nodes_hostnames: nodes to hostnames mapping (default: None).
:type nodes_hostnames: dict
:param verify_network: whether or not network verification should be :param verify_network: whether or not network verification should be
run before the deployment (default: False). run before the deployment (default: False).
:type verify_network: boolean :type verify_network: boolean
@ -305,12 +308,63 @@ class PluginHelper(object):
""" """
self.fuel_web.update_nodes(self.cluster_id, nodes_roles, self.fuel_web.update_nodes(self.cluster_id, nodes_roles,
update_interfaces=update_interfaces) update_interfaces=update_interfaces)
if nodes_hostnames:
for node in self.fuel_web.client.list_cluster_nodes(
self.cluster_id):
for k in nodes_hostnames.keys():
if node['name'].startswith(k):
logger.info(
("Setting hostname for Node Id {0} Name {1}" +
"to {2}").format(
node['id'], k, nodes_hostnames[k]))
self.fuel_web.client.set_hostname(
node['id'],
nodes_hostnames[k])
if verify_network: if verify_network:
self.fuel_web.verify_network(self.cluster_id) self.fuel_web.verify_network(self.cluster_id)
self.fuel_web.deploy_cluster_wait(self.cluster_id, self.fuel_web.deploy_cluster_wait(self.cluster_id,
check_services=check_services, check_services=check_services,
timeout=timeout) timeout=timeout)
def verify_custom_hostnames(self, nodes_hostnames):
"""Verify nodes hostnames after cluster deployment.
:param nodes_hostnames: nodes to hostnames mapping (default: None).
:type nodes_hostnames: dict
:returns: None
"""
# Verify that new hostnames are applied on the nodes
for node in self.fuel_web.client.list_cluster_nodes(self.cluster_id):
prev_node_name = filter(
lambda(x): node['name'].startswith(x),
nodes_hostnames.keys())
asserts.assert_true(
len(prev_node_name) > 0,
"Can not retrieve any node for name {0}".format(node['name']))
asserts.assert_true(
len(prev_node_name) == 1,
"Too many match for node name {0}: {1}".format(
node['name'], prev_node_name))
custom_hostname = nodes_hostnames[prev_node_name[0]]
devops_node = self.fuel_web.get_devops_node_by_nailgun_node(
node)
logger.info("Checking node name: {0} hostname: {1}".format(
node['name'], node['hostname']))
with self.env.d_env.get_admin_remote() as admin_remote:
# Must add SSH options because of cinder node(s)
cmd = ("ssh -o StrictHostKeyChecking=no -q {0}" +
" hostname -s").format(node['hostname'])
logger.debug("Launching ssh cmd: {0}".format(cmd))
cmd_ret = admin_remote.execute(cmd)
logger.debug("ssh cmd results: {0}".format(cmd_ret))
hostname = cmd_ret['stdout'][0].strip()
asserts.assert_equal(
custom_hostname,
hostname,
"Failed to apply the new '{0}' hostname to '{1}' node. "
"Current hostname is '{2}'".format(
custom_hostname, devops_node.name, hostname))
def run_ostf(self, *args, **kwargs): def run_ostf(self, *args, **kwargs):
"""Run the OpenStack health checks.""" """Run the OpenStack health checks."""
self.fuel_web.run_ostf(self.cluster_id, *args, **kwargs) self.fuel_web.run_ostf(self.cluster_id, *args, **kwargs)

View File

@ -72,6 +72,7 @@ def import_tests():
from stacklight_tests.toolchain import test_system # noqa from stacklight_tests.toolchain import test_system # noqa
from stacklight_tests.zabbix import test_destructive # noqa from stacklight_tests.zabbix import test_destructive # noqa
from stacklight_tests.zabbix import test_functional # noqa from stacklight_tests.zabbix import test_functional # noqa
from stacklight_tests.zabbix import test_regression # noqa
from stacklight_tests.zabbix import test_smoke_bvt # noqa from stacklight_tests.zabbix import test_smoke_bvt # noqa
from stacklight_tests.zabbix import test_system # noqa from stacklight_tests.zabbix import test_system # noqa

View File

@ -0,0 +1,74 @@
# coding=utf-8
# Copyright 2017 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 stacklight_tests.zabbix import api
from fuelweb_test.helpers.decorators import log_snapshot_after_test
@test(groups=["plugins"])
class TestZabbixPluginRegression(api.ZabbixApi):
"""Class for regression testing the Zabbix plugin."""
@test(depends_on_groups=["prepare_slaves_5"],
groups=["deploy_zabbix_custom_hostnames", "zabbix", "regression",
"bugs", "bug_1633701"])
@log_snapshot_after_test
def deploy_zabbix_custom_hostnames(self):
"""Change default nodes hostnames and deploy environment
Scenario:
1. Copy Zabbix plugin to the Fuel Master
node and install the plugin.
2. Create an environment with enabled plugin in the
Fuel Web UI and change nodes default hostnames.
3. Deploy environment.
4. Check plugin health.
Duration 60m
"""
self.env.revert_snapshot("ready_with_5_slaves")
self.prepare_plugin()
self.helpers.create_cluster(name=self.__class__.__name__)
self.activate_plugin()
nodes_hostnames = {
'slave-01': 'controller-A',
'slave-02': 'controller-B',
'slave-03': 'controller-C',
'slave-04': 'compute-A',
'slave-05': 'cinder-A'
}
self.helpers.deploy_cluster(
{
'slave-01': ['controller'],
'slave-02': ['controller'],
'slave-03': ['controller'],
'slave-04': ['compute'],
'slave-05': ['cinder']
}, timeout=10800,
check_services=False,
nodes_hostnames=nodes_hostnames
)
self.helpers.verify_custom_hostnames(nodes_hostnames)
self.check_plugin_online()