[PATCH] [TEST] .2# Retrieve revision and changeset string

# HG changeset patch # User Zhengang Li <lizg@cn.ibm.com> # Date 1208509216 -28800 # Node ID 1fc0ff2248ae99860b83abb5ce8952df82218798 # Parent a3b6354aa1fd6cd95a99a0abf877b4994ec0c839 [TEST] .2# Retrieve revision and changeset string Updates: - use env var instead - less cim query. now once per suite run. Test cases now need to import CIM_REV and CIM_SET to get the value. Signed-off-by: Zhengang Li <lizg@cn.ibm.com> diff -r a3b6354aa1fd -r 1fc0ff2248ae lib/CimTest/Globals.py --- a/lib/CimTest/Globals.py Fri Apr 18 16:12:37 2008 +0800 +++ b/lib/CimTest/Globals.py Fri Apr 18 17:00:16 2008 +0800 @@ -34,6 +34,8 @@ global platform_sup global platform_sup global CIM_IP global CIM_PORT +global CIM_REV +global CIM_SET global CIM_ERROR_ASSOCIATORNAMES global CIM_ERROR_ENUMERATE @@ -47,6 +49,8 @@ CIM_FUUID = os.getenv("CIM_FUUID") CIM_FUUID = os.getenv("CIM_FUUID") CIM_TC = os.getenv("CIM_TC") CIM_IP = os.getenv("CIM_IP") +CIM_REV = os.getenv("CIM_REV") +CIM_SET = os.getenv("CIM_SET") CIM_PORT = "5988" NM = "TEST LOG" platform_sup = ["Xen", "KVM", "XenFV"] @@ -86,6 +90,9 @@ if not CIM_TC: CIM_TC = " " if not CIM_IP: CIM_IP = "localhost" + +if not CIM_REV or not CIM_SET: + CIM_REV = CIM_SET = "Unknown" def log_param(debug=None): #FIXME debug=None is a temporary work around to avoid duplicate diff -r a3b6354aa1fd -r 1fc0ff2248ae suites/libvirt-cim/main.py --- a/suites/libvirt-cim/main.py Fri Apr 18 16:12:37 2008 +0800 +++ b/suites/libvirt-cim/main.py Fri Apr 18 17:00:16 2008 +0800 @@ -25,6 +25,7 @@ from optparse import OptionParser from optparse import OptionParser import os import sys +from pywbem import WBEMConnection sys.path.append('../../lib') import TestSuite import commands @@ -32,6 +33,8 @@ from VirtLib import groups from VirtLib import groups from CimTest.ReturnCodes import PASS, SKIP, XFAIL from CimTest.Globals import platform_sup +sys.path.append('./lib') +from XenKvmLib.classes import get_typed_class parser = OptionParser() parser.add_option("-i", "--ip", dest="ip", default="localhost", @@ -79,6 +82,19 @@ def remove_old_logs(ogroup): print "Cleaned log files." +def get_version(virt, ip): + conn = WBEMConnection('http://%s' % ip, + (os.getenv('CIM_USER'), os.getenv('CIM_PASS')), + os.getenv('CIM_NS')) + vsms_cn = get_typed_class(virt, 'VirtualSystemManagementService') + try: + inst = conn.EnumerateInstances(vsms_cn) + revision = inst[0]['Revision'] + changeset = inst[0]['Changeset'] + except Exception: + return 'Unknown', 'Unknown' + return revision, changeset + def main(): (options, args) = parser.parse_args() @@ -117,14 +133,18 @@ def main(): else: dbg = "" + revision, changeset = get_version(options.virt, options.ip) + print "Testing " + options.virt + " hypervisor" for test in test_list: t_path = os.path.join(TEST_SUITE, test['group']) os.environ['CIM_TC'] = test['test'] - - cmd = "cd %s && python %s -i %s -v %s %s" % \ - (t_path, test['test'], options.ip, options.virt, dbg) + cdto = 'cd %s' % t_path + env = 'CIM_REV=%s CIM_SET=%s' % (revision, changeset) + run = 'python %s -i %s -v %s %s' % (test['test'], options.ip, + options.virt, dbg) + cmd = cdto + ' && ' + env + ' ' + run status, output = commands.getstatusoutput(cmd) os_status = os.WEXITSTATUS(status)

zli@linux.vnet.ibm.com wrote:
# HG changeset patch # User Zhengang Li <lizg@cn.ibm.com> # Date 1208509216 -28800 # Node ID 1fc0ff2248ae99860b83abb5ce8952df82218798 # Parent a3b6354aa1fd6cd95a99a0abf877b4994ec0c839 [TEST] .2# Retrieve revision and changeset string
Updates: - use env var instead - less cim query. now once per suite run.
Test cases now need to import CIM_REV and CIM_SET to get the value.
Signed-off-by: Zhengang Li <lizg@cn.ibm.com>
diff -r a3b6354aa1fd -r 1fc0ff2248ae lib/CimTest/Globals.py
Nice - thanks Zhengang, I think this looks good. =) -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

KR> Nice - thanks Zhengang, I think this looks good. =) Indeed, but I don't think there's any reason to not put it into the suite-specific library, right? Other suites (should they ever materialize) won't want this, of course. Thanks! -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com

Dan Smith wrote:
KR> Nice - thanks Zhengang, I think this looks good. =)
Indeed, but I don't think there's any reason to not put it into the suite-specific library, right?
Other suites (should they ever materialize) won't want this, of course.
Thanks!
Good call - I overlooked this. We could come up place in the XenKvmLib library to store the CIM_REV / CIM_SET instead. -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

Kaitlin Rupert wrote:
Dan Smith wrote:
KR> Nice - thanks Zhengang, I think this looks good. =)
Indeed, but I don't think there's any reason to not put it into the suite-specific library, right?
Other suites (should they ever materialize) won't want this, of course.
Thanks!
Good call - I overlooked this. We could come up place in the XenKvmLib library to store the CIM_REV / CIM_SET instead.
XenKvmLib.const? -- - Zhengang

Zhengang Li wrote:
Kaitlin Rupert wrote:
Dan Smith wrote:
KR> Nice - thanks Zhengang, I think this looks good. =)
Indeed, but I don't think there's any reason to not put it into the suite-specific library, right?
Other suites (should they ever materialize) won't want this, of course.
Thanks!
Good call - I overlooked this. We could come up place in the XenKvmLib library to store the CIM_REV / CIM_SET instead.
XenKvmLib.const?
Sounds good to me. =) -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com
participants (4)
-
Dan Smith
-
Kaitlin Rupert
-
Zhengang Li
-
zli@linux.vnet.ibm.com