@@ -14,6 +14,7 @@ RUN_INTEGRATION=true
1414RUN_STACK=true
1515CAP=1
1616LOAD_TEST=" operators"
17+ LOAD_GREP=" Slow lane deterministic contention"
1718BOOTSTRAP_TIMEOUT_SECONDS=180
1819
1920RED=' \033[0;31m'
@@ -33,7 +34,8 @@ Options:
3334 --integration-only Run only deterministic Rust integration assertions.
3435 --stack-only Run only local-stack multi-listener SQL assertions.
3536 --cap N Slow-lane cap for stack scenario (default: 1).
36- --load-test NAME fhevm-cli test to generate load (default: operators).
37+ --load-grep PATTERN run-tests grep for deterministic load (default: "Slow lane deterministic contention").
38+ --load-test NAME fhevm-cli test fallback when --load-grep is empty (default: operators).
3739 --bootstrap-timeout SEC Timeout for key-bootstrap gate (default: 180).
3840 -h, --help Show this help.
3941EOF
@@ -128,9 +130,11 @@ wait_for_bootstrap() {
128130 local has_activate_key
129131 local has_fetched_keyset
130132 local has_key_material
133+ local sns_waiting_for_keys
131134
132135 has_activate_key=" $( docker logs --since=20m coprocessor-gw-listener 2>&1 | rg -c " ActivateKey event successful" || true) "
133136 has_fetched_keyset=" $( docker logs --since=20m coprocessor-sns-worker 2>&1 | rg -c " Fetched keyset" || true) "
137+ sns_waiting_for_keys=" $( docker logs --since=2m coprocessor-sns-worker 2>&1 | rg -c " No keys available, retrying" || true) "
134138 has_key_material=" $( db_query "
135139 SELECT COALESCE(bool_and(key_bytes > 0), false)
136140 FROM (
@@ -146,6 +150,10 @@ wait_for_bootstrap() {
146150 log " Bootstrap gate passed (ActivateKey + keyset + non-empty sns_pk)"
147151 return 0
148152 fi
153+ if [[ " ${has_key_material} " == " t" && " ${sns_waiting_for_keys} " == " 0" ]]; then
154+ log " Bootstrap gate passed (non-empty sns_pk and sns-worker not waiting for keys)"
155+ return 0
156+ fi
149157 sleep 3
150158 done
151159
@@ -155,11 +163,28 @@ wait_for_bootstrap() {
155163 local retry_deadline=$(( SECONDS + BOOTSTRAP_TIMEOUT_SECONDS))
156164 while (( SECONDS < retry_deadline )) ; do
157165 local has_fetched_keyset
166+ local has_key_material
167+ local sns_waiting_for_keys
158168 has_fetched_keyset=" $( docker logs --since=20m coprocessor-sns-worker 2>&1 | rg -c " Fetched keyset" || true) "
169+ sns_waiting_for_keys=" $( docker logs --since=2m coprocessor-sns-worker 2>&1 | rg -c " No keys available, retrying" || true) "
170+ has_key_material=" $( db_query "
171+ SELECT COALESCE(bool_and(key_bytes > 0), false)
172+ FROM (
173+ SELECT COALESCE(SUM(octet_length(lo.data)), 0) AS key_bytes
174+ FROM tenants t
175+ LEFT JOIN pg_largeobject lo
176+ ON lo.loid = t.sns_pk
177+ GROUP BY t.tenant_id
178+ ) s;
179+ " ) "
159180 if [[ " ${has_fetched_keyset} " -gt 0 ]]; then
160181 log " Bootstrap recovered after gw-listener restart"
161182 return 0
162183 fi
184+ if [[ " ${has_key_material} " == " t" && " ${sns_waiting_for_keys} " == " 0" ]]; then
185+ log " Bootstrap recovered from persisted key material state"
186+ return 0
187+ fi
163188 sleep 3
164189 done
165190
@@ -215,7 +240,11 @@ run_integration_assertions() {
215240}
216241
217242run_stack_assertions () {
218- log " Running local-stack assertions (cap=${CAP} , load=${LOAD_TEST} )"
243+ if [[ -n " ${LOAD_GREP} " ]]; then
244+ log " Running local-stack assertions (cap=${CAP} , grep=${LOAD_GREP} )"
245+ else
246+ log " Running local-stack assertions (cap=${CAP} , load=${LOAD_TEST} )"
247+ fi
219248 wait_for_bootstrap
220249
221250 local before_block_height
@@ -224,10 +253,14 @@ run_stack_assertions() {
224253
225254 apply_listener_cap_override " ${CAP} "
226255
227- (
228- cd " ${FHEVM_DIR} "
229- ./fhevm-cli test " ${LOAD_TEST} "
230- )
256+ if [[ -n " ${LOAD_GREP} " ]]; then
257+ docker exec fhevm-test-suite-e2e-debug ./run-tests.sh -n staging -g " ${LOAD_GREP} "
258+ else
259+ (
260+ cd " ${FHEVM_DIR} "
261+ ./fhevm-cli test " ${LOAD_TEST} "
262+ )
263+ fi
231264
232265 local counts
233266 counts=" $( db_query "
@@ -287,6 +320,11 @@ while (( "$#" )); do
287320 LOAD_TEST=" $2 "
288321 shift 2
289322 ;;
323+ --load-grep)
324+ [[ $# -ge 2 ]] || die " --load-grep requires a value"
325+ LOAD_GREP=" $2 "
326+ shift 2
327+ ;;
290328 --bootstrap-timeout)
291329 [[ $# -ge 2 ]] || die " --bootstrap-timeout requires a value"
292330 BOOTSTRAP_TIMEOUT_SECONDS=" $2 "
0 commit comments