blob: 0cb5feaf616d0c9b6ffcb9775bef51c27bdb37e9 [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
Jesse Andrews787af012011-11-01 16:44:19 -070020pushd $(cd $(dirname "$0")/.. && pwd)
Jesse Andrewsf6705492011-11-01 16:04:14 -070021source ./openrc
Jesse Andrews787af012011-11-01 16:44:19 -070022popd
Jesse Andrewsf6705492011-11-01 16:04:14 -070023
24# Max time till the vm is bootable
25BOOT_TIMEOUT=${BOOT_TIMEOUT:-15}
26
Jesse Andrews9f186342011-11-01 16:05:40 -070027# find a machine image to boot
Jesse Andrewsf6705492011-11-01 16:04:14 -070028IMAGE=`euca-describe-images | grep machine | cut -f2`
29
Jesse Andrews9f186342011-11-01 16:05:40 -070030# launch it
Jesse Andrewsf6705492011-11-01 16:04:14 -070031INSTANCE=`euca-run-instance $IMAGE | grep INSTANCE | cut -f2`
32
Jesse Andrews9f186342011-11-01 16:05:40 -070033# assure it has booted within a reasonable time
Jesse Andrewsf6705492011-11-01 16:04:14 -070034if ! timeout $BOOT_TIMEOUT sh -c "while euca-describe-instances $INSTANCE | grep -q running; do sleep 1; done"; then
35 echo "server didn't become active within $BOOT_TIMEOUT seconds"
36 exit 1
37fi
38
39euca-terminate-instances $INSTANCE