#!/usr/bin/env bash # number of entries to preload STATIC_LOAD=1400 NID=$(docker exec m1 docker network ls -q --no-trunc -f name=stressnet) # clear static load if [ -z "$1" -o "$1" = "clean" ]; then echo echo clearing static load for i in $(seq -w 1 $(($STATIC_LOAD/2))); do curl -s 'http://localhost:2000/deleteentry?tname=endpoint_table&nid='${NID}'&key='${i}'087f7d7bb704920af8e33a1e1b9ead7082f80109d175a348ab4f8d1c4e652' -o /dev/null curl -s 'http://localhost:2000/deleteentry?tname=overlay_peer_table&nid='${NID}'&key='${i}'087f7d7bb704920af8e33a1e1b9ead7082f80109d175a348ab4f8d1c4e652' -o /dev/null done fi # introduce static load if [ -z "$1" -o "$1" = "static" ]; then echo introducing static load for i in $(seq -w 1 $(($STATIC_LOAD/2))); do curl -s 'http://localhost:2000/createentry?tname=endpoint_table&nid='${NID}'&key='${i}'087f7d7bb704920af8e33a1e1b9ead7082f80109d175a348ab4f8d1c4e652&value=ChBpbmdyZXNzLWVuZHBvaW50IgU8bmlsPioKMTAuMjU1LjAuNw==' -o /dev/null curl -s 'http://localhost:2000/createentry?tname=overlay_peer_table&nid='${NID}'&key='${i}'087f7d7bb704920af8e33a1e1b9ead7082f80109d175a348ab4f8d1c4e652&value=Cg0xMC4yNTUuMC4yLzE2EhEwMjo0Mjow' -o /dev/null done fi # flap one endpoint in a tight loop if [ -z "$1" -o "$1" = "dynamic" ]; then echo starting dynamic load cat /dev/zero | tr '\0' '1' |pv -qL 300 | stdbuf -oL fold -w 100 | while read; do ( key=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | tr '[A-Z]' '[a-z]' | fold -w 64 | head -n 1) echo $(date -Ins) flapping endpoint_table key $key curl -s 'http://localhost:2000/createentry?tname=endpoint_table&nid='${NID}'&key='${key}'&value=ChBpbmdyZXNzLWVuZHBvaW50IgU8bmlsPioKMTAuMjU1LjAuNw==' >/dev/null sleep 0.5 curl -s 'http://localhost:2000/deleteentry?tname=endpoint_table&nid='${NID}'&key='${key} > /dev/null ) & done fi