Single domU, ping loopback and the local eth0.

Signed-off-by: Jim Dykman <dykman@us.ibm.com>
This commit is contained in:
emellor@leeni.uk.xensource.com committed 2005-12-09 10:40:00 +00:00
1 parent bb1275eca8
commit ef4e38f80a
3 files changed
+192

No files matched your search

+79
View File
@@ -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@us.ibm.com>
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"
@@ -0,0 +1,84 @@
#!/usr/bin/python
# Copyright (C) International Business Machines Corp., 2005
# Author: <dykman@us.ibm.com>
# 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)
+29
View File
@@ -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 *~
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.