Rework upgrade with plugin test

Since we are not testing detach-db plugin its time to switch to example plugin
- Move plugin test to separate file
- Replace detach-db plugin with example_v3 plugin
- Download the plugin by URL passed via EXAMPLE_V3_PLUGIN_REMOTE_URL env var

Change-Id: I99217686be856acd8e69e93e5dd3ae40cbb1f15b
Closes-bug:1603415
This commit is contained in:
Vladimir Khlyunev 2016-08-08 15:50:49 +03:00
parent 5ad3430af1
commit 461f7c582a
6 changed files with 228 additions and 200 deletions

View File

@ -670,6 +670,11 @@ Test Data-Driven Upgrade - Network templates
.. automodule:: fuelweb_test.tests.tests_upgrade.test_data_driven_upgrade_net_tmpl
:members:
Test Data-Driven Upgrade - Plugins engine
-----------------------------------------
.. automodule:: fuelweb_test.tests.tests_upgrade.test_data_driven_upgrade_plugin
:members:
Upgrade Master tool
-------------------
.. automodule:: fuelweb_test.tests.tests_upgrade.upgrader_tool

View File

@ -436,6 +436,8 @@ CUSTOM_FUEL_SETTING_YAML = os.environ.get('CUSTOM_FUEL_SETTING_YAML', None)
UPGRADE_FUEL_FROM = os.environ.get('UPGRADE_FUEL_FROM', '8.0')
UPGRADE_FUEL_TO = os.environ.get('UPGRADE_FUEL_TO', '9.0')
OCTANE_PATCHES = os.environ.get('OCTANE_PATCHES', None)
EXAMPLE_V3_PLUGIN_REMOTE_URL = os.environ.get('EXAMPLE_V3_PLUGIN_REMOTE_URL',
None)
SNAPSHOT = os.environ.get('SNAPSHOT', '')
# For 5.1.1 we have 2 releases in tarball and should specify what we need

View File

@ -16,4 +16,5 @@
from fuelweb_test.tests.tests_upgrade import test_data_driven_upgrade # noqa
from fuelweb_test.tests.tests_upgrade import test_data_driven_upgrade_net_tmpl # noqa
from fuelweb_test.tests.tests_upgrade import test_data_driven_upgrade_plugin # noqa
from fuelweb_test.tests.tests_upgrade import upgrader_tool # noqa

View File

@ -17,12 +17,10 @@ import os
from devops.helpers.helpers import wait
from proboscis import test
from proboscis.asserts import assert_equal
from proboscis.asserts import assert_not_equal
from proboscis.asserts import assert_true
from fuelweb_test import settings
from fuelweb_test.helpers.decorators import log_snapshot_after_test
from fuelweb_test.helpers.utils import run_on_remote
from fuelweb_test.tests.base_test_case import SetupEnvironment
from fuelweb_test.tests.tests_upgrade.test_data_driven_upgrade_base import \
DataDrivenUpgradeBase
@ -98,31 +96,6 @@ class UpgradePrepare(DataDrivenUpgradeBase):
super(self.__class__, self).prepare_upgrade_ceph_ha()
@test(groups=['upgrade_detach_plugin_backup'],
depends_on=[SetupEnvironment.prepare_slaves_9])
@log_snapshot_after_test
def upgrade_detach_plugin_backup(self):
"""Initial preparation of the cluster using previous version of Fuel;
Using: HA, ceph for all
Scenario:
1. Install detach-database plugin on master node
2. Create cluster with NeutronTUN network provider
3. Enable plugin for created cluster
4. Add 3 node with controller role
5. Add 3 node with separate-database role
6. Add 2 node with compute+ceph roles
7. Verify networks
8. Deploy cluster
9. Install fuel-octane package
10. Create backup file using 'octane fuel-backup'
11. Download the backup to the host
Duration: TODO
Snapshot: upgrade_detach_plugin_backup
"""
super(self.__class__, self).prepare_upgrade_detach_plugin()
@test(groups=['upgrade_smoke_tests'])
class UpgradeSmoke(DataDrivenUpgradeBase):
@ -515,114 +488,6 @@ class UpgradeCephHA(DataDrivenUpgradeBase):
self.fuel_web.run_ostf(cluster_id)
@test(groups=['upgrade_detach_plugin_tests'])
class UpgradeDetach_Plugin(DataDrivenUpgradeBase):
def __init__(self):
super(self.__class__, self).__init__()
self.source_snapshot_name = "upgrade_detach_plugin_backup"
self.snapshot_name = "upgrade_detach_plugin_restore"
self.backup_name = "backup_detach_plugin.tar.gz"
self.repos_backup_name = "repos_backup_detach_plugin.tar.gz"
@log_snapshot_after_test
@test(groups=['upgrade_detach_plugin_restore'])
def upgrade_detach_plugin_restore(self):
"""Reinstall Fuel and restore data with cluster with detach-db plugin
Scenario:
1. Revert "upgrade_detach_plugin_backup" snapshot
2. Reinstall Fuel master using iso given in ISO_PATH
3. Install fuel-octane package
4. Upload the backup back to reinstalled Fuel maser node
5. Restore master node using 'octane fuel-restore'
6. Ensure that plugin were restored
7. Verify networks for restored cluster
8. Run OSTF for restored cluster
Snapshot: upgrade_detach_plugin_restore
Duration: TODO
"""
self.check_run(self.snapshot_name)
assert_true(os.path.exists(self.repos_local_path))
assert_true(os.path.exists(self.local_path))
intermediate_snapshot = 'plugin_before_restore'
if not self.env.d_env.has_snapshot(intermediate_snapshot):
self.show_step(1, initialize=True)
assert_true(
self.env.revert_snapshot(self.source_snapshot_name),
"The test can not use given environment - snapshot "
"{!r} does not exists".format(self.source_snapshot_name))
self.show_step(2)
self.reinstall_master_node()
self.env.make_snapshot(intermediate_snapshot)
else:
self.env.d_env.revert(intermediate_snapshot)
self.env.resume_environment()
self.show_step(3)
self.show_step(4)
self.show_step(5)
self.do_restore(self.backup_path, self.local_path,
self.repos_backup_path, self.repos_local_path)
self.fuel_web.change_default_network_settings()
cluster_id = self.fuel_web.get_last_created_cluster()
self.show_step(6)
attr = self.fuel_web.client.get_cluster_attributes(cluster_id)
assert_true('detach-database' in attr['editable'],
"Can't find plugin data in cluster attributes!")
stdout = run_on_remote(
self.admin_remote,
"find /var/www/nailgun/plugins/ -name detach-database*")
assert_not_equal(len(stdout), 0, "Can not find plugin's directory")
plugin_dir = stdout[0].strip()
assert_true(
self.remote_file_exists(os.path.join(plugin_dir, "metadata.yaml")),
"Plugin's files does not found!")
self.show_step(7)
self.fuel_web.verify_network(cluster_id)
self.show_step(8)
self.fuel_web.run_ostf(cluster_id)
self.env.make_snapshot(self.snapshot_name, is_make=True)
self.cleanup()
@log_snapshot_after_test
@test(groups=['upgrade_detach_plugin_scale'],
depends_on_groups=['upgrade_detach_plugin_restore'])
def upgrade_detach_plugin_scale(self):
"""Add 1 node with plugin custom role to existing cluster
Scenario:
1. Revert "upgrade_detach_plugin_backup" snapshot.
2. Add 1 separate-database node
3. Verify networks
4. Deploy cluster
5. Run OSTF
Duration: 60m
"""
self.show_step(1, initialize=True)
self.env.revert_snapshot(self.snapshot_name)
self.show_step(2)
cluster_id = self.fuel_web.get_last_created_cluster()
self.env.bootstrap_nodes(
[self.env.d_env.get_node(name='slave-09')])
self.fuel_web.update_nodes(cluster_id,
{'slave-09': ['standalone-database']})
self.show_step(3)
self.fuel_web.verify_network(cluster_id)
self.show_step(4)
# LP 1562736 get_devops_node_by_nailgun_node is not working
self.fuel_web.deploy_cluster_wait(cluster_id)
self.show_step(5)
self.fuel_web.run_ostf(cluster_id)
@test(groups=['upgrade_no_cluster_tests'])
class UpgradeNoCluster(DataDrivenUpgradeBase):
def __init__(self):

View File

@ -265,13 +265,12 @@ class DataDrivenUpgradeBase(TestBasic):
logger.info("Applying backup from {}".format(repos_backup_path))
self.octane_action("repo-restore", repos_backup_path)
fuel_version = StrictVersion(settings.UPGRADE_FUEL_TO)
if fuel_version in (StrictVersion('7.0'), StrictVersion('8.0')):
if self.fuel_version in (StrictVersion('7.0'), StrictVersion('8.0')):
logger.info(
"Update CentOS bootstrap image with restored ssh keys")
self.octane_action('update-bootstrap-centos')
if fuel_version >= StrictVersion('8.0'):
if self.fuel_version >= StrictVersion('8.0'):
self.fuel_web.change_default_network_settings()
n_nodes = self.fuel_web.client.list_nodes()
@ -425,68 +424,6 @@ class DataDrivenUpgradeBase(TestBasic):
self.env.make_snapshot("upgrade_ceph_ha_backup", is_make=True)
def prepare_upgrade_detach_plugin(self):
self.backup_name = "backup_detach_plugin.tar.gz"
self.repos_backup_name = "repos_backup_detach_plugin.tar.gz"
self.check_run("upgrade_detach_plugin_backup")
self.env.revert_snapshot("ready", skip_timesync=True)
cmds = [
"yum -y install git python-pip createrepo "
"dpkg-devel dpkg-dev rpm rpm-build",
"pip install virtualenv ",
"virtualenv --system-site-packages fpb",
"source fpb/bin/activate",
"pip install -U setuptools",
"pip install fuel-plugin-builder",
"git clone https://github.com/"
"openstack/fuel-plugin-detach-database",
"cd fuel-plugin-detach-database && "
"git checkout stable/{branch} && "
"fpb --build . && "
"fuel plugins --install *.rpm "
"--user {user} --password {pwd}".format(
branch=settings.UPGRADE_FUEL_FROM,
user=settings.KEYSTONE_CREDS['username'],
pwd=settings.KEYSTONE_CREDS['password'])]
for cmd in cmds:
run_on_remote(self.admin_remote, cmd)
cluster_settings = {
'net_provider': settings.NEUTRON,
'net_segment_type': settings.NEUTRON_SEGMENT['tun'],
'volumes_lvm': False,
'volumes_ceph': True,
'images_ceph': True,
'objects_ceph': True,
'ephemeral_ceph': True,
}
cluster_settings.update(self.cluster_creds)
self.deploy_cluster({
'name': self.prepare_upgrade_detach_plugin.__name__,
'settings': cluster_settings,
'plugin':
{'name': 'detach-database',
'data': {'metadata/enabled': True}},
'nodes':
{'slave-01': ['controller'],
'slave-02': ['controller'],
'slave-03': ['controller'],
'slave-04': ['standalone-database'],
'slave-05': ['standalone-database'],
'slave-06': ['standalone-database'],
'slave-07': ['compute', 'ceph-osd'],
'slave-08': ['compute', 'ceph-osd']}
})
self.do_backup(self.backup_path, self.local_path,
self.repos_backup_path, self.repos_local_path)
self.env.make_snapshot("upgrade_detach_plugin_backup", is_make=True)
def prepare_upgrade_no_cluster(self):
self.backup_name = "backup_no_cluster.tar.gz"
self.repos_backup_name = "repos_backup_no_cluster.tar.gz"

View File

@ -0,0 +1,218 @@
# 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.
import os
from proboscis import test
from proboscis.asserts import assert_true, assert_not_equal, assert_is_not_none
from fuelweb_test import settings
from fuelweb_test.helpers.decorators import log_snapshot_after_test
from fuelweb_test.tests.base_test_case import SetupEnvironment
from fuelweb_test.tests.tests_upgrade.test_data_driven_upgrade_base import \
DataDrivenUpgradeBase
@test
class UpgradePlugin(DataDrivenUpgradeBase):
def __init__(self):
super(self.__class__, self).__init__()
self.source_snapshot_name = "upgrade_plugin_backup"
self.snapshot_name = "upgrade_plugin_restore"
self.backup_name = "backup_plugin.tar.gz"
self.repos_backup_name = "repos_backup_plugin.tar.gz"
@test(groups=['upgrade_plugin_backup'],
depends_on=[SetupEnvironment.prepare_release])
@log_snapshot_after_test
def upgrade_plugin_backup(self):
"""Prepare fuel+example plugin with cluster
Using: HA, ceph for all
Scenario:
1. Install fuel_plugin_example_v3 plugin on master node
2. Create cluster with NeutronTUN network provider
3. Enable plugin for created cluster
4. Add 1 node with controller role
5. Add 1 node with fuel_plugin_example_v3 role
6. Add 3 node with compute+ceph roles
7. Verify networks
8. Deploy cluster
9. Install fuel-octane package
10. Create backup file using 'octane fuel-backup'
11. Download the backup to the host
Duration: TODO
Snapshot: upgrade_plugin_backup
"""
assert_is_not_none(settings.EXAMPLE_V3_PLUGIN_REMOTE_URL,
"EXAMPLE_V3_PLUGIN_REMOTE_URL is not defined!")
example_plugin_remote_name = os.path.join(
"/var",
os.path.basename(settings.EXAMPLE_V3_PLUGIN_REMOTE_URL))
self.check_run(self.source_snapshot_name)
self.show_step(1)
self.env.revert_snapshot("ready", skip_timesync=True)
# using curl to predict file name and avoid '*.rpm'-like patterns
admin_remote = self.env.d_env.get_admin_remote()
admin_remote.check_call(
"curl -s {url} > {location}".format(
url=settings.EXAMPLE_V3_PLUGIN_REMOTE_URL,
location=example_plugin_remote_name))
admin_remote.check_call(
"fuel --username={user} --password {password}"
"plugins --install {location} ".format(
location=example_plugin_remote_name,
user=settings.KEYSTONE_CREDS['username'],
password=settings.KEYSTONE_CREDS['password']))
self.show_step(2)
self.show_step(3)
self.show_step(4)
self.show_step(5)
self.show_step(6)
self.show_step(7)
cluster_settings = {
'net_provider': settings.NEUTRON,
'net_segment_type': settings.NEUTRON_SEGMENT['tun'],
'volumes_lvm': False,
'volumes_ceph': True,
'images_ceph': True,
'objects_ceph': True,
'ephemeral_ceph': True,
}
cluster_settings.update(self.cluster_creds)
self.deploy_cluster({
'name': self.upgrade_plugin_backup.__name__,
'settings': cluster_settings,
'plugin':
{'name': 'fuel_plugin_example_v3',
'data': {'metadata/enabled': True}},
'nodes':
{'slave-01': ['controller'],
'slave-02': ['fuel_plugin_example_v3'],
'slave-03': ['compute', 'ceph-osd'],
'slave-04': ['compute', 'ceph-osd'],
'slave-05': ['compute', 'ceph-osd']}
})
self.show_step(9)
self.show_step(10)
self.show_step(11)
self.do_backup(self.backup_path, self.local_path,
self.repos_backup_path, self.repos_local_path)
self.env.make_snapshot(self.source_snapshot_name, is_make=True)
@log_snapshot_after_test
@test(groups=['upgrade_plugin_tests', 'upgrade_plugin_restore'])
def upgrade_plugin_restore(self):
"""Reinstall Fuel and restore data with cluster with example plugin
Scenario:
1. Revert "upgrade_plugin_backup" snapshot
2. Reinstall Fuel master using iso given in ISO_PATH
3. Install fuel-octane package
4. Upload the backup back to reinstalled Fuel maser node
5. Restore master node using 'octane fuel-restore'
6. Ensure that plugin were restored
7. Verify networks for restored cluster
8. Run OSTF for restored cluster
Snapshot: upgrade_plugin_restore
"""
self.check_run(self.snapshot_name)
assert_true(os.path.exists(self.repos_local_path))
assert_true(os.path.exists(self.local_path))
intermediate_snapshot = 'plugin_before_restore'
if not self.env.d_env.has_snapshot(intermediate_snapshot):
self.show_step(1)
assert_true(
self.env.revert_snapshot(self.source_snapshot_name),
"The test can not use given environment - snapshot "
"{!r} does not exists".format(self.source_snapshot_name))
self.show_step(2)
self.reinstall_master_node()
self.env.make_snapshot(intermediate_snapshot)
else:
self.env.d_env.revert(intermediate_snapshot)
self.env.resume_environment()
self.show_step(3)
self.show_step(4)
self.show_step(5)
self.do_restore(self.backup_path, self.local_path,
self.repos_backup_path, self.repos_local_path)
cluster_id = self.fuel_web.get_last_created_cluster()
self.show_step(6)
attr = self.fuel_web.client.get_cluster_attributes(cluster_id)
assert_true('fuel_plugin_example_v3' in attr['editable'],
"Can't find plugin data in cluster attributes!")
admin_remote = self.env.d_env.get_admin_remote()
stdout = admin_remote.check_call(
"find /var/www/nailgun/plugins/ "
"-name fuel_plugin_example_v3*")['stdout']
assert_not_equal(len(stdout), 0, "Can not find plugin's directory")
plugin_dir = stdout[0].strip()
assert_true(
admin_remote.exists(os.path.join(plugin_dir, "metadata.yaml")),
"Plugin's files does not found!")
self.show_step(7)
self.fuel_web.verify_network(cluster_id)
self.show_step(8)
# Live migration test could fail
# https://bugs.launchpad.net/fuel/+bug/1471172
# https://bugs.launchpad.net/fuel/+bug/1604749
self.fuel_web.run_ostf(cluster_id, should_fail=1)
self.env.make_snapshot(self.snapshot_name, is_make=True)
self.cleanup()
@log_snapshot_after_test
@test(groups=['upgrade_plugin_tests', 'upgrade_plugin_scale'],
depends_on_groups=['upgrade_plugin_restore'])
def upgrade_plugin_scale(self):
"""Add 1 node with plugin custom role to existing cluster
Scenario:
1. Revert "upgrade_plugin_backup" snapshot.
2. Add 1 fuel_plugin_example_v3 node
3. Verify networks
4. Deploy cluster
5. Run OSTF
Duration: 60m
"""
self.show_step(1)
self.env.revert_snapshot(self.snapshot_name)
self.show_step(2)
cluster_id = self.fuel_web.get_last_created_cluster()
slave_name = "slave-0{}".format(
len(self.fuel_web.client.list_nodes()) + 1)
self.env.bootstrap_nodes([self.env.d_env.get_node(name=slave_name)])
self.fuel_web.update_nodes(cluster_id,
{slave_name: ['fuel_plugin_example_v3']})
self.show_step(3)
self.fuel_web.verify_network(cluster_id)
self.show_step(4)
self.fuel_web.deploy_cluster_wait(cluster_id)
self.show_step(5)
self.fuel_web.run_ostf(cluster_id)