Add gate test for nailgun agent
Add gate test for nailgun agent: * should be run by group review_nailgun_agent * CUSTON_ENV should be false * UPDATE_FUEL should be TRUE * UPDATE_FUEL_PATH path to nailgun-agent rpm Change-Id: I8e2057ef61a53e704926bcb79a26b38cdcc5ad7a Closes-Bug: #1551346
This commit is contained in:
parent
20f6cb9463
commit
d2c6f59c35
|
@ -335,6 +335,16 @@ Test Fuel astute
|
|||
.. automodule:: gates_tests.test_review_in_astute
|
||||
:members:
|
||||
|
||||
Test Fuel nailgun agent
|
||||
-----------------------
|
||||
.. automodule:: gates_tests.test_nailgun_agent
|
||||
:members:
|
||||
|
||||
Test Fuel web
|
||||
-------------
|
||||
.. automodule:: gates_tests.test_review_fuel_web
|
||||
:members:
|
||||
|
||||
Fuel mirror verification
|
||||
========================
|
||||
|
||||
|
|
|
@ -164,7 +164,7 @@ def patch_and_assemble_ubuntu_bootstrap(environment):
|
|||
no_progress_bar,
|
||||
no_append)
|
||||
ssh.execute_on_remote(ip=ssh.admin_ip, cmd=image_rebuild)
|
||||
checkers.check_file_exists(ssh.admin_ip, str(bootstrap_file))
|
||||
checkers.check_file_exists(ssh.admin_ip, '{0}'.format(bootstrap_file))
|
||||
except Exception as e:
|
||||
logger.error("Could not upload package {e}".format(e=e))
|
||||
raise
|
||||
|
@ -183,7 +183,7 @@ def replace_centos_bootstrap(environment):
|
|||
rebuilded_bootstrap = '/var/initramfs.img.updated'
|
||||
checkers.check_file_exists(
|
||||
ssh.admin_ip,
|
||||
str(rebuilded_bootstrap))
|
||||
'{0}'.format(rebuilded_bootstrap))
|
||||
logger.info("Assigning new bootstrap from {}".format(rebuilded_bootstrap))
|
||||
bootstrap = "/var/www/nailgun/bootstrap"
|
||||
cmd = ("mv {0}/initramfs.img /var/initramfs.img;"
|
||||
|
@ -406,3 +406,83 @@ def get_full_filename(wildcard_name):
|
|||
ip=SSHManager().admin_ip,
|
||||
cmd=cmd)['stdout_str']
|
||||
return full_pkg_name
|
||||
|
||||
|
||||
def inject_nailgun_agent_ubuntu_bootstrap(environment):
|
||||
"""Inject nailgun agent packet from review into ubuntu bootsrap
|
||||
environment - Environment Model object - self.env
|
||||
"""
|
||||
logger.info("Update nailgun-agent code and assemble new ubuntu bootstrap")
|
||||
ssh = SSHManager()
|
||||
if not settings.UPDATE_FUEL:
|
||||
raise Exception("{} variable don't exist"
|
||||
.format(settings.UPDATE_FUEL))
|
||||
pack_path = '/var/www/nailgun/nailgun-agent-review/'
|
||||
# Step 1 - install squashfs-tools
|
||||
cmd = "yum install -y squashfs-tools"
|
||||
ssh.execute_on_remote(ip=ssh.admin_ip, cmd=cmd)
|
||||
|
||||
# Step 2 - unpack bootstrap
|
||||
bootstrap = "/var/www/nailgun/bootstraps/active_bootstrap"
|
||||
bootstrap_var = "/var/root.squashfs"
|
||||
|
||||
cmd = "unsquashfs -d /var/root.squashfs {}/root.squashfs".format(
|
||||
bootstrap)
|
||||
ssh.execute_on_remote(ip=ssh.admin_ip, cmd=cmd)
|
||||
|
||||
# Step 3 - replace nailgun-agent code in unpacked bootstrap
|
||||
agent_path = "/usr/bin/nailgun-agent"
|
||||
bootstrap_file = bootstrap + "/root.squashfs"
|
||||
logger.info('bootsrap file {0}{1}'.format(bootstrap_var, agent_path))
|
||||
old_sum = get_sha_sum('{0}{1}'.format(bootstrap_var, agent_path))
|
||||
logger.info('Old sum is {0}'.format(old_sum))
|
||||
cmd_etc_sync = ('rsync -r {1}etc/* {0}/etc/'.format(
|
||||
bootstrap_var, pack_path))
|
||||
ssh.execute_on_remote(ssh.admin_ip, cmd=cmd_etc_sync)
|
||||
cmd = ("rsync -r {1}usr/* {0}/usr/;" "mv {2} "
|
||||
"/var/root.squashfs.old;"
|
||||
"").format(bootstrap_var, pack_path, bootstrap_file)
|
||||
ssh.execute_on_remote(ip=ssh.admin_ip, cmd=cmd)
|
||||
new_sum = get_sha_sum('{0}{1}'.format(bootstrap_var, agent_path))
|
||||
logger.info('new sum is {0}'.format(new_sum))
|
||||
assert_equal(new_sum != old_sum, True)
|
||||
|
||||
# Step 4 - assemble new bootstrap
|
||||
compression = "-comp xz"
|
||||
no_progress_bar = "-no-progress"
|
||||
no_append = "-noappend"
|
||||
image_rebuild = "mksquashfs {0} {1} {2} {3} {4}".format(
|
||||
bootstrap_var,
|
||||
bootstrap_file,
|
||||
compression,
|
||||
no_progress_bar,
|
||||
no_append)
|
||||
ssh.execute_on_remote(ip=ssh.admin_ip, cmd=image_rebuild)
|
||||
checkers.check_file_exists(ssh.admin_ip, bootstrap_file)
|
||||
|
||||
|
||||
def upload_nailgun_agent_rpm():
|
||||
"""Upload nailgun_agent.rpm on master node
|
||||
"""
|
||||
ssh = SSHManager()
|
||||
logger.info("Upload nailgun-agent")
|
||||
if not settings.UPDATE_FUEL:
|
||||
raise exceptions.FuelQAVariableNotSet('UPDATE_FUEL', 'True')
|
||||
pack_path = '/var/www/nailgun/nailgun-agent-review/'
|
||||
ssh.upload_to_remote(
|
||||
ip=ssh.admin_ip,
|
||||
source=settings.UPDATE_FUEL_PATH.rstrip('/'),
|
||||
target=pack_path)
|
||||
# Extract rpm context
|
||||
cmd = 'cd {0}; rpm2cpio {1} | cpio -idmv'.format(
|
||||
pack_path, 'nailgun-agent-*.noarch.rpm ')
|
||||
ssh.execute_on_remote(ssh.admin_ip, cmd)
|
||||
|
||||
|
||||
def get_sha_sum(file_path):
|
||||
logger.debug('Get md5 fo file {0}'.format(file_path))
|
||||
md5_sum = SSHManager().execute_on_remote(
|
||||
SSHManager().admin_ip, cmd='md5sum {0}'.format(
|
||||
file_path))['stdout_str'].strip()
|
||||
logger.info('MD5 is {0}'.format(md5_sum))
|
||||
return md5_sum
|
||||
|
|
|
@ -0,0 +1,87 @@
|
|||
# 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 proboscis import test
|
||||
|
||||
from gates_tests.helpers.utils import inject_nailgun_agent_ubuntu_bootstrap
|
||||
from gates_tests.helpers.utils import upload_nailgun_agent_rpm
|
||||
|
||||
from fuelweb_test.helpers.decorators import log_snapshot_after_test
|
||||
from fuelweb_test.settings import OPENSTACK_RELEASE
|
||||
from fuelweb_test.tests.base_test_case import TestBasic
|
||||
|
||||
from fuelweb_test import settings
|
||||
|
||||
|
||||
@test(groups=["review_nailgun_agent"])
|
||||
class NailgunAgentGate(TestBasic):
|
||||
"""Using in CI-gates
|
||||
Update nailgun-agent on master node, deploy one node environment"""
|
||||
|
||||
@test(depends_on_groups=['prepare_release'],
|
||||
groups=["review_nailgun_agent_one_node"])
|
||||
@log_snapshot_after_test
|
||||
def gate_patch_nailgun_agent(self):
|
||||
""" Revert snapshot, update nailgun-agent, deploy one node
|
||||
|
||||
Scenario:
|
||||
1. Revert snapshot "ready"
|
||||
2. Upload nailgun-agent
|
||||
3. Update bootstrap
|
||||
4. Bootstrap 1 slave
|
||||
5. Create environment via FUEL CLI
|
||||
6. Assign controller role
|
||||
7. Deploy
|
||||
|
||||
"""
|
||||
if not settings.UPDATE_FUEL:
|
||||
raise Exception("{} variable don't exist"
|
||||
.format(settings.UPDATE_FUEL))
|
||||
self.show_step(1, initialize=True)
|
||||
self.env.revert_snapshot("ready")
|
||||
|
||||
self.show_step(2)
|
||||
upload_nailgun_agent_rpm()
|
||||
|
||||
self.show_step(3)
|
||||
inject_nailgun_agent_ubuntu_bootstrap(self.env)
|
||||
|
||||
self.show_step(4)
|
||||
self.env.bootstrap_nodes(
|
||||
self.env.d_env.nodes().slaves[:1])
|
||||
|
||||
release_id = self.fuel_web.get_releases_list_for_os(
|
||||
release_name=OPENSTACK_RELEASE)[0]
|
||||
|
||||
self.show_step(5)
|
||||
cmd = ('fuel env create --name={0} --release={1} --nst=tun '
|
||||
'--json'.format(self.__class__.__name__, release_id))
|
||||
env_result = self.ssh_manager.execute_on_remote(
|
||||
ip=self.ssh_manager.admin_ip,
|
||||
cmd=cmd, jsonify=True)['stdout_json']
|
||||
cluster_id = env_result['id']
|
||||
|
||||
self.show_step(6)
|
||||
self.fuel_web.update_nodes(
|
||||
cluster_id,
|
||||
{
|
||||
'slave-01': ['controller'],
|
||||
}
|
||||
)
|
||||
|
||||
cluster_id = self.fuel_web.get_last_created_cluster()
|
||||
self.show_step(7)
|
||||
self.fuel_web.deploy_cluster_wait(cluster_id)
|
||||
|
||||
self.env.make_snapshot("review_nailgun_agent_one_node")
|
Loading…
Reference in New Issue