aboutsummaryrefslogtreecommitdiffstats
path: root/tools/xm-test
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2009-08-20 10:30:53 +0100
committerKeir Fraser <keir.fraser@citrix.com>2009-08-20 10:30:53 +0100
commitf0321cbffa61f08db52799a10d6d85ab59a238e0 (patch)
treee2f9e8d62fd6d79fa4f33cdbf51a85d34ab781c4 /tools/xm-test
parent1ef2f79d046aa91462f15e10adc4aee09f8cdec8 (diff)
downloadxen-f0321cbffa61f08db52799a10d6d85ab59a238e0.tar.gz
xen-f0321cbffa61f08db52799a10d6d85ab59a238e0.tar.bz2
xen-f0321cbffa61f08db52799a10d6d85ab59a238e0.zip
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@flonatel.org>
Diffstat (limited to 'tools/xm-test')
-rw-r--r--tools/xm-test/grouptest/default1
-rw-r--r--tools/xm-test/lib/XmTestLib/XenAPIDomain.py3
-rw-r--r--tools/xm-test/lib/XmTestLib/XenDevice.py3
-rw-r--r--tools/xm-test/lib/XmTestLib/xapi.py25
-rwxr-xr-xtools/xm-test/runtest.sh4
-rw-r--r--tools/xm-test/tests/xapi/02_xapi-vbd_basic.py21
-rw-r--r--tools/xm-test/tests/xapi/03_xapi-network_pos.py114
7 files changed, 105 insertions, 66 deletions
diff --git a/tools/xm-test/grouptest/default b/tools/xm-test/grouptest/default
index d82ca73d21..1db6a73398 100644
--- a/tools/xm-test/grouptest/default
+++ b/tools/xm-test/grouptest/default
@@ -29,3 +29,4 @@ unpause
vcpu-disable
vcpu-pin
vtpm
+xapi
diff --git a/tools/xm-test/lib/XmTestLib/XenAPIDomain.py b/tools/xm-test/lib/XmTestLib/XenAPIDomain.py
index 31b91eed68..3c5310f061 100644
--- a/tools/xm-test/lib/XmTestLib/XenAPIDomain.py
+++ b/tools/xm-test/lib/XmTestLib/XenAPIDomain.py
@@ -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 --git a/tools/xm-test/lib/XmTestLib/XenDevice.py b/tools/xm-test/lib/XmTestLib/XenDevice.py
index 688b39e543..d51ee28ef7 100644
--- a/tools/xm-test/lib/XmTestLib/XenDevice.py
+++ b/tools/xm-test/lib/XmTestLib/XenDevice.py
@@ -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 --git a/tools/xm-test/lib/XmTestLib/xapi.py b/tools/xm-test/lib/XmTestLib/xapi.py
index 773b3c1739..de552ef171 100644
--- a/tools/xm-test/lib/XmTestLib/xapi.py
+++ b/tools/xm-test/lib/XmTestLib/xapi.py
@@ -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 xen.xm.opts import OptionError
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 --git a/tools/xm-test/runtest.sh b/tools/xm-test/runtest.sh
index 287d6cf701..13f9c87118 100755
--- a/tools/xm-test/runtest.sh
+++ b/tools/xm-test/runtest.sh
@@ -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 --git a/tools/xm-test/tests/xapi/02_xapi-vbd_basic.py b/tools/xm-test/tests/xapi/02_xapi-vbd_basic.py
index 294e6baf21..7b14702e08 100644
--- a/tools/xm-test/tests/xapi/02_xapi-vbd_basic.py
+++ b/tools/xm-test/tests/xapi/02_xapi-vbd_basic.py
@@ -1,7 +1,9 @@
#!/usr/bin/python
# Copyright (C) International Business Machines Corp., 2007
-# Author: Stefan Berger <stefanb@us.ibm.com>
+# Copyright (C) flonatel GmbH & Co. KG
+# Authors: Stefan Berger <stefanb@us.ibm.com>
+# Andreas Florath <xen@flonatel.org>
# 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",
@@ -72,12 +73,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
# FIXME: Check this. Should not have to subtract '1'.
@@ -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")
@@ -106,7 +101,6 @@ if vbd_ref not in res:
session.xenapi.VDI.destroy(vdi_ref)
FAIL("VM_get_VBDS does not show created VBD")
-
rc = domain.start()
console = domain.getConsole()
@@ -118,7 +112,6 @@ except ConsoleError, e:
session.xenapi.VDI.destroy(vdi_ref)
FAIL("Could not access proc-filesystem")
-
domain.stop()
domain.destroy()
diff --git a/tools/xm-test/tests/xapi/03_xapi-network_pos.py b/tools/xm-test/tests/xapi/03_xapi-network_pos.py
index 9ae2daea1b..900d487907 100644
--- a/tools/xm-test/tests/xapi/03_xapi-network_pos.py
+++ b/tools/xm-test/tests/xapi/03_xapi-network_pos.py
@@ -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@flonatel.org>
+# Loosly based on the original testcase from
+# Tom Wilkie <tom.wilkie@gmail.com>
+#
+# 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))
-# Create a network
+# Clean up relicts
+TCConfig.remove_network(guest1)
-status, ouptut = traceCommand("xm network-new xapi-network")
-if status:
- FAIL(output)
+# Create a network
+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)