blob: fc81af8f6f9365a5e34b8efa3548be83bec2735a [file] [log] [blame]
Jesse Andrewsf6705492011-11-01 16:04:14 -07001#!/usr/bin/env bash
2
Jesse Andrews9f186342011-11-01 16:05:40 -07003# we will use the ``euca2ools`` cli tool that wraps the python boto
4# library to test ec2 compatibility
Jesse Andrewsf6705492011-11-01 16:04:14 -07005#
6
Jesse Andrewsf6705492011-11-01 16:04:14 -07007# This script exits on an error so that errors don't compound and you see
8# only the first error that occured.
9set -o errexit
10
11# Print the commands being run so that we can see the command that triggers
12# an error. It is also useful for following allowing as the install occurs.
13set -o xtrace
14
15
16# Settings
17# ========
18
19# Use openrc + stackrc + localrc for settings
20source ./openrc
21
22# Max time till the vm is bootable
23BOOT_TIMEOUT=${BOOT_TIMEOUT:-15}
24
Jesse Andrews9f186342011-11-01 16:05:40 -070025# find a machine image to boot
Jesse Andrewsf6705492011-11-01 16:04:14 -070026IMAGE=`euca-describe-images | grep machine | cut -f2`
27
Jesse Andrews9f186342011-11-01 16:05:40 -070028# launch it
Jesse Andrewsf6705492011-11-01 16:04:14 -070029INSTANCE=`euca-run-instance $IMAGE | grep INSTANCE | cut -f2`
30
Jesse Andrews9f186342011-11-01 16:05:40 -070031# assure it has booted within a reasonable time
Jesse Andrewsf6705492011-11-01 16:04:14 -070032if ! timeout $BOOT_TIMEOUT sh -c "while euca-describe-instances $INSTANCE | grep -q running; do sleep 1; done"; then
33 echo "server didn't become active within $BOOT_TIMEOUT seconds"
34 exit 1
35fi
36
37euca-terminate-instances $INSTANCE