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 | |
Dean Troyer | 51fb454 | 2012-03-09 22:21:59 -0600 | [diff] [blame] | 21 | # Keep track of the current directory |
| 22 | EXERCISE_DIR=$(cd $(dirname "$0") && pwd) |
| 23 | TOP_DIR=$(cd $EXERCISE_DIR/..; pwd) |
Dean Troyer | 489bd2a | 2012-03-02 10:44:29 -0600 | [diff] [blame] | 24 | |
| 25 | # Import common functions |
Dean Troyer | 51fb454 | 2012-03-09 22:21:59 -0600 | [diff] [blame] | 26 | source $TOP_DIR/functions |
Dean Troyer | 489bd2a | 2012-03-02 10:44:29 -0600 | [diff] [blame] | 27 | |
| 28 | # Import configuration |
Dean Troyer | 51fb454 | 2012-03-09 22:21:59 -0600 | [diff] [blame] | 29 | source $TOP_DIR/openrc |
| 30 | |
| 31 | # Import exercise configuration |
| 32 | source $TOP_DIR/exerciserc |
Dean Troyer | 489bd2a | 2012-03-02 10:44:29 -0600 | [diff] [blame] | 33 | |
| 34 | # Container name |
| 35 | CONTAINER=ex-swift |
Todd Willey | 3e6ec23 | 2011-11-04 12:23:35 -0400 | [diff] [blame] | 36 | |
| 37 | |
| 38 | # Testing Swift |
| 39 | # ============= |
| 40 | |
| 41 | # Check if we have to swift via keystone |
Chmouel Boudjnah | a6bdfdd | 2012-02-29 14:11:01 +0000 | [diff] [blame] | 42 | swift stat |
Dean Troyer | 489bd2a | 2012-03-02 10:44:29 -0600 | [diff] [blame] | 43 | die_if_error "Failure geting status" |
Todd Willey | 3e6ec23 | 2011-11-04 12:23:35 -0400 | [diff] [blame] | 44 | |
| 45 | # We start by creating a test container |
Dean Troyer | 489bd2a | 2012-03-02 10:44:29 -0600 | [diff] [blame] | 46 | swift post $CONTAINER |
| 47 | die_if_error "Failure creating container $CONTAINER" |
Todd Willey | 3e6ec23 | 2011-11-04 12:23:35 -0400 | [diff] [blame] | 48 | |
| 49 | # add some files into it. |
Dean Troyer | 489bd2a | 2012-03-02 10:44:29 -0600 | [diff] [blame] | 50 | swift upload $CONTAINER /etc/issue |
| 51 | die_if_error "Failure uploading file to container $CONTAINER" |
Todd Willey | 3e6ec23 | 2011-11-04 12:23:35 -0400 | [diff] [blame] | 52 | |
| 53 | # list them |
Dean Troyer | 489bd2a | 2012-03-02 10:44:29 -0600 | [diff] [blame] | 54 | swift list $CONTAINER |
| 55 | die_if_error "Failure listing contents of container $CONTAINER" |
Todd Willey | 3e6ec23 | 2011-11-04 12:23:35 -0400 | [diff] [blame] | 56 | |
| 57 | # And we may want to delete them now that we have tested that |
| 58 | # everything works. |
Dean Troyer | 489bd2a | 2012-03-02 10:44:29 -0600 | [diff] [blame] | 59 | swift delete $CONTAINER |
| 60 | die_if_error "Failure deleting container $CONTAINER" |
| 61 | |
| 62 | set +o xtrace |
| 63 | echo "**************************************************" |
| 64 | echo "End DevStack Exercise: $0" |
| 65 | echo "**************************************************" |