Moving test_setup.display_attributes to kvm_utils
PATCH 2/5 KVM test: Moving enospc test setup to test code
In reply to Lucas Meneghel RodriguesMichael Goldish has pointed out that some of the test setup code contained inside test_setup could be easily moved to the tests themselves, so we avoid some 'hardcoding' present on kvm_preprocessing.
So let's start by moving enospc test setup to the test code itself. The only caveat here is that we need to specify start_vm = no so test setup can happen before the vm is started.
--- client/tests/kvm/kvm_preprocessing.py | 8 --- client/tests/kvm/test_setup.py | 93 ----------------------------- client/tests/kvm/tests/enospc.py | 101 +++++++++++++++++++++++++++++++- client/tests/kvm/tests_base.cfg.sample | 1 + 4 files changed, 99 insertions(+), 104 deletions(-)
client/tests/kvm/kvm_preprocessing.py +0 -8
@@ -261,10 +261,6 @@ def preprocess(test, params, env): u = test_setup.UnattendedInstallConfig(test, params) u.setup() - if params.get("type") == "enospc": - e = test_setup.EnospcConfig(test, params) - e.setup() - # Execute any pre_commands if params.get("pre_command"): process_command(test, params, env, params.get("pre_command"),
@@ -365,10 +361,6 @@ def postprocess(test, params, env): h = test_setup.HugePageConfig(params) h.cleanup() - if params.get("type") == "enospc": - e = test_setup.EnospcConfig(test, params) - e.cleanup() - # Execute any post_commands if params.get("post_command"): process_command(test, params, env, params.get("post_command"),
client/tests/kvm/test_setup.py +0 -93
96 lines not on this page · raw message
client/tests/kvm/tests/enospc.py +98 -3
116 lines not on this page · raw message
client/tests/kvm/tests_base.cfg.sample +1 -0
@@ -610,6 +610,7 @@ variants: - enospc: type = enospc + start_vm = no images += " stg" drive_werror = stop drive_cache = none
Signature · 1 line
1.7.4.2
PATCH 3/5 KVM test: Moving unattended_install setup to test code
In reply to Lucas Meneghel RodriguesAlso, set start_vm = no
--- client/tests/kvm/kvm_preprocessing.py | 4 - client/tests/kvm/test_setup.py | 486 ------------------------- client/tests/kvm/tests/unattended_install.py | 495 +++++++++++++++++++++++++- client/tests/kvm/tests_base.cfg.sample | 1 + 4 files changed, 493 insertions(+), 493 deletions(-)
client/tests/kvm/kvm_preprocessing.py +0 -4
@@ -257,10 +257,6 @@ def preprocess(test, params, env): h = test_setup.HugePageConfig(params) h.setup() - if params.get("type") == "unattended_install": - u = test_setup.UnattendedInstallConfig(test, params) - u.setup() - # Execute any pre_commands if params.get("pre_command"): process_command(test, params, env, params.get("pre_command"),
client/tests/kvm/test_setup.py +0 -486
492 lines not on this page · raw message
client/tests/kvm/tests/unattended_install.py +492 -3
506 lines not on this page · raw message
client/tests/kvm/tests_base.cfg.sample +1 -0
@@ -97,6 +97,7 @@ variants: - unattended_install: type = unattended_install + start_vm = no kill_vm = yes kill_vm_gracefully = yes kill_vm_on_error = yes
Signature · 1 line
1.7.4.2
PATCH 4/5 KVM test: Cleaning unused imports on test_setup
In reply to Lucas Meneghel Rodrigues--- client/tests/kvm/test_setup.py | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-)
client/tests/kvm/test_setup.py +1 -3
@@ -1,11 +1,9 @@ """ Library to perform pre/post test setup for KVM autotest. """ -import os, shutil, tempfile, re, ConfigParser, glob, inspect -import logging, time +import os, logging from autotest_lib.client.common_lib import error from autotest_lib.client.bin import utils -import kvm_utils class HugePageConfig(object):
Signature · 1 line
1.7.4.2
PATCH 5/5 KVM test: installer: Fix bug on patch applying code
In reply to Lucas Meneghel RodriguesPatch command was missing <, let's fix it.
--- client/tests/kvm/installer.py | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
client/tests/kvm/installer.py +3 -3
@@ -680,7 +680,7 @@ class GitInstaller(SourceDirInstaller): for patch in user_patches: utils.get_file(patch, os.path.join(self.userspace_srcdir, os.path.basename(patch))) - utils.system('patch -p1 %s' % os.path.basename(patch)) + utils.system('patch -p1 < %s' % os.path.basename(patch)) if kernel_repo: kernel_srcdir = os.path.join(self.srcdir, "kvm")
@@ -692,7 +692,7 @@ class GitInstaller(SourceDirInstaller): for patch in kernel_patches: utils.get_file(patch, os.path.join(self.userspace_srcdir, os.path.basename(patch))) - utils.system('patch -p1 %s' % os.path.basename(patch)) + utils.system('patch -p1 < %s' % os.path.basename(patch)) else: self.kernel_srcdir = None
@@ -706,7 +706,7 @@ class GitInstaller(SourceDirInstaller): for patch in kmod_patches: utils.get_file(patch, os.path.join(self.userspace_srcdir, os.path.basename(patch))) - utils.system('patch -p1 %s' % os.path.basename(patch)) + utils.system('patch -p1 < %s' % os.path.basename(patch)) else: self.kmod_srcdir = None
Signature · 1 line
1.7.4.2
PATCH 1/5 Moving test_setup.display_attributes to kvm_utils
--- client/tests/kvm/kvm_utils.py | 14 ++++++++++++++ client/tests/kvm/test_setup.py | 18 +++--------------- 2 files changed, 17 insertions(+), 15 deletions(-)
client/tests/kvm/kvm_utils.py +14 -0
@@ -6,6 +6,7 @@ KVM test utility functions. import time, string, random, socket, os, signal, re, logging, commands, cPickle import fcntl, shelve, ConfigParser, rss_file_transfer, threading, sys, UserDict +import inspect from autotest_lib.client.bin import utils, os_dep from autotest_lib.client.common_lib import error, logging_config import kvm_subprocess
@@ -1199,6 +1200,19 @@ def create_report(report_dir, results_dir): os.system('%s -r %s -f %s -R' % (reporter, results_dir, html_file)) +def display_attributes(instance): + """ + Inspects a given class instance attributes and displays them, convenient + for debugging. + """ + logging.debug("Attributes set:") + for member in inspect.getmembers(instance): + name, value = member + attribute = getattr(instance, name) + if not (name.startswith("__") or callable(attribute) or not value): + logging.debug(" %s: %s", name, value) + + def get_full_pci_id(pci_id): """ Get full PCI ID of pci_id.
client/tests/kvm/test_setup.py +3 -15
@@ -5,6 +5,7 @@ import os, shutil, tempfile, re, ConfigParser, glob, inspect import logging, time from autotest_lib.client.common_lib import error from autotest_lib.client.bin import utils +import kvm_utils @error.context_aware
@@ -42,19 +43,6 @@ def clean_old_image(image): os.remove(image) -def display_attributes(instance): - """ - Inspects a given class instance attributes and displays them, convenient - for debugging. - """ - logging.debug("Attributes set:") - for member in inspect.getmembers(instance): - name, value = member - attribute = getattr(instance, name) - if not (name.startswith("__") or callable(attribute) or not value): - logging.debug(" %s: %s", name, value) - - class Disk(object): """ Abstract class for Disk objects, with the common methods implemented.
@@ -490,7 +478,7 @@ class UnattendedInstallConfig(object): Uses an appropriate strategy according to each install model. """ logging.info("Starting unattended install setup") - display_attributes(self) + kvm_utils.display_attributes(self) if self.unattended_file and (self.floppy or self.cdrom_unattended): self.setup_boot_disk()
@@ -640,7 +628,7 @@ class EnospcConfig(object): def setup(self): logging.debug("Starting enospc setup") error.context("performing enospc setup") - display_attributes(self) + kvm_utils.display_attributes(self) # Double check if there aren't any leftovers self.cleanup() try:
Signature · 1 line
1.7.4.2