Merge "Add createmirror test for LMA toolchain"

This commit is contained in:
Jenkins
2016-05-31 12:22:39 +00:00
committed by Gerrit Code Review
4 changed files with 106 additions and 8 deletions

View File

@@ -320,14 +320,22 @@ class PluginHelper(object):
return node['hostname']
def fuel_createmirror(self, option="", exit_code=0):
logger.info("Executing 'fuel-createmirror' command.")
cmd = "fuel-createmirror {0}".format(option)
logger.info("Executing '{}' command.".format(cmd))
with self.env.d_env.get_admin_remote() as remote:
exec_res = remote.execute(
"fuel-createmirror {0}".format(option))
exec_res = remote.execute(cmd)
asserts.assert_equal(
exit_code, exec_res['exit_code'],
'fuel-createmirror failed: {0}'.format(exec_res['stderr']))
def replace_ubuntu_mirror_with_mos(self):
cmds = ["fuel-mirror create -P ubuntu -G mos",
"fuel-mirror apply --replace -P ubuntu -G mos"]
logger.info("Executing '{}' commands.".format('\n'.join(cmds)))
with self.env.d_env.get_admin_remote() as remote:
for cmd in cmds:
remote.check_call(cmd)
@staticmethod
def get_services_for_version(services_mapping, version):
"""Returns processes for needed version only.
@@ -341,3 +349,22 @@ class PluginHelper(object):
return ".".join(version.split(".")[:2])
major_version = get_major_version()
return services_mapping[major_version]
def fuel_create_repositories(self, nodes):
"""Start task to setup repositories on provided nodes
:param nodes: list of nodes to run task on them
:type nodes: list
"""
nodes_ids = [str(node['id']) for node in nodes]
cmd = (
"fuel --env {env_id} "
"node --node-id {nodes_ids} "
"--tasks setup_repositories".format(
env_id=self.cluster_id,
nodes_ids=' '.join(nodes_ids))
)
logger.info(
"Executing {cmd} command.".format(cmd=cmd))
with self.env.d_env.get_admin_remote() as remote:
remote.check_call(cmd)

View File

@@ -34,20 +34,28 @@ class LMACollectorPluginApi(base_test.PluginApi):
def get_plugin_vip(self):
pass
def verify_services(self):
"""Check that LMA services started in the right quantity."""
nodes = self.helpers.get_all_ready_nodes()
def get_services_to_check(self):
services_to_check = self.helpers.get_services_for_version(
self.settings.services_to_check,
self.settings.version)
return services_to_check
def verify_services(self):
"""Check that LMA services started in the right quantity."""
nodes = self.helpers.get_all_ready_nodes()
pids = {}
services_to_check = self.get_services_to_check()
for node in nodes:
logger.info("Check {services} services on the {name} node".format(
name=node['name'],
services=', '.join(services_to_check.keys()),))
services_pids = {}
with self.env.d_env.get_ssh_to_remote(node['ip']) as remote:
for service, count in services_to_check.items():
self.checkers.verify_services(remote, service, count)
services_pids[service] = (
self.checkers.verify_services(remote, service, count))
pids[node['name']] = services_pids
return pids
def check_plugin_online(self):
# Run OSTF test to check pacemaker status

View File

@@ -80,3 +80,6 @@ class ToolchainApi(object):
def check_uninstall_failure(self):
for plugin in self.plugins:
plugin.check_uninstall_failure()
def get_pids_of_services(self):
return self.plugins_mapping["lma_collector"].verify_services()

View File

@@ -13,6 +13,7 @@
# under the License.
from fuelweb_test.helpers.decorators import log_snapshot_after_test
from proboscis import asserts
from proboscis import test
from stacklight_tests.toolchain import api
@@ -178,3 +179,62 @@ class TestNodesToolchain(api.ToolchainApi):
self.check_plugins_online()
self.helpers.run_ostf()
@test(depends_on_groups=["deploy_toolchain"],
groups=["toolchain_createmirror_setup_repos",
"system", "toolchain", "createmirror"])
@log_snapshot_after_test
def toolchain_createmirror_setup_repos(self):
"""Check work after fuel-createmirror and setup core repositories.
Scenario:
1. Revert the snapshot with 3 deployed nodes
2. Get pid of services which were launched
on controller/compute/storage/etc nodes by plugin and store them
3. Run the following commands on the master node:
`fuel-mirror create -P ubuntu -G mos`
`fuel-mirror apply --replace -P ubuntu -G mos`
4. Run the following command on the master node:
`fuel --env ENV_ID node --node-id Node1 ... NodeN --tasks setup_repositories` # noqa
5. Check that all nodes are remain in ready status
6. Get pid of services which were launched
on controller/compute/storage/etc nodes by plugin
and check that they wasn't changed from last check
7. Run OSTF
Duration 60m
"""
self.env.revert_snapshot("deploy_toolchain")
ready_nodes_before = self.helpers.get_all_ready_nodes()
ready_nodes_hostnames_before = {node["hostname"]
for node in ready_nodes_before}
pids_before = self.get_pids_of_services()
# NOTE(rpromyshlennikov): fuel-createmirror cmd is depricated
# since fuel-8.0 release
self.helpers.replace_ubuntu_mirror_with_mos()
self.helpers.fuel_create_repositories(ready_nodes_before)
ready_nodes_hostnames_after = {node["hostname"] for node
in self.helpers.get_all_ready_nodes()}
asserts.assert_equal(
ready_nodes_hostnames_before, ready_nodes_hostnames_after,
"List of ready nodes is not equal, "
"before createmirror:{}, "
"after createmirror: {}.".format(ready_nodes_hostnames_before,
ready_nodes_hostnames_after)
)
pids_after = self.get_pids_of_services()
asserts.assert_equal(
pids_after, pids_before,
"PIDs of services not equal, "
"before createmirror:{}, "
"after createmirror: {}.".format(pids_before, pids_after))
self.check_plugins_online()
self.helpers.run_ostf()