]> xenbits.xensource.com Git - osstest.git/commitdiff
distros: add support for installing Debian PV guests via d-i, flight and jobs
authorIan Campbell <ian.campbell@citrix.com>
Wed, 8 Jul 2015 12:30:51 +0000 (13:30 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Thu, 23 Jul 2015 14:36:59 +0000 (15:36 +0100)
This patch introduces ts-debian-di-install which can install Debian
from a netboot (PXE) debian installer image. By default it installs
from the d-i image used by osstest (using the special Xen PV guest
enabled flavour where necessary) but it can also fetch the kernel and
ramdisk from URLs specified in runvars. The resulting guests boot the
distro kernel using pygrub (pvgrub will follow).

The distros flights differ substantially from the existing flights.
Introduce make-distros-flight using the functionality previously
refactored into mfi-common. The new flight tests all versions of
Debian from Squeeze onward as an amd64, i386 and armhf guests (armhf
from Jessie onwards only) using the usual smoke tests.

Test names are suffixed -pygrub pending the addition of pvgrub
variants in a future commit.

Add the new cases to sg-run-job

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Osstest/TestSupport.pm
make-distros-flight [new file with mode: 0755]
sg-run-job
ts-debian-di-install [new file with mode: 0755]

index 306330eccd0ec3e70a66d4a8dc4443d364417fd5..b872006e25fc2d23989057f62400599f6c102838 100644 (file)
@@ -931,8 +931,11 @@ sub propname_massage ($) {
     return $prop;
 }
 
+# It is fine to call this on a guest object too, in which case it will
+# always return $defval.
 sub get_host_property ($$;$) {
     my ($ho, $prop, $defval) = @_;
+    return $defval unless $ho->{Properties};
     my $val = $ho->{Properties}{propname_massage($prop)};
     return defined($val) ? $val : $defval;
 }
diff --git a/make-distros-flight b/make-distros-flight
new file mode 100755 (executable)
index 0000000..bdca7d1
--- /dev/null
@@ -0,0 +1,138 @@
+#!/bin/bash
+
+# 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/>.
+
+
+set -e
+
+branch=$1
+xenbranch=$2
+blessing=$3
+buildflight=$4
+
+flight=`./cs-flight-create $blessing $branch`
+
+. cri-common
+. ap-common
+. mfi-common
+
+defsuite=`getconfig DebianSuite`
+defguestsuite=`getconfig GuestDebianSuite`
+
+case $branch in
+  distros-debian-*) debian_suite=${branch#distros-debian-} ;;
+  *)                echo $branch >&2; exit 1               ;;
+esac
+
+job_create_build_filter_callback () {
+  local job=$1; shift
+
+  case "$job" in
+    build-*-libvirt) return 1;;
+  esac
+  case " $* " in
+    *" enable_xsm=true "*) return 1;;
+  esac
+  return 0
+}
+
+if [ x$buildflight = x ]; then
+
+  WANT_XEND=false REVISION_LINUX_OLD=disable
+
+  create_build_jobs
+
+else
+
+  bfi=$buildflight.
+
+fi
+
+job_create_test_filter_callback () {
+  if [ "$xenarch" = "i386" ]; then return 1; fi
+  return 0
+}
+
+test_matrix_branch_filter_callback () {
+    :
+}
+
+test_do_one_netboot () {
+  local diurl=
+
+  if [ x$gsuite = xsnapshot ] ; then
+      diurl="http://d-i.debian.org/daily-images/$domU/daily/netboot"
+      gsuite=sid
+      gver=daily
+  else
+    local mirror="http://`getconfig DebianMirrorHost`/`getconfig DebianMirrorSubpath`"
+    diurl="$mirror/dists/$gsuite/main/installer-$domU/current/images/netboot"
+    gver=$gsuite
+  fi
+
+  case ${domU}_${gsuite} in
+    armhf_squeeze) return;; # No armhf in Squeeze
+    armhf_wheezy) return;; # No armhf guest support in Wheezy
+    *) ;;
+  esac
+
+  case $domU in
+    i386|amd64)
+      diurl="$diurl/xen";;
+    arm64)
+      diurl="$diurl/debian-installer/arm64";;
+  esac
+
+  job_create_test                                               \
+   test-$xenarch$kern-$dom0arch-$domU-$gver-netboot-pygrub      \
+    test-debian-di xl $xenarch $dom0arch                        \
+      kernbuildjob=${bfi}build-$dom0arch-$kernbuild             \
+      debian_arch=$domU                                         \
+      debian_suite=$gsuite                                      \
+      debian_method=netboot                                     \
+      debian_netboot_kernel="$diurl/vmlinuz"                    \
+      debian_netboot_ramdisk="$diurl/initrd.gz"                 \
+      all_hostflags=$most_hostflags
+}
+
+test_matrix_do_one () {
+  case ${xenarch} in
+  amd64) domUarches="amd64 i386";;
+  armhf) domUarches="armhf";;
+  esac
+
+  for domU in $domUarches ; do
+
+    if [ -n $debian_suite ] ; then
+        gsuite=$debian_suite
+
+        test_do_one_netboot
+
+    fi
+
+  done
+}
+
+test_matrix_iterate
+
+echo $flight
+
+# Local variables:
+# mode: sh
+# sh-basic-offset: 2
+# indent-tabs-mode: nil
+# End:
index d53fd838d9ecf51d8aed2240c81f8e11a5c157dc..bba52eddd17a0c4f5dbdfa8a2bdca493a92c10be 100755 (executable)
@@ -258,6 +258,17 @@ proc run-job/test-debian {} {
     test-guest debian
 }
 
+proc install-guest-debian-di {} {
+    run-ts . = ts-debian-di-install
+    run-ts . = ts-guest-start + debian
+}
+
+proc need-hosts/test-debian-di {} { return host }
+proc run-job/test-debian-di {} {
+    install-guest-debian-di
+    test-guest debian
+}
+
 proc need-hosts/test-freebsd {} { return host }
 proc run-job/test-freebsd {} {
     run-ts . = ts-freebsd-install
diff --git a/ts-debian-di-install b/ts-debian-di-install
new file mode 100755 (executable)
index 0000000..08019a9
--- /dev/null
@@ -0,0 +1,180 @@
+#!/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/>.
+
+# Configured via the following runvars (which are mandatory unless
+# otherwise noted):
+#
+# - <gident>_arch:
+#      Debian arch to install.
+# - <gident>_method:
+#      Install method, currently only "netboot".
+#
+# For method="netboot":
+#
+#  - <gident>_netboot_kernel:
+#       URL of the kernel to boot
+#  - <gident>_netboot_ramdisk:
+#       URL of the ramdisk to boot
+#
+#    If neither kernel nor ramdisk are specified then the current
+#    TftpDiVersion of d-i will be used, and the runvars will be set to
+#    the file path used.
+
+use strict qw(vars);
+use DBI;
+use Osstest;
+use Osstest::Debian;
+use Osstest::TestSupport;
+
+tsreadconfig();
+
+our ($whhost,$gn) = @ARGV;
+$whhost ||= 'host';
+$gn ||= 'debian';
+
+our $ho= selecthost($whhost);
+
+our $ram_mb=    512;
+our $disk_mb= 10000;
+
+our $guesthost= "$gn.guest.osstest";
+our $gho;
+
+sub prep () {
+    target_install_packages_norec($ho, qw(lvm2));
+
+    $gho= prepareguest($ho, $gn, $guesthost, 22,
+                       $disk_mb, 40);
+
+    prepareguest_part_lvmdisk($ho, $gho, $disk_mb);
+
+    target_cmd_root($ho, "umount $gho->{Lvdev} ||:");
+}
+
+sub setup_netboot($$$)
+{
+    my ($didir, $arch, $suite) = @_;
+
+    my ($kernel,$ramdisk);
+
+    if ( $r{ "$gho->{Guest}_netboot_kernel" } &&
+        $r{ "$gho->{Guest}_netboot_ramdisk" } ) {
+       target_fetchurl($ho, $r{ "$gho->{Guest}_netboot_kernel" },
+                            "$didir/kernel_${suite}_${arch}");
+       target_fetchurl($ho, $r{ "$gho->{Guest}_netboot_ramdisk" },
+                            "$didir/ramdisk_${suite}_${arch}");
+    } else {
+       # Both or neither must be specified
+       die if $r{ "$gho->{Guest}_netboot_kernel" }
+       ||     $r{ "$gho->{Guest}_netboot_ramdisk" };
+
+       my $di_path = $c{TftpPath}.'/'.$ho->{Tftp}{DiBase}.'/'.${arch}.'/'.$c{TftpDiVersion}.'-'.$ho->{Suite};
+
+        my $suffix = '';
+        $suffix .= "-xen" if ${arch} =~ m/amd64|i386/;
+       $kernel = "$di_path/vmlinuz$suffix";
+       $ramdisk = "$di_path/initrd.gz$suffix";
+
+       target_putfile_root($ho, 60, $kernel, "$didir/kernel_${suite}_${arch}");
+       target_putfile_root($ho, 60, $ramdisk, "$didir/ramdisk_${suite}_${arch}");
+
+       store_runvar("$gho->{Guest}_netboot_kernel", $kernel);
+       store_runvar("$gho->{Guest}_netboot_ramdisk", $ramdisk);
+    }
+
+    return <<END;
+kernel      = "$didir/kernel_${suite}_${arch}"
+ramdisk     = "$didir/ramdisk_${suite}_${arch}"
+END
+}
+
+sub ginstall () {
+    my $arch= $r{"$gho->{Guest}_arch"};
+    my $method= $r{"$gho->{Guest}_method"};
+
+    my $tmpdir= "/root/$flight-$job-di";
+    target_cmd_root($ho, <<END);
+rm -rf $tmpdir
+mkdir $tmpdir
+END
+
+    my ($method_cfg, $ps_url, $extra_disk);
+
+    if ( $method eq "netboot" )
+    {
+       my $suite= $r{"$gho->{Guest}_suite"};
+       logm("$method $suite/$arch");
+
+       $method_cfg = setup_netboot($tmpdir, $arch, $suite);
+
+       $ps_url = preseed_create_guest($gho, '', Suite=>$suite);
+
+       $extra_disk = "";
+    }
+    else
+    {
+       die "$method";
+    }
+
+    my @cmdline = ();
+    push @cmdline, "debian-installer/exit/always_halt=true";
+    push @cmdline, "domain=$c{TestHostDomain}";
+    push @cmdline, "console=hvc0";
+    push @cmdline, di_installcmdline_core($gho, $ps_url);
+    push @cmdline, "--";
+    # See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=762007 for
+    # why this is repeated.
+    push @cmdline, "console=hvc0";
+
+    my $cmdline = join(" ", @cmdline);
+
+    my %install_xopts = (
+       OnPowerOff => "preserve"
+    );
+
+    prepareguest_part_xencfg($ho, $gho, $ram_mb, \%install_xopts, <<END);
+$method_cfg
+extra       = "$cmdline"
+#
+disk        = [
+            $extra_disk 'phy:$gho->{Lvdev},xvda,w'
+            ]
+END
+
+    guest_create($gho);
+
+    guest_checkrunning($ho, $gho) or die "$gho->{Name} not running";
+
+    guest_await_shutdown($ho,$gho,3600);
+    guest_destroy($gho);
+
+    my $blcfg = <<END;
+bootloader = "pygrub"
+END
+
+    prepareguest_part_xencfg($ho, $gho, $ram_mb, {}, <<END);
+$blcfg
+#
+disk        = [
+            'phy:$gho->{Lvdev},xvda,w'
+            ]
+END
+    return;
+}
+
+prep();
+ginstall();