Skip to content

Instantly share code, notes, and snippets.

@mark-rushakoff
Created August 18, 2016 04:31
Show Gist options
  • Save mark-rushakoff/dfd1141d0a61dbc302c69af72d4997de to your computer and use it in GitHub Desktop.
Save mark-rushakoff/dfd1141d0a61dbc302c69af72d4997de to your computer and use it in GitHub Desktop.
Simple micro-load generator for InfluxDB using docker-compose
#!/bin/bash
url=http://influxdb:8086
db=loadtest_$RANDOM
set -e
curl -s -XPOST "$url/query?" --data-urlencode "q=CREATE DATABASE $db WITH DURATION 1h SHARD DURATION 10s" > /dev/null
write_and_test() {
local series=$1
local n=$2
local point="ctr,s=$series n=$n"
curl -s -XPOST "$url/write?db=$db" --data-binary "$point" > /dev/null
local query="SELECT last(n) FROM ctr WHERE s='$series'"
curl -s "$url/query?db=$db" --data-urlencode "q=$query" > /dev/null
}
n=0
while true; do
n=$((n+1))
for series in $(seq 10); do
write_and_test $series $n
done
done
version: '2'
services:
influxdb:
environment:
INFLUXDB_HTTP_LOG_ENABLED: "false"
INFLUXDB_DATA_QUERY_LOG_ENABLED: "false"
image: influxdb:1.0.0-beta3-alpine
ports:
- 8086
client:
build:
context: .
dockerfile: Dockerfile_client
links:
- influxdb
FROM alpine:latest
RUN apk add --no-cache \
bash \
curl
COPY ./client.sh /client.sh
CMD ["/client.sh"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment