def _kernel_install_koji(self, koji_tag, package="kernel", dep_pkgs=None, need_reboot=True): sm = software_manager.SoftwareManager() for utility in ['/usr/bin/koji', '/usr/bin/brew']: if not os.access(utility, os.X_OK): logging.debug("%s missing - trying to install", utility) pkg = sm.provides(utility) if pkg is not None: sm.install(pkg) else: logging.error("No %s available on software sources" % utility) # First, download packages via koji/brew c = utils_misc.KojiClient() deps_rpms = "" if dep_pkgs: for p in dep_pkgs.split(): logging.info('Fetching kernel dependencies: %s', p) k_dep = utils_misc.KojiPkgSpec(tag=koji_tag, package=p, subpackages=[p]) c.get_pkgs(k_dep, self.bindir) deps_rpms += " " deps_rpms += os.path.join(self.bindir, c.get_pkg_rpm_file_names(k_dep)[0]) k = utils_misc.KojiPkgSpec(tag=koji_tag, package=package, subpackages=[package]) c.get_pkgs(k, self.bindir) rpm_file = os.path.join(self.bindir, c.get_pkg_rpm_file_names(k)[0]) # Then install kernel rpm packages. self._kernel_install_rpm(rpm_file, deps_rpms, need_reboot)
def run_install(test, params, env): """ Installs virtualization software using the selected installers @param test: test object. @param params: Dictionary with test parameters. @param env: Test environment. """ srcdir = params.get("srcdir", test.srcdir) params["srcdir"] = srcdir # Flag if a installer minor failure ocurred minor_failure = False minor_failure_reasons = [] sm = software_manager.SoftwareManager() try: for name in params.get("installers", "").split(): installer_obj = installer.make_installer(name, params, test) if installer_obj.name == "ovirt_engine_sdk": installer_obj.install(cleanup=False, build=False, install=False) if installer_obj.minor_failure == True: minor_failure = True reason = "%s_%s: %s" % (installer_obj.name, installer_obj.mode, installer_obj.minor_failure_reason) minor_failure_reasons.append(reason) env.register_installer(installer_obj) ovirt_src = os.path.join(srcdir, installer_obj.name) topdir = os.getcwd() os.chdir(ovirt_src) utils.make("rpm") os.chdir(topdir) pkgs = glob.glob( os.path.join(ovirt_src, "rpmtop/RPMS/noarch/*")) for pkg in pkgs: sm.install(pkg) else: installer_obj.install(cleanup=False, build=False) time.sleep(5) if installer_obj.minor_failure == True: minor_failure = True reason = "%s_%s: %s" % (installer_obj.name, installer_obj.mode, installer_obj.minor_failure_reason) minor_failure_reasons.append(reason) env.register_installer(installer_obj) except Exception, e: # if the build/install fails, don't allow other tests # to get a installer. msg = "Virtualization software install failed: %s" % (e) env.register_installer(base_installer.FailedInstaller(msg)) raise
def setup(self, source_type, source_location, disk_addr, patches, **kwargs): if source_type == "tar": tarball = utils.unmap_url(self.bindir, source_location, self.tmpdir) self.repodir = os.path.join(self.tmpdir, "scsi_testsuite") utils.extract_tarball_to_dir(tarball, self.repodir) elif source_type == "git": self.repodir = git.get_repo(source_location) else: raise UnknownSourceType(source_type) sm = software_manager.SoftwareManager() for utility in ['/usr/bin/sg_raw', '/usr/bin/lsscsi']: if not os.access(utility, os.X_OK): logging.debug("%s missing - trying to install", utility) pkg = sm.provides(utility) if pkg is None: raise SCSIUtilNotAvailable(utility) else: sm.install(pkg) self.devname = "" if disk_addr[0] == "scsi": addr = (disk_addr[1]["host"], disk_addr[1]["channel"], disk_addr[1]["target"], disk_addr[1]["lun"]) self.devname = utils.system_output( "lsscsi %d %d %d %d | sed -n 's,.*/dev,/dev,p' " % addr) elif disk_addr[0] == "serial": disklist = os.listdir("/dev/disk/by-id/") for diskfile in disklist: if re.match("scsi-.*%s$" % disk_addr[1], diskfile) is not None: self.devname = os.path.join("/dev/disk/by-id", diskfile) break elif disk_addr[0] == "file": if os.access(disk_addr[1], os.F_OK): self.devname = disk_addr[1] if self.devname == "": output = utils.system_output("lsscsi") logging.debug(output) raise error.TestFail("Disk not found, cannot execute tests") try: cf = open(self.scsi_testsuite_config, "w") cf.write("export TEST_DEV=%s" % self.devname) cf.close() except IOError: logging.warning("Can't write configuration file. Using defaults") for patch in patches: utils.system("cd %s; patch -p1 < %s/%s" % (self.repodir, self.bindir, patch))
def run_once(self, test='antlr', config='./dacapo.cfg', jvm='default'): cfg = config_loader(cfg=config, tmpdir=self.tmpdir, raise_errors=True) self.test = test cachedir = os.path.join(os.path.dirname(self.srcdir), 'cache') if not os.path.isdir(cachedir): os.makedirs(cachedir) dacapo_url = cfg.get('dacapo', 'tarball_url') dacapo_md5 = cfg.get('dacapo', 'package_md5') dacapo_pkg = utils.unmap_url_cache(cachedir, dacapo_url, dacapo_md5) if not jvm == 'default': # Get the jvm package jvm_pkg_url = cfg.get(jvm, 'jvm_pkg_url') jvm_pkg_md5 = cfg.get(jvm, 'package_md5') jvm_pkg = utils.unmap_url_cache(cachedir, jvm_pkg_url, jvm_pkg_md5) # Install it swman = software_manager.SoftwareManager() swman.install(jvm_pkg) # Basic Java environment variables setup java_root = cfg.get(jvm, 'java_root') self.set_java_environment(jvm, java_root) if cfg.get('global', 'use_global') == 'yes': iterations = cfg.get('global', 'iterations') workload = cfg.get('global', 'workload') else: iterations = cfg.get(test, 'iterations') workload = cfg.get(test, 'workload') verbose = '-v ' workload = '-s %s ' % workload iterations = '-n %s ' % iterations self.scratch = os.path.join(self.resultsdir, test) scratch = '--scratch-directory %s ' % self.scratch args = verbose + workload + scratch + iterations + test self.raw_result_file = os.path.join(self.resultsdir, 'raw_output_%s' % self.iteration) raw_result = open(self.raw_result_file, 'w') logging.info('Running dacapo benchmark %s', test) try: cmd = 'java -jar %s %s' % (dacapo_pkg, args) results = utils.run(command=cmd, stdout_tee=raw_result, stderr_tee=raw_result) self.results = results.stderr raw_result.close() except error.CmdError, e: raise error.TestError('Dacapo benchmark %s has failed: %s' % (test, e))
def run_install(test, params, env): """ Installs virtualization software using the selected installers :param test: test object. :param params: Dictionary with test parameters. :param env: Test environment. """ srcdir = params.get("srcdir", test.srcdir) params["srcdir"] = srcdir # Flag if a installer minor failure occurred minor_failure = False minor_failure_reasons = [] sm = software_manager.SoftwareManager() for name in params.get("installers", "").split(): installer_obj = installer.make_installer(name, params, test) if installer_obj.name == "ovirt_engine_sdk": installer_obj.install( cleanup=False, build=False, install=False) if installer_obj.minor_failure is True: minor_failure = True reason = "%s_%s: %s" % (installer_obj.name, installer_obj.mode, installer_obj.minor_failure_reason) minor_failure_reasons.append(reason) ovirt_src = os.path.join(srcdir, installer_obj.name) topdir = os.getcwd() os.chdir(ovirt_src) utils.make("rpm") os.chdir(topdir) pkgs = glob.glob( os.path.join(ovirt_src, "rpmtop/RPMS/noarch/*")) for pkg in pkgs: sm.install(pkg) else: installer_obj.install(cleanup=False, build=False) time.sleep(5) if installer_obj.minor_failure is True: minor_failure = True reason = "%s_%s: %s" % (installer_obj.name, installer_obj.mode, installer_obj.minor_failure_reason) minor_failure_reasons.append(reason) env.register_installer(installer_obj) if minor_failure: raise error.TestWarn("Minor (worked around) failures during build " "test: %s" % ", ".join(minor_failure_reasons))
def __init__(self, job_resultsdir): self.sysinfodir = self._get_sysinfodir(job_resultsdir) # pull in the post-test logs to collect self.test_loggables = set() for cmd in _DEFAULT_COMMANDS_TO_LOG_PER_TEST: self.test_loggables.add(command(cmd)) for filename in _DEFAULT_FILES_TO_LOG_PER_TEST: self.test_loggables.add(logfile(filename)) # pull in the EXTRA post-boot logs to collect self.boot_loggables = set() for cmd in _DEFAULT_COMMANDS_TO_LOG_PER_BOOT: self.boot_loggables.add(command(cmd)) for filename in _DEFAULT_FILES_TO_LOG_PER_BOOT: self.boot_loggables.add(logfile(filename)) # pull in the pre test iteration logs to collect self.before_iteration_loggables = set() for cmd in _DEFAULT_COMMANDS_TO_LOG_BEFORE_ITERATION: self.before_iteration_loggables.add( command(cmd, logf=cmd.replace(" ", "_") + '.before')) for fname in _DEFAULT_FILES_TO_LOG_BEFORE_ITERATION: self.before_iteration_loggables.add( logfile(fname, logf=os.path.basename(fname) + '.before')) # pull in the post test iteration logs to collect self.after_iteration_loggables = set() for cmd in _DEFAULT_COMMANDS_TO_LOG_AFTER_ITERATION: self.after_iteration_loggables.add( command(cmd, logf=cmd.replace(" ", "_") + '.after')) for fname in _DEFAULT_FILES_TO_LOG_AFTER_ITERATION: self.after_iteration_loggables.add( logfile(fname, logf=os.path.basename(fname) + '.after')) # add in a couple of extra files and commands we want to grab self.test_loggables.add(command("df -mP", logf="df")) # We compress the dmesg because it can get large when kernels are # configured with a large buffer and some tests trigger OOMs or # other large "spam" that fill it up... self.test_loggables.add(command("dmesg -c", logf="dmesg", compress_log=True)) self.boot_loggables.add(logfile("/proc/cmdline", log_in_keyval=True)) # log /proc/mounts but with custom filename since we already # log the output of the "mount" command as the filename "mount" self.boot_loggables.add(logfile('/proc/mounts', logf='proc_mounts')) self.boot_loggables.add(command("uname -a", logf="uname", log_in_keyval=True)) self.sm = software_manager.SoftwareManager()
def setup(self, tarball='smatch-b0e645.tar.bz2'): self.tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir) utils.extract_tarball_to_dir(self.tarball, self.srcdir) sm = software_manager.SoftwareManager() for header in ['/usr/include/sqlite3.h', '/usr/include/llvm']: if not os.access(header, os.X_OK): logging.debug("%s missing - trying to install", header) pkg = sm.provides(header) if pkg is None: raise error.TestError( "Unable to find header %s to satisfy 'smatch' dependence" % header) else: sm.install(pkg) os.chdir(self.srcdir) utils.make()
#!/bin/python import os, subprocess import logging from autotest.client import test from autotest.client.shared import error, software_manager sm = software_manager.SoftwareManager() class pam(test.test): """ Autotest module for testing basic functionality of pam @author Manoj Iyer [email protected] """ version = 1 nfail = 0 path = '' def initialize(self, test_path=''): """ Sets the overall failure counter for the test. """ self.nfail = 0 for package in ['gcc', 'pam-devel']: if not sm.check_installed(package): logging.debug("%s missing - trying to install", package) sm.install(package) ret_val = subprocess.Popen(['make', 'all'], cwd="%s/pam" % (test_path)) ret_val.communicate()
def setup(self): backend = software_manager.SoftwareManager() logging.info('Installing pax') backend.install('pax')
class kernelinstall(test.test): version = 1 sm = software_manager.SoftwareManager() def _kernel_install_rpm(self, rpm_file, kernel_deps_rpms=None, need_reboot=True): """ Install kernel rpm package. The rpm packages should be a url or put in this test's directory (client/test/kernelinstall) """ if kernel_deps_rpms: LOG.info("Installing kernel dependencies.") if isinstance(kernel_deps_rpms, list): kernel_deps_rpms = " ".join(kernel_deps_rpms) self.sm.install(kernel_deps_rpms) dst = os.path.join("/tmp", os.path.basename(rpm_file)) knl = utils.get_file(rpm_file, dst) kernel = self.job.kernel(knl) LOG.info("Installing kernel %s", rpm_file) kernel.install(install_vmlinux=False) if need_reboot: kernel.boot() else: kernel.add_to_bootloader() def _kernel_install_koji(self, kernel_koji_spec, kernel_deps_koji_spec, need_reboot=True): # Using hardcoded package names (the names are not expected to change) # we avoid lookup errors due to SSL problems, so let's go with that. for koji_package in ['koji', 'brewkoji']: if not self.sm.check_installed(koji_package): LOG.debug("%s missing - trying to install", koji_package) self.sm.install(koji_package) sys.path.append(self.bindir) try: from staging import utils_koji except ImportError: from autotest.client.shared import utils_koji # First, download packages via koji/brew c = utils_koji.KojiClient() deps_rpms = [] k_dep = utils_koji.KojiPkgSpec(text=kernel_deps_koji_spec) LOG.info('Fetching kernel dependencies: %s', kernel_deps_koji_spec) c.get_pkgs(k_dep, self.bindir) rpm_file_name_list = c.get_pkg_rpm_file_names(k_dep) if len(rpm_file_name_list) == 0: raise error.TestError("No packages on brew/koji match spec %s" % kernel_deps_koji_spec) dep_rpm_basename = rpm_file_name_list[0] deps_rpms.append(os.path.join(self.bindir, dep_rpm_basename)) k = utils_koji.KojiPkgSpec(text=kernel_koji_spec) LOG.info('Fetching kernel: %s', kernel_koji_spec) c.get_pkgs(k, self.bindir) rpm_file_name_list = c.get_pkg_rpm_file_names(k) if len(rpm_file_name_list) == 0: raise error.TestError("No packages on brew/koji match spec %s" % kernel_koji_spec) kernel_rpm_basename = rpm_file_name_list[0] kernel_rpm_path = os.path.join(self.bindir, kernel_rpm_basename) # Then install kernel rpm packages. self._kernel_install_rpm(kernel_rpm_path, deps_rpms, need_reboot) def _kernel_install_src(self, base_tree, config=None, config_list=None, patch_list=None, need_reboot=True): if not utils.is_url(base_tree): base_tree = os.path.join(self.bindir, base_tree) if not utils.is_url(config): config = os.path.join(self.bindir, config) kernel = self.job.kernel(base_tree, self.outputdir) if patch_list: patches = [] for p in patch_list.split(): # Make sure all the patches are in local. if not utils.is_url(p): continue dst = os.path.join(self.bindir, os.path.basename(p)) local_patch = utils.get_file(p, dst) patches.append(local_patch) kernel.patch(*patches) if not os.path.isfile(config): config = None if not config and not config_list: kernel.config() else: kernel.config(config, config_list) kernel.build() kernel.install() if need_reboot: kernel.boot() else: kernel.add_to_bootloader() def _kernel_install_git(self, repo, config, repo_base=None, branch="master", commit=None, config_list=None, patch_list=None, need_reboot=True): repodir = os.path.join("/tmp", 'kernel_src') repodir = git.get_repo(uri=repo, branch=branch, destination_dir=repodir, commit=commit, base_uri=repo_base) self._kernel_install_src(repodir, config, config_list, patch_list, need_reboot) def execute(self, install_type="koji", params=None): need_reboot = params.get("need_reboot") == "yes" LOG.info("Chose to install kernel through '%s', proceeding", install_type) if install_type == "rpm": rpm_url = params.get("kernel_rpm_path") kernel_deps_rpms = params.get("kernel_deps_rpms", None) self._kernel_install_rpm(rpm_url, kernel_deps_rpms, need_reboot) elif install_type in ["koji", "brew"]: kernel_koji_spec = params.get("kernel_koji_spec") kernel_deps_koji_spec = params.get("kernel_deps_koji_spec") self._kernel_install_koji(kernel_koji_spec, kernel_deps_koji_spec, need_reboot) elif install_type == "git": repo = params.get('kernel_git_repo') repo_base = params.get('kernel_git_repo_base', None) branch = params.get('kernel_git_branch', "master") commit = params.get('kernel_git_commit', None) patch_list = params.get("kernel_patch_list", None) config = params.get('kernel_config') config_list = params.get("kernel_config_list", None) self._kernel_install_git(repo, config, repo_base, branch, commit, config_list, patch_list, need_reboot) elif install_type == "tar": src_pkg = params.get("kernel_src_pkg") config = params.get('kernel_config') patch_list = params.get("kernel_patch_list", None) self._kernel_install_src(src_pkg, config, None, patch_list, need_reboot) else: LOG.error( "Could not find '%s' method, " "keep the current kernel.", install_type)