Verified Commit 6d3ae38c authored by Philipp Winter's avatar Philipp Winter
Browse files

Make it possible to test bridges in buckets.

parent 21b28c65
...@@ -3,27 +3,47 @@ ...@@ -3,27 +3,47 @@
# Test a batch of bridge lines by running: # Test a batch of bridge lines by running:
# ./test-bridge-lines /path/to/file # ./test-bridge-lines /path/to/file
if [ "$#" -ne 1 ]; then if [ "$#" -ne 1 ] && [ "$#" -ne 2 ]
echo "Usage: $0 BRIDGE_LINE_FILE" then
echo "Usage: $0 BRIDGE_LINE_FILE [LINES_PER_TEST]"
exit 1 exit 1
fi fi
bridge_lines="" # By default, we're testing 25 bridge lines at a time.
if [ "$#" -eq 2 ]
then
lines_per_test="$2"
else
lines_per_test=25
fi
IFS=$'\n' IFS=$'\n'
num_bridges=$(wc -l "$1" | cut -d ' ' -f 1)
for line in $(cat "$1") # Iterate over our bridge lines, in chunks of $lines_per_test.
for i in $(seq 1 "$lines_per_test" "$num_bridges")
do do
inc=$(( $lines_per_test < $num_bridges ? $lines_per_test : $num_bridges ))
j=$((i + $inc - 1))
bridge_lines=""
for line in $(sed -n "${i},${j}p" "$1")
do
if [ -z "$bridge_lines" ] if [ -z "$bridge_lines" ]
then then
bridge_lines="\"$line\"" bridge_lines="\"$line\""
else else
bridge_lines="${bridge_lines}, \"${line}\"" bridge_lines="${bridge_lines}, \"${line}\""
fi fi
done done
filename=$(mktemp) tmp_file=$(mktemp)
echo "{\"bridge_lines\": [ $bridge_lines ]}" > "$filename" echo "{\"bridge_lines\": [ $bridge_lines ]}" > "$tmp_file"
curl -s -X GET localhost:5000/bridge-state -d "@${filename}" | python -m json.tool # cat "$tmp_file"
rm -f "$filename" curl -s -X GET localhost:5000/bridge-state -d "@${tmp_file}" | python -m json.tool
rm -f "$tmp_file"
done
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment