Skip to content

Commit 1ba26c9

Browse files
committed
add the script for common run stress test
1 parent bcd87dd commit 1ba26c9

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/raft/runtest.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
3+
# check the number of arguments
4+
if [ "$#" -ne 2 ]; then
5+
echo "Usage: $0 <test_type> <iterations>"
6+
echo "test_type must be one of 3A, 3B, 3C, 3D"
7+
exit 1
8+
fi
9+
10+
test_type=$1
11+
iterations=$2
12+
13+
# check the test_type
14+
if [[ "$test_type" != "3A" && "$test_type" != "3B" && "$test_type" != "3C" && "$test_type" != "3D" ]]; then
15+
echo "Invalid test_type: $test_type"
16+
echo "test_type must be one of 3A, 3B, 3C, 3D"
17+
exit 1
18+
fi
19+
20+
# check the iterations is a positive integer
21+
if ! [[ "$iterations" =~ ^[0-9]+$ ]]; then
22+
echo "Invalid iterations: $iterations"
23+
echo "iterations must be a positive integer"
24+
exit 1
25+
fi
26+
27+
echo "go test -run $test_type"
28+
for ((i=1; i<=iterations; i++))
29+
do
30+
echo "Running test iteration $i"
31+
output=$(go test -run $test_type 2>&1) # 2>&1 redirects stderr to stdout
32+
if [[ $? -ne 0 ]]; then
33+
echo "Error in iteration $i:"
34+
echo "$output"
35+
fi
36+
done

0 commit comments

Comments
 (0)