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

zli at linux.vnet.ibm.com zli at linux.vnet.ibm.com
Fri Apr 18 09:00:43 UTC 2008


# HG changeset patch
# User Zhengang Li <lizg at 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 at 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)




More information about the Libvirt-cim mailing list