# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1250760653 -3600
# Node ID 6c2362ce82c93afb7c752ee0d31959f1b630a710
# Parent 5126f08476543683ff252768909d0eb66b1a5b64
Fix xapi xm-tests.
There were a couple of small bugs in the xapi xm-test:
o outdated XenAPI calls were removed from testcase
(02_xapi-vbd_basic)
o minor problem with XendLocalStorageRepository
is fixed (missed list_images() function - which
is moved from the XenQCoWStroageRepo to the common
base class XendStorageRepository)
which was detected running 02_xapi-vbd_basic.
o XenAPI session handling and connecting is fixed.
o 03_xapi-network_pos was rewritten and now uses
XenAPI.
Signed-off-by: Andreas Florath <xen@xxxxxxxxxxxx>
---
tools/python/xen/xend/XendQCoWStorageRepo.py | 12 --
tools/python/xen/xend/XendStorageRepository.py | 13 ++
tools/xm-test/grouptest/default | 1
tools/xm-test/lib/XmTestLib/XenAPIDomain.py | 3
tools/xm-test/lib/XmTestLib/XenDevice.py | 3
tools/xm-test/lib/XmTestLib/xapi.py | 25 +----
tools/xm-test/runtest.sh | 4
tools/xm-test/tests/xapi/02_xapi-vbd_basic.py | 21 +---
tools/xm-test/tests/xapi/03_xapi-network_pos.py | 114 +++++++++++++++++-------
9 files changed, 118 insertions(+), 78 deletions(-)
diff -r 5126f0847654 -r 6c2362ce82c9
tools/python/xen/xend/XendQCoWStorageRepo.py
--- a/tools/python/xen/xend/XendQCoWStorageRepo.py Thu Aug 20 10:27:37
2009 +0100
+++ b/tools/python/xen/xend/XendQCoWStorageRepo.py Thu Aug 20 10:30:53
2009 +0100
@@ -260,18 +260,6 @@ class XendQCoWStorageRepo(XendStorageRep
return False
- def list_images(self):
- """ List all the available images by UUID.
-
- @rtype: list of strings.
- @return: list of UUIDs
- """
- self.lock.acquire()
- try:
- return self.images.keys()
- finally:
- self.lock.release()
-
def free_space_bytes(self):
"""Returns the amount of available space in KB.
@rtype: int
diff -r 5126f0847654 -r 6c2362ce82c9
tools/python/xen/xend/XendStorageRepository.py
--- a/tools/python/xen/xend/XendStorageRepository.py Thu Aug 20 10:27:37
2009 +0100
+++ b/tools/python/xen/xend/XendStorageRepository.py Thu Aug 20 10:30:53
2009 +0100
@@ -103,3 +103,16 @@ class XendStorageRepository:
def destroy_vdi(self, vdi_struct):
raise NotImplementedError()
+
+ def list_images(self):
+ """ List all the available images by UUID.
+
+ @rtype: list of strings.
+ @return: list of UUIDs
+ """
+ self.lock.acquire()
+ try:
+ return self.images.keys()
+ finally:
+ self.lock.release()
+
diff -r 5126f0847654 -r 6c2362ce82c9 tools/xm-test/grouptest/default
--- a/tools/xm-test/grouptest/default Thu Aug 20 10:27:37 2009 +0100
+++ b/tools/xm-test/grouptest/default Thu Aug 20 10:30:53 2009 +0100
@@ -29,3 +29,4 @@ vcpu-disable
vcpu-disable
vcpu-pin
vtpm
+xapi
diff -r 5126f0847654 -r 6c2362ce82c9 tools/xm-test/lib/XmTestLib/XenAPIDomain.py
--- a/tools/xm-test/lib/XmTestLib/XenAPIDomain.py Thu Aug 20 10:27:37
2009 +0100
+++ b/tools/xm-test/lib/XmTestLib/XenAPIDomain.py Thu Aug 20 10:30:53
2009 +0100
@@ -94,9 +94,8 @@ class XenAPIDomain(XenDomain):
self.netEnv = "bridge"
self.session = xapi.connect()
- session = self.session
try:
- self.vm_uuid = session.xenapi.VM.create(self.config.getOpts())
+ self.vm_uuid = self.session.xenapi.VM.create(self.config.getOpts())
addXAPIDomain(self.vm_uuid)
except:
raise DomainError("Could not create VM config file for "
diff -r 5126f0847654 -r 6c2362ce82c9 tools/xm-test/lib/XmTestLib/XenDevice.py
--- a/tools/xm-test/lib/XmTestLib/XenDevice.py Thu Aug 20 10:27:37 2009 +0100
+++ b/tools/xm-test/lib/XmTestLib/XenDevice.py Thu Aug 20 10:30:53 2009 +0100
@@ -244,6 +244,9 @@ class XenNetDevice(XenDevice):
def getNetwork(self):
return self.network
+ def get_netmask(self):
+ return self.netmask
+
def setNetDevIP(self, ip=None):
# Function to set a new IP for NetDevice.
if NETWORK_IP_RANGE == "dhcp":
diff -r 5126f0847654 -r 6c2362ce82c9 tools/xm-test/lib/XmTestLib/xapi.py
--- a/tools/xm-test/lib/XmTestLib/xapi.py Thu Aug 20 10:27:37 2009 +0100
+++ b/tools/xm-test/lib/XmTestLib/xapi.py Thu Aug 20 10:30:53 2009 +0100
@@ -15,6 +15,7 @@
#============================================================================
# Copyright (C) 2006 XenSource Ltd.
# Copyright (C) 2006 IBM Corporation
+# Copyright (C) 2009 flonatel GmbH & Co. KG
#============================================================================
import atexit
@@ -27,33 +28,21 @@ from types import DictType
from types import DictType
import xml.dom.minidom
-def get_login_pwd():
- if xmmain.serverType == xmmain.SERVER_XEN_API:
- try:
- login, password = xmmain.parseAuthentication()
- return (login, password)
- except:
- raise OptionError("Configuration for login/pwd not found. "
- "Need to run xapi-setup.py?")
- raise OptionError("Xm configuration file not using Xen-API for "
- "communication with xend.")
-
sessions=[]
def connect(*args):
+ creds = ("", "")
+ uri = "http://localhost:9363"
+
try:
- creds = get_login_pwd()
- except Exception, e:
- FAIL("%s" % str(e))
- try:
- session = XenAPI.Session(xmmain.serverURI)
+ session = XenAPI.Session(uri)
except:
raise OptionError("Could not create XenAPI session with Xend." \
- "URI=%s" % xmmain.serverURI)
+ "URI=%s" % uri)
try:
session.login_with_password(*creds)
except:
- raise OptionError("Could not login to Xend. URI=%s" % xmmain.serverURI)
+ raise OptionError("Could not login to Xend. URI=%s" % uri)
def logout():
try:
for s in sessions:
diff -r 5126f0847654 -r 6c2362ce82c9 tools/xm-test/runtest.sh
--- a/tools/xm-test/runtest.sh Thu Aug 20 10:27:37 2009 +0100
+++ b/tools/xm-test/runtest.sh Thu Aug 20 10:30:53 2009 +0100
@@ -11,7 +11,9 @@ usage() {
echo " Where opts are:"
echo " -d : do not submit a report for this run"
echo " -b : do not ask any questions (batch mode)"
- echo " -g : run a group test set"
+ echo " -g <group> : run a group test set"
+ echo " available goups are:"
+ echo " "`ls grouptest`
echo " -e <email> : set email address for report"
echo " -r <url> : url of test results repository to use"
echo " -s <report> : just submit report <report>"
diff -r 5126f0847654 -r 6c2362ce82c9
tools/xm-test/tests/xapi/02_xapi-vbd_basic.py
--- a/tools/xm-test/tests/xapi/02_xapi-vbd_basic.py Thu Aug 20 10:27:37
2009 +0100
+++ b/tools/xm-test/tests/xapi/02_xapi-vbd_basic.py Thu Aug 20 10:30:53
2009 +0100
@@ -1,7 +1,9 @@
#!/usr/bin/python
# Copyright (C) International Business Machines Corp., 2007
-# Author: Stefan Berger <stefanb@xxxxxxxxxx>
+# Copyright (C) flonatel GmbH & Co. KG
+# Authors: Stefan Berger <stefanb@xxxxxxxxxx>
+# Andreas Florath <xen@xxxxxxxxxxxx>
# Tests related to SR, VDI, VBD
#
@@ -10,7 +12,7 @@
#
# VDI: create, get_name_label, destroy
#
-# VBD: create, get_driver, get_mode, get_VM, get_VDI, get_device
+# VBD: create, get_mode, get_VM, get_VDI, get_device
#
# VM: get_VBDs
@@ -43,7 +45,8 @@ vdi_rec = { 'name_label' : "My disk",
'sector_size' : 512,
'type' : 0,
'shareable' : 0,
- 'read-only' : 0
+ 'read-only' : 0,
+ 'other_config': { 'location': "phy:/dev/xg/storage_root" },
}
vdi_ref = session.xenapi.VDI.create(vdi_rec)
@@ -61,8 +64,6 @@ if res != vdi_rec['name_label']:
#MORE method calls to VDI to add here...
-
-
vbd_rec = { 'VM' : vm_uuid,
'VDI' : vdi_ref,
'device': "xvda1",
@@ -71,12 +72,6 @@ vbd_rec = { 'VM' : vm_uuid,
}
vbd_ref = session.xenapi.VBD.create(vbd_rec)
-
-res = session.xenapi.VBD.get_driver(vbd_ref)
-print "VBD driver: %s" % res
-if res != XendAPIConstants.XEN_API_DRIVER_TYPE[int(vbd_rec['driver'])]:
- session.xenapi.VDI.destroy(vdi_ref)
- FAIL("VBD_get_driver returned wrong information")
res = session.xenapi.VBD.get_mode(vbd_ref)
print "VBD mode: %s" % res
@@ -97,7 +92,7 @@ if res != vdi_ref:
res = session.xenapi.VBD.get_device(vbd_ref)
print "VBD device: %s" % res
-if res != vbd_rec['device']+":disk":
+if res != vbd_rec['device']:
session.xenapi.VDI.destroy(vdi_ref)
FAIL("VBD_get_device returned wrong result")
@@ -105,7 +100,6 @@ if vbd_ref not in res:
if vbd_ref not in res:
session.xenapi.VDI.destroy(vdi_ref)
FAIL("VM_get_VBDS does not show created VBD")
-
rc = domain.start()
@@ -118,7 +112,6 @@ except ConsoleError, e:
session.xenapi.VDI.destroy(vdi_ref)
FAIL("Could not access proc-filesystem")
-
domain.stop()
domain.destroy()
diff -r 5126f0847654 -r 6c2362ce82c9
tools/xm-test/tests/xapi/03_xapi-network_pos.py
--- a/tools/xm-test/tests/xapi/03_xapi-network_pos.py Thu Aug 20 10:27:37
2009 +0100
+++ b/tools/xm-test/tests/xapi/03_xapi-network_pos.py Thu Aug 20 10:30:53
2009 +0100
@@ -1,71 +1,123 @@
#!/usr/bin/python
-
-# Try and create two VMs and a private network betwene the two
+#============================================================================
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of version 2.1 of the GNU Lesser General Public
+# License as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#============================================================================
+# Copyright (C) 2009 flonatel GmbH & Co. KG
+#============================================================================
+#
+# Author: Andreas Florath <xen@xxxxxxxxxxxx>
+# Loosly based on the original testcase from
+# Tom Wilkie <tom.wilkie@xxxxxxxxx>
+#
+# This test case creates two guest systems, creates a (very) private
+# network between them and attaches the ethernet apropriate.
+# Note: in this test case there are some fixed IP and network
+# addresses used. This is not a problem, because those are really
+# used only for local communication.
+#
import sys
+import time
from XmTestLib import *
from XmTestLib.network_utils import *
+from XmTestLib.XenAPIDomain import XmTestAPIDomain
+
+# Some config for this testcase
+class TCConfig:
+ network_name = "xapi-network-xm-test-03"
+
+ ip_addr_1 = "172.16.77.70"
+ ip_addr_2 = "172.16.77.71"
+ default_gateway = "172.16.77.72"
+ default_netmask = "255.255.255.0"
+
+ @staticmethod
+ def remove_network(guest):
+ nw = guest.session.xenapi.network.get_all()
+ for n in nw:
+ name = guest.session.xenapi.network.get_name_label(n)
+ if name == TCConfig.network_name:
+ guest.session.xenapi.network.destroy(n)
+
# Create two domains (default XmTestDomain, with our ramdisk)
try:
- domain1 = XmTestDomain()
- console1 = domain1.start()
- domain2 = XmTestDomain()
- console2 = domain2.start()
+ guest1 = XmTestAPIDomain()
+ console1 = guest1.start()
+# guest1.newDevice(XenNetDevice, "eth0")
+# guest1_netdev = guest1.getDevice("eth0")
+ guest2 = XmTestAPIDomain()
+ console2 = guest2.start()
except DomainError, e:
if verbose:
- print "Failed to create test domain because:"
- print e.extra
+ print("Failed to create test domain because: %s" % e.extra)
FAIL(str(e))
+# Clean up relicts
+TCConfig.remove_network(guest1)
+
# Create a network
-
-status, ouptut = traceCommand("xm network-new xapi-network")
-if status:
- FAIL(output)
+network = guest1.session.xenapi.network.create(
+ { "name_label": TCConfig.network_name,
+ "name_description": "This is a testing network",
+ "default_gateway": TCConfig.default_gateway,
+ "default_netmask": TCConfig.default_netmask,
+ "other_config": {} } )
# Attach two domains to it
-status, msg = network_attach(domain1.getName(),
- console1, bridge='xapi-network')
+status, msg = network_attach(
+ guest1.getName(), console1, bridge=TCConfig.network_name)
if status:
FAIL(msg)
-status, msg = network_attach(domain2.getName(),
- console2, bridge='xapi-network')
+status, msg = network_attach(
+ guest2.getName(), console2, bridge=TCConfig.network_name)
if status:
FAIL(msg)
-# Configure IP addresses on two domains
+# Configure IP addresses on two guests
try:
- # Run 'ls'
- run = console1.runCmd("ifconfig eth0 172.30.206.1 netmask 255.255.255.0
up")
- run = console2.runCmd("ifconfig eth0 172.30.206.2 netmask 255.255.255.0
up")
+ run = console1.runCmd(
+ "ifconfig eth0 " + TCConfig.ip_addr_1
+ + " netmask " + TCConfig.default_netmask + " up")
+ run = console2.runCmd(
+ "ifconfig eth0 " + TCConfig.ip_addr_2
+ + " netmask " + TCConfig.default_netmask + " up")
except ConsoleError, e:
saveLog(console.getHistory())
FAIL(str(e))
# Now ping...
try:
- run = console1.runCmd("ping -c 4 172.30.206.2")
+ run = console1.runCmd("ping -c 4 " + TCConfig.ip_addr_2)
if run['return'] > 0:
FAIL("Could not ping other host")
- run = console2.runCmd("ping -c 4 172.30.206.1")
+ run = console2.runCmd("ping -c 4 " + TCConfig.ip_addr_1)
if run['return'] > 0:
FAIL("Could not pint other host")
except ConsoleError, e:
saveLog(console.getHistory())
FAIL(str(e))
-status, msg = network_detach(domain1.getName(), console1)
-status, msg = network_detach(domain2.getName(), console2)
+status, msg = network_detach(guest1.getName(), console1)
+status, msg = network_detach(guest2.getName(), console2)
# Clean up
-domain1.closeConsole()
-domain1.stop()
-domain2.closeConsole()
-domain2.stop()
+TCConfig.remove_network(guest1)
+guest1.closeConsole()
+guest1.stop()
+guest2.closeConsole()
+guest2.stop()
-status, ouptut = traceCommand("xm network-del xapi-network")
-if status:
- FAIL(output)
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|