Skip to content

Instantly share code, notes, and snippets.

@escowles
Created May 23, 2014 15:48
Show Gist options
  • Select an option

  • Save escowles/f4ededd956747ac1a56a to your computer and use it in GitHub Desktop.

Select an option

Save escowles/f4ededd956747ac1a56a to your computer and use it in GitHub Desktop.
3level.sh
#!/bin/sh
BASE_URL=http://localhost:8080/rest/federated
BASE_DIR=$HOME/src/x
head -c $(( 10 * 1024 )) /dev/urandom > tmp.in
md5sum tmp.in
MAX=256 # number of files/directories to create
SLEEP=10
#TIME="/usr/bin/time -f %e"
TIME="time"
echo `date +%T` start
BATCH=0
while [ $BATCH -lt $MAX ]; do
BATCH=$(( $BATCH + 1 ))
DIR=0
while [ $DIR -lt $MAX ]; do
DIR=$(( $DIR + 1 ))
mkdir -p $BASE_DIR/$BATCH/$DIR || exit 1
FILE=0
while [ $FILE -lt $MAX ]; do
FILE=$(( $FILE + 1 ))
mkdir $BASE_DIR/$BATCH/$DIR/$FILE
cp tmp.in $BASE_DIR/$BATCH/$DIR/$FILE/
done
done
# wait for TTL so repo is in sync with disk
sleep $SLEEP
# list top level objects
/bin/echo -n `date +%T` "$BATCH toplist "
TOPCOUNT=`$TIME curl -s $BASE_URL/ | grep "hasChild> <" | wc -l`
/bin/echo `date +%T` "$BATCH $TOPCOUNT"
# list directory $BATCH/Y
/bin/echo -n `date +%T` "$BATCH dirlist: $BATCH/$DIR "
DIRCOUNT=`$TIME curl -s $BASE_URL/$BATCH/$DIR | grep "hasChild> <" | wc -l`
/bin/echo `date +%T` "$BATCH $DIRCOUNT"
# get file $BATCH/X/Y
/bin/echo -n `date +%T` "$BATCH fileget $BATCH/$DIR/$FILE "
$TIME curl -s $BASE_URL/$BATCH/$DIR/$FILE/tmp.in/fcr:content > tmp.out
CHK=`md5sum tmp.out`
echo `date +%T` "$BATCH filechk $CHK"
echo
done
echo `date +%T` done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment