Skip to contentSkip to conversation

XenManagedDomain and initial test case for vTPM management using xen-api

PATCH In review Stefan Berger 2 participants 4 messages Nov 28, 2006 – Dec 3, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 XenManagedDomain and initial test case for vTPM management using xen-api

This patch provides XmTestManagedDomain and XenManagedDomain classes similar to the XmTestDomain and XenDomain classes. I have wrapped the xen-api for VM configuration creation, starting and stopping of VMs and destruction of the VM configuration in the XenManagedDomain class's methods. No device-related functions are provided through the class.

The managed domains' UUIDs are tracked and all created VMs are destroyed upon failure or skipping of the test or by calling xapi.vm_destroy_all().

I am adding a new grouptest 'xapi' for running xen-api tests.

Only caveat: I am using an empty username and password (XmTestList/xapi.py) with Xend's authentication deactivated to run these tests.

xen-unstable.hg/tools/xm-test/grouptest/xapi new file +1 -0
Index: root/xen-unstable.hg/tools/xm-test/grouptest/xapi
===================================================================
@@ -0,0 +1 @@
+vtpm 09_vtpm-xapi.test
xen-unstable.hg/tools/xm-test/tests/vtpm/09_vtpm-xapi.py new file +76 -0

76 lines not on this page · raw message

xen-unstable.hg/tools/xm-test/lib/XmTestLib/xapi.py new file +66 -0

66 lines not on this page · raw message

xen-unstable.hg/tools/xm-test/tests/vtpm/Makefile.am +2 -1
Index: root/xen-unstable.hg/tools/xm-test/tests/vtpm/Makefile.am
===================================================================
@@ -7,7 +7,8 @@ TESTS = 01_vtpm-list_pos.test \
         05_vtpm-loc_migr.test \
         06_vtpm-susp_res_pcrs.test \
         07_vtpm-mig_pcrs.test \
-        08_vtpm-mig_pcrs.test
+        08_vtpm-mig_pcrs.test \
+        09_vtpm-xapi.test
 
 XFAIL_TESTS =
 
xen-unstable.hg/tools/python/scripts/xapi.py +0 -11
Index: root/xen-unstable.hg/tools/python/scripts/xapi.py
===================================================================
@@ -412,17 +412,6 @@ def xapi_vtpm_create(*args):
     print "Creating vTPM with cfg = %s" % cfg
     vtpm_uuid = execute(server.VTPM.create, session, cfg)
     print "Done. (%s)" % vtpm_uuid
-    vtpm_id = execute(server.VTPM.get_instance, session, vtpm_uuid)
-    print "Has instance number '%s'" % vtpm_id
-    vtpm_be = execute(server.VTPM.get_backend, session, vtpm_uuid)
-    print "Has backend in '%s'" % vtpm_be
-    driver = execute(server.VTPM.get_driver, session, vtpm_uuid)
-    print "Has driver type '%s'" % driver
-    vtpm_rec = execute(server.VTPM.get_record, session, vtpm_uuid)
-    print "Has vtpm record '%s'" % vtpm_rec
-    vm = execute(server.VTPM.get_VM, session, vtpm_uuid)
-    print "Has VM '%s'" % vm
-
 
 #
 # Command Line Utils
xen-unstable.hg/tools/xm-test/lib/XmTestLib/Test.py +3 -0
Index: root/xen-unstable.hg/tools/xm-test/lib/XmTestLib/Test.py
===================================================================
@@ -33,6 +33,7 @@ import select
 import signal
 import re
 import glob
+import xapi
 
 TEST_PASS = 0
 TEST_FAIL = 255
@@ -133,10 +134,12 @@ def becomeNonRoot():
 
 def FAIL(format, *args):
     print "\nREASON:", (format % args)
+    xapi.vm_destroy_all()
     sys.exit(TEST_FAIL)
 
 def SKIP(format, *args):
     print "\nREASON:", (format % args)
+    xapi.vm_destroy_all()
     sys.exit(TEST_SKIP)
 
 def saveLog(logText, filename=None):
xen-unstable.hg/tools/xm-test/lib/XmTestLib/XenManagedDomain.py new file +176 -0

176 lines not on this page · raw message

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw
Quoted 10 lines · Stefan Berger

This patch provides XmTestManagedDomain and XenManagedDomain classes similar to the XmTestDomain and XenDomain classes. I have wrapped the xen-api for VM configuration creation, starting and stopping of VMs and destruction of the VM configuration in the XenManagedDomain class's methods. No device-related functions are provided through the class.

The managed domains' UUIDs are tracked and all created VMs are destroyed upon failure or skipping of the test or by calling xapi.vm_destroy_all().

Quoted 7 lines

I am adding a new grouptest 'xapi' for running xen-api tests.

Only caveat: I am using an empty username and password (XmTestList/xapi.py) with Xend's authentication deactivated to run these tests.

Applied, thanks Stefan. Now all we need is some tests that _don't_ need a TPM ;-)

Ewan.

#2 lore raw

Ewan Mellor <[email protected]> wrote on 12/01/2006 12:36:47 PM:

Quoted 5 lines · Stefan Berger
Quoted 4 lines

This patch provides XmTestManagedDomain and XenManagedDomain classes similar to the XmTestDomain and XenDomain classes. I have wrapped the xen-api for VM configuration creation, starting and stopping of VMs

and

Quoted 4 lines
Quoted 4 lines

destruction of the VM configuration in the XenManagedDomain class's methods. No device-related functions are provided through the class.

The managed domains' UUIDs are tracked and all created VMs are

destroyed

Quoted 7 lines
Quoted 7 lines

upon failure or skipping of the test or by calling xapi.vm_destroy_all().

I am adding a new grouptest 'xapi' for running xen-api tests.

Only caveat: I am using an empty username and password (XmTestList/xapi.py) with Xend's authentication deactivated to run

these

Quoted 5 lines
Quoted 3 lines

tests.

Applied, thanks Stefan. Now all we need is some tests that _don't_ need

a TPM

Quoted 1 line

;-)

Yes, I understand that, but I must say that I don't know what would be the best way to go about it and maybe what has been committed so far is not that good. One could either cut and paste all existing tests and modify them to work with the xen-api, or we could use a global variable 'xapi' that allows us to resuse existing tests like this:

if (xapi)
domain = XenManagedTestDomain()
else
domain = XenTestDomain()

This way all tests would need to be run twice.

And then the question is whether XenManagedTestDomain() should not rather be implemented with XenTestDomain(managed=xapi), which would lead to a messier implementation inside XenTestDomain().

Often there are statements in the tests like traceCommand('xm xyz'), which would also need to be surrounded with an if (xapi) statement. I guess the goal could be to reduce the test implementation work while not messing up the implementations.

Thoughts?

Stefan

Quoted 2 lines

Ewan.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#3 lore raw
Quoted 46 lines · Stefan Berger

Ewan Mellor <[email protected]> wrote on 12/01/2006 12:36:47 PM:

Quoted 5 lines · Stefan Berger
Quoted 4 lines

This patch provides XmTestManagedDomain and XenManagedDomain classes similar to the XmTestDomain and XenDomain classes. I have wrapped the xen-api for VM configuration creation, starting and stopping of VMs

and

Quoted 4 lines
Quoted 4 lines

destruction of the VM configuration in the XenManagedDomain class's methods. No device-related functions are provided through the class.

The managed domains' UUIDs are tracked and all created VMs are

destroyed

Quoted 7 lines
Quoted 7 lines

upon failure or skipping of the test or by calling xapi.vm_destroy_all().

I am adding a new grouptest 'xapi' for running xen-api tests.

Only caveat: I am using an empty username and password (XmTestList/xapi.py) with Xend's authentication deactivated to run

these

Quoted 5 lines
Quoted 3 lines

tests.

Applied, thanks Stefan. Now all we need is some tests that _don't_ need

a TPM

Quoted 1 line

;-)

Yes, I understand that, but I must say that I don't know what would be the best way to go about it and maybe what has been committed so far is not that good. One could either cut and paste all existing tests and modify them to work with the xen-api, or we could use a global variable 'xapi' that allows us to resuse existing tests like this:

if (xapi)
domain = XenManagedTestDomain()
else
domain = XenTestDomain()

This way all tests would need to be run twice.

And then the question is whether XenManagedTestDomain() should not rather be implemented with XenTestDomain(managed=xapi), which would lead to a messier implementation inside XenTestDomain().

Quoted 6 lines

Often there are statements in the tests like traceCommand('xm xyz'), which would also need to be surrounded with an if (xapi) statement. I guess the goal could be to reduce the test implementation work while not messing up the implementations.

Thoughts?

Well, my first concern is to get the new lifecycle commands covered -- that's xm new, start, delete, suspend, resume. For those, there's no need to address the worries that you have, because of course those commands aren't supported in the non-managed case.

The next set of things to test is the negative cases around VM lifecycle -- do you get good error messages when trying to resume a VM that isn't suspended, or start one that's already running, and so on. I know for sure that we're getting this wrong at the moment, and the error messages that you get back are very poor, so coverage here would be valuable.

Next week, I intend to add a config file to xm, so that xm itself can decide whether it is talking to the old server or the new, and which username and password to use when talking to the new server. Then, xm-test will be able to run the main body of the tests twice, once talking to the old server and once talking to the new, without us having to change xm-test itself too much. All those traceCommand calls should just work without change.

For Xen 3.0.4, the default for this flag will be to talk to the old server of course, because the Xen-API work is only going to be available in preview form for that release. It will be good to be able to test both old and new, nonetheless.

Ewan.