blob: 732445d35092da90151814b5f324891d120ed184 [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
43# Testing Swift
44# =============
45
46# Check if we have to swift via keystone
Dean Troyer27e32692012-03-16 16:16:56 -050047swift stat || die "Failure geting status"
Todd Willey3e6ec232011-11-04 12:23:35 -040048
49# We start by creating a test container
Dean Troyer27e32692012-03-16 16:16:56 -050050swift post $CONTAINER || die "Failure creating container $CONTAINER"
Todd Willey3e6ec232011-11-04 12:23:35 -040051
52# add some files into it.
Dean Troyer27e32692012-03-16 16:16:56 -050053swift upload $CONTAINER /etc/issue || die "Failure uploading file to container $CONTAINER"
Todd Willey3e6ec232011-11-04 12:23:35 -040054
55# list them
Dean Troyer27e32692012-03-16 16:16:56 -050056swift list $CONTAINER || die "Failure listing contents of container $CONTAINER"
Todd Willey3e6ec232011-11-04 12:23:35 -040057
58# And we may want to delete them now that we have tested that
59# everything works.
Dean Troyer27e32692012-03-16 16:16:56 -050060swift delete $CONTAINER || die "Failure deleting container $CONTAINER"
Dean Troyer489bd2a2012-03-02 10:44:29 -060061
62set +o xtrace
Dean Troyer27e32692012-03-16 16:16:56 -050063echo "*********************************************************************"
64echo "SUCCESS: End DevStack Exercise: $0"
65echo "*********************************************************************"