Skip to content

Commit

Permalink
Update urlgen to do batching.
Browse files Browse the repository at this point in the history
  • Loading branch information
benbjohnson committed Jan 29, 2015
1 parent 138474f commit b1417ea
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 21 deletions.
6 changes: 3 additions & 3 deletions tests/siege/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ To run siege, first start one or more InfluxDB nodes. At least one of those
nodes should run on the default port of `8086`.

Next, generate a URL file to run. You can use the `urlgen` utility in this
folder to make the file. Simply set the number of unique series and number of
points to generate:
folder to make the file. Simply set the number of unique clients and number of
series to generate:

```sh
$ ./urlgen -s 10 -p 1000 > urls.txt
$ ./urlgen -c 10 -s 100 > urls.txt
```

Now you can execute siege. There are several arguments available but only
Expand Down
55 changes: 37 additions & 18 deletions tests/siege/urlgen
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@
TIME=`date -j -f "%b %d %T %Z %Y" "Jan 01 00:00:00 EDT 2000" "+%s"`

# Set defaults.
INTERVAL=1 # 1s
INTERVAL=10 # 1s
NUMCLIENTS=10
NUMSERIES=1
NUMPOINTS=100

# Parse arguments
while getopts "s:p:i:h" opt; do
while getopts "s:c:i:h" opt; do
case $opt in
i)
INTERVAL=$OPTARG
;;
c)
NUMCLIENTS=$OPTARG
;;
s)
NUMSERIES=$OPTARG
;;
p)
NUMPOINTS=$OPTARG
;;
h)
echo "urlgen is a utility for generating URL files for siege."
echo ""
Expand All @@ -29,34 +29,53 @@ while getopts "s:p:i:h" opt; do
echo "The following arguments can be specified:"
echo ""
echo " -i seconds"
echo " Interval between generated points per series."
echo " Defaults to 1 second."
echo " Interval between requests."
echo " Defaults to 10 seconds."
echo ""
echo " -s num"
echo " Number of unique series to generate."
echo " Defaults to 1 series."
echo ""
echo " -p num"
echo " Number of points per series to generate."
echo " Defaults to 100 points."
echo " -c num"
echo " Number of clients to simulate."
echo " One request per client."
echo " Defaults to 10 clients."
echo ""
exit 1
;;
esac
done

# Generate a new value every interval per series.
for i in `seq 1 $NUMPOINTS`;
# Generate a new request every interval per client.
for i in `seq 1 $NUMCLIENTS`;
do
# Move forward the current time.
let TIME=TIME+INTERVAL
TIMESTAMP=`date -j -f "%s" $TIME +"%Y-%m-%dT%H:%M:%SZ"`

# Generate a URL for each series.
for series in `seq 1 $NUMSERIES`;
do
echo 'http://localhost:8086/write POST {"database" : "db", "retentionPolicy" : "raw", "points": [{"name": "cpu", "tags": {"host": "server'$series'"}, "timestamp": "'$TIMESTAMP'","values": {"value": 100}}]}'
# Generate a URL for each second in the interval.
POINTS=""
for j in `seq 0 $INTERVAL`;
do
# Format the timestamp to ISO 8601.
let CURRTIME=TIME+j
TIMESTAMP=`date -j -f "%s" $CURRTIME +"%Y-%m-%dT%H:%M:%SZ"`

# Add comma separator.
if [ "$j" -ne "0" ]
then
POINTS=$POINTS,
fi

# Append the point.
POINTS=$POINTS'{"name": "cpu", "tags": {"host": "server'$series'"}, "timestamp": "'$TIMESTAMP'","values": {"value": 100}}'
done

# Write out point.
echo 'http://localhost:8086/write POST {"database" : "db", "retentionPolicy" : "raw", "points": ['$POINTS']}'
done

# Move forward the current time.
let TIME=TIME+INTERVAL
done


0 comments on commit b1417ea

Please sign in to comment.