
This patch adds an xfstests-style functional test suite. Run "tox -e tempauth" to test swift3 with TempAuth, and "tox -e keystone" to test with the Keystone auth system. You don't need to prepare Swift and Keystone system for that. They will be started with minimum configuration automatically. If you already have a Swift cluster for the functional test, run "./check" in the test directory directly. Individual tests can be run using "./check 003", and various other options are also supported. Try "./check -h" for more information. I added some sample test cases but they are not enough at all obviously. More tests will be added soon. Change-Id: I75abce574768abbe88f60d8c1eee87757651e357
109 lines
2.1 KiB
Bash
109 lines
2.1 KiB
Bash
#!/bin/bash
|
|
#
|
|
# Copyright (c) 2014 OpenStack Foundation.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
# implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
_s3_setup()
|
|
{
|
|
echo "
|
|
%awsSecretAccessKeys = (
|
|
tester => {
|
|
id => '$TESTER_ACCESS_KEY',
|
|
key => '$TESTER_SECRET_KEY',
|
|
endpoints => '${SWIFT_HOST%:*}',
|
|
},
|
|
|
|
tester2 => {
|
|
id => '$TESTER2_ACCESS_KEY',
|
|
key => '$TESTER2_SECRET_KEY',
|
|
endpoints => '${SWIFT_HOST%:*}',
|
|
},
|
|
|
|
admin => {
|
|
id => '$ADMIN_ACCESS_KEY',
|
|
key => '$ADMIN_SECRET_KEY',
|
|
endpoints => '${SWIFT_HOST%:*}',
|
|
},
|
|
);" > .s3curl
|
|
|
|
chmod 600 .s3curl
|
|
}
|
|
|
|
_s3curl()
|
|
{
|
|
local tmp_file=$tmp.$RANDOM
|
|
local args=""
|
|
|
|
if [ "$S3USER" == "" ]; then
|
|
_die "S3USER is not defined."
|
|
fi
|
|
args="--id $S3USER"
|
|
|
|
if [ "$MD5" != "" ]; then
|
|
args="$args --contentMd5 $MD5"
|
|
fi
|
|
|
|
if [ "$CONTENT_TYPE" != "" ]; then
|
|
args="$args --contentType $CONTENT_TYPE"
|
|
fi
|
|
|
|
LANG=C ./s3curl.pl $args -- -s "$@" -w '%{http_code}' > $tmp_file
|
|
|
|
status=$(tail -c -3 $tmp_file)
|
|
echo "> s3curl $args -- $@... $status" | _filter_curl_command >&2
|
|
|
|
head -c -3 $tmp_file
|
|
|
|
_is_http_success $status
|
|
}
|
|
|
|
_s3_head()
|
|
{
|
|
local path=$1; shift
|
|
|
|
_s3curl -I -X HEAD "$@" http://${SWIFT_HOST}${path}
|
|
}
|
|
|
|
_s3_get()
|
|
{
|
|
local path=$1; shift
|
|
|
|
_s3curl -X GET "$@" http://${SWIFT_HOST}${path}
|
|
}
|
|
|
|
_s3_put()
|
|
{
|
|
local path=$1; shift
|
|
|
|
_s3curl -X PUT "$@" http://${SWIFT_HOST}${path}
|
|
}
|
|
|
|
_s3_post()
|
|
{
|
|
local path=$1; shift
|
|
|
|
_s3curl -X POST "$@" http://${SWIFT_HOST}${path}
|
|
}
|
|
|
|
_s3_delete()
|
|
{
|
|
local path=$1; shift
|
|
|
|
_s3curl -X DELETE "$@" http://${SWIFT_HOST}${path}
|
|
}
|
|
|
|
# make sure this script returns success
|
|
/bin/true
|