[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] Single domU, ping loopback and the local eth0.



# HG changeset patch
# User emellor@xxxxxxxxxxxxxxxxxxxxxx
# Node ID a22ad856d19969b13cfecfe7244a2dcf355d154d
# Parent  06b7f33e954cb1309b774f527563bff931fefb28
Single domU, ping loopback and the local eth0.

Signed-off-by: Jim Dykman <dykman@xxxxxxxxxx>

diff -r 06b7f33e954c -r a22ad856d199 tools/xm-test/lib/XmTestLib/Network.py
--- /dev/null   Fri Dec  9 10:39:31 2005
+++ b/tools/xm-test/lib/XmTestLib/Network.py    Fri Dec  9 10:40:00 2005
@@ -0,0 +1,79 @@
+#!/usr/bin/python
+"""
+ Network.py - Common utilities for network tests
+
+ Copyright (C) International Business Machines Corp., 2005
+ Author: Jim Dykman <dykman@xxxxxxxxxx>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; under version 2 of the License.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+"""
+import sys;
+import os;
+import atexit;
+
+from Test import *
+from Xm import *
+
+class NetworkError(Exception):
+    def __init__(self, msg):
+        self.errMsg = msg
+
+    def __str__(self):
+        return str(self.errMsg)
+
+def undo_dom0_alias(eth, ip):
+    traceCommand("ip addr del " + ip + " dev " + eth)
+
+class XmNetwork:
+
+    def __init__(self):
+        # Check for existing zeroconf address. We are using the zeroconf 
+        # address range as static IP addresses.... if someone is using 
+        # real zeroconf addresses, then we're going to skip tests to 
+        # avoid interfering with them.
+        rc, out = traceCommand(
+                  "ip addr show |grep \"inet 169.254\" | grep -v vif")
+
+        if rc == 0:
+            SKIP("Zeroconf address found: " + out)
+
+    def calc_ip_address(self, dom, interface):
+        # Generate an IP address from the dom# and eth#:
+        #      169.254.(eth#+153).(dom#+10)
+        ethnum = int(interface[len("eth"):])
+        domnum = int(dom[len("dom"):])
+        return "169.254."+ str(ethnum+153) + "." + str(domnum+10)
+
+    def ip(self, dom, interface, todomname=None, toeth=None):
+        newip = self.calc_ip_address(dom, interface)
+
+        # If the testcase is going to talk to dom0, we need to add an 
+        # IP address in the proper subnet
+        if dom == "dom0":
+            # The domain's vif is a convenient place to add to
+            vifname = "vif" + str(domid(todomname)) + "." + toeth[3:]
+
+            # register the exit handler FIRST, just in case
+            atexit.register(undo_dom0_alias, vifname, newip)
+
+            # add the alias
+            status, output = traceCommand("ip addr add " + newip + 
+                                              " dev " + vifname)
+            if status:
+                SKIP("\"ip addr add\" failed")
+        return newip
+
+    def mask(self, dom, interface):
+        return "255.255.255.0"
diff -r 06b7f33e954c -r a22ad856d199 
tools/xm-test/tests/network/02_network_local_ping_pos.py
--- /dev/null   Fri Dec  9 10:39:31 2005
+++ b/tools/xm-test/tests/network/02_network_local_ping_pos.py  Fri Dec  9 
10:40:00 2005
@@ -0,0 +1,84 @@
+#!/usr/bin/python
+
+# Copyright (C) International Business Machines Corp., 2005
+# Author:  <dykman@xxxxxxxxxx>
+
+# Ping tests on local interfaces.
+#  - creates a single guest domain
+#  - sets up a single NIC
+#  - conducts ping tests to the local loopback and IP address.
+
+# ping -c 1 -s $size 127.0.0.1
+# ping -c 1 -s $size $local_IP 
+#   where $size = 1, 48, 64, 512, 1440, 1500, 1505, 
+#                 4096, 4192, 32767, 65507, 65508
+
+pingsizes = [ 1, 48, 64, 512, 1440, 1500, 1505, 4096, 4192, 
+              32767, 65507 ]
+
+
+
+from XmTestLib import *
+rc = 0
+
+Net = XmNetwork()
+
+# read an IP address from the config
+ip   = Net.ip("dom1", "eth0")
+mask = Net.mask("dom1", "eth0")
+
+# Fire up a guest domain w/1 nic
+domain = XmTestDomain(extraOpts={ 'nics' : 1 })
+try:
+    domain.configSetVar('vif', " [ 'ip=" + ip + "' ]")
+    domain.start()
+except DomainError, e:
+    if verbose:
+        print "Failed to create test domain because:"
+        print e.extra
+    FAIL(str(e))
+
+
+# Attach a console
+try:
+    console = XmConsole(domain.getName(), historySaveCmds=True)
+except ConsoleError, e:
+    FAIL(str(e))
+
+try:
+    # Activate the console
+    console.sendInput("bhs")
+
+    # Bring up the "lo" interface.
+    console.runCmd("ifconfig lo up")
+
+    console.runCmd("ifconfig eth0 inet "+ip+" netmask "+mask+" up")
+
+    # First the loopback pings
+    lofails=""
+    for size in pingsizes:
+        out = console.runCmd("ping -q -c 1 -s " + str(size) + " 127.0.0.1")
+        if out["return"]:
+            lofails += " " + str(size)
+
+    # Next comes eth0
+    eth0fails=""
+    for size in pingsizes:
+        out = console.runCmd("ping -q -c 1 -s " + str(size) + " " + ip)
+        if out["return"]:
+            eth0fails += " " + str(size) 
+except ConsoleError, e:
+        FAIL(str(e))
+except NetworkError, e:
+        FAIL(str(e))
+
+
+# Tally up failures
+failures=""
+if len(lofails):
+        failures += "ping loopback failed for size" + lofails + ". "
+if len(eth0fails):
+        failures += "ping eth0 failed for size" + eth0fails + "."
+if len(failures):
+    FAIL(failures)
+
diff -r 06b7f33e954c -r a22ad856d199 tools/xm-test/tests/network/Makefile.am
--- /dev/null   Fri Dec  9 10:39:31 2005
+++ b/tools/xm-test/tests/network/Makefile.am   Fri Dec  9 10:40:00 2005
@@ -0,0 +1,29 @@
+
+SUBDIRS =
+
+TESTS = \
+       02_network_local_ping_pos.test          \
+       05_network_dom0_ping_pos.test           \
+       11_network_domU_ping_pos.test
+
+
+
+XFAIL_TESTS =                          \
+       02_network_local_ping_pos.test          \
+       05_network_dom0_ping_pos.test           \
+       11_network_domU_ping_pos.test
+
+EXTRA_DIST = $(TESTS) $(XFAIL_TESTS)
+
+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 *~

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.