[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH RFC 3/5] Introduce ts-ovmf-debian-install



This is OVMF guest test case. It resembles ts-redhat-install:
1. prepare a auto install CD
2. install OVMF guest
3. test if the guets is up

Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx>
---
 ts-ovmf-debian-install |  251 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 251 insertions(+)
 create mode 100755 ts-ovmf-debian-install

diff --git a/ts-ovmf-debian-install b/ts-ovmf-debian-install
new file mode 100755
index 0000000..723bf4f
--- /dev/null
+++ b/ts-ovmf-debian-install
@@ -0,0 +1,251 @@
+#!/usr/bin/perl -w
+# This is part of "osstest", an automated testing framework for Xen.
+# Copyright (C) 2009-2013 Citrix Inc.
+# 
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 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 Affero General Public License for more details.
+# 
+# You should have received a copy of the GNU Affero General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+use strict qw(vars);
+use DBI;
+use Osstest;
+use Osstest::TestSupport;
+
+tsreadconfig();
+
+our $stage=0;
+if (@ARGV && $ARGV[0] =~ m/^--stage(\d+)$/) { $stage=$1; shift @ARGV; }
+
+our ($whhost,$gn) = @ARGV;
+$whhost ||= 'host';
+$gn ||= 'ovmf';
+
+our $ho= selecthost($whhost);
+
+our $ram_mb=    768;
+our $disk_mb= 10000;
+
+our $guesthost= "$gn.guest.osstest";
+our $gho;
+
+our $xl= toolstack()->{Command};
+
+
+sub preseed () {
+
+    return <<"END";
+#### Contents of the preconfiguration file (for wheezy)
+#### Prepared for OVMF guest -- liuw
+
+d-i mirror/suite string wheezy
+
+d-i debian-installer/locale string en_GB
+d-i console-keymaps-at/keymap select gb
+d-i keyboard-configuration/xkb-keymap string en_GB
+
+d-i netcfg/get_hostname string ovmf-test
+d-i netcfg/get_domain string
+d-i netcfg/wireless_wep string
+
+d-i mirror/country string manual
+d-i mirror/http/proxy string
+
+d-i clock-setup/utc boolean true
+d-i time/zone string Europe/London
+d-i clock-setup/ntp boolean true
+
+d-i partman-auto/disk string /dev/xvda
+d-i partman-auto/method string  regular
+d-i partman-md/device_remove_md boolean true
+d-i partman-lvm/device_remove_lvm boolean true
+d-i partman-partitioning/confirm_write_new_label boolean true
+d-i partman/choose_partition select finish
+d-i partman/confirm boolean true
+d-i partman-lvm/confirm boolean true
+
+d-i partman/confirm_nooverwrite true
+d-i partman-lvm/confirm_nooverwrite true
+d-i partman-md/confirm_nooverwrite true
+d-i partman-crypto/confirm_nooverwrite true
+
+d-i partman-auto/expert_recipe string \\
+       boot-root :: \\
+               512 50 512 vfat \\
+                       \$primary{ } \$bootable{ } \\
+                       method{ efi } format{ } \\
+                       use_filesystem{ } filesystem{ vfat } \\
+                       mountpoint{ /boot/efi } \\
+               . \\
+               5000 50 5000 ext4 \\
+                       method{ format } format{ } \\
+                       use_filesystem{ } filesystem{ ext4 } \\
+                       mountpoint{ / } \\
+               . \\
+               512 30 100% linux-swap \\
+                       method{ swap } format{ } \\
+               .
+
+
+d-i passwd/root-password password xenroot
+d-i passwd/root-password-again password xenroot
+d-i passwd/user-fullname string FLOSS Xen Test
+d-i passwd/username string osstest
+d-i passwd/user-password password osstest
+d-i passwd/user-password-again password osstest
+
+console-common  console-data/keymap/policy      select  Don't touch keymap
+console-data    console-data/keymap/policy      select  Don't touch keymap
+console-data    console-data/keymap/family      select  qwerty
+console-data console-data/keymap/template/layout select British
+
+d-i apt-setup/use_mirror boolean false
+d-i apt-setup/another boolean false
+d-i apt-setup/non-free boolean false
+d-i apt-setup/contrib boolean false
+d-i apt-setup/cdrom/set-first boolean false
+
+popularity-contest popularity-contest/participate boolean false
+tasksel tasksel/first multiselect standard
+
+d-i pkgsel/include string openssh-server, ntp, ntpdate, 
+
+d-i grub-installer/only_debian boolean true
+
+d-i finish-install/keep-consoles boolean true
+d-i finish-install/reboot_in_progress note
+d-i cdrom-detect/eject boolean false
+
+d-i preseed/early_command string
+
+d-i preseed/late_command string \\
+       in-target mkdir -p /boot/efi/EFI/boot; \\
+       in-target cp /boot/efi/EFI/debian/grubx64.efi 
/boot/efi/EFI/boot/bootx64.efi ;\\
+       in-target mkdir -p /root/.ssh; \\
+        cp /authorized_keys /target/root/.ssh
+
+d-i clock-setup/ntp-server string ntp.uk.xensource.com
+
+END
+
+}
+
+sub grub_cfg () {
+
+    return <<"END";
+set default="0"
+set timeout=5
+
+menuentry 'OVMF guest auto Install' {
+    linux /install.amd/vmlinuz console=vga console=ttyS0,115200n8 
preseed/file=/preseed.cfg
+    initrd /install.amd/initrd.gz
+}
+END
+}
+
+our $emptyiso= '/root/empty.iso';
+
+sub prep () {
+    target_install_packages_norec($ho, qw(lvm2 rsync xorriso genisoimage));
+
+    my $isotimeout= 600;
+
+    $gho= prepareguest($ho, $gn, $guesthost, 22,
+                       $disk_mb + 1,
+                       100);
+
+    my $newiso= '/root/newiso';
+    my $emptydir= '/root/empty-dir';
+    my $initrddir= '/root/initrd-dir';
+
+    my @isogen_base= qw(-R -J -T);
+    my @xorriso_opts= qw(-as mkisofs
+                         -r
+                         -b isolinux/isolinux.bin
+                         -c isolinux/boot.cat
+                         -no-emul-boot
+                         -boot-load-size 4
+                         -boot-info-table
+                         -eltorito-alt-boot
+                         -e boot/grub/efi.img
+                         -no-emul-boot);
+
+    target_putfilecontents_root_stash($ho, 10, preseed(),
+                                      "/root/ovmf-guest-preseed");
+    target_putfilecontents_root_stash($ho, 10, authorized_keys(),
+                                      "/root/ovmf-guest-authkeys");
+    target_cmd_root($ho, <<END, 60);
+            mkdir -p $emptydir
+            genisoimage -o $emptyiso @isogen_base $emptydir/.
+END
+
+    more_prepareguest_hvm($ho,$gho, $ram_mb, $disk_mb,
+                          OnReboot => 'preserve',
+                          Bios => 'ovmf',
+                          PostImageHook => sub {
+        target_cmd_root($ho, <<END, $isotimeout);
+            set -x
+            umount /mnt ||:
+            rm -rf $newiso
+            mount -o loop -r $gho->{Rimage} /mnt
+            mkdir $newiso
+            cp -a /mnt/. $newiso/.
+            umount /mnt
+            rm -rf $initrddir
+            mkdir $initrddir
+            cd $initrddir
+            gzip -d \< $newiso/install.amd/initrd.gz | cpio --extract 
--make-directories --no-absolute-filename
+            cp /root/ovmf-guest-preseed preseed.cfg
+            cp /root/ovmf-guest-authkeys authorized_keys
+            find . | cpio -H newc --create | gzip -9 \> 
$newiso/install.amd/initrd.gz
+            cd -
+            rm -rf $initrddir
+            cd $newiso
+            md5sum `find -follow -type f` \> md5sum.txt
+            cd -
+END
+        target_putfilecontents_root_stash($ho, 10, grub_cfg(),
+                                         "$newiso/debian/boot/grub/grub.cfg");
+
+       target_cmd_root($ho, <<END, $isotimeout);
+           xorriso  @xorriso_opts -o $gho->{Rimage} $newiso/.
+END
+    });
+}
+
+sub start () {
+    target_cmd_root($ho, "$xl create $gho->{CfgPath}", 100);
+}
+
+sub rewrite_config_nocd () {
+    guest_editconfig($ho, $gho, sub {
+        if (m/^\s*disk\s*\=/ .. /\]/) {
+            s/\Q$gho->{Rimage}\E/$emptyiso/;
+        }
+        s/^on_reboot.*/on_reboot='restart'/;
+    });
+}
+
+if (!$stage) {
+    prep();
+    start();
+} else {
+    $gho= selectguest($gn,$gho);
+}
+if ($stage<2) {
+    guest_await_reboot($ho,$gho,2000);
+    guest_destroy($ho,$gho);
+}
+
+rewrite_config_nocd();
+start();
+guest_await_dhcp_tcp($gho,300);
+guest_check_up($gho);
-- 
1.7.10.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.