#!/bin/bash # # A script to upload random data to a swarm cluster. # # Example: # # random-uploads.sh --addr 192.168.33.101:8500 --size 40k --count 1000 set -e ROOT="$(cd "$(dirname "$0")/../../.." && pwd)" source "${ROOT}/swarm/dev/scripts/util.sh" DEFAULT_ADDR="localhost:8500" DEFAULT_UPLOAD_SIZE="40k" DEFAULT_UPLOAD_COUNT="1000" usage() { cat >&2 </dev/null } parse_args() { while true; do case "$1" in -h | --help) usage exit 0 ;; -a | --addr) if [[ -z "$2" ]]; then fail "--addr flag requires an argument" fi addr="$2" shift 2 ;; -s | --size) if [[ -z "$2" ]]; then fail "--size flag requires an argument" fi upload_size="$2" shift 2 ;; -c | --count) if [[ -z "$2" ]]; then fail "--count flag requires an argument" fi upload_count="$2" shift 2 ;; *) break ;; esac done if [[ $# -ne 0 ]]; then usage fail "ERROR: invalid arguments: $@" fi } main "$@"