Skip to content
Permalink
Browse files

Added support Libvirt package build test

The patch implements the build capability for avocado-vt for libvirt sources
from the git repository. The implemention is to get libvirt git repo and make
binaries and build rpms and install as part of the build test.

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
Signed-off-by: Satheesh Rajendran <sathnaga@linux.vnet.ibm.com>
  • Loading branch information...
sathnaga committed Jan 24, 2017
1 parent ea1b4b8 commit 74fbe0cf2e832afafdff728333a838be897466fd
Showing with 185 additions and 5 deletions.
  1. +3 −0 shared/cfg/base.cfg
  2. +33 −5 virttest/base_installer.py
  3. +9 −0 virttest/build_helper.py
  4. +5 −0 virttest/installer.py
  5. +135 −0 virttest/libvirt_installer.py
@@ -660,6 +660,9 @@ libvirtd_debug_file = ""
enable_host_sosreport = "no"
enable_remote_host_sosreport = "no"

# libvirt installer default options
rpmbuild_path = "/root/rpmbuild/"

Linux:
# param for stress tests
stress_args = '--cpu 4 --io 4 --vm 2 --vm-bytes 256M'
@@ -74,6 +74,7 @@ def __init__(self, mode, name, test=None, params=None):
self.mode = mode
self.name = name
self.params = params
self.test = test
self.param_key_prefix = '%s_%s' % (self.mode,
self.name)

@@ -84,7 +85,7 @@ def __init__(self, mode, name, test=None, params=None):
if test and params:
self.set_install_params(test, params)

def _set_test_dirs(self, test):
def _set_test_dirs(self, test, params=None):
"""
Save common test directories paths as class attributes
@@ -107,8 +108,12 @@ def _set_test_dirs(self, test):
* resultsdir = results/<job>/kvm.<other_variant_names>.build/results
"""
self.test_bindir = test.bindir
self.test_workdir = test.workdir
self.test_builddir = test.builddir
if params.get("preserve_srcdir") == "yes":
self.test_workdir = os.path.join(test.bindir, "build")
self.test_builddir = os.path.join(test.bindir, "bin")
else:
self.test_workdir = test.workdir
self.test_builddir = test.builddir
self.test_resultsdir = test.resultsdir

#
@@ -184,7 +189,7 @@ def set_install_params(self, test=None, params=None):
"""
logging.info("calling set install params")
if test is not None:
self._set_test_dirs(test)
self._set_test_dirs(test, params)

if params is not None:
self.params = params
@@ -324,6 +329,21 @@ def _install_phase_init_verify(self):
"""
pass

def _install_phase_package(self):
"""
"""
pass

def _install_phase_package_verify(self):
'''
Optional install phase for checking that software is packaged.
This should verify that the packages are actually created. Ideas for
using this include:
* checking /root/rpmbuild/RPMS'
'''
pass

def write_version_keyval(self, test):
try:
version = self.get_version()
@@ -380,7 +400,7 @@ def reload_modules_if_needed(self):
self.reload_modules()

def install(self, cleanup=True, download=True, prepare=True,
build=True, install=True, init=True):
build=True, install=True, package=False, init=True):
"""
Performs the installation of the virtualization software
@@ -404,6 +424,10 @@ def install(self, cleanup=True, download=True, prepare=True,
self._install_phase_build()
self._install_phase_build_verify()

if package:
self._install_phase_package()
self._install_phase_package_verify()

if install:
self._install_phase_install()
self._install_phase_install_verify()
@@ -482,6 +506,10 @@ def _install_phase_cleanup(self):
packages_to_remove = " ".join(self.yum_pkgs)
process.system("yum remove -y %s" % packages_to_remove)

def _install_phase_package(self):
if self.build_helper is not None:
self.build_helper.package()

def _install_phase_install(self):
if self.yum_pkgs:
os.chdir(self.test_workdir)
@@ -688,6 +688,15 @@ def make_install(self):

install = make_install

def make_rpm(self):
"""
Run "make rpm"
"""
os.chdir(self.build_dir)
process.system("make rpm")

package = make_rpm

def execute(self):
"""
Runs appropriate steps for *building* this source code tree
@@ -10,6 +10,7 @@

from . import base_installer
from . import qemu_installer
from . import libvirt_installer

__all__ = ['InstallerRegistry', 'INSTALLER_REGISTRY', 'make_installer',
'run_installers']
@@ -133,6 +134,10 @@ def get_modes(self, virt=None):
qemu_installer.RemoteSourceTarInstaller,
'qemu')

INSTALLER_REGISTRY.register('git_repo',
libvirt_installer.GitRepoInstaller,
'libvirt')


def installer_name_split(fullname, virt=None):
"""
@@ -0,0 +1,135 @@
"""
Installer code that implement KVM specific bits.
See BaseInstaller class in base_installer.py for interface details.
"""

import os
import platform
import logging

from avocado.utils import process
from virttest import base_installer


__all__ = ['GitRepoInstaller', 'LocalSourceDirInstaller',
'LocalSourceTarInstaller', 'RemoteSourceTarInstaller']


class LIBVIRTBaseInstaller(base_installer.BaseInstaller):

'''
Base class for libvirt installations
'''

def _set_install_prefix(self):
"""
Prefix for installation of application built from source
When installing virtualization software from *source*, this is where
the resulting binaries will be installed. Usually this is the value
passed to the configure script, ie: ./configure --prefix=<value>
"""
prefix = self.test_builddir
self.install_prefix = os.path.abspath(prefix)

def _install_phase_package(self):
"""
Create libvirt package
"""
self.rpmbuild_path = self.params.get("rpmbuild_path", "/root/rpmbuild/")
if os.path.isdir(self.rpmbuild_path):
process.system("rm -rf %s/*" % self.rpmbuild_path)
logging.debug("Build libvirt rpms")
process.system("make rpm", allow_output_check="combined")

def _install_phase_package_verify(self):
"""
Check if rpms are generated
"""
logging.debug("Check for libvirt rpms")
found = False
for fl in os.listdir('%s/RPMS/%s/' % (self.rpmbuild_path,
platform.machine())):
if fl.endswith('.rpm'):
found = True
if not found:
self.test.fail("Failed to build rpms")

def _install_phase_install(self):
"""
Install libvirt package
"""
logging.debug("Install libvirt rpms")
package_install_cmd = "rpm -Uvh --nodeps --replacepkgs"
package_install_cmd += " --replacefiles --oldpackage"
package_install_cmd += " %s/RPMS/%s/libvirt*" % (self.rpmbuild_path,
platform.machine())
process.system(package_install_cmd, allow_output_check="combined")

def _install_phase_init(self):
"""
Initializes the built and installed software
:return: None
"""
logging.debug("Initialize installed libvirt package")
process.system("service libvirtd restart", allow_output_check="combined")

def _install_phase_init_verify(self):
"""
Check if package install is success
:return: None
"""
logging.debug("Check libvirt package install")
process.system("service libvirtd status", allow_output_check="combined")
process.system("virsh capabilities", allow_output_check="combined")

def uninstall(self):
'''
Performs the uninstallation of KVM userspace component
:return: None
'''
self._cleanup_links()
super(LIBVIRTBaseInstaller, self).uninstall()

def install(self):
super(LIBVIRTBaseInstaller, self).install(package=True)


class GitRepoInstaller(LIBVIRTBaseInstaller,
base_installer.GitRepoInstaller):

'''
Installer that deals with source code on Git repositories
'''
pass


class LocalSourceDirInstaller(LIBVIRTBaseInstaller,
base_installer.LocalSourceDirInstaller):

"""
Installer that deals with source code on local directories
"""
pass


class LocalSourceTarInstaller(LIBVIRTBaseInstaller,
base_installer.LocalSourceTarInstaller):

"""
Installer that deals with source code on local tarballs
"""
pass


class RemoteSourceTarInstaller(LIBVIRTBaseInstaller,
base_installer.RemoteSourceTarInstaller):

"""
Installer that deals with source code on remote tarballs
"""
pass

0 comments on commit 74fbe0c

Please sign in to comment.
You can’t perform that action at this time.