Skip to content

Instantly share code, notes, and snippets.

@stefanbenten
Last active June 24, 2019 20:09
Show Gist options
  • Save stefanbenten/cde0b0ce412e876f7c28886f6d240022 to your computer and use it in GitHub Desktop.
Save stefanbenten/cde0b0ce412e876f7c28886f6d240022 to your computer and use it in GitHub Desktop.
#!/bin/bash
BUCKET="srv11"
FILE="500M.data"
FILEPATH="/root/load-test"
THREAD=`date +%Y%m%d%H%M%S`
LOG="logs/$THREAD.log"
DEBUG="trace"
UPLOADLOG="logs/$THREAD-detailed.log"
PARAMS="--config-dir ./uplink --log.level debug --log.output $UPLOADLOG --debug.trace-out $DEBUG/$THREAD/$i-up.trace --profile.cpu $DEBUG/$THREAD/$i-up-cpu.profile --profile.mem $DEBUG/$THREAD/$i-up-mem.profile"
mkdir /tmp/$THREAD/
mkdir $DEBUG/$THREAD/
echo "Network Test with File $FILE and $1 iterations" >> $LOG
echo "The following metrics are kept:" >> $LOG
echo "Operation - FileCount - Time in seconds" >> $LOG
for i in `seq 1 $1`;
do
echo "File $i of $1"
START=$(date +%s.%N)
uplink $PARAMS cp $FILEPATH/$FILE sj://$BUCKET/$THREAD/$i-$FILE
END=$(date +%s.%N)
DIFF=$(echo "$END - $START" | bc)
echo "Upload - $i - $DIFF s" >> $LOG
for j in `seq 1 $2`;
do
START=$(date +%s.%N)
uplink $PARAMS cp sj://$BUCKET/$THREAD/$i-$FILE /tmp/$THREAD/$i-$FILE
END=$(date +%s.%N)
DIFF=$(echo "$END - $START" | bc)
echo "Download - $i - $DIFF s" >> $LOG
rm /tmp/$THREAD/$i-$FILE
done
#START=$(date +%s.%N)
#uplink $PARAMS rm sj://$BUCKET/$THREAD/$i-$FILE
#END=$(date +%s.%N)
#DIFF=$(echo "$END - $START" | bc)
#echo "Delete - $i - $DIFF s" >> $LOG
done
rm -r /tmp/$THREAD/
@stefanbenten
Copy link
Author

This script assumes the following:

  1. Having the file to upload in FILEPATH and names FILE
  2. Having a folder called logs and trace in the directory where the script is ran.
  3. Having a bucket in your account entered in BUCKET, it does not generate it for you
  4. Having the uplink correctly configured or append the folder to the correct config in L10

All parameters of the actual uplink command can be appended/changed in L10.

To run execute it in the following schema:

./upload-v3.sh <AMOUNTOFUPLOADS> <AMOUNTOFDOWNLOADSPERFILE>

This will run the script and output two log files named by the startdate (this contains the actual upload and download times) and one with the suffix -detailed, which contains all debug logs of the uploads.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment