Add Upgrade test

Check that after Maintenance Update from 9.0 to 9.1 murano plugin
work correctly

Change-Id: I62d8769db0dc04aa5e6efe84b962047c3604a97c
This commit is contained in:
MStolyarenko 2016-09-27 17:22:31 +03:00 committed by Victor Ryzhenkin (freerunner)
parent 7e4898097d
commit b39062c406
5 changed files with 246 additions and 1 deletions

View File

@ -19,13 +19,15 @@ import urllib2
from devops.helpers import helpers
from fuelweb_test.helpers import os_actions
from fuelweb_test.helpers.ssh_manager import SSHManager
from fuelweb_test import logger
from proboscis import asserts
from devops.helpers.helpers import wait
from murano_plugin_tests.helpers import remote_ops
from murano_plugin_tests import settings
PLUGIN_PACKAGE_RE = re.compile(r'([^/]+)-(\d+\.\d+)-(\d+\.\d+\.\d+)')
@ -84,6 +86,7 @@ class PluginHelper(object):
self._cluster_id = None
self.nailgun_client = self.fuel_web.client
self._os_conn = None
self.ssh_manager = SSHManager()
@property
def cluster_id(self):
@ -608,3 +611,100 @@ class PluginHelper(object):
resource_name, pcm_nodes), config), None,
'Resource [{0}] is not properly configured'.format(
resource_name))
def add_centos_test_proposed_repo(self, repo_url, timestamp):
cmds = ["yum-config-manager --add-repo {0}{1}/x86_64/".format(
repo_url, timestamp),
"rpm --import {0}{1}/RPM-GPG-KEY-mos9.0".format(
repo_url, timestamp)]
for cmd in cmds:
self.ssh_manager.check_call(
ip=self.ssh_manager.admin_ip,
command=cmd)
def add_cluster_repo(self, repo):
attributes = self.fuel_web.client.get_cluster_attributes(
self.cluster_id)
repos_attr = attributes['editable']['repo_setup']['repos']
repos_attr['value'].append(repo)
self.fuel_web.client.update_cluster_attributes(
self.cluster_id, attributes)
def install_python_cudet(self):
cmd = "yum install -y python-cudet"
self.ssh_manager.check_call(
ip=self.ssh_manager.admin_ip,
command=cmd)
def prepare_update_master_node(self):
cmds = ['update-prepare prepare master',
'update-prepare update master']
for cmd in cmds:
self.ssh_manager.check_call(
ip=self.ssh_manager.admin_ip,
command=cmd)
def prepare_for_update(self):
cmd = "update-prepare prepare env {}".format(self.cluster_id)
self.ssh_manager.check_call(
ip=self.ssh_manager.admin_ip,
command=cmd)
def install_mu(self, repos='proposed'):
if repos:
cmd = "fuel2 update install --env {} --repos {} " \
"--restart-rabbit --restart-mysql".format(self.cluster_id,
repos)
else:
cmd = "fuel2 update install --env {}" \
"--restart-rabbit --restart-mysql ".format(self.cluster_id)
std_out = self.ssh_manager.check_call(
ip=self.ssh_manager.admin_ip,
command=cmd).stderr_str
# "fuel2 update" command don't have json output
asserts.assert_true(
"fuel2 task show" in std_out,
"fuel2 update command don't return task id: \n {}".format(std_out))
task_id = int(std_out.split("fuel2 task show")[1].split("`")[0])
task = self.fuel_web.client.get_task(task_id)
self.assert_cli_task_success(task, timeout=120 * 60)
def assert_cli_task_success(self, task, timeout=70 * 60, interval=20):
logger.info('Wait {timeout} seconds for task: {task}'
.format(timeout=timeout, task=task))
start = time.time()
wait(
lambda: (self.fuel_web.client.get_task(task['id'])['status'] not in
('pending', 'running')),
interval=interval,
timeout=timeout,
timeout_msg='Waiting timeout {timeout} sec was reached '
'for task: {task}'.format(task=task["name"],
timeout=timeout)
)
took = time.time() - start
task = self.fuel_web.client.get_task(task['id'])
logger.info('Task finished in {took} seconds with the result: {task}'
.format(took=took, task=task))
asserts.assert_equal(
task['status'], 'ready',
"Task '{name}' has incorrect status. {status} != {exp}".format(
status=task['status'], exp='ready', name=task["name"]
)
)
def check_update(self):
cmd = "cudet -e {}".format(self.cluster_id)
std_out = self.ssh_manager.execute_on_remote(
ip=self.ssh_manager.admin_ip,
cmd=cmd)['stdout']
asserts.assert_true("ALL NODES UP-TO-DATE" in std_out[-1],
"Cluster wasn't updated")

View File

@ -18,6 +18,8 @@ from devops.helpers import helpers as devops_helpers
from fuelweb_test import logger
from fuelweb_test.tests import base_test_case
from murano_plugin_tests import settings
from murano_plugin_tests.helpers import checkers
from murano_plugin_tests.helpers import helpers
from murano_plugin_tests.helpers import remote_ops
@ -152,3 +154,59 @@ class MuranoPluginApi(object):
nailgun_nodes[:1])
operations[operation](target_node)
self.wait_plugin_online()
def apply_maintenance_update_90_to_91(self):
"""Method applies maintenance updates on whole cluster
from MOS9.0 to MOS9.1
1) Add latest proposed repository
2) Import PGP key for installed repository
3) Install `python-cudet`
4) Add repository and deploy changes
5) Update with keys all nodes
6) Update-prepare prepare master
7) Update-prepare update master
8) Update-prepare prepare env
9) Update
10) Verify that you have the latest packages included in
Mirantis OpenStack 9.1 - Potential updates: ALL NODES UP-TO-DATE
"""
logger.info("Add latest proposed repository")
timestamp = settings.MOS_CENTOS_PROPOSED_MIRROR_ID
self.helpers.add_centos_test_proposed_repo(
settings.CENTOS_REPO_URL, timestamp)
logger.info("Add extra Ubuntu repo to deployed cluster")
timestamp_ubuntu = settings.MOS_UBUNTU_MIRROR_ID
proposed = {
'name': 'proposed',
'section': 'main restricted',
'uri': settings.UBUNTU_REPO_URL + timestamp_ubuntu + '/',
'priority': 1200,
'suite': 'mos9.0-proposed',
'type': 'deb'}
self.helpers.add_cluster_repo(proposed)
logger.info("Install python-cudet library")
self.helpers.install_python_cudet()
logger.info("Update-prepare prepare master and "
"Update-prepare update master")
self.helpers.prepare_update_master_node()
logger.info("Update-prepare prepare env")
self.helpers.prepare_for_update()
logger.info("Install MU")
self.helpers.install_mu()
self.helpers.check_update()

View File

@ -0,0 +1,73 @@
# 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 murano_plugin_tests.murano_plugin import api
@test(groups=["plugins"])
class TestMuranoPluginMU(api.MuranoPluginApi):
"""Class for Maintenance Update testing the Murano plugin."""
@test(depends_on_groups=["deploy_murano_plugin"],
groups=["test_mu_upgrade_murano_node", "murano",
"test_mu_upgrade", "murano_plugin_upgrade"])
@log_snapshot_after_test
def test_mu_upgrade_murano_node(self):
"""Apply MU over cluster with plugin and Murano node
Scenario:
1. Deploy MOS 9.0 with Murano plugin and murano-node in non-ha
2. Run OSTF
3. Apply MU for 9.1
4. Run OSTF
Duration 70m
Snapshot test_mu_upgrade_murano_node
"""
self.env.revert_snapshot("deploy_murano_plugin")
self.wait_plugin_online()
self.apply_maintenance_update_90_to_91()
self.run_ostf(['sanity', 'smoke'])
self.check_plugin_online()
@test(depends_on_groups=["deploy_murano_plugin_on_controller"],
groups=["test_mu_upgrade_murano_plugin", "murano",
"test_mu_upgrade", "murano_plugin_upgrade"])
@log_snapshot_after_test
def test_mu_upgrade_without_murano_node(self):
"""Apply MU over cluster with plugin without Murano node
Scenario:
1. Deploy MOS 9.0 with Murano plugin in non-ha
2. Run OSTF
3. Apply MU for 9.1
4. Run OSTF
Duration 100m
Snapshot test_mu_upgrade_without_murano_node
"""
self.env.revert_snapshot("deploy_murano_plugin_on_controller")
self.wait_plugin_online()
self.apply_maintenance_update_90_to_91()
self.run_ostf(['sanity', 'smoke'])
self.check_plugin_online()

View File

@ -40,6 +40,7 @@ class CloseSSHConnectionsPlugin(plugins.Plugin):
def import_tests():
from murano_plugin import test_failover # noqa
from murano_plugin import test_murano_maintenance_update # noqa
from murano_plugin import test_murano_plugin_bvt # noqa
from murano_plugin import test_murano_plugin_update # noqa
from murano_plugin import test_post_install # noqa

View File

@ -19,3 +19,16 @@ from fuelweb_test.settings import * # noqa
# Murano plugins
MURANO_PLUGIN_PATH = os.environ.get('MURANO_PLUGIN_PATH')
# Centos Repo for upgrade
CENTOS_REPO_URL = 'http://mirror.fuel-infra.org/mos-repos/centos/' \
'mos9.0-centos7/snapshots/'
UBUNTU_REPO_URL = 'http://mirror.fuel-infra.org/mos-repos/ubuntu/snapshots/'
# Timestamps for upgrade
MOS_CENTOS_PROPOSED_MIRROR_ID = os.environ.get('MOS_CENTOS_PROPOSED_MIRROR_ID')
MOS_UBUNTU_MIRROR_ID = os.environ.get('MOS_UBUNTU_MIRROR_ID')