Work to get KVM autotest upstream
RFC PATCH 1/1 Work to get KVM autotest upstream
These are the patches I have so far related to the work to get kvm autotest in shape for upstream merge. Please note that once the patches are applied, the kvm_runtest_2 directory should be placed on a fresh svn trunk checkout to work, so there's a little bit of tweaking to get them working.
That said, this haven't had enough testing. I am posting them here only if someone wants to take a look at them.
Cheers,
Signature · 3 lines
Lucas Meneghel Rodrigues Software Engineer (QE) Red Hat - Emerging Technologies
Quoted 1 line
From
5be42c2d663fce8f96616c55afb2161a34a2fe44Mon Sep 17 00:00:00 2001
From: [email protected] <[email protected]>
Date: Mon, 4 May 2009 21:00:56 -0300
Subject: [PATCH 1/7] Moving from kvm_log to the upstream logging system.
--- client/tests/kvm_runtest_2/kvm_guest_wizard.py | 14 ++-- client/tests/kvm_runtest_2/kvm_install.py | 56 +++++++------- client/tests/kvm_runtest_2/kvm_preprocessing.py | 52 ++++++------ client/tests/kvm_runtest_2/kvm_runtest_2.py | 18 ++-- client/tests/kvm_runtest_2/kvm_tests.py | 96 +++++++++++----------- client/tests/kvm_runtest_2/kvm_vm.py | 78 +++++++++--------- client/tests/kvm_runtest_2/stepmaker.py | 6 +- 7 files changed, 160 insertions(+), 160 deletions(-)
client/tests/kvm_runtest_2/kvm_guest_wizard.py +7 -7
@@ -9,7 +9,7 @@ import shutil from autotest_lib.client.common_lib import utils, error import kvm_utils -import kvm_log +import logging import ppm_utils
@@ -23,7 +23,7 @@ def handle_var(vm, params, varname): def barrier_2(vm, words, fail_if_stuck_for, stuck_detection_history, output_dir, data_scrdump_filename, current_step_num): if len(words) < 7: - kvm_log.error("Bad barrier_2 command line") + logging.error("Bad barrier_2 command line") return False cmd, dx, dy, x1, y1, md5sum, timeout = words[:7]
@@ -69,7 +69,7 @@ def barrier_2(vm, words, fail_if_stuck_for, stuck_detection_history, output_dir, # Request screendump (status, output) = vm.send_monitor_cmd("screendump %s" % scrdump_filename) if status: - kvm_log.error("Could not fetch screendump") + logging.error("Could not fetch screendump") continue # Make sure image is valid
@@ -108,7 +108,7 @@ def barrier_2(vm, words, fail_if_stuck_for, stuck_detection_history, output_dir, # What should we do with this failure? if words[-1] == "optional": - kvm_log.info(message) + logging.info(message) return False else: # Collect information and put it in output_dir
@@ -126,7 +126,7 @@ def barrier_2(vm, words, fail_if_stuck_for, stuck_detection_history, output_dir, ppm_utils.image_write_to_ppm_file(comparison_filename, w, h, data) # Print error messages and fail the test long_message = message + "\n(see analysis at %s)" % output_dir - kvm_log.error(long_message) + logging.error(long_message) raise error.TestFail, message
@@ -171,7 +171,7 @@ def run_steps(test, params, env): line = line.strip() if not line: continue - kvm_log.info(line) + logging.info(line) if line.startswith("#"): continue
@@ -191,7 +191,7 @@ def run_steps(test, params, env): vm.send_key(words[1]) elif words[0] == "var": if not handle_var(vm, params, words[1]): - kvm_log.error("Variable not defined: %s" % words[1]) + logging.error("Variable not defined: %s" % words[1]) elif words[0] == "barrier_2": if current_screendump: scrdump_filename = os.path.join(ppm_utils.get_data_dir(steps_filename), current_screendump)
client/tests/kvm_runtest_2/kvm_install.py +28 -28
190 lines not on this page · raw message
client/tests/kvm_runtest_2/kvm_preprocessing.py +26 -26
154 lines not on this page · raw message
client/tests/kvm_runtest_2/kvm_runtest_2.py +9 -9
@@ -42,7 +42,7 @@ class kvm_runtest_2(test.test): sys.path.append(self.bindir) def run_once(self, params): - import kvm_log + import logging import kvm_utils import kvm_preprocessing
@@ -53,20 +53,20 @@ class kvm_runtest_2(test.test): resource.setrlimit(resource.RLIMIT_CORE, (-1, -1)) # Set the logging prefix - kvm_log.set_prefix(params.get("shortname")) + #kvm_log.set_prefix(params.get("shortname")) # Report the parameters we've received and write them as keyvals - kvm_log.debug("Test parameters:") + logging.debug("Test parameters:") keys = params.keys() keys.sort() for key in keys: - kvm_log.debug(" %s = %s" % (key, params[key])) + logging.debug(" %s = %s" % (key, params[key])) self.write_test_keyval({key: params[key]}) # Open the environment file env_filename = os.path.join(self.bindir, "env") env = shelve.open(env_filename, writeback=True) - kvm_log.debug("Contents of environment: %s" % str(env)) + logging.debug("Contents of environment: %s" % str(env)) try: try:
@@ -76,7 +76,7 @@ class kvm_runtest_2(test.test): # If type could not be found in self.test_routines... if not routine_obj: message = "Unsupported test type: %s" % type - kvm_log.error(message) + logging.error(message) raise error.TestError, message # If we don't have the test routine yet... if not routine_obj.routine:
@@ -93,8 +93,8 @@ class kvm_runtest_2(test.test): env.sync() except Exception, e: - kvm_log.error("Test failed: %s" % e) - kvm_log.debug("Postprocessing on error...") + logging.error("Test failed: %s" % e) + logging.debug("Postprocessing on error...") kvm_preprocessing.postprocess_on_error(self, params, env) env.sync() raise
@@ -102,7 +102,7 @@ class kvm_runtest_2(test.test): finally: # Postprocess kvm_preprocessing.postprocess(self, params, env) - kvm_log.debug("Contents of environment: %s" % str(env)) + logging.debug("Contents of environment: %s" % str(env)) env.sync() env.close()
client/tests/kvm_runtest_2/kvm_tests.py +48 -48
299 lines not on this page · raw message
client/tests/kvm_runtest_2/kvm_vm.py +39 -39
214 lines not on this page · raw message
client/tests/kvm_runtest_2/stepmaker.py +3 -3
@@ -15,7 +15,7 @@ import commands from autotest_lib.client.common_lib import error import kvm_utils -import kvm_log +import logging import ppm_utils import stepeditor
@@ -136,7 +136,7 @@ class StepMaker(stepeditor.StepMakerWindow): (status, output) = self.vm.send_monitor_cmd("screendump " + self.screendump_filename) if status: # Failure - kvm_log.info("Could not fetch screendump") + logging.info("Could not fetch screendump") else: self.set_image_from_file(self.screendump_filename)
@@ -281,7 +281,7 @@ class StepMaker(stepeditor.StepMakerWindow): (status, output) = self.vm.send_monitor_cmd("screendump " + self.screendump_filename) if status: # Failure - kvm_log.info("Could not fetch screendump") + logging.info("Could not fetch screendump") else: self.set_image_from_file(self.screendump_filename)
Signature · 1 line
1.6.2.2
Quoted 1 line
From
cf99024f90ae524ae2f194c9985ae1c2b8d2288aMon Sep 17 00:00:00 2001
From: [email protected] <[email protected]>
Date: Mon, 4 May 2009 21:18:22 -0300
Subject: [PATCH 2/7] Make imports follow autotest coding style
--- client/tests/kvm_runtest_2/kvm_guest_wizard.py | 12 ++---------- client/tests/kvm_runtest_2/kvm_install.py | 11 +---------- client/tests/kvm_runtest_2/kvm_runtest_2.py | 8 +------- client/tests/kvm_runtest_2/kvm_tests.py | 10 ++-------- client/tests/kvm_runtest_2/kvm_utils.py | 15 ++------------- client/tests/kvm_runtest_2/kvm_vm.py | 6 +----- client/tests/kvm_runtest_2/make_html_report.py | 8 +------- client/tests/kvm_runtest_2/ppm_utils.py | 7 +------ client/tests/kvm_runtest_2/stepeditor.py | 10 ++-------- 9 files changed, 13 insertions(+), 74 deletions(-)
client/tests/kvm_runtest_2/kvm_guest_wizard.py +2 -10
@@ -1,16 +1,8 @@ #!/usr/bin/python -import os -import time -import md5 -import re -import shutil - +import os, time, md5, re, shutil, logging from autotest_lib.client.common_lib import utils, error - -import kvm_utils -import logging -import ppm_utils +import kvm_utils, ppm_utils def handle_var(vm, params, varname):
client/tests/kvm_runtest_2/kvm_install.py +1 -10
@@ -1,18 +1,9 @@ -import time -import os -import sys -import urllib -import re -import signal +import time, os, sys, urllib, re, signal, logging from datetime import * - from autotest_lib.client.bin import utils, test from autotest_lib.client.common_lib import error - -import logging import kvm_utils - def run_kvm_install(test, params, env): install_mode = params.get("mode") logging.info("Selected installation mode: %s" % install_mode)
client/tests/kvm_runtest_2/kvm_runtest_2.py +1 -7
@@ -1,12 +1,6 @@ #!/usr/bin/python -import sys -import os -import time -import shelve -import random -import resource - +import sys, os, time, shelve, random, resource, logging from autotest_lib.client.bin import test from autotest_lib.client.common_lib import error
client/tests/kvm_runtest_2/kvm_tests.py +2 -8
@@ -1,12 +1,6 @@ -import time -import os - +import time, os, logging from autotest_lib.client.common_lib import utils, error - -import logging -import kvm_utils -import ppm_utils -import scan_results +import kvm_utils, ppm_utils, scan_results def run_boot(test, params, env):
client/tests/kvm_runtest_2/kvm_utils.py +2 -13
@@ -1,18 +1,7 @@ #!/usr/bin/python -import md5 -import thread -import subprocess -import time -import string -import random -import socket -import os -import signal -import pty -import select -import re - +import md5, thread, subprocess, time, string, random, socket, os, signal, pty +import select, re import kvm_log
client/tests/kvm_runtest_2/kvm_vm.py +1 -5
@@ -1,11 +1,7 @@ #!/usr/bin/python -import time -import socket -import os - +import time, socket, os, logging import kvm_utils -import logging def get_image_filename(params, image_dir):
client/tests/kvm_runtest_2/make_html_report.py +1 -7
@@ -4,13 +4,7 @@ # Copyright (c)2005-2007 Matt Kruse (javascripttoolbox.com) # Copyright 2008-2009 Red Hat - -import os, sys -import re -import getopt -import time -import datetime -import commands +import os, sys, re, getopt, time, datetime, commands format_css=""" html,body {
client/tests/kvm_runtest_2/ppm_utils.py +1 -6
@@ -1,11 +1,6 @@ #!/usr/bin/python -import md5 -import os -import struct -import time -import re - +import md5, os, struct, time, re # Some directory/filename utils, for consistency
client/tests/kvm_runtest_2/stepeditor.py +2 -8
@@ -4,15 +4,9 @@ # Written by Michael Goldish version = "20090401" -import pygtk -pygtk.require('2.0') -import gtk -import os -import glob -import shutil -import sys - +import pygtk, gtk, os, glob, shutil, sys import ppm_utils +pygtk.require('2.0') # General utilities
Signature · 1 line
1.6.2.2
Quoted 1 line
From
890d87f91fc0240222fa7c6e156639a927f07bf9Mon Sep 17 00:00:00 2001
From: Lucas Meneghel Rodrigues <[email protected]>
Date: Wed, 6 May 2009 21:26:56 -0300
Subject: [PATCH 3/7] Fixing more places that were using kvm_log.
--- client/tests/kvm_runtest_2/kvm_preprocessing.py | 6 +-- client/tests/kvm_runtest_2/kvm_utils.py | 54 +++++++++++----------- 2 files changed, 28 insertions(+), 32 deletions(-)
client/tests/kvm_runtest_2/kvm_preprocessing.py +1 -5
@@ -1,10 +1,6 @@ #!/usr/bin/python -import sys -import os -import time -import commands -import re +import sys, os, time, commands, re from autotest_lib.client.bin import test from autotest_lib.client.common_lib import error
client/tests/kvm_runtest_2/kvm_utils.py +27 -27
180 lines not on this page · raw message
Signature · 1 line
1.6.2.2
Quoted 1 line
From
29e4d4802e6945e65ca6dd7cd99d358c84d2f2d8Mon Sep 17 00:00:00 2001
From: Lucas Meneghel Rodrigues <[email protected]>
Date: Wed, 6 May 2009 21:47:51 -0300
Subject: [PATCH 4/7] Fixing exception raising to be compliant with the autotest coding standard.
--- client/tests/kvm_runtest_2/kvm_guest_wizard.py | 8 +- client/tests/kvm_runtest_2/kvm_install.py | 18 +++--- client/tests/kvm_runtest_2/kvm_preprocessing.py | 4 +- client/tests/kvm_runtest_2/kvm_runtest_2.py | 2 +- client/tests/kvm_runtest_2/kvm_tests.py | 70 +++++++++++----------- client/tests/kvm_runtest_2/stepmaker.py | 8 +- 6 files changed, 55 insertions(+), 55 deletions(-)
client/tests/kvm_runtest_2/kvm_guest_wizard.py +4 -4
@@ -125,16 +125,16 @@ def barrier_2(vm, words, fail_if_stuck_for, stuck_detection_history, output_dir, def run_steps(test, params, env): vm = kvm_utils.env_get_vm(env, params.get("main_vm")) if not vm: - raise error.TestError, "VM object not found in environment" + raise error.TestError("VM object not found in environment") if not vm.is_alive(): - raise error.TestError, "VM seems to be dead; Guestwizard requires a living VM" + raise error.TestError("VM seems to be dead; Guestwizard requires a living VM") steps_filename = params.get("steps") if not steps_filename: - raise error.TestError, "Steps filename not specified" + raise error.TestError("Steps filename not specified") steps_filename = os.path.join(test.bindir, "steps", steps_filename) if not os.path.exists(steps_filename): - raise error.TestError, "Steps file not found: %s" % steps_filename + raise error.TestError("Steps file not found: %s" % steps_filename) fail_if_stuck_for = params.get("fail_if_stuck_for") if fail_if_stuck_for:
client/tests/kvm_runtest_2/kvm_install.py +9 -9
@@ -27,11 +27,11 @@ def run_kvm_install(test, params, env): if not repo: message = "KVM git repository path not specified" logging.error(message) - raise error.TestError, message + raise error.TestError(message) if not user_repo: message = "KVM user git repository path not specified" logging.error(message) - raise error.TestError, message + raise error.TestError(message) __install_kvm_from_git(test, srcdir, repo, user_repo, branch, tag, user_tag, lbranch)
@@ -42,7 +42,7 @@ def run_kvm_install(test, params, env): if not release_dir: message = "Release dir not specified" logging.error(message) - raise error.TestError, message + raise error.TestError(message) __install_kvm_release(test, srcdir, release_dir, release_tag) # install from snapshot
@@ -52,7 +52,7 @@ def run_kvm_install(test, params, env): if not snapshot_dir: message = "Snapshot dir not specified" logging.error(message) - raise error.TestError, message + raise error.TestError(message) __install_kvm_from_snapshot(test, srcdir, snapshot_dir, snapshot_date) # install from tarball
@@ -61,7 +61,7 @@ def run_kvm_install(test, params, env): if not tarball: message = "Local tarball filename not specified" logging.error(message) - raise error.TestError, message + raise error.TestError(message) __install_kvm_from_local_tarball(test, srcdir, tarball) # install from local sources
@@ -72,7 +72,7 @@ def run_kvm_install(test, params, env): else: message = "Invalid installation mode: '%s'" % install_mode logging.error(message) - raise error.TestError, message + raise error.TestError(message) # load kvm modules (unless requested not to) if params.get('load_modules', "yes") == "yes":
@@ -86,7 +86,7 @@ def __cleanup_dir(dir): if dirs or files: message = "Directory \'%s\' is not empty" % dir logging.error(message) - raise error.TestError, message + raise error.TestError(message) def __install_kvm_release(test, srcdir, release_dir, release_tag): if not release_tag:
@@ -199,7 +199,7 @@ def __load_kvm_modules(): if utils.system("grep kvm /proc/modules 1>/dev/null", ignore_status=True) == 0: message = "Failed to remove old KVM modules" logging.error(message) - raise error.TestError, message + raise error.TestError(message) logging.info("Loading new KVM modules...") os.chdir("kernel")
@@ -215,7 +215,7 @@ def __load_kvm_modules(): if utils.system("grep kvm_%s /proc/modules 1>/dev/null" %(vendor), ignore_status=True) != 0: message = "Failed to load KVM modules" logging.error(message) - raise error.TestError, message + raise error.TestError(message) def __install_kvm(test, srcdir): # create destination dir
client/tests/kvm_runtest_2/kvm_preprocessing.py +2 -2
@@ -35,7 +35,7 @@ def preprocess_image(test, params): if not kvm_vm.create_image(params, qemu_img_path, image_dir): message = "Could not create image" logging.error(message) - raise error.TestError, message + raise error.TestError(message) def preprocess_vm(test, params, env, name):
@@ -84,7 +84,7 @@ def preprocess_vm(test, params, env, name): if not vm.create(name, params, qemu_path, image_dir, iso_dir, for_migration): message = "Could not start VM" logging.error(message) - raise error.TestError, message + raise error.TestError(message) scrdump_filename = os.path.join(test.debugdir, "pre_%s.ppm" % name) vm.send_monitor_cmd("screendump %s" % scrdump_filename)
client/tests/kvm_runtest_2/kvm_runtest_2.py +1 -1
@@ -71,7 +71,7 @@ class kvm_runtest_2(test.test): if not routine_obj: message = "Unsupported test type: %s" % type logging.error(message) - raise error.TestError, message + raise error.TestError(message) # If we don't have the test routine yet... if not routine_obj.routine: # Dynamically import the module
client/tests/kvm_runtest_2/kvm_tests.py +35 -35
240 lines not on this page · raw message
client/tests/kvm_runtest_2/stepmaker.py +4 -4
@@ -323,16 +323,16 @@ class StepMaker(stepeditor.StepMakerWindow): def run_stepmaker(test, params, env): vm = kvm_utils.env_get_vm(env, params.get("main_vm")) if not vm: - raise error.TestError, "VM object not found in environment" + raise error.TestError("VM object not found in environment") if not vm.is_alive(): - raise error.TestError, "VM seems to be dead; Step Maker requires a living VM" + raise error.TestError("VM seems to be dead; Step Maker requires a living VM") steps_filename = params.get("steps") if not steps_filename: - raise error.TestError, "Steps filename not specified" + raise error.TestError("Steps filename not specified") steps_filename = os.path.join(test.bindir, "steps", steps_filename) if os.path.exists(steps_filename): - raise error.TestError, "Steps file %s already exists" % steps_filename + raise error.TestError("Steps file %s already exists" % steps_filename) StepMaker(vm, steps_filename, test.debugdir, params) gtk.main()
Signature · 1 line
1.6.2.2
Quoted 1 line
From
d701d9e3c9aea382f521985cc3d6814b63faaddeMon Sep 17 00:00:00 2001
From: Lucas Meneghel Rodrigues <[email protected]>
Date: Wed, 6 May 2009 21:50:29 -0300
Subject: [PATCH 5/7] Fixing a kvm_log import lying around, imported logging on kvm_utils.
--- client/tests/kvm_runtest_2/kvm_utils.py | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)
client/tests/kvm_runtest_2/kvm_utils.py +1 -2
@@ -1,8 +1,7 @@ #!/usr/bin/python import md5, thread, subprocess, time, string, random, socket, os, signal, pty -import select, re -import kvm_log +import select, re, logging # Functions for working with dicts obtained from the test config file
Signature · 1 line
1.6.2.2
Quoted 1 line
From
bfee1c83daca69c8cafb2490145da1a571e088cbMon Sep 17 00:00:00 2001
From: Lucas Meneghel Rodrigues <[email protected]>
Date: Wed, 6 May 2009 22:37:19 -0300
Subject: [PATCH 6/7] Deleting kvm_log
--- client/tests/kvm_runtest_2/kvm_log.py | 60 --------------------------------- 1 files changed, 0 insertions(+), 60 deletions(-) delete mode 100644 client/tests/kvm_runtest_2/kvm_log.py
client/tests/kvm_runtest_2/kvm_log.py deleted +0 -60
60 lines not on this page · raw message
Signature · 1 line
1.6.2.2
Quoted 1 line
From
4ddeaaa8e23c8bba23c7be83ba6d07a4c9efdaa5Mon Sep 17 00:00:00 2001
From: Lucas Meneghel Rodrigues <[email protected]>
Date: Wed, 6 May 2009 22:43:14 -0300
Subject: [PATCH 7/7] Import fixes, removing unnecessary shebangs
--- client/tests/kvm_runtest_2/calc_md5sum_1m.py | 2 -- client/tests/kvm_runtest_2/kvm_preprocessing.py | 10 ++-------- client/tests/kvm_runtest_2/kvm_runtest_2.py | 4 ---- client/tests/kvm_runtest_2/kvm_tests.py | 2 -- client/tests/kvm_runtest_2/kvm_utils.py | 3 --- 5 files changed, 2 insertions(+), 19 deletions(-)
client/tests/kvm_runtest_2/calc_md5sum_1m.py +0 -2
@@ -12,5 +12,3 @@ else: else: print kvm_utils.md5sum_file(fname, 1024*1024) - -
client/tests/kvm_runtest_2/kvm_preprocessing.py +2 -8
@@ -1,13 +1,7 @@ -#!/usr/bin/python - -import sys, os, time, commands, re - +import sys, os, time, commands, re, logging from autotest_lib.client.bin import test from autotest_lib.client.common_lib import error - -import kvm_vm -import kvm_utils -import logging +import kvm_vm, kvm_utils def preprocess_image(test, params):
client/tests/kvm_runtest_2/kvm_runtest_2.py +0 -4
@@ -1,5 +1,3 @@ -#!/usr/bin/python - import sys, os, time, shelve, random, resource, logging from autotest_lib.client.bin import test from autotest_lib.client.common_lib import error
@@ -46,8 +44,6 @@ class kvm_runtest_2(test.test): # Enable core dumps resource.setrlimit(resource.RLIMIT_CORE, (-1, -1)) - # Set the logging prefix - #kvm_log.set_prefix(params.get("shortname")) # Report the parameters we've received and write them as keyvals logging.debug("Test parameters:")
client/tests/kvm_runtest_2/kvm_tests.py +0 -2
@@ -299,9 +299,7 @@ def run_autotest(test, params, env): raise error.TestError(message_error) - # I'm not sure if we need these... - def internal_yum_update(session, command, prompt, timeout): session.sendline(command) end_time = time.time() + timeout
client/tests/kvm_runtest_2/kvm_utils.py +0 -3
@@ -1,11 +1,8 @@ -#!/usr/bin/python - import md5, thread, subprocess, time, string, random, socket, os, signal, pty import select, re, logging # Functions for working with dicts obtained from the test config file - def get_sub_dict(dict, name): """Return a "sub-dict" corresponding to a specific object.
Signature · 1 line
1.6.2.2