source: trunk/debathena/scripts/tests/installer/install-test.sh @ 25833

Revision 25833, 3.3 KB checked in by wpreston, 12 years ago (diff)
588: automated install tests. This works, but has a few items to be resolved: a notification mechanism for reporting pass/fail, and any amount of documentation, if determined to be lacking.
  • Property svn:executable set to *
Line 
1#!/bin/bash
2
3# install debathena into a blank vm, and run tests confirming the install
4#
5#
6# This was developed and tested using VMWare Workstation 9,
7# and mkisofs(2.01)/genisoimage 1.1.11
8#
9# example usage:
10# -s precise
11# -a i386
12# -h <vmware host>
13# -i (this was tested using a static IP taken from vmnet8)
14# -p http://<your preseed>
15
16BASEDIR=.
17
18SUITE=
19ARCH=
20IP=
21HOSTNAME=
22PRESEED=
23
24LOGDIR=$BASEDIR/log
25NOW=$(date +"%d-%m-%y")
26LOG=$LOGDIR/"install-test-"$NOW".log"
27
28
29function usage() {
30  cat<< EO
31        Usage:  -s <suite> -a <architecture> -h <hostname> -i <ip> -p <preseed>
32EO
33}
34
35
36while getopts "s:a:h:i:p:" OPTION
37
38do
39  case $OPTION in
40  s)
41    SUITE=$OPTARG
42    ;;
43  a)
44    ARCH=$OPTARG
45    ;;
46  h)
47    HOSTNAME=$OPTARG
48    ;;
49  i)
50    IP=$OPTARG
51    ;;
52  p)
53    PRESEED=$OPTARG
54    ;;
55  ?)
56   usage
57   exit 1
58   ;;
59  esac
60done
61
62if [[ -z $HOSTNAME || -z $ARCH || -z $PRESEED || -z $IP ]] ; then
63  echo "Empty option. HOSTNAME: $HOSTNAME, ARCH: $ARCH, PRESEED: $PRESEED, IP: $IP"  | tee -a $LOG
64  usage
65  exit 1
66fi
67
68if [ -d tmp ] ; then
69  rm -rf tmp
70fi
71
72mkdir $BASEDIR/tmp
73TMPDIR=$BASEDIR/tmp
74
75echo "creating build files..." | tee -a $LOG
76cp -R $BASEDIR/isolinux $TMPDIR
77
78echo "fetching kernel and initrd..." | tee -a $LOG
79wget -q http://mirrors.mit.edu/ubuntu/dists/$SUITE/main/installer-$ARCH/current/images/netboot/ubuntu-installer/$ARCH/linux -O $TMPDIR/linux
80wget -q http://mirrors.mit.edu/ubuntu/dists/$SUITE/main/installer-$ARCH/current/images/netboot/ubuntu-installer/$ARCH/initrd.gz -O $TMPDIR/initrd.gz
81
82ISOLINUXBIN=$TMPDIR/isolinux/isolinux.bin
83ISOLINUXBOOT=$TMPDIR/isolinux/boot.cat
84ISOLINUXCFG=$TMPDIR/isolinux/isolinux.cfg
85
86# sane?
87if [ ! -f $ISOLINUXBIN ] ; then
88  echo "isolinux.bin not found at: $ISOLINUXBIN exiting..." | tee -a $LOG
89  exit 1
90fi
91
92if [ ! -f $ISOLINUXBOOT ] ; then
93  echo "boot.cat not found at: $ISOLINUXBOOT exiting..." | tee -a $LOG
94  exit 1
95fi
96
97if [ ! -f $ISOLINUXCFG ] ; then
98  echo "isolinux.cfg not found at: $ISOLINUXCFG exiting..." | tee -a $LOG
99  exit 1
100fi
101
102echo "seeding isolinux.cfg..." | tee -a $LOG
103
104sed -i "s|%HOSTNAME%|$HOSTNAME|g" $ISOLINUXCFG
105sed -i "s|%IP%|$IP|g" $ISOLINUXCFG
106sed -i "s|%PRESEED%|$PRESEED|g" $ISOLINUXCFG
107
108echo "creating iso image..." | tee -a $LOG
109
110IMAGENAME=$SUITE-$ARCH-netboot.iso
111BUILDDIR=$TMPDIR
112
113mkisofs -r -V "Debathena Boot" \
114        -cache-inodes \
115        -J -l -b isolinux/isolinux.bin \
116        -c isolinux/boot.cat -no-emul-boot \
117        -boot-load-size 4 -boot-info-table \
118        -o $IMAGENAME $BUILDDIR 2>&1 | tee -a $LOG
119
120if [ ! -f $BASEDIR/$IMAGENAME ] ; then
121  echo "iso creation failed. exiting..." | tee -a $LOG
122else
123  echo "iso creation success..." | tee -a $LOG
124fi
125
126echo "installing iso into VM image..." | tee -a $LOG
127
128VMWARE_CONFIG=$BASEDIR/vmware_config
129
130#make vmwware boot out virtual disk / iso
131mkdir $TMPDIR/vm
132cp -R $VMWARE_CONFIG/* $TMPDIR/vm
133mv $BASEDIR/$IMAGENAME $TMPDIR/vm
134
135sed -i "s|%ISO%|$IMAGENAME|g" $TMPDIR/vm/default.vmx
136
137vmrun start $TMPDIR/vm/default.vmx 2>&1 | tee -a $LOG
138
139echo "sleeping for 4 hours before launching tests..." | tee -a $LOG
140
141sleep 240m
142
143ATHINFO_VERSION=`athinfo $IP version`
144ATHINFO_VERSION_PASS=`$ATHINFO_VERSION | grep -c debathena-cluster`
145
146if [[ $ATHINFO_VERSION_PASS -ne 1 ]] ; then
147  echo "athinfo version returned: $ATHINFO_VERSION. Test Failed." | tee -a $LOG
148else
149 echo "Test Passed! athinfo version: $ATHINFO_VERSION" | tee -a $LOG
150fi
151
152echo "done."
153
154exit 0
Note: See TracBrowser for help on using the repository browser.