blob: 4cd487bc07ffb6762e2dbc595fcf9956d5254f22 [file] [log] [blame]
Todd Willey3e6ec232011-11-04 12:23:35 -04001#!/usr/bin/env bash
2
Dean Troyer27e32692012-03-16 16:16:56 -05003# **swift.sh**
4
Todd Willey3e6ec232011-11-04 12:23:35 -04005# Test swift via the command line tools that ship with it.
6
Dean Troyer27e32692012-03-16 16:16:56 -05007echo "*********************************************************************"
Dean Troyer489bd2a2012-03-02 10:44:29 -06008echo "Begin DevStack Exercise: $0"
Dean Troyer27e32692012-03-16 16:16:56 -05009echo "*********************************************************************"
Dean Troyer489bd2a2012-03-02 10:44:29 -060010
Todd Willey3e6ec232011-11-04 12:23:35 -040011# This script exits on an error so that errors don't compound and you see
12# only the first error that occured.
13set -o errexit
14
15# Print the commands being run so that we can see the command that triggers
16# an error. It is also useful for following allowing as the install occurs.
17set -o xtrace
18
19
20# Settings
21# ========
22
Dean Troyer51fb4542012-03-09 22:21:59 -060023# Keep track of the current directory
24EXERCISE_DIR=$(cd $(dirname "$0") && pwd)
25TOP_DIR=$(cd $EXERCISE_DIR/..; pwd)
Dean Troyer489bd2a2012-03-02 10:44:29 -060026
27# Import common functions
Dean Troyer51fb4542012-03-09 22:21:59 -060028source $TOP_DIR/functions
Dean Troyer489bd2a2012-03-02 10:44:29 -060029
30# Import configuration
Dean Troyer51fb4542012-03-09 22:21:59 -060031source $TOP_DIR/openrc
32
33# Import exercise configuration
34source $TOP_DIR/exerciserc
Dean Troyer489bd2a2012-03-02 10:44:29 -060035
36# Container name
37CONTAINER=ex-swift
Todd Willey3e6ec232011-11-04 12:23:35 -040038
Chmouel Boudjnah408b0092012-03-15 23:21:55 +000039# If swift is not enabled we exit with exitcode 55 which mean
40# exercise is skipped.
41is_service_enabled swift || exit 55
Todd Willey3e6ec232011-11-04 12:23:35 -040042
Dean Troyerad101762012-06-27 22:04:40 -050043
Todd Willey3e6ec232011-11-04 12:23:35 -040044# Testing Swift
45# =============
46
47# Check if we have to swift via keystone
Dean Troyer27e32692012-03-16 16:16:56 -050048swift stat || die "Failure geting status"
Todd Willey3e6ec232011-11-04 12:23:35 -040049
50# We start by creating a test container
Dean Troyer27e32692012-03-16 16:16:56 -050051swift post $CONTAINER || die "Failure creating container $CONTAINER"
Todd Willey3e6ec232011-11-04 12:23:35 -040052
53# add some files into it.
Dean Troyer27e32692012-03-16 16:16:56 -050054swift upload $CONTAINER /etc/issue || die "Failure uploading file to container $CONTAINER"
Todd Willey3e6ec232011-11-04 12:23:35 -040055
56# list them
Dean Troyer27e32692012-03-16 16:16:56 -050057swift list $CONTAINER || die "Failure listing contents of container $CONTAINER"
Todd Willey3e6ec232011-11-04 12:23:35 -040058
59# And we may want to delete them now that we have tested that
60# everything works.
Dean Troyer27e32692012-03-16 16:16:56 -050061swift delete $CONTAINER || die "Failure deleting container $CONTAINER"
Dean Troyer489bd2a2012-03-02 10:44:29 -060062
63set +o xtrace
Dean Troyer27e32692012-03-16 16:16:56 -050064echo "*********************************************************************"
65echo "SUCCESS: End DevStack Exercise: $0"
66echo "*********************************************************************"