rpms/python-virtinst/F-11 virtinst-0.400.3-add-cli-test.patch, NONE, 1.1 python-virtinst.spec, 1.72, 1.73
Cole Robinson
crobinso at fedoraproject.org
Tue Oct 6 15:10:01 UTC 2009
Author: crobinso
Update of /cvs/pkgs/rpms/python-virtinst/F-11
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv7035
Modified Files:
python-virtinst.spec
Added Files:
virtinst-0.400.3-add-cli-test.patch
Log Message:
Add CLI tests from upstream.
virtinst-0.400.3-add-cli-test.patch:
setup.py | 25
tests/cli-test-xml/clone-disk.xml | 34 +
tests/cli-test-xml/faketree/images/boot.iso | 1
tests/cli-test-xml/faketree/images/pxeboot/initrd.img | 1
tests/cli-test-xml/faketree/images/pxeboot/vmlinuz | 1
tests/cli-test-xml/image.xml | 38 +
tests/clitest.py | 489 ++++++++++++++++++
7 files changed, 587 insertions(+), 2 deletions(-)
--- NEW FILE virtinst-0.400.3-add-cli-test.patch ---
diff -Nrup virtinst-0.400.3/setup.py new/setup.py
--- virtinst-0.400.3/setup.py 2009-03-09 23:34:29.000000000 -0400
+++ new/setup.py 2009-06-18 14:46:45.023790000 -0400
@@ -58,14 +58,34 @@ class TestCommand(TestBaseCommand):
'''
testfiles = []
for t in glob(pjoin(self._dir, 'tests', '*.py')):
- if not t.endswith('__init__.py') and \
- not t.endswith("urltest.py"):
+ if (not t.endswith('__init__.py') and
+ not t.endswith("urltest.py") and
+ not t.endswith("clitest.py")):
testfiles.append('.'.join(
['tests', splitext(basename(t))[0]])
)
self._testfiles = testfiles
TestBaseCommand.run(self)
+class TestCLI(TestBaseCommand):
+
+ description = "Test various CLI invocations"
+
+ user_options = (TestBaseCommand.user_options +
+ [("prompt", None, "Run interactive CLI invocations.")])
+
+ def initialize_options(self):
+ TestBaseCommand.initialize_options(self)
+ self.prompt = 0
+
+ def run(self):
+ cmd = "python tests/clitest.py"
+ if self.debug:
+ cmd += " debug"
+ if self.prompt:
+ cmd += " prompt"
+ os.system(cmd)
+
class TestURLFetch(TestBaseCommand):
description = "Test fetching kernels and isos from various distro trees"
@@ -281,6 +301,7 @@ setup(name='virtinst',
packages=pkgs,
data_files = datafiles,
cmdclass = { 'test': TestCommand, 'test_urls' : TestURLFetch,
+ 'test_cli' : TestCLI,
'check': CheckPylint,
'rpm' : custom_rpm,
'sdist': sdist, 'build': build,
diff -Nrup virtinst-0.400.3/tests/clitest.py new/tests/clitest.py
--- virtinst-0.400.3/tests/clitest.py 1969-12-31 19:00:00.000000000 -0500
+++ new/tests/clitest.py 2009-06-18 14:46:28.081167000 -0400
@@ -0,0 +1,489 @@
+#
+# 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; either version 2 of the License, or
+# (at your option) any later version.
+#
+# 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., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301 USA.
+
+import commands
+import os, sys
+
+# Location
+xmldir = "tests/cli-test-xml"
+treedir = "tests/cli-test-xml/faketree"
+
+# Images that will be created by virt-install/virt-clone, and removed before
+# each run
+new_images = [ "cli_new1.img", "cli_new2.img", "cli_new3.img",
+ "cli_exist1-clone.img", "cli_exist2-clone.img"]
+
+# Images that are expected to exist before a command is run
+exist_images = [ "cli_exist1.img", "cli_exist2.img" ]
+
+# Images that need to exist ahead of time for virt-image
+virtimage_exist = [os.path.join(xmldir, "cli_root.raw")]
+
+# Images created by virt-image
+virtimage_new = [os.path.join(xmldir, "cli_scratch.raw")]
+
+exist_files = exist_images + virtimage_exist
+new_files = new_images + virtimage_new
+clean_files = new_images + exist_images + virtimage_exist + virtimage_new
+
+test_files = {
+ 'CLONE_DISK_XML' : "%s/clone-disk.xml" % xmldir,
+ 'IMAGE_XML' : "%s/image.xml" % xmldir,
+ 'NEWIMG1' : new_images[0],
+ 'NEWIMG2' : new_images[1],
+ 'NEWIMG3' : new_images[2],
+ 'EXISTIMG1' : exist_images[0],
+ 'EXISTIMG2' : exist_images[1],
+}
+
+debug = False
+testprompt = False
+
+"""
+CLI test matrix
+
+Format:
+
+"appname" {
+ "global_args" : Arguments to be passed to every app invocation
+
+ "categoryfoo" : { Some descriptive test catagory name (e.g. storage)
+
+ "categoryfoo_args" : Args to be applied to all invocations in category
+
+ "valid" : { # Argument strings that should succeed
+ "--option --string --number1" # Some option string to test. The
+ resulting cmdstr would be:
+ $ appname global_args categoryfoo_args --option --string --number1
+ }
+
+ "invalid" : { # Argument strings that should fail
+ "--opt1 --opt2",
+ }
+ } # End categoryfoo
+
+ "prompt" : { # Special category that will launch an interactive command.
+ # which is only run if special args are passed to the test
+ "--some --prompt --command --string"
+ }
+}
+ "
+"""
+args_dict = {
+
+
+ "virt-install" : {
+ "global_args" : " --connect test:///default -d --name foobar --ram 64",
+
+ "storage" : {
+ "storage_args": "--pxe --nographics --noautoconsole --hvm",
+
+ "valid" : [
+ # Existing file, other opts
+ "--file %(EXISTIMG1)s --nonsparse --file-size 4",
+ # Existing file, no opts
+ "--file %(EXISTIMG1)s",
+ # Multiple existing files
+ "--file %(EXISTIMG1)s --file virt-image --file virt-clone",
+ # Nonexistent file
+ "--file %(NEWIMG1)s --file-size .00001 --nonsparse",
+
+ # Existing disk, lots of opts
+ "--disk path=%(EXISTIMG1)s,perms=ro,size=.0001,cache=writethrough",
+ # Existing floppy
+ "--disk path=%(EXISTIMG1)s,device=floppy",
+ # Existing disk, no extra options
+ "--disk path=%(EXISTIMG1)s",
+ # Create volume in a pool
+ "--disk pool=default-pool,size=.0001",
+ ],
+
+ "invalid": [
+ # Nonexisting file, size too big
+ "--file %(NEWIMG1)s --file-size 100000 --nonsparse",
+ # Huge file, sparse, but no prompting
+ "--file %(NEWIMG1)s --file-size 100000",
+ # Nonexisting file, no size
+ "--file %(NEWIMG1)s",
+ # Size, no file
+ "--file-size .0001",
+ # Specify a nonexistent pool
+ "--disk pool=foopool,size=.0001",
+ # Specify a nonexistent volume
+ "--disk vol=default-pool/foovol",
+ # Specify a pool with no size
+ "--disk pool=default-pool",
+ ]
+ }, # category "storage"
+
+ "install" : {
+ "install_args": "--nographics --noautoconsole --nodisks",
+
+ "valid" : [
+ # Simple cdrom install
+ "--hvm --cdrom %(EXISTIMG1)s",
+ # Windows (2 stage) install
+ #"--hvm --wait 0 --os-variant winxp --cdrom %(EXISTIMG1)s",
+ # Explicit virt-type
+ #"--hvm --pxe --virt-type test",
+ # Explicity fullvirt + arch
+ "--arch i686 --pxe",
+ # Convert i*86 -> i686
+ #"--arch i486 --pxe",
+ # Directory tree URL install
+ #"--hvm --location %s" % treedir,
+ # Directory tree CDROM install
+ #"--hvm --cdrom %s" % treedir,
+ ],
+
+ "invalid": [
+ # Bogus virt-type
+ #"--hvm --pxe --virt-type bogus",
+ # Bogus arch
+ "--hvm --pxe --arch bogus",
+ # PXE w/ paravirt
+ "--paravirt --pxe",
+ # Import with no disks
+ "--import",
+ # LiveCD with no media
+ "--livecd",
+ ],
+ }, # category "install"
+
+ "graphics": {
+ "graphics_args": "--noautoconsole --nodisks --pxe",
+
+ "valid": [
+ # SDL
+ "--sdl",
+ # VNC w/ lots of options
+ #"--vnc --keymap ja --vncport 5950 --vnclisten 1.2.3.4",
+ ],
+
+ "invalid": [
+ # Invalid keymap
+ #"--vnc --keymap ZZZ",
+ # Invalid port
+ "--vnc --vncport -50",
+ ],
+
+ }, # category "graphics"
+
+ "misc": {
+ "misc_args": "--nographics --noautoconsole",
+
+ "valid": [
+ # Specifying cdrom media via --disk
+ "--hvm --disk path=virt-install,device=cdrom",
+ # FV Import install
+ "--hvm --import --disk path=virt-install",
+ # PV Import install
+ "--paravirt --import --disk path=virt-install",
+ ],
+
+ "invalid": [
+ # pxe and nonetworks
+ "--nodisks --pxe --nonetworks",
+ ],
+ }, # category "misc"
+
+ "network": {
+ "network_args": "--pxe --nographics --noautoconsole --nodisks",
+
+ "valid": [
+ # Just a macaddr
+ "--mac 11:22:33:44:55:66",
+ # user networking
+ "--network=user",
+ # Old bridge option
+ "--bridge mybr0",
+ # Old bridge w/ mac
+ "--bridge mybr0 --mac 11:22:33:44:55:66",
+ # --network bridge:
+ "--network bridge:mybr0,model=e1000",
+ # VirtualNetwork with a random macaddr
+ "--network network:default --mac RANDOM",
+ # VirtualNetwork with a random macaddr
+ "--network network:default --mac 00:11:22:33:44:55",
+ # Using '=' as the net type delimiter
+ #"--network network=default,mac=11:00:11:00:11:00",
+ # with NIC model
+ #"--network=user,model=e1000",
+ # several networks
+ #"--network=network:default,model=e1000 --network=user,model=virtio,mac=11:22:33:44:55:66",
+ ],
+ "invalid": [
+ # Nonexistent network
+ "--network=FOO",
+ # Invalid mac
+ "--network=network:default --mac 1234",
+ # More mac addrs than nics
+ "--network user --mac 00:11:22:33:44:55 --mac 00:11:22:33:44:66",
+ # Mixing bridge and network
+ "--network user --bridge foo0",
+ ],
+
+ }, # category "network"
+
+
+ "prompt" : [ " --connect test:///default --debug --prompt" ]
+ },
+
+
+
+
+ "virt-clone": {
+ "global_args" : " --connect test:///default -d",
+
+ "general" : {
+ "general_args": "-n clonetest ",
+
+ "valid" : [
+ # Nodisk guest
+ "-o test",
+ # Nodisk, but with spurious files passed
+ "-o test --file %(NEWIMG1)s --file %(NEWIMG2)s",
+
+ # XML File with 2 disks
+ "--original-xml %(CLONE_DISK_XML)s --file %(NEWIMG1)s --file %(NEWIMG2)s",
+ # XML w/ disks, overwriting existing files with --preserve
+ "--original-xml %(CLONE_DISK_XML)s --file virt-install --file %(EXISTIMG1)s --preserve",
+ # XML w/ disks, force copy a readonly target
+ "--original-xml %(CLONE_DISK_XML)s --file %(NEWIMG1)s --file %(NEWIMG2)s --file %(NEWIMG3)s --force-copy=hdc",
+ # XML w/ disks, force copy a target with no media
+ "--original-xml %(CLONE_DISK_XML)s --file %(NEWIMG1)s --file %(NEWIMG2)s --force-copy=fda",
+ ],
+
+ "invalid": [
+ # Non-existent vm name
+ "-o idontexist --force",
+ # Non-existent vm name with auto flag,
+ #"-o idontexist --auto-clone",
+ # Colliding new name
+ "-o test -n test --force",
+ # XML file with several disks, but non specified
+ "--original-xml %(CLONE_DISK_XML)s --force",
+ # XML w/ disks, overwriting existing files with no --preserve
+ #"--original-xml %(CLONE_DISK_XML)s --file virt-install --file %(EXISTIMG1)s",
+ # XML w/ disks, force copy but not enough disks passed
+ "--original-xml %(CLONE_DISK_XML)s --file %(NEWIMG1)s --file %(NEWIMG2)s --force-copy=hdc --force",
+ ]
+ }, # category "general"
+
+ "misc" : {
+ "misc_args": "",
+
+ "valid" : [
+ # Auto flag, no storage
+ #"-o test --auto-clone",
+ # Auto flag w/ storage,
+ #"--original-xml %(CLONE_DISK_XML)s --auto-clone",
+ ],
+
+ "invalid" : [
+ # Just the auto flag
+ #"--auto-clone"
+ ]
+ }, # category "misc"
+
+ "prompt" : [ " --connect test:///default --debug --prompt",
+ " --connect test:///default --debug --original-xml %(CLONE_DISK_XML)s --prompt" ]
+ }, # app 'virt-clone'
+
+
+
+
+ 'virt-image': {
+ "global_args" : " --connect test:///default -d %(IMAGE_XML)s",
+
+ "general" : {
+ "general_args" : "--name test-image",
+
+ "valid": [
+ # All default values
+ "",
+ # Manual boot idx 0
+ "--boot 0",
+ # Manual boot idx 1
+ "--boot 1",
+ # Lots of options
+ "--name foobar --ram 64 --os-variant winxp",
+ ],
+
+ "invalid": [
+ # Out of bounds index
+ "--boot 10",
+ ],
+ }, # category 'general'
+
+ "graphics" : {
+ "graphics_args" : "--name test-image --boot 0",
+
+ "valid": [
+ # SDL
+ "--sdl",
+ # VNC w/ lots of options
+ #"--vnc --keymap ja --vncport 5950 --vnclisten 1.2.3.4",
+ ],
+
+ "invalid": [],
+ },
+
+ "misc": {
+ "misc_args" : "",
+
+ "valid" : [],
+ "invalid" : [
+ # No name specified, and no prompt flag
+ "",
+ ],
+
+ }, # category 'misc'
+
+ "network": {
+ #"network_args": "--name test-image --boot 0 --nographics",
+ "network_args": "--name test-image --boot 0",
+
+ "valid": [
+ # user networking
+ "--network=user",
+ # VirtualNetwork with a random macaddr
+ "--network network:default --mac RANDOM",
+ # VirtualNetwork with a random macaddr
+ "--network network:default --mac 00:11:22:33:44:55",
+ # with NIC model
+ #"--network=user,model=e1000",
+ # several networks
+ #"--network=network:default,model=e1000 --network=user,model=virtio",
+ # no networks
+ #"--nonetworks",
+ ],
+ "invalid": [
+ # Nonexistent network
+ "--network=FOO",
+ # Invalid mac
+ "--network=network:default --mac 1234",
+ ],
+
+ }, # category "network"
+ "prompt" : [ " --connect test:///default %(IMAGE_XML)s --debug --prompt" ],
+
+ } # app 'virt-image'
+}
+
+def runcomm(comm):
+ for i in new_files:
+ os.system("rm %s > /dev/null 2>&1" % i)
+
+ if debug:
+ print comm % test_files
+
+ ret = commands.getstatusoutput(comm % test_files)
+ if debug:
+ print ret[1]
+ print "\n"
+
+ return ret
+
+def run_prompt_comm(comm):
+ print comm
+ os.system(comm % test_files)
+
+def assertPass(comm):
+ ret = runcomm(comm)
+ if ret[0] is not 0:
+ raise AssertionError("Expected command to pass, but failed.\n" + \
+ "Command was: %s\n" % (comm) + \
+ "Error code : %d\n" % ret[0] + \
+ "Output was:\n%s" % ret[1])
+
+def assertFail(comm):
+ ret = runcomm(comm)
+ if ret[0] is 0:
+ raise AssertionError("Expected command to fail, but passed.\n" + \
+ "Command was: %s\n" % (comm) + \
+ "Error code : %d\n" % ret[0] + \
+ "Output was:\n%s" % ret[1])
+
+# Setup: build cliarg dict, which uses
+def run_tests():
+ for app in args_dict:
+ unique = {}
+ prompts = []
+ global_args = ""
+
+ # Build default command line dict
+ for option in args_dict.get(app):
+ if option == "global_args":
+ global_args = args_dict[app][option]
+ continue
+ elif option == "prompt":
+ prompts = args_dict[app][option]
+ continue
+
+ # Default is a unique cmd string
+ unique[option]= args_dict[app][option]
+
+ # Build up prompt cases
+ if testprompt:
+ for optstr in prompts:
+ cmd = "./" + app + " " + optstr
+ run_prompt_comm(cmd)
+ continue
+
+ # Build up unique command line cases
+ for category in unique.keys():
+ catdict = unique[category]
+ category_args = catdict["%s_args" % category]
+
+ for optstr in catdict["valid"]:
+ cmdstr = "./%s %s %s %s" % (app, global_args,
+ category_args, optstr)
+ assertPass(cmdstr)
+
+ for optstr in catdict["invalid"]:
+ cmdstr = "./%s %s %s %s" % (app, global_args,
+ category_args, optstr)
+ assertFail(cmdstr)
+
+def main():
+ # CLI Args
+ global debug
+ global testprompt
+
+ if len(sys.argv) > 1:
+ for i in range(1, len(sys.argv)):
+ if sys.argv[i].count("debug"):
+ debug = True
+ elif sys.argv[i].count("prompt"):
+ testprompt = True
+
+ # Setup needed files
+ for i in exist_files:
+ if os.path.exists(i):
+ raise ValueError("'%s' will be used by testsuite, can not already"
+ " exist." % i)
+ os.system("touch %s" % i)
+
+ try:
+ run_tests()
+ finally:
+ # Cleanup files
+ for i in clean_files:
+ os.system("rm %s > /dev/null 2>&1" % i)
+
+if __name__ == "__main__":
+ main()
diff -Nrup virtinst-0.400.3/tests/cli-test-xml/clone-disk.xml new/tests/cli-test-xml/clone-disk.xml
--- virtinst-0.400.3/tests/cli-test-xml/clone-disk.xml 1969-12-31 19:00:00.000000000 -0500
+++ new/tests/cli-test-xml/clone-disk.xml 2009-06-18 14:46:28.102170000 -0400
@@ -0,0 +1,34 @@
+<domain type='test' id='1'>
+ <name>origtest</name>
+ <uuid>db69fa1f-eef0-e567-3c20-3ef16f10376b</uuid>
+ <memory>8388608</memory>
+ <currentMemory>2097152</currentMemory>
+ <vcpu>2</vcpu>
+ <os>
+ <type arch='i686'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <disk type='file' device='disk'>
+ <target dev='hda' bus='ide'/>
+ <source file='cli_exist1.img'/>
+ </disk>
+ <disk type='file' device='disk'>
+ <target dev='hdb' bus='ide'/>
+ <source file='cli_exist2.img'/>
+ </disk>
+ <disk type='file' device='cdrom'>
+ <target dev='hdc' bus='ide'/>
+ <source file='cli_exist2.img'/>
+ <readonly/>
+ </disk>
+ <disk type='file' device='floppy'>
+ <target dev='fda' bus='fdc'/>
+ <readonly/>
+ </disk>
+ </devices>
+</domain>
diff -Nrup virtinst-0.400.3/tests/cli-test-xml/faketree/images/boot.iso new/tests/cli-test-xml/faketree/images/boot.iso
--- virtinst-0.400.3/tests/cli-test-xml/faketree/images/boot.iso 1969-12-31 19:00:00.000000000 -0500
+++ new/tests/cli-test-xml/faketree/images/boot.iso 2009-06-18 14:46:28.110167000 -0400
@@ -0,0 +1 @@
+testiso
diff -Nrup virtinst-0.400.3/tests/cli-test-xml/faketree/images/pxeboot/initrd.img new/tests/cli-test-xml/faketree/images/pxeboot/initrd.img
--- virtinst-0.400.3/tests/cli-test-xml/faketree/images/pxeboot/initrd.img 1969-12-31 19:00:00.000000000 -0500
+++ new/tests/cli-test-xml/faketree/images/pxeboot/initrd.img 2009-06-18 14:46:28.114169000 -0400
@@ -0,0 +1 @@
+testinitrd
diff -Nrup virtinst-0.400.3/tests/cli-test-xml/faketree/images/pxeboot/vmlinuz new/tests/cli-test-xml/faketree/images/pxeboot/vmlinuz
--- virtinst-0.400.3/tests/cli-test-xml/faketree/images/pxeboot/vmlinuz 1969-12-31 19:00:00.000000000 -0500
+++ new/tests/cli-test-xml/faketree/images/pxeboot/vmlinuz 2009-06-18 14:46:28.112171000 -0400
@@ -0,0 +1 @@
+testvmlinuz
diff -Nrup virtinst-0.400.3/tests/cli-test-xml/image.xml new/tests/cli-test-xml/image.xml
--- virtinst-0.400.3/tests/cli-test-xml/image.xml 1969-12-31 19:00:00.000000000 -0500
+++ new/tests/cli-test-xml/image.xml 2009-06-18 14:46:28.104169000 -0400
@@ -0,0 +1,38 @@
+<image>
+ <label>A simple test image</label>
+ <domain>
+ <boot type='xen'>
+ <guest>
+ <os_type>xen</os_type>
+ <arch>i686</arch>
+ <features><pae/></features>
+ </guest>
+ <os>
+ <loader>pygrub</loader>
+ </os>
+ <drive disk="cli_root.raw" target="xvda"/>
+ <drive disk="cli_scratch.raw" target="xvdc"/>
+ </boot>
+ <boot type="hvm">
+ <guest>
+ <arch>i686</arch>
+ <features><pae/></features>
+ </guest>
+ <os>
+ <type>hvm</type>
+ <loader dev="hd"/>
+ </os>
+ <drive disk="cli_root.raw" target="hda"/>
+ </boot>
+ <devices>
+ <vcpu>7</vcpu>
+ <memory>262144</memory>
+ <interface/>
+ <graphics/>
+ </devices>
+ </domain>
+ <storage>
+ <disk file="cli_root.raw" format="raw" size="4096" use="system"/>
+ <disk file="cli_scratch.raw" format="raw" size='100' use='scratch'/>
+ </storage>
+</image>
Index: python-virtinst.spec
===================================================================
RCS file: /cvs/pkgs/rpms/python-virtinst/F-11/python-virtinst.spec,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -p -r1.72 -r1.73
--- python-virtinst.spec 5 Oct 2009 19:09:09 -0000 1.72
+++ python-virtinst.spec 6 Oct 2009 15:10:00 -0000 1.73
@@ -47,6 +47,8 @@ Patch14: %{appname}-%{version}-f12-distr
Patch15: %{appname}-%{version}-sasl-auth.patch
# Use ACPI for windows on KVM (bz 479977)
Patch16: %{appname}-%{version}-windows-acpi.patch
+# Add CLI tests
+Patch17: %{appname}-%{version}-add-cli-test.patch
License: GPLv2+
Group: Development/Libraries
@@ -90,6 +92,7 @@ and install new VMs) and virt-clone (clo
%patch14 -p1
%patch15 -p1
%patch16 -p1
+%patch17 -p1
%build
python setup.py build
More information about the fedora-extras-commits
mailing list