aboutsummaryrefslogtreecommitdiffstats
path: root/tools/xm-test/tests
diff options
context:
space:
mode:
authorEwan Mellor <ewan@xensource.com>2007-01-11 19:00:35 +0000
committerEwan Mellor <ewan@xensource.com>2007-01-11 19:00:35 +0000
commitbaacea8058282908ae5078f8f0373de10d58e150 (patch)
tree95350cd16431fe3b6643c1eef39d846783cb2c4f /tools/xm-test/tests
parentaeb7c09a6613aae8e39c271283f8db9f7a99d32f (diff)
downloadxen-baacea8058282908ae5078f8f0373de10d58e150.tar.gz
xen-baacea8058282908ae5078f8f0373de10d58e150.tar.bz2
xen-baacea8058282908ae5078f8f0373de10d58e150.zip
This patch does the following:
- renames the XenManagedDomain.py file to XenAPIDomain.py, since this name better reflects its functionality/purpose - adds domain tracking to the XenAPIDomain class so that xend-managed domains can be deleted in an 'atexit' handler upon test case termination - adds one basic xapi-related test which is part of the grouptests 'xapi' - refactors the vtpm-related test using xen-api and adds it to the grouptest 'xapi' - adds documentation to the README for how to configure xm and xend to use XML-RPC or Xen-API for communication Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
Diffstat (limited to 'tools/xm-test/tests')
-rw-r--r--tools/xm-test/tests/vtpm/09_vtpm-xapi.py99
-rw-r--r--tools/xm-test/tests/xapi/01_xapi-vm_basic.py61
-rw-r--r--tools/xm-test/tests/xapi/Makefile.am19
3 files changed, 127 insertions, 52 deletions
diff --git a/tools/xm-test/tests/vtpm/09_vtpm-xapi.py b/tools/xm-test/tests/vtpm/09_vtpm-xapi.py
index 8547a08b03..89975d077f 100644
--- a/tools/xm-test/tests/vtpm/09_vtpm-xapi.py
+++ b/tools/xm-test/tests/vtpm/09_vtpm-xapi.py
@@ -6,71 +6,66 @@
# Test to test the vtpm class through the Xen-API
from XmTestLib import xapi
-from XmTestLib.XenManagedDomain import XmTestManagedDomain
+from XmTestLib.XenAPIDomain import XmTestAPIDomain
from XmTestLib import *
from vtpm_utils import *
import commands
import os
-def do_test():
- domain = XmTestManagedDomain()
- vm_uuid = domain.get_uuid()
-
- vtpmcfg = {}
- vtpmcfg['type'] = "paravirtualised"
- vtpmcfg['backend'] = "Domain-0"
- vtpmcfg['instance'] = 1
- vtpmcfg['VM'] = vm_uuid
-
- server, session = xapi._connect()
-
- vtpm_uuid = xapi.execute(server.VTPM.create, session, vtpmcfg)
-
- vtpm_id = xapi.execute(server.VTPM.get_instance, session, vtpm_uuid)
- vtpm_be = xapi.execute(server.VTPM.get_backend , session, vtpm_uuid)
- if vtpm_be != vtpmcfg['backend']:
- FAIL("vTPM's backend is in '%s', expected: '%s'" %
- (vtpm_be, vtpmcfg['backend']))
-
- driver = xapi.execute(server.VTPM.get_driver, session, vtpm_uuid)
- if driver != vtpmcfg['type']:
- FAIL("vTPM has driver type '%s', expected: '%s'" %
- (driver, vtpmcfg['type']))
+try:
+ # XmTestAPIDomain tries to establish a connection to XenD
+ domain = XmTestAPIDomain()
+except Exception, e:
+ SKIP("Skipping test. Error: %s" % str(e))
+vm_uuid = domain.get_uuid()
- vtpm_rec = xapi.execute(server.VTPM.get_record, session, vtpm_uuid)
+vtpmcfg = {}
+vtpmcfg['type'] = "paravirtualised"
+vtpmcfg['backend'] = "Domain-0"
+vtpmcfg['instance'] = 1
+vtpmcfg['VM'] = vm_uuid
- if vtpm_rec['driver'] != vtpmcfg['type']:
- FAIL("vTPM record shows driver type '%s', expected: '%s'" %
- (vtpm_rec['driver'], vtpmcfg['type']))
- if vtpm_rec['uuid'] != vtpm_uuid:
- FAIL("vTPM record shows vtpm uuid '%s', expected: '%s'" %
- (vtpm_rec['uuid'], vtpm_uuid))
- if vtpm_rec['VM'] != vm_uuid:
- FAIL("vTPM record shows VM uuid '%s', expected: '%s'" %
- (vtpm_rec['VM'], vm_uuid))
+session = xapi.connect()
- success = domain.start()
+vtpm_uuid = session.xenapi.VTPM.create(vtpmcfg)
- console = domain.getConsole()
+vtpm_id = session.xenapi.VTPM.get_instance(vtpm_uuid)
+vtpm_be = session.xenapi.VTPM.get_backend(vtpm_uuid)
+if vtpm_be != vtpmcfg['backend']:
+ FAIL("vTPM's backend is in '%s', expected: '%s'" %
+ (vtpm_be, vtpmcfg['backend']))
- try:
- run = console.runCmd("cat /sys/devices/xen/vtpm-0/pcrs")
- except ConsoleError, e:
- saveLog(console.getHistory())
- vtpm_cleanup(domName)
- FAIL("No result from dumping the PCRs")
+driver = session.xenapi.VTPM.get_driver(vtpm_uuid)
+if driver != vtpmcfg['type']:
+ FAIL("vTPM has driver type '%s', expected: '%s'" %
+ (driver, vtpmcfg['type']))
- if re.search("No such file",run["output"]):
- vtpm_cleanup(domName)
- FAIL("TPM frontend support not compiled into (domU?) kernel")
+vtpm_rec = session.xenapi.VTPM.get_record(vtpm_uuid)
- domain.stop()
- domain.destroy()
+if vtpm_rec['driver'] != vtpmcfg['type']:
+ FAIL("vTPM record shows driver type '%s', expected: '%s'" %
+ (vtpm_rec['driver'], vtpmcfg['type']))
+if vtpm_rec['uuid'] != vtpm_uuid:
+ FAIL("vTPM record shows vtpm uuid '%s', expected: '%s'" %
+ (vtpm_rec['uuid'], vtpm_uuid))
+if vtpm_rec['VM'] != vm_uuid:
+ FAIL("vTPM record shows VM uuid '%s', expected: '%s'" %
+ (vtpm_rec['VM'], vm_uuid))
+success = domain.start()
+console = domain.getConsole()
try:
- do_test()
-finally:
- #Make sure all domains are gone that were created in this test case
- xapi.vm_destroy_all()
+ run = console.runCmd("cat /sys/devices/xen/vtpm-0/pcrs")
+except ConsoleError, e:
+ saveLog(console.getHistory())
+ vtpm_cleanup(domName)
+ FAIL("No result from dumping the PCRs")
+
+if re.search("No such file",run["output"]):
+ vtpm_cleanup(domName)
+ FAIL("TPM frontend support not compiled into (domU?) kernel")
+
+domain.stop()
+domain.destroy()
diff --git a/tools/xm-test/tests/xapi/01_xapi-vm_basic.py b/tools/xm-test/tests/xapi/01_xapi-vm_basic.py
new file mode 100644
index 0000000000..6f149a0dd9
--- /dev/null
+++ b/tools/xm-test/tests/xapi/01_xapi-vm_basic.py
@@ -0,0 +1,61 @@
+#!/usr/bin/python
+
+# Copyright (C) International Business Machines Corp., 2006
+# Author: Stefan Berger <stefanb@us.ibm.com>
+
+# Basic VM creation test
+
+from XmTestLib import xapi
+from XmTestLib.XenAPIDomain import XmTestAPIDomain
+from XmTestLib import *
+from xen.xend import XendAPIConstants
+import commands
+import os
+
+try:
+ # XmTestAPIDomain tries to establish a connection to XenD
+ domain = XmTestAPIDomain()
+except Exception, e:
+ SKIP("Skipping test. Error: %s" % str(e))
+vm_uuid = domain.get_uuid()
+
+session = xapi.connect()
+
+domain.start(startpaused=True)
+
+res = session.xenapi.VM.get_power_state(vm_uuid)
+
+if res != XendAPIConstants.XEN_API_VM_POWER_STATE[XendAPIConstants.XEN_API_VM_POWER_STATE_PAUSED]:
+ FAIL("VM was not started in 'paused' state")
+
+res = session.xenapi.VM.unpause(vm_uuid)
+
+res = session.xenapi.VM.get_power_state(vm_uuid)
+
+if res != XendAPIConstants.XEN_API_VM_POWER_STATE[XendAPIConstants.XEN_API_VM_POWER_STATE_RUNNING]:
+ FAIL("VM could not be put into 'running' state")
+
+console = domain.getConsole()
+
+try:
+ run = console.runCmd("cat /proc/interrupts")
+except ConsoleError, e:
+ saveLog(console.getHistory())
+ FAIL("Could not access proc-filesystem")
+
+res = session.xenapi.VM.pause(vm_uuid)
+
+res = session.xenapi.VM.get_power_state(vm_uuid)
+
+if res != XendAPIConstants.XEN_API_VM_POWER_STATE[XendAPIConstants.XEN_API_VM_POWER_STATE_PAUSED]:
+ FAIL("VM could not be put into 'paused' state")
+
+res = session.xenapi.VM.unpause(vm_uuid)
+
+res = session.xenapi.VM.get_power_state(vm_uuid)
+
+if res != XendAPIConstants.XEN_API_VM_POWER_STATE[XendAPIConstants.XEN_API_VM_POWER_STATE_RUNNING]:
+ FAIL("VM could not be 'unpaused'")
+
+domain.stop()
+domain.destroy()
diff --git a/tools/xm-test/tests/xapi/Makefile.am b/tools/xm-test/tests/xapi/Makefile.am
new file mode 100644
index 0000000000..2a0c44f578
--- /dev/null
+++ b/tools/xm-test/tests/xapi/Makefile.am
@@ -0,0 +1,19 @@
+SUBDIRS =
+
+TESTS = 01_xapi-vm_basic.test
+
+XFAIL_TESTS =
+
+EXTRA_DIST = $(TESTS) $(XFAIL_TESTS) xapi_utils.py
+TESTS_ENVIRONMENT=@TENV@
+
+%.test: %.py
+ cp $< $@
+ chmod +x $@
+
+clean-local: am_config_clean-local
+
+am_config_clean-local:
+ rm -f *test
+ rm -f *log
+ rm -f *~