Refactor test_nailgun_agent

1)As we have method for rebuilding bootstrap with packages from review
so no needed upload this package to master node and rebuild boostrap manually
and manually updating nailgun agent
2) moved update_bootstrap_cli_yaml to helpers/utils
3) removed not needed methods

Change-Id: I42008d795fc2875386144c10ec557ccc8e25df49
Closes-Bug: #1590331
This commit is contained in:
Artem Grechanichenko 2016-06-08 15:46:15 +03:00
parent 9e37b06c6a
commit d3f262c368
3 changed files with 49 additions and 103 deletions

View File

@ -19,7 +19,8 @@ from proboscis import register
from proboscis.asserts import assert_equal
from devops.helpers import helpers
from fuelweb_test.helpers import checkers
from fuelweb_test.helpers.fuel_actions import BaseActions
from fuelweb_test.helpers.gerrit.gerrit_info_provider import \
FuelLibraryModulesProvider
from fuelweb_test.helpers.ssh_manager import SSHManager
@ -279,77 +280,6 @@ def get_full_filename(wildcard_name):
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(
@ -494,3 +424,17 @@ def check_package_version_injected_in_bootstraps(
ssh.execute_on_remote(
ip=ssh.admin_ip,
cmd=cmd)
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)

View File

@ -14,14 +14,14 @@
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 import settings
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 gates_tests.helpers.utils import \
check_package_version_injected_in_bootstraps
from gates_tests.helpers.utils import update_bootstrap_cli_yaml
@test(groups=["review_nailgun_agent"])
@ -37,12 +37,13 @@ class NailgunAgentGate(TestBasic):
Scenario:
1. Revert snapshot "ready"
2. Upload nailgun-agent
3. Update bootstrap
2. Update fuel_bootstrap_cli.yaml
3. Rebuild bootstrap
4. Bootstrap 1 slave
5. Create environment via FUEL CLI
6. Assign controller role
7. Deploy
5. Verify nailgun-agent version in ubuntu bootstrap image
6. Create environment via FUEL CLI
7. Assign controller role
8. Deploy
"""
if not settings.UPDATE_FUEL:
@ -52,19 +53,34 @@ class NailgunAgentGate(TestBasic):
self.env.revert_snapshot("ready")
self.show_step(2)
upload_nailgun_agent_rpm()
update_bootstrap_cli_yaml()
self.show_step(3)
inject_nailgun_agent_ubuntu_bootstrap(self.env)
if settings.UPDATE_FUEL:
self.env.admin_actions.upload_packages(
local_packages_dir=settings.UPDATE_FUEL_PATH,
centos_repo_path=None,
ubuntu_repo_path=settings.LOCAL_MIRROR_UBUNTU,
clean_target=True)
uuid, bootstrap_location = \
self.env.fuel_bootstrap_actions.build_bootstrap_image()
self.env.fuel_bootstrap_actions. \
import_bootstrap_image(bootstrap_location)
self.env.fuel_bootstrap_actions. \
activate_bootstrap_image(uuid)
self.show_step(4)
self.env.bootstrap_nodes(
self.env.d_env.nodes().slaves[:1])
self.show_step(5)
check_package_version_injected_in_bootstraps("nailgun-agent")
release_id = self.fuel_web.get_releases_list_for_os(
release_name=OPENSTACK_RELEASE)[0]
self.show_step(5)
self.show_step(6)
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(
@ -72,7 +88,7 @@ class NailgunAgentGate(TestBasic):
cmd=cmd, jsonify=True)['stdout_json']
cluster_id = env_result['id']
self.show_step(6)
self.show_step(7)
self.fuel_web.update_nodes(
cluster_id,
{
@ -81,7 +97,7 @@ class NailgunAgentGate(TestBasic):
)
cluster_id = self.fuel_web.get_last_created_cluster()
self.show_step(7)
self.show_step(8)
self.fuel_web.deploy_cluster_wait(cluster_id)
self.env.make_snapshot("review_nailgun_agent_one_node")

View File

@ -15,16 +15,16 @@
from proboscis import test
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
from gates_tests.helpers.utils import replace_rpm_package
from gates_tests.helpers.utils import update_bootstrap_cli_yaml
@test(groups=["review_fuel_agent"])
@ -33,20 +33,6 @@ class Gate(TestIronicDeploy):
Update fuel-agent on master node, bootstrap from review,
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'],
groups=["review_fuel_agent_ironic_deploy"])
@log_snapshot_after_test
@ -84,7 +70,7 @@ class Gate(TestIronicDeploy):
replace_rpm_package('fuel-bootstrap-cli')
self.show_step(3)
self.update_bootstrap_cli_yaml()
update_bootstrap_cli_yaml()
self.show_step(4)
if settings.UPDATE_FUEL: