From patchwork Tue Mar 2 14:29:44 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yogi X-Patchwork-Id: 83179 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o22ETrQb007687 for ; Tue, 2 Mar 2010 14:29:53 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753215Ab0CBO3v (ORCPT ); Tue, 2 Mar 2010 09:29:51 -0500 Received: from e28smtp06.in.ibm.com ([122.248.162.6]:49276 "EHLO e28smtp06.in.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751390Ab0CBO3u (ORCPT ); Tue, 2 Mar 2010 09:29:50 -0500 Received: from d28relay05.in.ibm.com (d28relay05.in.ibm.com [9.184.220.62]) by e28smtp06.in.ibm.com (8.14.3/8.13.1) with ESMTP id o22ETmOK017184 for ; Tue, 2 Mar 2010 19:59:48 +0530 Received: from d28av01.in.ibm.com (d28av01.in.ibm.com [9.184.220.63]) by d28relay05.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o22ETlaD2965532 for ; Tue, 2 Mar 2010 19:59:48 +0530 Received: from d28av01.in.ibm.com (loopback [127.0.0.1]) by d28av01.in.ibm.com (8.14.3/8.13.1/NCO v10.0 AVout) with ESMTP id o22ETkJS019905 for ; Tue, 2 Mar 2010 19:59:47 +0530 Received: from localhost.localdomain (yogi-laptop.in.ibm.com [9.124.158.64]) by d28av01.in.ibm.com (8.14.3/8.13.1/NCO v10.0 AVin) with ESMTP id o22ETkZD019898; Tue, 2 Mar 2010 19:59:46 +0530 From: Yogananth Subramanian To: lmr@redhat.com Cc: anantyog@linux.vnet.ibm.com, autotest@test.kernel.org, kvm@vger.kernel.org Subject: [PATCH 1/2] [Autotest] [KVM-AUTOTEST] Parallel install of guest OS Date: Tue, 2 Mar 2010 19:59:44 +0530 Message-Id: <1267540185-30761-2-git-send-email-anantyog@linux.vnet.ibm.com> X-Mailer: git-send-email 1.6.0.4 In-Reply-To: <1267540185-30761-1-git-send-email-anantyog@linux.vnet.ibm.com> References: <1267540185-30761-1-git-send-email-anantyog@linux.vnet.ibm.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Tue, 02 Mar 2010 14:29:53 +0000 (UTC) diff --git a/client/tests/kvm/scripts/unattended.py b/client/tests/kvm/scripts/unattended.py index 63c01b1..ea822a9 100755 --- a/client/tests/kvm/scripts/unattended.py +++ b/client/tests/kvm/scripts/unattended.py @@ -59,8 +59,11 @@ class UnattendedInstall(object): self.cdrom_iso = os.path.join(kvm_test_dir, cdrom_iso) self.floppy_mount = tempfile.mkdtemp(prefix='floppy_', dir='/tmp') self.cdrom_mount = tempfile.mkdtemp(prefix='cdrom_', dir='/tmp') - self.floppy_img = os.path.join(images_dir, 'floppy.img') - + flopy_name = os.path.basename(os.environ['KVM_TEST_floppy']) + self.floppy_img = os.path.join(images_dir, flopy_name) + self.pxe_dir = os.environ['KVM_TEST_pxe_dir'] + self.pxe_image = os.environ['KVM_TEST_pxe_image'] + self.pxe_initrd = os.environ['KVM_TEST_pxe_initrd'] def create_boot_floppy(self): """ @@ -96,7 +99,10 @@ class UnattendedInstall(object): elif self.unattended_file.endswith('.ks'): dest_fname = 'ks.cfg' elif self.unattended_file.endswith('.xml'): - dest_fname = "autounattend.xml" + if self.tftp_root is '': + dest_fname = "autounattend.xml" + else: + dest_fname = "autoinst.xml" dest = os.path.join(self.floppy_mount, dest_fname) @@ -166,21 +172,20 @@ class UnattendedInstall(object): raise SetupError('Could not mount CD image %s.' % self.cdrom_iso) - p = os.path.join('images', 'pxeboot') - pxe_dir = os.path.join(self.cdrom_mount, p) - pxe_image = os.path.join(pxe_dir, 'vmlinuz') - pxe_initrd = os.path.join(pxe_dir, 'initrd.img') + pxe_dir = os.path.join(self.cdrom_mount, self.pxe_dir) + pxe_image = os.path.join(pxe_dir, self.pxe_image) + pxe_initrd = os.path.join(pxe_dir, self.pxe_initrd) if not os.path.isdir(pxe_dir): raise SetupError('The ISO image does not have a %s dir. The ' 'script assumes that the cd has a %s dir ' 'where to search for the vmlinuz image.' % - (p, p)) + (self.pxe_dir, self.pxe_dir)) if not os.path.isfile(pxe_image) or not os.path.isfile(pxe_initrd): raise SetupError('The location %s is lacking either a vmlinuz ' 'or a initrd.img file. Cannot find a PXE ' - 'image to proceed.' % pxe_dir) + 'image to proceed.' % self.pxe_dir) tftp_image = os.path.join(self.tftp_root, 'vmlinuz') tftp_initrd = os.path.join(self.tftp_root, 'initrd.img') diff --git a/client/tests/kvm/tests/unattended_install.py b/client/tests/kvm/tests/unattended_install.py index e3df72a..3978e26 100644 --- a/client/tests/kvm/tests/unattended_install.py +++ b/client/tests/kvm/tests/unattended_install.py @@ -13,11 +13,11 @@ def run_unattended_install(test, params, env): @param params: Dictionary with the test parameters. @param env: Dictionary with test environment. """ + buf = 1024 vm = kvm_test_utils.get_living_vm(env, params.get("main_vm")) - server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - server.bind(('', 12323)) - server.listen(1) + port = vm.get_port(int(params.get("guest_port_unattend_shell"))) + addr = ('localhost', port) install_timeout = float(params.get("timeout", 3000)) logging.info("Starting unattended install watch process. " @@ -26,21 +26,19 @@ def run_unattended_install(test, params, env): start_time = time.time() while True: - server.settimeout(install_timeout) + client = socket.socket(socket.AF_INET, socket.SOCK_STREAM) try: - (client, addr) = server.accept() - except socket.timeout: - server.close() - raise error.TestFail('Timeout elapsed while waiting for install to ' - 'finish.') - msg = client.recv(1024) - logging.debug("Received '%s' from %s", msg, addr) - if msg == 'done': - end_time = time.time() - time_elapsed = int(end_time - start_time) - logging.info('Guest reported successful installation after %ds ' - '(%d min)', time_elapsed, time_elapsed/60) - server.close() - break - else: - logging.error('Got invalid string from client: %s.' % msg) + client.connect(addr) + msg = client.recv(1024) + if msg == 'thank u for connecting': + break + else: + raise Exception + except: + time.sleep(1) + client.close() + + end_time = time.time() + time_elapsed = int(end_time - start_time) + logging.info('Guest reported successful installation after %ds ' + '(%d min)', time_elapsed, time_elapsed/60) diff --git a/client/tests/kvm/tests_base.cfg.sample b/client/tests/kvm/tests_base.cfg.sample index 040d0c3..b4f7b34 100644 --- a/client/tests/kvm/tests_base.cfg.sample +++ b/client/tests/kvm/tests_base.cfg.sample @@ -33,6 +33,7 @@ used_mem = 512 # Port redirections redirs = remote_shell guest_port_remote_shell = 22 +guest_port_unattend_shell = 12323 # NIC parameters nic_mode = user @@ -515,6 +516,9 @@ variants: block_hotplug: modprobe_module = acpiphp unattended_install: + pxe_dir = "images/pxeboot" + pxe_image = "vmlinuz" + pxe_initrd = "initrd.img" tftp = "images/tftpboot" extra_params += " -bootp /pxelinux.0 -boot n" kernel_args = "ks=floppy nicdelay=60" @@ -614,6 +618,8 @@ variants: md5sum_1m = 0dbeb8f58d213752d8c029e8601abfbb unattended_install: unattended_file = unattended/RHEL-5-series.ks + tftp = "images/rhel54-32/tftpboot" + floppy = "images/rhel54-32floppy.img" - 5.4.x86_64: no setup @@ -623,6 +629,8 @@ variants: md5sum_1m = 3e74112003e88a966754849dbb8f5c3f unattended_install: unattended_file = unattended/RHEL-5-series.ks + tftp = "images/rhel54-64/tftpboot" + floppy = "images/rhel54-64floppy.img" # Windows section - @Windows: diff --git a/client/tests/kvm/unattended/RHEL-5-series.ks b/client/tests/kvm/unattended/RHEL-5-series.ks index 41bb391..aea4150 100644 --- a/client/tests/kvm/unattended/RHEL-5-series.ks +++ b/client/tests/kvm/unattended/RHEL-5-series.ks @@ -28,10 +28,10 @@ os.system('dhclient') os.system('chkconfig sshd on') os.system('iptables -F') os.system('echo 0 > /selinux/enforce') -port = 12323 -buf = 1024 -addr = ('10.0.2.2', port) -client = socket.socket(socket.AF_INET, socket.SOCK_STREAM) -client.connect(addr) -client.sendto('done', addr) +os.system('dhclient eth0') +server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) +server.bind(('', 12323)) +server.listen(1) +(client, addr) = server.accept() +client.send("thank u for connecting") client.close()