It's not complete yet, we will merge it to master once it is finished.
---
tests/anaconda/dvd_install.py | 378 -----------------------------------------
tests/anaconda/ks.cfg | 54 ------
2 files changed, 0 insertions(+), 432 deletions(-)
delete mode 100755 tests/anaconda/dvd_install.py
delete mode 100755 tests/anaconda/ks.cfg
diff --git a/tests/anaconda/dvd_install.py b/tests/anaconda/dvd_install.py
deleted file mode 100755
index 5bcd350..0000000
--- a/tests/anaconda/dvd_install.py
+++ /dev/null
@@ -1,378 +0,0 @@
-#!/usr/bin/python
-# Anaconda Test Suite - install testing
-#
-# basic usage: ./dvd_install.py -n VMname -k KickstartFile -a Arch -i DVD_image
-# some example of tests:
-#./dvd_install.py -k
http://server/ks.cfg -a i386 -i DVD_image.iso |tee test.log
-#./dvd_install.py -k /path/to/ks.cfg -a i386 -i DVD_image.iso |tee test.log
-#./dvd_install.py -n VMname -k
http://server/ks.cfg -a x86_64 -i DVD_image.iso |tee
test.log
-# Copyright 2009, Red Hat, Inc.
-#
-# 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.
-#
-# Author: Liam Li <lili(a)redhat.com>
-
-import os
-import sys
-import rpm
-import time
-import gconf
-import select
-import commands
-import optparse
-import ConfigParser
-import curses
-from subprocess import *
-from SimpleXMLRPCServer import SimpleXMLRPCServer
-
-console = None
-pollobj = select.poll()
-data = ''
-
-def parse_args():
- archlist = ['i386', 'x86_64']
- parse = optparse.OptionParser(usage="dvd_install.py -n VMname -k KickstartFile
-a Arch -i DVD_image",version="%prog 1.0")
-
parse.add_option("-a","--arch",action="store",type="choice",choices=archlist,default=get_basearch(),dest="arch")
-
parse.add_option("-k","--kickstart",action="store",dest="kickstart")
-
parse.add_option("-i","--image",action="store",dest="image")
-
parse.add_option("-n","--name",action="store",dest="name")
- (opt,args) = parse.parse_args()
- return opt
-
-def get_basearch():
- '''get the system's arch'''
- arch = os.uname()[4]
- if arch in ('i486','i586','i686'):
- arch = 'i386'
- elif arch == 'x86_64':
- arch = arch
- else:
- arch = 'Unsupport'
- print "Auto install only support i386 and x86_64"
- return arch
-
-def user_env_check():
- login_id = os.getuid()
- login_user = os.environ['LOGNAME']
- print "log in user uid is: %s, user name is: %s" % (login_id, login_user)
- if login_id == 0 and login_user == "root" :
- gconf_val =
gconf.client_get_default().get_bool('/desktop/gnome/interface/accessibility')
- print "accessibility support is: %s" % gconf_val
- if gconf_val != True:
- print "Setting accessibility to True..."
-
gconf.client_get_default().set_bool('/desktop/gnome/interface/accessibility',
True)
- else :
- print "ERROR: Can't be run as a normal user!!"
- print "You may have to run 'su -' or log in gnome as root!!"
- sys.exit(1)
-
-def package_check(package_name):
- rpm_state = False
- rpm_ts = rpm.TransactionSet()
- rpm_query = rpm_ts.dbMatch('name', package_name)
- for i in rpm_query:
- print "%s-%s-%s was found in system." %
(i['name'],i['version'],i['release'])
- rpm_state = True
- if not rpm_state:
- print "Package %s was not installed in system,please install it
first!!" % package_name
- return rpm_state
-
-def input_text(str):
- import dogtail.procedural
- for s in str:
- if ord(s) >=65 and ord(s) <= 90:
- dogtail.procedural.keyCombo("<Shift>%s" % chr(ord(s)+32))
- elif ord(s) == 58:
- dogtail.procedural.keyCombo("<Shift>colon")
- else:
- dogtail.procedural.type(s)
-
-def get_kickstart_file(ksfile):
- if os.path.exists(ksfile):
- time.sleep(1)
- ksfile = os.path.split(ksfile)[1]
- kstype = 'local'
- else :
- ksfile = ksfile
- kstype = 'remote'
- return (ksfile, kstype)
-
-def set_disk(name, ksfile, kstype):
- if kstype == 'local':
- disk = [
- '--disk', 'path=/var/lib/libvirt/images/%s.img,size=8' %
name,
- '--disk', 'path=/var/lib/libvirt/images/ks.img' ]
- kickstart = 'hd:/dev/vdb1:/%s' % ksfile
- else :
- disk = [
- '--disk', 'path=/var/lib/libvirt/images/%s.img,size=8' % name
]
- kickstart = ksfile
- return (disk, kickstart)
-
-def put_local_ks(ksfile):
- import guestfs
- print "creating object..."
- g = guestfs.GuestFS()
- f = open("/var/lib/libvirt/images/ks.img", "w")
- f.truncate (500 * 1024 * 1024)
- f.close()
- g.add_drive("/var/lib/libvirt/images/ks.img")
- g.launch()
- g.sfdiskM("/dev/sda",["4",])
- print "disk was formatted\n"
- g.mkfs("ext3", "/dev/sda1")
- print "file system was created\n"
- g.mount("/dev/sda1", "/")
- g.upload(opt.kickstart, "/%s" % ksfile)
- g.sync()
- g.umount_all()
-
-def poll_and_read(wait=None, blocksize=4096):
- data = ''
- events = pollobj.poll(wait*1000)
- if not events:
- print "Read nothing from tty\n "
- return None
- for (fd, event) in events:
- assert fd == console.fileno()
- if (event & (select.POLLIN | select.POLLPRI)):
- data += os.read(fd,blocksize)
- else:
- print_to_screen('?')
- return data
-
-def print_to_screen(dot='.', out=sys.stdout):
- out.write(dot)
- out.flush()
-
-def read_until(condition, readtimeout=60,max_wait=10800):
- global data
- start = time.time()
- while(time.time() - start) < max_wait:
- newdata = poll_and_read(readtimeout)
- if newdata is None:
- break
- print_to_screen(newdata)
- data += newdata
- if condition(data):
- return data
- os.system('clear')
- print_to_screen('error!,did not get output data\n')
-
-
-def create_guest(dvd_image, name, kickstart, disk):
- "Create a new virt guest"
- virt_args = [
- '--name', name,
- '--ram' , '768',
- '--vcpus', '1',
- '--os-type', 'linux',
- '--os-variant', 'fedora13',
- '--cdrom', dvd_image,
- '--accelerate',
- '--noautoconsole' ]
- create_command = ['virt-install'] + virt_args + disk
- print "create command is: %s" % create_command
- retval = call(create_command)
- if retval !=0:
- delete(name)
- print "virt-install failed: %i" % retval
- sys.exit(1)
- return name
-
-def delete(name):
- vmstate = get_vmstate(name)
- if vmstate == 'running' or vmstate == 'paused' or vmstate ==
'idle' :
- call(["virsh", "destroy", name])
- call(["virsh", "undefine", name])
- elif vmstate == None :
- print "vm %s was not found,nothing to do." % name
- else :
- call(["virsh","undefine", name])
-
-def clean_guest(name):
- print "Cleaning up guest %s ...\n" % name
- delete(name)
-
-def pass_boot_args(vmname, ks):
- import dogtail.procedural
- print "Begin to start virt-viewer\n"
- dogtail.procedural.run("virt-viewer","%s" % vmname)
- print "mouse focus on the viewer\n"
- time.sleep(2)
- dogtail.procedural.focus.application('virt-viewer')
- dogtail.procedural.focus.frame('%s - Virt Viewer' % vmname)
- dogtail.procedural.click('', roleName='unknown', raw=True)
- dogtail.procedural.keyCombo("Tab")
- dogtail.procedural.keyCombo("Tab")
- time.sleep(2)
- if len(ks) >1:
- input_text(" serial console=ttyS0 ks=%s" % ks )
- else:
- print "kickstart args error!\n"
- sys.exit(1)
- time.sleep(2)
- dogtail.procedural.keyCombo("Return")
- dogtail.procedural.keyCombo("<Control><Alt>")
-
-def close_win(name):
- import dogtail.procedural
- print "begin to close window"
- dogtail.procedural.focus.frame('%s - Virt Viewer' % name)
- dogtail.procedural.click('File', roleName='menu item')
- dogtail.procedural.click('Quit', roleName='menu item')
-
-def get_vmstate(name):
- if name :
- status,line = commands.getstatusoutput('virsh list --all |grep %s' %
name)
- time.sleep(1)
- if line :
- vmstate = line.split()[2]
- return vmstate
-
-def opentty(name):
- p = Popen(['virsh', 'ttyconsole', name], stdout=PIPE)
- (output, dummy) = p.communicate()
- tty = output.strip()
- assert os.path.exists(tty)
- print "tty is %s" % tty
- global console
- console = open(tty)
- print "console is : %s" % console
- pollobj.register(console, select.POLLIN)
- return (tty, console)
-
-def closetty(console):
- pollobj.unregister(console)
- console.close()
-
-def kernel_boot_test(name):
- print "start to open tty\n"
- (tty, console) = opentty(name)
- print "Serial console at %s" % tty
- print "Begin to poll and read....\n"
- data = read_until(lambda data: "\nGreetings." in data, 60, 300)
- if data:
- version = "[unknow]"
- for line in data.splitlines():
- if line.startswith("Linux version 2."):
- version = line.split()[2]
- break
- time.sleep(1)
- print "\nkernel version %s booted, initrd started OK" % version
- return version
- print "Test failed,boot timeout reached.\n"
- clean_guest(name)
- error_complete()
- sys.exit(1)
- return False
-
-def loader_stage2_test(name, readtimeout=300):
- print "polling for stage2 startup message"
- global data
- condition = lambda data: "Running anaconda" in data
- data = read_until(condition, readtimeout)
- if data:
- time.sleep(1)
- line = data[data.rfind("Running anaconda"):]
- version = line.split()[2]
- version = version.strip(",")
- time.sleep(1)
- print "\nanaconda %s stage2 has started" % version
- print "\nloader stage2 was successfully completed."
- return version
- print "Test failed,loader stage2 timeout reached.\n"
- error_complete()
- clean_guest(name)
- sys.exit(1)
-
-def anaconda_package_installation(name, readtimeout = 10800):
- global data
- condition = lambda data: "Reboot" in data
- data = read_until(condition, readtimeout)
- if data:
- time.sleep(5)
- os.system('clear')
- print_to_screen('\n\nPackage Installation completed successfully\n')
- return True
- print "\n Package Installation failed, timeout reached\n"
- error_complete()
- clean_guest(name)
- sys.exit(1)
-
-def error_complete():
- print "\n== testing complete ==\n"
- print "The error was detected above,test failed,test result is fail!!"
-
-if __name__ == '__main__':
- user_env_check()
- opt = parse_args()
- if opt.image is None and opt.kickstart is None:
- print "usage: ./dvd_install.py -n VMname -k KickstartFile -a Arch -i
DVD_image"
- print "For example:"
- print "./dvd_install.py -k
http://server/ks.cfg -a i386 -i DVD_image |tee
test.log\n"
- sys.exit(1)
- sys_arch = get_basearch()
- if not opt.arch == sys_arch:
- print "The current system does not support your test image arch"
- sys.exit(1)
- if not package_check('qemu-kvm'):
- print "KVM was not installed in system, you have to install virtualization
first"
- print "more information,please see
at:http://fedoraproject.org/wiki/Virtualization_Quick_Start"
- sys.exit(1)
- if not package_check('python-libguestfs'):
- sys.exit(1)
- if not package_check('dogtail'):
- sys.exit(1)
- if opt.name == None:
- vmname = 'fedoratest'
- else:
- vmname = opt.name
- if not get_vmstate(vmname) :
- delete(vmname)
- (kickstart, kstype) = get_kickstart_file(opt.kickstart)
- if kstype == 'local':
- print "Creating disk to save local kickstart file...."
- put_local_ks(kickstart)
- (disk, kickstart) = set_disk(vmname, kickstart, kstype)
-
- try:
- print "Start to create virtual machine: %s" % vmname
- name = create_guest(opt.image, vmname, kickstart, disk)
-
- print "\n== start to pass kernel boot arguments ==\n"
- pass_boot_args(name, kickstart)
-
- print "\n== kernel boot test ==\n"
- kernel_boot_test(name)
-
- close_win(name)
-
- print "\n== anaconda loading stage2 test ==\n"
- loader_stage2_test(name)
-
- if anaconda_package_installation(name):
- closetty(console)
- time.sleep(5)
- print "\nTest is sucessful and test result is pass,system will be shut
off..."
-
- except (Exception, KeyboardInterrupt), e:
- print "\nCaught execption.Deleting failed guest."
- error_complete()
- clean_guest(name)
- raise
-
- print "\n== testing complete ==\n"
- clean_guest(name)
diff --git a/tests/anaconda/ks.cfg b/tests/anaconda/ks.cfg
deleted file mode 100755
index 5bf1267..0000000
--- a/tests/anaconda/ks.cfg
+++ /dev/null
@@ -1,54 +0,0 @@
-# Install a fresh system rather than upgrade an existing system
-install
-# Perform the kickstart installation in text mode
-text
-# Install from an installation tree on a remote server via FTP or HTTP
-
-#nfs --server=10.66.70.83 --dir=/lili/f12-beta-tc/iso_i386
-#nfs --server=10.66.65.50 --dir=/home/liam/vmware/ppc
-url --url
http://download.englab.nay.redhat.com/pub/fedora/linux/releases/12/Fedora...
-#url --url ftp://192.168.1.100
-# Sets the language to use during installation
-lang en_US.UTF-8
-# Sets the language(s) to install on the system
-#langsupport en_US
-# Sets system keyboard type
-keyboard us
-# auto mouse
-#mouse
-# Sets up the authentication options for the system
-authconfig --enableshadow --enablemd5
-# Sets the system time zone
-timezone America/New_York
-# Configures network information for the system
-#network --device eth0 --bootproto bootp # doesn't seem to work
-network --device eth0 --mtu=1500 --bootproto dhcp
-#network --device eth0 --bootproto static --ip=192.168.0.51 --netmask=255.255.255.0 -\
-#-gateway=192.168.0.1 --nameserver=192.168.0.1
-# Sets the system's root password to "whatever"
-rootpw 111111
-# no firewall
-firewall --disabled
-# No SE Linux!
-selinux --disabled
-# Specifies how the GRUB boot loader should be installed
-bootloader --location mbr
-# Removes partitions from the system, prior to creation of new partitions
-clearpart --all --initlabel
-autopart
-#part Boot --fstype PPC PReP Boot --size 4
-#part /boot --fstype ext4 --size 200
-#part / --fstype ext2 --size 5120
-#part swap --fstype swap --size 512
-# Package Selection
-%packages
-#@X Window System
-#@GNOME Desktop Environment
-#@Graphical Internet
-@Sound and Video
-%end
-## Post-installation Script
-%post
-rpm --import /usr/share/rhn/RPM-GPG-KEY-fedora
-# magic config
-
--
1.7.3.2