blob: c4ec3e90955e33aa42568449c8f38ad0ec2ee0b6 [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
Dean Troyerda85cda2013-02-15 11:07:14 -06005# Test swift via the ``swift`` command line from ``python-swiftclient`
Todd Willey3e6ec232011-11-04 12:23:35 -04006
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
Chmouel Boudjnah408b0092012-03-15 23:21:55 +000036# If swift is not enabled we exit with exitcode 55 which mean
37# exercise is skipped.
Chmouel Boudjnah0c3a5582013-03-06 10:58:33 +010038is_service_enabled s-proxy || exit 55
Todd Willey3e6ec232011-11-04 12:23:35 -040039
Dean Troyerda85cda2013-02-15 11:07:14 -060040# Container name
41CONTAINER=ex-swift
42
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
Nachi Ueno07115eb2013-02-26 12:38:18 -080048swift stat || die $LINENO "Failure geting status"
Todd Willey3e6ec232011-11-04 12:23:35 -040049
50# We start by creating a test container
Nachi Ueno07115eb2013-02-26 12:38:18 -080051swift post $CONTAINER || die $LINENO "Failure creating container $CONTAINER"
Todd Willey3e6ec232011-11-04 12:23:35 -040052
53# add some files into it.
Nachi Ueno07115eb2013-02-26 12:38:18 -080054swift upload $CONTAINER /etc/issue || die $LINENO "Failure uploading file to container $CONTAINER"
Todd Willey3e6ec232011-11-04 12:23:35 -040055
56# list them
Nachi Ueno07115eb2013-02-26 12:38:18 -080057swift list $CONTAINER || die $LINENO "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.
Nachi Ueno07115eb2013-02-26 12:38:18 -080061swift delete $CONTAINER || die $LINENO "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 "*********************************************************************"