Skip to content

Commit 2803494

Browse files
committed
remove error silencing code
1 parent 6abe968 commit 2803494

File tree

2 files changed

+77
-1
lines changed

2 files changed

+77
-1
lines changed

scripts/tests/archive-node-test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ MINA_TEST_POSTGRES_URI=${POSTGRES_URI:-"postgres://postgres:postgres@localhost:5
1717

1818
echo "Running archive node test"
1919
echo "WARN: Silencing the errors from the archive node test app. One of the tests is expected to fail."
20-
MINA_TEST_POSTGRES_URI=$MINA_TEST_POSTGRES_URI $ARCHIVE_TEST_APP || true
20+
MINA_TEST_POSTGRES_URI=$MINA_TEST_POSTGRES_URI $ARCHIVE_TEST_APP -v

scripts/tests/rosetta-load.sh

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ readonly DEFAULT_PAYMENT_TX_INTERVAL="2"
5858
# Default interval (in seconds) for zkApp transaction API calls
5959
readonly DEFAULT_ZKAPP_TX_INTERVAL="1"
6060

61+
# Default memory threshold for PostgreSQL processes
62+
readonly DEFAULT_POSTGRES_MEMORY_THRESHOLD="2500" # MB
63+
64+
# Default memory threshold for Rosetta API processes
65+
readonly DEFAULT_ROSETTA_MEMORY_THRESHOLD="300" # MB
66+
6167
# Statistics reporting interval (in seconds)
6268
readonly STATS_REPORTING_INTERVAL="10"
6369

@@ -77,6 +83,9 @@ BLOCK_INTERVAL="$DEFAULT_BLOCK_INTERVAL"
7783
ACCOUNT_BALANCE_INTERVAL="$DEFAULT_ACCOUNT_BALANCE_INTERVAL"
7884
PAYMENT_TX_INTERVAL="$DEFAULT_PAYMENT_TX_INTERVAL"
7985
ZKAPP_TX_INTERVAL="$DEFAULT_ZKAPP_TX_INTERVAL"
86+
# Memory thresholds for PostgreSQL and Rosetta processes
87+
POSTGRES_MEMORY_THRESHOLD="$DEFAULT_POSTGRES_MEMORY_THRESHOLD"
88+
ROSETTA_MEMORY_THRESHOLD="$DEFAULT_ROSETTA_MEMORY_THRESHOLD"
8089

8190
# Optional duration limit for test run (in seconds)
8291
DURATION=""
@@ -122,9 +131,14 @@ function usage() {
122131
echo " --max-requests N Stop after N total requests"
123132
echo " If neither is specified, runs indefinitely"
124133
echo ""
134+
echo "Memory thresholds (in MB):"
135+
echo " --postgres-memory-threshold N PostgreSQL memory threshold (default: $DEFAULT_POSTGRES_MEMORY_THRESHOLD)"
136+
echo " --rosetta-memory-threshold N Rosetta memory threshold (default: $DEFAULT_ROSETTA_MEMORY_THRESHOLD)"
137+
echo ""
125138
echo "Examples:"
126139
echo " $0 --network mainnet --duration 300 --max-requests 1000"
127140
echo " $0 --network devnet --address http://localhost:3087 --block-interval 5"
141+
echo " $0 --postgres-memory-threshold 4096 --rosetta-memory-threshold 2048"
128142
}
129143

130144
# Argument parsing
@@ -178,6 +192,14 @@ while [[ $# -gt 0 ]]; do
178192
usage
179193
exit 0
180194
;;
195+
--postgres-memory-threshold)
196+
POSTGRES_MEMORY_THRESHOLD="$2"
197+
shift 2
198+
;;
199+
--rosetta-memory-threshold)
200+
ROSETTA_MEMORY_THRESHOLD="$2"
201+
shift 2
202+
;;
181203
*)
182204
echo "Unknown option: $1"
183205
usage
@@ -427,7 +449,61 @@ function print_load_test_statistics() {
427449
else
428450
echo "$(date '+%Y-%m-%d %H:%M:%S') - 🔄 Current TPS: $current_tps, 📈 Average TPS: $average_tps, 📊 Total Requests: $total_requests"
429451
fi
452+
430453
print_memory_usage
454+
455+
# Assert memory usage is within thresholds
456+
assert_memory_usage_within_thresholds "$POSTGRES_MEMORY_THRESHOLD" "$ROSETTA_MEMORY_THRESHOLD"
457+
}
458+
459+
################################################################################
460+
# Memory Assertion Functions
461+
################################################################################
462+
463+
# Check memory usage against defined thresholds and exit if exceeded
464+
#
465+
# This function monitors memory consumption of PostgreSQL and Rosetta processes
466+
# against specified thresholds. If any process exceeds its threshold, the script
467+
# will log an error and exit with a non-zero status code.
468+
#
469+
# Memory usage is calculated by summing RSS (Resident Set Size) values
470+
# for all matching processes and converting from KB to MB.
471+
#
472+
# Globals:
473+
# None
474+
#
475+
# Arguments:
476+
# $1 - PostgreSQL memory threshold in MB
477+
# $2 - Rosetta memory threshold in MB
478+
#
479+
# Returns:
480+
# 0 if all memory usage is within thresholds
481+
# Exits with code 1 if any threshold is exceeded
482+
function assert_memory_usage_within_thresholds() {
483+
local postgres_threshold="$1"
484+
local rosetta_threshold="$2"
485+
486+
# Check PostgreSQL memory usage
487+
local postgres_memory
488+
postgres_memory=$(ps -p $(pgrep -d, -f postgres) -o rss= 2>/dev/null | awk '{sum+=$1} END {print sum/1024}' 2>/dev/null)
489+
if [[ -n "$postgres_memory" ]]; then
490+
if (( $(echo "$postgres_memory > $postgres_threshold" | bc -l) )); then
491+
echo "❌ MEMORY THRESHOLD EXCEEDED: PostgreSQL using ${postgres_memory} MB (threshold: ${postgres_threshold} MB)"
492+
echo "Load test terminated due to excessive memory usage."
493+
exit 1
494+
fi
495+
fi
496+
497+
# Check Rosetta memory usage
498+
local rosetta_memory
499+
rosetta_memory=$(ps -p $(pgrep -d, -f mina-rosetta) -o rss= 2>/dev/null | awk '{sum+=$1} END {print sum/1024}' 2>/dev/null)
500+
if [[ -n "$rosetta_memory" ]]; then
501+
if (( $(echo "$rosetta_memory > $rosetta_threshold" | bc -l) )); then
502+
echo "❌ MEMORY THRESHOLD EXCEEDED: Mina-rosetta using ${rosetta_memory} MB (threshold: ${rosetta_threshold} MB)"
503+
echo "Load test terminated due to excessive memory usage."
504+
exit 1
505+
fi
506+
fi
431507
}
432508

433509
################################################################################

0 commit comments

Comments
 (0)