Todd Willey | 3e6ec23 | 2011-11-04 12:23:35 -0400 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | # Test swift via the command line tools that ship with it. |
| 4 | |
Dean Troyer | 489bd2a | 2012-03-02 10:44:29 -0600 | [diff] [blame^] | 5 | echo "**************************************************" |
| 6 | echo "Begin DevStack Exercise: $0" |
| 7 | echo "**************************************************" |
| 8 | |
Todd Willey | 3e6ec23 | 2011-11-04 12:23:35 -0400 | [diff] [blame] | 9 | # This script exits on an error so that errors don't compound and you see |
| 10 | # only the first error that occured. |
| 11 | set -o errexit |
| 12 | |
| 13 | # Print the commands being run so that we can see the command that triggers |
| 14 | # an error. It is also useful for following allowing as the install occurs. |
| 15 | set -o xtrace |
| 16 | |
| 17 | |
| 18 | # Settings |
| 19 | # ======== |
| 20 | |
| 21 | # Use openrc + stackrc + localrc for settings |
Dean Troyer | 489bd2a | 2012-03-02 10:44:29 -0600 | [diff] [blame^] | 22 | pushd $(cd $(dirname "$0")/.. && pwd) >/dev/null |
| 23 | |
| 24 | # Import common functions |
| 25 | source ./functions |
| 26 | |
| 27 | # Import configuration |
Todd Willey | 3e6ec23 | 2011-11-04 12:23:35 -0400 | [diff] [blame] | 28 | source ./openrc |
Dean Troyer | 489bd2a | 2012-03-02 10:44:29 -0600 | [diff] [blame^] | 29 | popd >/dev/null |
| 30 | |
| 31 | # Container name |
| 32 | CONTAINER=ex-swift |
Todd Willey | 3e6ec23 | 2011-11-04 12:23:35 -0400 | [diff] [blame] | 33 | |
| 34 | |
| 35 | # Testing Swift |
| 36 | # ============= |
| 37 | |
| 38 | # Check if we have to swift via keystone |
Chmouel Boudjnah | a6bdfdd | 2012-02-29 14:11:01 +0000 | [diff] [blame] | 39 | swift stat |
Dean Troyer | 489bd2a | 2012-03-02 10:44:29 -0600 | [diff] [blame^] | 40 | die_if_error "Failure geting status" |
Todd Willey | 3e6ec23 | 2011-11-04 12:23:35 -0400 | [diff] [blame] | 41 | |
| 42 | # We start by creating a test container |
Dean Troyer | 489bd2a | 2012-03-02 10:44:29 -0600 | [diff] [blame^] | 43 | swift post $CONTAINER |
| 44 | die_if_error "Failure creating container $CONTAINER" |
Todd Willey | 3e6ec23 | 2011-11-04 12:23:35 -0400 | [diff] [blame] | 45 | |
| 46 | # add some files into it. |
Dean Troyer | 489bd2a | 2012-03-02 10:44:29 -0600 | [diff] [blame^] | 47 | swift upload $CONTAINER /etc/issue |
| 48 | die_if_error "Failure uploading file to container $CONTAINER" |
Todd Willey | 3e6ec23 | 2011-11-04 12:23:35 -0400 | [diff] [blame] | 49 | |
| 50 | # list them |
Dean Troyer | 489bd2a | 2012-03-02 10:44:29 -0600 | [diff] [blame^] | 51 | swift list $CONTAINER |
| 52 | die_if_error "Failure listing contents of container $CONTAINER" |
Todd Willey | 3e6ec23 | 2011-11-04 12:23:35 -0400 | [diff] [blame] | 53 | |
| 54 | # And we may want to delete them now that we have tested that |
| 55 | # everything works. |
Dean Troyer | 489bd2a | 2012-03-02 10:44:29 -0600 | [diff] [blame^] | 56 | swift delete $CONTAINER |
| 57 | die_if_error "Failure deleting container $CONTAINER" |
| 58 | |
| 59 | set +o xtrace |
| 60 | echo "**************************************************" |
| 61 | echo "End DevStack Exercise: $0" |
| 62 | echo "**************************************************" |