Extend fuel-agent gate with ironic checking

-Extend fuel-agent gate with ironic checking.
-Refactor update_fuel_agent_rpm method to be more universal
-Change updating fuel-agent in bootstrap to use fuel-bootstrap methods
-Delete patch_and_assemble ubuntu bootstrap method

Change-Id: I495e8c15ad05188bb0312ca8cf4fbc1169a88bae
Closes-Bug: #1551156
This commit is contained in:
Artem Grechanichenko 2016-04-08 18:44:48 +03:00
parent 83e922f5d0
commit 261922a951
2 changed files with 197 additions and 126 deletions

View File

@ -28,102 +28,39 @@ from fuelweb_test import settings
from gates_tests.helpers import exceptions from gates_tests.helpers import exceptions
def replace_fuel_agent_rpm(): def replace_rpm_package(package):
"""Replaced fuel_agent.rpm on master node with fuel_agent.rpm """Replaced rpm package.rpm on master node with package.rpm
from review from review
""" """
ssh = SSHManager() ssh = SSHManager()
logger.info("Patching fuel-agent") logger.info("Patching {}".format(package))
if not settings.UPDATE_FUEL: if not settings.UPDATE_FUEL:
raise exceptions.FuelQAVariableNotSet('UPDATE_FUEL', 'True') raise exceptions.FuelQAVariableNotSet('UPDATE_FUEL', 'True')
try: try:
pack_path = '/var/www/nailgun/fuel-agent/' # Upload package
full_pack_path = os.path.join(pack_path, 'fuel-agent*.noarch.rpm') target_path = '/var/www/nailgun/{}/'.format(package)
ssh.upload_to_remote( ssh.upload_to_remote(
ip=ssh.admin_ip, ip=ssh.admin_ip,
source=settings.UPDATE_FUEL_PATH.rstrip('/'), source=settings.UPDATE_FUEL_PATH.rstrip('/'),
target=pack_path) target=target_path)
# Update fuel-agent on master node package_name = package
cmd = "rpm -q fuel-agent" package_ext = '*.noarch.rpm'
old_package = ssh.execute_on_remote(ssh.admin_ip, cmd)['stdout_str'] pkg_path = os.path.join(target_path,
cmd = "rpm -qp {0}".format(full_pack_path) '{}{}'.format(package_name, package_ext))
new_package = ssh.execute_on_remote(ssh.admin_ip, cmd)['stdout_str'] full_package_name = get_full_filename(wildcard_name=pkg_path)
logger.info("Updating package {0} with {1}" logger.debug('Package name is {0}'.format(full_package_name))
.format(old_package, new_package)) full_package_path = os.path.join(os.path.dirname(pkg_path),
full_package_name)
if old_package != new_package: # Update package on master node
logger.info("Updating fuel-agent package on master node") if not does_new_pkg_equal_to_installed_pkg(
logger.info('Try to install package {0}'.format( installed_package=package_name,
new_package)) new_package=full_package_path):
cmd = "rpm -Uvh --oldpackage {0}".format(full_pack_path) update_rpm(path=full_package_path)
ssh.execute_on_remote(ssh.admin_ip, cmd)
cmd = "rpm -q fuel-agent" except Exception:
installed_package = ssh.execute_on_remote( logger.error("Could not upload package")
ssh.admin_ip, cmd)['stdout_str']
assert_equal(installed_package, new_package,
"The new package {0} was not installed".
format(new_package))
except Exception as e:
logger.error("Could not upload package {e}".format(e=e))
raise
def patch_and_assemble_ubuntu_bootstrap(environment):
"""Replaced initramfs.img in /var/www/nailgun/
with newly_builded from review
environment - Environment Model object - self.env
"""
logger.info("Update fuel-agent code and assemble new ubuntu bootstrap")
ssh = SSHManager()
if not settings.UPDATE_FUEL:
raise Exception("{} variable don't exist"
.format(settings.UPDATE_FUEL))
try:
pack_path = '/var/www/nailgun/fuel-agent-review/'
ssh.upload_to_remote(
ip=ssh.admin_ip,
source=settings.FUEL_AGENT_REPO_PATH.rstrip('/'),
target=pack_path)
# renew code in bootstrap
# 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 fuel-agent code in unpacked bootstrap
agent_path = "/usr/lib/python2.7/dist-packages/fuel_agent"
bootstrap_file = bootstrap + "/root.squashfs"
cmd = ("rsync -r {2}fuel_agent/* {0}{1}/;"
"mv {3} /var/root.squashfs.old;"
).format(bootstrap_var, agent_path, pack_path, bootstrap_file)
ssh.execute_on_remote(ip=ssh.admin_ip, cmd=cmd)
# 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, '{0}'.format(bootstrap_file))
except Exception as e:
logger.error("Could not upload package {e}".format(e=e))
raise raise
@ -317,13 +254,13 @@ def does_new_pkg_equal_to_installed_pkg(installed_package,
.format(rpm=rpm_query_cmd, package=new_package) .format(rpm=rpm_query_cmd, package=new_package)
logger.info("Comparing installed package version against " logger.info("Comparing installed package version against "
"the package version to be installed in the") "the package version to be installed")
current_version = SSHManager().execute_on_remote( current_version = SSHManager().execute_on_remote(
ip=SSHManager().admin_ip, cmd=current_version_cmd) ip=SSHManager().admin_ip, cmd=current_version_cmd)['stdout_str']
new_version = SSHManager().execute_on_remote( new_version = SSHManager().execute_on_remote(
ip=SSHManager().admin_ip, cmd=urlfile_version_cmd) ip=SSHManager().admin_ip, cmd=urlfile_version_cmd)['stdout_str']
logger.info("Installed package version: {}".format(current_version)) logger.info("Installed package version: {}".format(current_version))
logger.info("Package version to be installed: {}".format(new_version)) logger.info("Package version to be installed: {}".format(new_version))
@ -493,3 +430,67 @@ def map_test_review_in_fuel_library(**kwargs):
else: else:
modules = dict() modules = dict()
puppet_modules_mapping(modules) puppet_modules_mapping(modules)
def check_package_version_injected_in_bootstraps(
package,
cluster_id=None,
ironic=None):
ssh = SSHManager()
try:
pack_path = '/var/www/nailgun/{}/'.format(package)
ssh.upload_to_remote(
ip=ssh.admin_ip,
source=settings.UPDATE_FUEL_PATH.rstrip('/'),
target=pack_path)
except Exception:
logger.exception("Could not upload package")
raise
# Step 1 - unpack active bootstrap
logger.info("unpack active bootstrap")
if ironic:
bootstrap = "/var/www/nailgun/bootstrap/ironic/{}".format(cluster_id)
else:
bootstrap = "/var/www/nailgun/bootstraps/active_bootstrap"
bootstrap_var = "/var/root.squashfs"
cmd = "unsquashfs -d {} {}/root.squashfs".format(
bootstrap_var, bootstrap)
ssh.execute_on_remote(
ip=ssh.admin_ip,
cmd=cmd)
# Step 2 - check package version
logger.info(
"check package {} version injected in ubuntu bootstrap".format(
package))
cmd = "ls {}|grep {} |grep deb |cut -f 2 -d '_'".format(
pack_path, package)
package_from_review = ssh.execute_on_remote(
ip=ssh.admin_ip,
cmd=cmd)['stdout_str']
logger.info("package from review is {}".format(package_from_review))
awk_pattern = "awk '{print $2}'"
cmd = "chroot {}/ /bin/bash -c \"dpkg -s {}\"|grep Version|{}".format(
bootstrap_var, package, awk_pattern)
installed_package = ssh.execute_on_remote(
ip=ssh.admin_ip,
cmd=cmd)['stdout_str']
logger.info("injected package is {}".format(installed_package))
assert_equal(installed_package, package_from_review,
"The new package {0} wasn't injected in bootstrap".format(
package_from_review))
# Step 3 - remove unpacked bootstrap
cmd = "rm -rf {}".format(bootstrap_var)
ssh.execute_on_remote(
ip=ssh.admin_ip,
cmd=cmd)

View File

@ -14,24 +14,41 @@
from proboscis import test from proboscis import test
from gates_tests.helpers.utils import patch_and_assemble_ubuntu_bootstrap
from gates_tests.helpers.utils import replace_fuel_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 from fuelweb_test import settings
from fuelweb_test.helpers.fuel_actions import BaseActions
from fuelweb_test.helpers import ironic_actions
from fuelweb_test.helpers.checkers import verify_bootstrap_on_node
from fuelweb_test.helpers.decorators import log_snapshot_after_test
from fuelweb_test.tests.test_ironic_base import TestIronicDeploy
from gates_tests.helpers import exceptions
from gates_tests.helpers.utils import replace_rpm_package
from gates_tests.helpers.utils import \
check_package_version_injected_in_bootstraps
@test(groups=["review_fuel_agent"]) @test(groups=["review_fuel_agent"])
class Gate(TestBasic): class Gate(TestIronicDeploy):
"""Using in fuel-agent CI-gates """Using in fuel-agent CI-gates
Update fuel-agent on master node, bootstrap from review, Update fuel-agent on master node, bootstrap from review,
build environment images and provision one node""" build environment images and provision one node"""
@staticmethod
def update_bootstrap_cli_yaml():
actions = BaseActions()
path = "/etc/fuel-bootstrap-cli/fuel_bootstrap_cli.yaml"
element = ['repos']
new_repo = {'name': 'auxiliary', 'priority': "1200",
'section': 'main restricted',
'suite': 'auxiliary', 'type': 'deb',
'uri': 'http://127.0.0.1:8080/ubuntu/auxiliary/'}
repos = actions.get_value_from_remote_yaml(path, element)
repos.append(new_repo)
actions.change_remote_yaml(path, element, repos)
@test(depends_on_groups=['prepare_release'], @test(depends_on_groups=['prepare_release'],
groups=["review_fuel_agent_one_node_provision"]) groups=["review_fuel_agent_ironic_deploy"])
@log_snapshot_after_test @log_snapshot_after_test
def gate_patch_fuel_agent(self): def gate_patch_fuel_agent(self):
""" Revert snapshot, update fuel-agent, bootstrap from review """ Revert snapshot, update fuel-agent, bootstrap from review
@ -39,51 +56,104 @@ class Gate(TestBasic):
Scenario: Scenario:
1. Revert snapshot "ready" 1. Revert snapshot "ready"
2. Update fuel-agent on master node 2. Update fuel-agent, fuel-bootstrap-cli on master node
3. Update bootstrap 3. Update fuel_bootstrap_cli.yaml
4. Bootstrap 1 slave 4. Rebuild bootstrap
5. Create environment via FUEL CLI 5. Bootstrap 5 slaves
6. Assign controller role 6. Verify Ubuntu bootstrap on slaves
7. Provisioning node 7. Add 1 node with controller and ceph roles
8. Add 1 node with controller, ironic, ceph roles
9. Add 1 node with controller, ironic, ceph roles
10. Add 1 node with ironic role
11. Add 1 node with compute
12. Deploy the cluster
13. Verify fuel-agent version in ubuntu and ironic-bootstrap
14. Upload image to glance
15. Enroll Ironic nodes
16. Boot nova instance
17. Check Nova instance status
Snapshot review_fuel_agent_ironic_deploy
""" """
if not settings.UPDATE_FUEL: if not settings.UPDATE_FUEL:
raise Exception( raise exceptions.FuelQAVariableNotSet(settings.UPDATE_FUEL, 'true')
"{} variable doesn't exist".format(settings.UPDATE_FUEL))
self.show_step(1, initialize=True) self.show_step(1, initialize=True)
self.env.revert_snapshot("ready") self.env.revert_snapshot("ready")
self.show_step(2) self.show_step(2)
replace_fuel_agent_rpm() replace_rpm_package('fuel-agent')
replace_rpm_package('fuel-bootstrap-cli')
self.show_step(3) self.show_step(3)
patch_and_assemble_ubuntu_bootstrap(self.env) self.update_bootstrap_cli_yaml()
self.show_step(4) self.show_step(4)
self.env.bootstrap_nodes( uuid, bootstrap_location = \
self.env.d_env.nodes().slaves[:1]) self.env.fuel_bootstrap_actions.build_bootstrap_image()
self.env.fuel_bootstrap_actions. \
release_id = self.fuel_web.get_releases_list_for_os( import_bootstrap_image(bootstrap_location)
release_name=OPENSTACK_RELEASE)[0] self.env.fuel_bootstrap_actions. \
activate_bootstrap_image(uuid)
self.show_step(5) self.show_step(5)
cmd = ('fuel env create --name={0} --release={1} --nst=tun ' self.env.bootstrap_nodes(
'--json'.format(self.__class__.__name__, release_id)) self.env.d_env.nodes().slaves[:5])
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.show_step(6)
self.fuel_web.update_nodes( for node in self.env.d_env.nodes().slaves[:5]:
cluster_id, _ip = self.fuel_web.get_nailgun_node_by_devops_node(node)['ip']
{ verify_bootstrap_on_node(_ip, os_type="ubuntu", uuid=uuid)
'slave-01': ['controller'],
} data = {
) 'volumes_ceph': True,
'images_ceph': True,
'objects_ceph': True,
'volumes_lvm': False,
'tenant': 'ceph1',
'user': 'ceph1',
'password': 'ceph1',
'net_provider': settings.NEUTRON,
'net_segment_type': settings.NEUTRON_SEGMENT['vlan'],
'ironic': True}
nodes = {
'slave-01': ['controller', 'ceph-osd'],
'slave-02': ['controller', 'ironic', 'ceph-osd'],
'slave-03': ['controller', 'ironic', 'ceph-osd'],
'slave-04': ['ironic'],
'slave-05': ['compute']}
cluster_id = self.fuel_web.get_last_created_cluster()
self.show_step(7) self.show_step(7)
self.fuel_web.provisioning_cluster_wait(cluster_id) self.show_step(8)
self.show_step(9)
self.show_step(10)
self.show_step(11)
self.show_step(12)
self.env.make_snapshot("review_fuel_agent_one_node_provision") cluster_id = self._deploy_ironic_cluster(settings=data, nodes=nodes)
ironic_conn = ironic_actions.IronicActions(
self.fuel_web.get_public_vip(cluster_id),
user='ceph1',
passwd='ceph1',
tenant='ceph1')
self.show_step(13)
check_package_version_injected_in_bootstraps("fuel-agent")
check_package_version_injected_in_bootstraps("fuel-agent",
cluster_id=cluster_id,
ironic=True)
self.show_step(14)
self.show_step(15)
self._create_os_resources(ironic_conn)
self.show_step(16)
self._boot_nova_instances(ironic_conn)
self.show_step(17)
ironic_conn.wait_for_vms(ironic_conn)
ironic_conn.verify_vms_connection(ironic_conn)
self.env.make_snapshot("review_fuel_agent_ironic_deploy")