From: Murillo Fernandes Bernardes <mfb@br.ibm.com>
To: xen-devel@lists.xensource.com
Subject: [PATCH][XM-TEST] Add network-attach tests
Date: Tue, 22 Nov 2005 14:59:44 -0200 [thread overview]
Message-ID: <200511221459.45010.mfb@br.ibm.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 152 bytes --]
Add some network-attach tests
Signed-off-by: Murillo Fernandes Bernardes <mfb@br.ibm.com>
--
Murillo Fernandes Bernardes
IBM Linux Technology Center
[-- Attachment #2: network-attach_xm-test.patch --]
[-- Type: text/x-diff, Size: 7922 bytes --]
# HG changeset patch
# User root@localhost.localdomain
# Node ID 5fcbd8885523fae79eb192c180a9311b6ac71830
# Parent 29b6de0d503ef068609f2c60d54bc00d52b7cbdb
xm-test: add tests for network-attach command
Signed-off-by: Murillo Fernandes Bernardes <mfb@br.ibm.com>
diff -r 29b6de0d503e -r 5fcbd8885523 tools/xm-test/configure.ac
--- a/tools/xm-test/configure.ac Tue Nov 22 16:50:17 2005
+++ b/tools/xm-test/configure.ac Tue Nov 22 16:52:33 2005
@@ -50,6 +50,7 @@
tests/memmax/Makefile
tests/memset/Makefile
tests/migrate/Makefile
+ tests/network-attach/Makefile
tests/pause/Makefile
tests/reboot/Makefile
tests/restore/Makefile
diff -r 29b6de0d503e -r 5fcbd8885523 tools/xm-test/tests/Makefile.am
--- a/tools/xm-test/tests/Makefile.am Tue Nov 22 16:50:17 2005
+++ b/tools/xm-test/tests/Makefile.am Tue Nov 22 16:52:33 2005
@@ -13,6 +13,7 @@
list \
memmax \
memset \
+ network-attach \
pause \
reboot \
sedf \
diff -r 29b6de0d503e -r 5fcbd8885523 tools/xm-test/tests/network-attach/01_network_attach_pos.py
--- /dev/null Tue Nov 22 16:50:17 2005
+++ b/tools/xm-test/tests/network-attach/01_network_attach_pos.py Tue Nov 22 16:52:33 2005
@@ -0,0 +1,48 @@
+#!/usr/bin/python
+
+# Copyright (C) International Business Machines Corp., 2005
+# Author: Murillo F. Bernardes <mfb@br.ibm.com>
+
+import sys
+
+from XmTestLib import *
+from network_utils import *
+
+# Create a domain (default XmTestDomain, with our ramdisk)
+domain = XmTestDomain()
+
+try:
+ domain.start()
+except DomainError, e:
+ if verbose:
+ print "Failed to create test domain because:"
+ print e.extra
+ FAIL(str(e))
+
+# Attach a console to it
+try:
+ console = XmConsole(domain.getName(), historySaveCmds=True)
+except ConsoleError, e:
+ FAIL(str(e))
+
+try:
+ # Activate the console
+ console.sendInput("input")
+ # Run 'ls'
+ run = console.runCmd("ls")
+except ConsoleError, e:
+ saveLog(console.getHistory())
+ FAIL(str(e))
+
+## Real test
+status, msg = network_attach(domain.getName(), console)
+if status:
+ FAIL(msg)
+
+
+##
+# Close the console
+console.closeConsole()
+
+# Stop the domain (nice shutdown)
+domain.stop()
diff -r 29b6de0d503e -r 5fcbd8885523 tools/xm-test/tests/network-attach/02_network_attach_detach_pos.py
--- /dev/null Tue Nov 22 16:50:17 2005
+++ b/tools/xm-test/tests/network-attach/02_network_attach_detach_pos.py Tue Nov 22 16:52:33 2005
@@ -0,0 +1,54 @@
+#!/usr/bin/python
+
+# Copyright (C) International Business Machines Corp., 2005
+# Author: Murillo F. Bernardes <mfb@br.ibm.com>
+
+import sys
+import re
+import time
+
+from XmTestLib import *
+from network_utils import *
+
+# Create a domain (default XmTestDomain, with our ramdisk)
+domain = XmTestDomain()
+
+try:
+ domain.start()
+except DomainError, e:
+ if verbose:
+ print "Failed to create test domain because:"
+ print e.extra
+ FAIL(str(e))
+
+# Attach a console to it
+try:
+ console = XmConsole(domain.getName(), historySaveCmds=True)
+except ConsoleError, e:
+ FAIL(str(e))
+
+try:
+ # Activate the console
+ console.sendInput("input")
+ # Run 'ls'
+ run = console.runCmd("ls")
+except ConsoleError, e:
+ saveLog(console.getHistory())
+ FAIL(str(e))
+
+## Real test - attach and detach
+status, msg = network_attach(domain.getName(), console)
+if status:
+ FAIL(msg)
+
+status, msg = network_detach(domain.getName(), console)
+if status:
+ FAIL(msg)
+
+
+
+# Close the console
+console.closeConsole()
+
+# Stop the domain (nice shutdown)
+domain.stop()
diff -r 29b6de0d503e -r 5fcbd8885523 tools/xm-test/tests/network-attach/03_network_attach_detach_multiple_pos.py
--- /dev/null Tue Nov 22 16:50:17 2005
+++ b/tools/xm-test/tests/network-attach/03_network_attach_detach_multiple_pos.py Tue Nov 22 16:52:33 2005
@@ -0,0 +1,54 @@
+#!/usr/bin/python
+
+# Copyright (C) International Business Machines Corp., 2005
+# Author: Murillo F. Bernardes <mfb@br.ibm.com>
+
+import sys
+import re
+import time
+
+from XmTestLib import *
+from network_utils import *
+
+# Create a domain (default XmTestDomain, with our ramdisk)
+domain = XmTestDomain()
+
+try:
+ domain.start()
+except DomainError, e:
+ if verbose:
+ print "Failed to create test domain because:"
+ print e.extra
+ FAIL(str(e))
+
+# Attach a console to it
+try:
+ console = XmConsole(domain.getName(), historySaveCmds=True)
+except ConsoleError, e:
+ FAIL(str(e))
+
+try:
+ # Activate the console
+ console.sendInput("input")
+ # Run 'ls'
+ run = console.runCmd("ls")
+except ConsoleError, e:
+ saveLog(console.getHistory())
+ FAIL(str(e))
+
+for i in range(10):
+ print "Attaching %d device" % i
+ status, msg = network_attach(domain.getName(), console)
+ if status:
+ FAIL(msg)
+
+ print "Detaching %d device" % i
+ status, msg = network_detach(domain.getName(), console, i)
+ if status:
+ FAIL(msg)
+
+# Close the console
+console.closeConsole()
+
+# Stop the domain (nice shutdown)
+domain.stop()
diff -r 29b6de0d503e -r 5fcbd8885523 tools/xm-test/tests/network-attach/04_network_attach_baddomain_neg.py
--- /dev/null Tue Nov 22 16:50:17 2005
+++ b/tools/xm-test/tests/network-attach/04_network_attach_baddomain_neg.py Tue Nov 22 16:52:33 2005
@@ -0,0 +1,17 @@
+#!/usr/bin/python
+
+# Copyright (C) International Business Machines Corp., 2005
+# Author: Murillo F. Bernardes <mfb@br.ibm.com>
+
+from XmTestLib import *
+
+status, output = traceCommand("xm network-attach NOT-EXIST")
+
+eyecatcher = "Error"
+where = output.find(eyecatcher)
+if status == 0:
+ FAIL("xm block-attach returned bad status, expected non 0, status is: %i" % status )
+elif where == -1:
+ FAIL("xm block-attach returned bad output, expected Error, output is: %s" % output )
+
+
diff -r 29b6de0d503e -r 5fcbd8885523 tools/xm-test/tests/network-attach/Makefile.am
--- /dev/null Tue Nov 22 16:50:17 2005
+++ b/tools/xm-test/tests/network-attach/Makefile.am Tue Nov 22 16:52:33 2005
@@ -0,0 +1,24 @@
+
+SUBDIRS =
+
+TESTS = 01_network_attach_pos.test \
+ 02_network_attach_detach_pos.test \
+ 03_network_attach_detach_multiple_pos.test \
+ 04_network_attach_baddomain_neg.test
+
+DISABLED =
+
+EXTRA_DIST = $(TESTS) $(XFAIL_TESTS) network_utils.py
+
+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 *~
diff -r 29b6de0d503e -r 5fcbd8885523 tools/xm-test/tests/network-attach/network_utils.py
--- /dev/null Tue Nov 22 16:50:17 2005
+++ b/tools/xm-test/tests/network-attach/network_utils.py Tue Nov 22 16:52:33 2005
@@ -0,0 +1,37 @@
+#!/usr/bin/python
+
+# Copyright (C) International Business Machines Corp., 2005
+# Author: Murillo F. Bernardes <mfb@br.ibm.com>
+
+from XmTestLib import *
+
+def count_eth(console):
+ try:
+ run = console.runCmd("ifconfig -a | grep eth")
+ except ConsoleError, e:
+ FAIL(str(e))
+ return = len(run['output'].splitlines())
+
+def network_attach(domain_name, console):
+ eths_before = count_eth(console)
+ status, output = traceCommand("xm network-attach %s" % domain_name)
+ if status != 0:
+ return -1, "xm network-attach returned invalid %i != 0" % status
+
+ eths_after = count_eth(console)
+ if (eths_after != (eths_before+1)):
+ return -2, "Network device is not actually connected to domU"
+
+ return 0, None
+
+def network_detach(domain_name, console, num=0):
+ eths_before = count_eth(console)
+ status, output = traceCommand("xm network-detach %s %d" % (domain_name, num))
+ if status != 0:
+ return -1, "xm network-attach returned invalid %i != 0" % status
+
+ eths_after = count_eth(console)
+ if eths_after != (eths_before-1):
+ return -2, "Network device was not actually disconnected from domU"
+
+ return 0, None
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
next reply other threads:[~2005-11-22 16:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-22 16:59 Murillo Fernandes Bernardes [this message]
2005-11-23 11:33 ` [PATCH][XM-TEST] Add network-attach tests Ewan Mellor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200511221459.45010.mfb@br.ibm.com \
--to=mfb@br.ibm.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.