diff --git a/tests/siege/README.md b/tests/siege/README.md index 466bb9ca033..ce6c91ca5b3 100644 --- a/tests/siege/README.md +++ b/tests/siege/README.md @@ -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 diff --git a/tests/siege/urlgen b/tests/siege/urlgen index 3ce184dbede..e89eeaaddc2 100755 --- a/tests/siege/urlgen +++ b/tests/siege/urlgen @@ -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 "" @@ -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