@@ -21,9 +21,19 @@ echo ""
2121echo -e " ${YELLOW} Testing Small, Medium, Large, and XLarge scales...${NC} "
2222echo " "
2323
24+ # Determine correct path to internal/state (works from root or ci/ directory)
25+ if [ -d " ./internal/state" ]; then
26+ STATE_PATH=" ./internal/state"
27+ elif [ -d " ../internal/state" ]; then
28+ STATE_PATH=" ../internal/state"
29+ else
30+ echo " Error: Cannot find internal/state directory"
31+ exit 1
32+ fi
33+
2434# Run tests and save output to temp file
2535temp_output=$( mktemp)
26- go test -v -timeout 5m -run ' TestStateOperationsWithinThreshold' ./internal/state/ 2>&1 | tee " $temp_output "
36+ go test -v -timeout 5m -run ' TestStateOperationsWithinThreshold' " $STATE_PATH " 2>&1 | tee " $temp_output "
2737test_exit_code=${PIPESTATUS[0]}
2838
2939echo " "
@@ -33,28 +43,72 @@ printf "%-8s | %-35s | %-10s | %-15s | %-10s | %-6s\n" "Scale" "Entries" "JSON S
3343echo " ------------------------------------------------------------------------------------------------------------"
3444
3545extract_time () {
36- $GREP_CMD -A1 " TestStateOperationsWithinThreshold/$1 /SaveStateToFile" " $temp_output " | $GREP_CMD ' SaveStateToFile took' | $GREP_CMD -oP ' \d+ms' | head -1
46+ # Extract timing by finding the context after "=== RUN TestStateOperationsWithinThreshold/$1/SaveStateToFile"
47+ # then getting the next "SaveStateToFile took" line
48+ awk " /=== RUN TestStateOperationsWithinThreshold\/$1 \/SaveStateToFile/{flag=1; next} flag && /SaveStateToFile took/{print; flag=0}" " $temp_output " | \
49+ sed -E ' s/.*took ([0-9]+)ms.*/\1/' | \
50+ head -1
51+ }
52+
53+ extract_size () {
54+ # Extract size by finding the context after "=== RUN TestStateOperationsWithinThreshold/$1/Marshal"
55+ # then getting the next "Marshal took" line with size
56+ awk " /=== RUN TestStateOperationsWithinThreshold\/$1 \/Marshal/{flag=1; next} flag && /Marshal took.*size:/{print; flag=0}" " $temp_output " | \
57+ sed -E ' s/.*size: ([0-9.]+) MB.*/\1 MB/' | \
58+ head -1
3759}
3860
3961# Small
4062small_time=$( extract_time " Small" )
41- [ -n " $small_time " ] && printf " %-8s | %-35s | %-10s | %-15s | %-10s | " " Small" " 16 rate / 65K bots / 256 verified" " 3.87 MB" " $small_time " " <500ms"
42- [ -n " $small_time " ] && [ " ${small_time% ms} " -le 500 ] && echo -e " ${GREEN} ✅${NC} " || echo -e " ${RED} ❌${NC} "
63+ small_size=$( extract_size " Small" )
64+ if [ -n " $small_time " ]; then
65+ printf " %-8s | %-35s | %-10s | %-15s | %-10s | " " Small" " 16 rate / 65K bots / 256 verified" " ${small_size:- N/ A} " " ${small_time} ms" " <500ms"
66+ if [ " $small_time " -le 500 ]; then
67+ echo -e " ${GREEN} ✅${NC} "
68+ else
69+ echo -e " ${RED} ❌${NC} "
70+ test_exit_code=1
71+ fi
72+ fi
4373
4474# Medium
4575medium_time=$( extract_time " Medium" )
46- [ -n " $medium_time " ] && printf " %-8s | %-35s | %-10s | %-15s | %-10s | " " Medium" " 256 rate / 262K bots / 65K verified" " 19.31 MB" " $medium_time " " <1s"
47- [ -n " $medium_time " ] && [ " ${medium_time% ms} " -le 1000 ] && echo -e " ${GREEN} ✅${NC} " || echo -e " ${RED} ❌${NC} "
76+ medium_size=$( extract_size " Medium" )
77+ if [ -n " $medium_time " ]; then
78+ printf " %-8s | %-35s | %-10s | %-15s | %-10s | " " Medium" " 256 rate / 262K bots / 65K verified" " ${medium_size:- N/ A} " " ${medium_time} ms" " <1s"
79+ if [ " $medium_time " -le 1000 ]; then
80+ echo -e " ${GREEN} ✅${NC} "
81+ else
82+ echo -e " ${RED} ❌${NC} "
83+ test_exit_code=1
84+ fi
85+ fi
4886
4987# Large
5088large_time=$( extract_time " Large" )
51- [ -n " $large_time " ] && printf " %-8s | %-35s | %-10s | %-15s | %-10s | " " Large" " 1K rate / 1M bots / 262K verified" " 77.61 MB" " $large_time " " <3s"
52- [ -n " $large_time " ] && [ " ${large_time% ms} " -le 3000 ] && echo -e " ${GREEN} ✅${NC} " || echo -e " ${RED} ❌${NC} "
89+ large_size=$( extract_size " Large" )
90+ if [ -n " $large_time " ]; then
91+ printf " %-8s | %-35s | %-10s | %-15s | %-10s | " " Large" " 1K rate / 1M bots / 262K verified" " ${large_size:- N/ A} " " ${large_time} ms" " <3s"
92+ if [ " $large_time " -le 3000 ]; then
93+ echo -e " ${GREEN} ✅${NC} "
94+ else
95+ echo -e " ${RED} ❌${NC} "
96+ test_exit_code=1
97+ fi
98+ fi
5399
54100# XLarge
55101xlarge_time=$( extract_time " XLarge" )
56- [ -n " $xlarge_time " ] && printf " %-8s | %-35s | %-10s | %-15s | %-10s | " " XLarge" " 4K rate / 4.2M bots / 1M verified" " 312.68 MB" " $xlarge_time " " <10s"
57- [ -n " $xlarge_time " ] && [ " ${xlarge_time% ms} " -le 10000 ] && echo -e " ${GREEN} ✅${NC} " || echo -e " ${RED} ❌${NC} "
102+ xlarge_size=$( extract_size " XLarge" )
103+ if [ -n " $xlarge_time " ]; then
104+ printf " %-8s | %-35s | %-10s | %-15s | %-10s | " " XLarge" " 4K rate / 4.2M bots / 1M verified" " ${xlarge_size:- N/ A} " " ${xlarge_time} ms" " <10s"
105+ if [ " $xlarge_time " -le 10000 ]; then
106+ echo -e " ${GREEN} ✅${NC} "
107+ else
108+ echo -e " ${RED} ❌${NC} "
109+ test_exit_code=1
110+ fi
111+ fi
58112
59113echo " "
60114
0 commit comments