Simple testing scripts

S3 and Swift testing scriptsBelow the code of the primitive shell scripts to test S3 and Swift.

S3 testing script

#! /bin/bash
# That is a script to test S3 
echo "--- S3 test ---"

# Specify s3curl directory here
export S3curl_DIR=~/s3curl/
cd $S3curl_DIR

# S3 credentials are in the .s3curl file
# Specify s3curl profile id here
export ID=ecsid

# Specify ECS or Load Balancer IP here
export IP=10.10.10.10

# Specify testing Bucket here
export BUCKET=bucket1

# Specify Port here
# Use http/9020 or https/9021 for protocol/port
export PORT=9020

# URL is defined here
STORAGE_URL=http://$IP:$PORT/$BUCKET
echo "URL is: " $STORAGE_URL

# Update the file which will be written
echo "OK" > file

# Define files' prefix
FILE_PREFIX=file_

while true;
do
 d=`date`
 echo "--- $d ---"
 i=`date +%s`
 echo "Write $FILE_PREFIX$i"
 ./s3curl.pl --id=$ID --put=file -- -ks $STORAGE_URL/$FILE_PREFIX$i
 echo "Read $FILE_PREFIX$i"
 ./s3curl.pl --id=$ID -- -k -s $STORAGE_URL/$FILE_PREFIX$i
 sleep 1
done

Swift testing script

#! /bin/bash
# That is a script to test Swift 
echo "--- Swift test ---"

# Scpecify ECS or Load Balancer IP
export IP=10.10.10.10

# Specify Swift credentials here
export USER=objectuser1
export PASSWORD=123456

# Specify testing Namespace and Bucket here
export NAMESPACE=ns1
export BUCKET=container1

# Receive Authentication Token
export TOKEN=`curl -ski -H "X-Auth-User: $USER" -H "X-Auth-Key:$PASSWORD" https://$IP:9025/auth/v1.0 | grep -i X-Auth-Token | awk '{ print $2 }' | tr -d '\015'`
echo "Authenticated with: " $TOKEN 

# URL is defined here
export STORAGE_URL=https://$IP:9025/v1/$NAMESPACE
echo "URL is: " $STORAGE_URL

# Update the file which will be written
echo "OK" > file

while true;
do
 d=`date`
 echo ""
 echo "--- $d ---"
 i=`date +%s`
 echo "Write file_$i"
 curl -k -X PUT -H "Content-Type: plain/text" --data-binary "OK" -H "X-Auth-Token:$TOKEN" -s "$STORAGE_URL/$BUCKET/file_$i"
 echo "Read file_$i"
 curl -ks -H "X-Auth-Token:$TOKEN" "$STORAGE_URL/$BUCKET/file_$i"
 sleep 1
done

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s