Add gate test for Astute
Add gate test for Astute that should be executed for each review in openstack/fuel-astute repo. Next variables should be exported: UPDATE_FUEL=True UPDATE_FUEL_PATH=/path/to/rpm/to/be/downloaded Test depends on ready_with_3_slaves, so it is better to run it with -k/-K options. Scenario: 1. Revert environment ready_with_3_slaves 2. Upload package 3. Update Astute rpm package from review 4. Update network configuration 5. Create env 6. Update nodes with roles: controller, compute, cinder 7. Deploy cluster 8. Start ostf tests to check that changes do not reproduce regression Change-Id: I4de4513e0f9186fda8750a74b44b5cff0edfbc21
This commit is contained in:
parent
d10b382915
commit
f5475aa4cb
|
@ -320,6 +320,11 @@ Test Fuel cli
|
|||
.. automodule:: gates_tests.test_review_in_fuel_client
|
||||
:members:
|
||||
|
||||
Test Fuel astute
|
||||
----------------
|
||||
.. automodule:: gates_tests.test_review_in_astute
|
||||
:members:
|
||||
|
||||
Fuel mirror verification
|
||||
========================
|
||||
|
||||
|
|
|
@ -145,6 +145,7 @@ def import_tests():
|
|||
from tests.tests_strength import test_failover_group_1 # noqa
|
||||
from tests.tests_strength import test_failover_mongo # noqa
|
||||
from tests.tests_strength import test_failover_group_2 # noqa
|
||||
from gates_tests.tests import test_review_in_astute # noqa
|
||||
|
||||
|
||||
def run_tests():
|
||||
|
|
|
@ -382,3 +382,75 @@ def replace_fuel_nailgun_rpm(environment):
|
|||
except Exception as e:
|
||||
logger.error("Could not upload package {e}".format(e=e))
|
||||
raise
|
||||
|
||||
|
||||
def update_rpm_in_container(env, container, path,
|
||||
rpm_cmd='/bin/rpm -Uvh --force'):
|
||||
cmd = '{rpm_cmd} {rpm_path}'\
|
||||
.format(rpm_cmd=rpm_cmd, rpm_path=path)
|
||||
logger.info("Updating rpm '{0}' in the '{1}' container"
|
||||
.format(path, container))
|
||||
try:
|
||||
env.base_actions.execute_in_container(
|
||||
cmd, container=container, exit_code=0)
|
||||
logger.info("Rpm '{0}' has been updated successfully "
|
||||
"in the '{1}' container".format(path, container))
|
||||
except Exception as ex:
|
||||
logger.error("Could not update rpm '{0}' in the '{1}' container: {2}"
|
||||
.format(path, container, ex))
|
||||
raise
|
||||
|
||||
|
||||
def restart_service_in_container(env, container, service_name, timeout=30):
|
||||
restart_cmd = 'service {} restart'.format(service_name)
|
||||
get_status_cmd = 'service {} status'.format(service_name)
|
||||
logger.info("Restarting service '{0}' in the '{1}' container"
|
||||
.format(service_name, container))
|
||||
try:
|
||||
env.base_actions.execute_in_container(restart_cmd, container=container)
|
||||
helpers.wait(
|
||||
lambda: 'running' in
|
||||
env.base_actions.execute_in_container(
|
||||
get_status_cmd, container=container, exit_code=0),
|
||||
timeout=timeout)
|
||||
logger.info("Service '{0}' has been restarted successfully "
|
||||
"in the '{1}' container".format(service_name, container))
|
||||
except Exception as ex:
|
||||
logger.error("Could not restart '{0}' service "
|
||||
"in the '{1}' container: {2}"
|
||||
.format(service_name, container, ex))
|
||||
raise
|
||||
|
||||
|
||||
def does_new_pkg_equal_to_installed_pkg(env, container, installed_package,
|
||||
new_package):
|
||||
rpm_query_cmd = '/bin/rpm -q'
|
||||
current_version_cmd = '{rpm} {package}'\
|
||||
.format(rpm=rpm_query_cmd, package=installed_package)
|
||||
urlfile_version_cmd = '{rpm} --package {package}'\
|
||||
.format(rpm=rpm_query_cmd, package=new_package)
|
||||
|
||||
logger.info("Comparing installed package version against "
|
||||
"the package version to be installed in the '{}' container"
|
||||
.format(container))
|
||||
|
||||
current_version = env.base_actions.execute_in_container(
|
||||
current_version_cmd, container=container, exit_code=0)
|
||||
new_version = env.base_actions.execute_in_container(
|
||||
urlfile_version_cmd, container=container, exit_code=0)
|
||||
|
||||
logger.info("Installed package version: {}".format(current_version))
|
||||
logger.info("Package version to be installed: {}".format(new_version))
|
||||
|
||||
return current_version == new_version
|
||||
|
||||
|
||||
def get_full_filename(env, container, wildcard_name):
|
||||
cmd = 'ls {}'.format(wildcard_name)
|
||||
|
||||
logger.info("Getting full file name for: {}".format(wildcard_name))
|
||||
|
||||
full_pkg_name = env.base_actions.execute_in_container(
|
||||
cmd, container=container, exit_code=0)
|
||||
|
||||
return full_pkg_name
|
||||
|
|
|
@ -0,0 +1,117 @@
|
|||
# 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 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.settings import OPENSTACK_RELEASE
|
||||
from fuelweb_test.tests.base_test_case import SetupEnvironment
|
||||
from fuelweb_test.tests.base_test_case import TestBasic
|
||||
from gates_tests.helpers import utils
|
||||
|
||||
|
||||
@test(groups=['review_astute'])
|
||||
class GateAstute(TestBasic):
|
||||
"""Using in Astute CI-gates
|
||||
Update Astute, create cluster, provision and deploy via CLI"""
|
||||
|
||||
@test(depends_on=[SetupEnvironment.prepare_slaves_3],
|
||||
groups=['review_astute_patched'])
|
||||
@log_snapshot_after_test
|
||||
def gate_patch_astute(self):
|
||||
""" Revert 'ready_with_3_slaves' snapshot,
|
||||
download package with astute changes, install package,
|
||||
start deployment, check for regression
|
||||
|
||||
Scenario:
|
||||
1. Revert environment ready_with_3_slaves
|
||||
2. Upload package
|
||||
3. Update Astute rpm package from review
|
||||
4. Update network configuration
|
||||
5. Create env
|
||||
6. Update nodes with roles: controller, compute, cinder
|
||||
7. Deploy cluster
|
||||
8. Start ostf tests to check that changes do not reproduce regression
|
||||
"""
|
||||
if not settings.UPDATE_FUEL:
|
||||
raise Exception('UPDATE_FUEL variable is not set. '
|
||||
'UPDATE_FUEL value is {}'
|
||||
.format(settings.UPDATE_FUEL))
|
||||
|
||||
astute_container = 'astute'
|
||||
astute_service = 'astute'
|
||||
package_name = 'rubygem-astute'
|
||||
package_ext = '*noarch.rpm'
|
||||
target_path = '/var/www/nailgun/'
|
||||
|
||||
self.show_step(1)
|
||||
self.env.revert_snapshot('ready_with_3_slaves')
|
||||
|
||||
self.show_step(2)
|
||||
with self.env.d_env.get_admin_remote() as remote:
|
||||
remote.upload(settings.UPDATE_FUEL_PATH.rstrip('/'), target_path)
|
||||
|
||||
self.show_step(3)
|
||||
pkg_path = os.path.join(target_path,
|
||||
'{}{}'.format(package_name, package_ext))
|
||||
full_package_name = utils.get_full_filename(
|
||||
self.env, container=astute_container, wildcard_name=pkg_path)
|
||||
full_package_path = os.path.join(os.path.dirname(pkg_path),
|
||||
full_package_name)
|
||||
if not utils.does_new_pkg_equal_to_installed_pkg(
|
||||
self.env,
|
||||
container=astute_container,
|
||||
installed_package=package_name,
|
||||
new_package=full_package_path):
|
||||
utils.update_rpm_in_container(self.env,
|
||||
container=astute_container,
|
||||
path=full_package_path)
|
||||
utils.restart_service_in_container(self.env,
|
||||
container=astute_container,
|
||||
service_name=astute_service,
|
||||
timeout=10)
|
||||
|
||||
self.show_step(4)
|
||||
self.fuel_web.change_default_network_settings()
|
||||
|
||||
self.show_step(5)
|
||||
release_id = self.fuel_web.get_releases_list_for_os(
|
||||
release_name=OPENSTACK_RELEASE)[0]
|
||||
with self.env.d_env.get_admin_remote() as remote:
|
||||
cmd = ('fuel env create --name={0} --release={1} '
|
||||
'--nst=tun --json'.format(self.__class__.__name__,
|
||||
release_id))
|
||||
env_result = run_on_remote(remote, cmd, jsonify=True)
|
||||
|
||||
self.show_step(6)
|
||||
cluster_id = env_result['id']
|
||||
self.fuel_web.update_nodes(
|
||||
cluster_id,
|
||||
{
|
||||
'slave-01': ['controller'],
|
||||
'slave-02': ['compute'],
|
||||
'slave-03': ['cinder'],
|
||||
}
|
||||
)
|
||||
|
||||
self.show_step(7)
|
||||
cluster_id = self.fuel_web.get_last_created_cluster()
|
||||
self.fuel_web.deploy_cluster_wait(cluster_id)
|
||||
|
||||
self.show_step(8)
|
||||
self.fuel_web.run_ostf(cluster_id=cluster_id, test_sets=['smoke'])
|
Loading…
Reference in New Issue