devstack/exercises/swift.sh
Dean Troyer 489bd2a62b Improve exercise robustness
* Test returns and exit codes on most command invocations
* Add start and end banners to make output easier to find in
  long log files
* Adds die_if_error(), die_if_not_set() and is_set() to functions
* Add some function tests

Fixes bug 944593

Change-Id: I55e2962c5fec9aad237b674732b1e922ad37a62e
2012-03-02 17:55:37 -08:00

63 lines
1.5 KiB
Bash
Executable File

#!/usr/bin/env bash
# Test swift via the command line tools that ship with it.
echo "**************************************************"
echo "Begin DevStack Exercise: $0"
echo "**************************************************"
# This script exits on an error so that errors don't compound and you see
# only the first error that occured.
set -o errexit
# Print the commands being run so that we can see the command that triggers
# an error. It is also useful for following allowing as the install occurs.
set -o xtrace
# Settings
# ========
# Use openrc + stackrc + localrc for settings
pushd $(cd $(dirname "$0")/.. && pwd) >/dev/null
# Import common functions
source ./functions
# Import configuration
source ./openrc
popd >/dev/null
# Container name
CONTAINER=ex-swift
# Testing Swift
# =============
# Check if we have to swift via keystone
swift stat
die_if_error "Failure geting status"
# We start by creating a test container
swift post $CONTAINER
die_if_error "Failure creating container $CONTAINER"
# add some files into it.
swift upload $CONTAINER /etc/issue
die_if_error "Failure uploading file to container $CONTAINER"
# list them
swift list $CONTAINER
die_if_error "Failure listing contents of container $CONTAINER"
# And we may want to delete them now that we have tested that
# everything works.
swift delete $CONTAINER
die_if_error "Failure deleting container $CONTAINER"
set +o xtrace
echo "**************************************************"
echo "End DevStack Exercise: $0"
echo "**************************************************"