Skip to content

Commit ddda0c3

Browse files
authored
feat: Enhance Integration Tests with Load Testing for the indexer-service (#723)
* feat: add new load test to measure receipt handler in service * refactor: remove duplicated start script * chore: move constants to its own file * feat: Implement CLI for test execution using Clap Introduces a command-line interface powered by Clap to select and configure integration tests. This allows for more flexible test runs, including the ability to pass specific parameters like 'num_receipts' to different test suites. Additionally, constants used across tests have been centralized into a dedicated module for improved organization and maintainability. * chore: remove line to wait for db * style: fix typo in comments
1 parent 6681ed7 commit ddda0c3

File tree

10 files changed

+293
-172
lines changed

10 files changed

+293
-172
lines changed

Cargo.lock

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

contrib/docker-compose.prof.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ services:
99
- ./local-network/.env:/opt/.env:ro
1010
- ./profiling:/opt/profiling:rw
1111
- ./indexer-service/config.toml:/opt/config/config.toml
12-
- ./indexer-service/start-perf.sh:/usr/local/bin/start-perf.sh
12+
- ./indexer-service/start.sh:/usr/local/bin/start.sh
1313
- ../migrations:/opt/migrations:ro
1414
- ../target/release/indexer-service-rs:/usr/local/bin/indexer-service-rs
15-
entrypoint: ["/usr/local/bin/start-perf.sh"]
15+
entrypoint: ["/usr/local/bin/start.sh"]
1616
environment:
1717
- RUST_BACKTRACE=1
1818
- RUST_LOG=debug

contrib/indexer-service/Dockerfile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ COPY --from=build /root/target/release/indexer-service-rs /usr/local/bin/indexer
2323
# Copy our start script into the image
2424
COPY contrib/indexer-service/start.sh /usr/local/bin/start.sh
2525
COPY contrib/indexer-service/config.toml /opt/config/config.toml
26-
COPY contrib/indexer-service/start-perf.sh /usr/local/bin/start-perf.sh
2726

2827
RUN chmod +x /usr/local/bin/start.sh
29-
RUN chmod +x /usr/local/bin/start-perf.sh
3028

31-
ENTRYPOINT [ "/usr/local/bin/start-perf.sh" ]
29+
ENTRYPOINT [ "/usr/local/bin/start.sh" ]

contrib/indexer-service/start-perf.sh

Lines changed: 0 additions & 126 deletions
This file was deleted.

contrib/indexer-service/start.sh

Lines changed: 72 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@ VERIFIER_ADDRESS=$(jq -r '."1337".TAPVerifier.address' /opt/contracts.json)
1313
# Override with test values taken from test-assets/src/lib.rs
1414
ALLOCATION_ID="0xfa44c72b753a66591f241c7dc04e8178c30e13af" # ALLOCATION_ID_0
1515

16-
# Wait for postgres to be ready
17-
until pg_isready -h postgres -U postgres -d indexer_components_1; do
18-
stdbuf -oL echo "Waiting for postgres..."
19-
sleep 2
20-
done
21-
2216
# Get network subgraph deployment ID
2317
NETWORK_DEPLOYMENT=$(curl -s "http://graph-node:8000/subgraphs/name/graph-network" \
2418
-H 'content-type: application/json' \
@@ -57,8 +51,76 @@ stdbuf -oL echo "Testing graph-node endpoints..."
5751
curl -s "http://graph-node:8000" >/dev/null && stdbuf -oL echo "Query endpoint OK" || stdbuf -oL echo "Query endpoint FAILED"
5852
curl -s "http://graph-node:8030/graphql" >/dev/null && stdbuf -oL echo "Status endpoint OK" || stdbuf -oL echo "Status endpoint FAILED"
5953

60-
# Run service with verbose logging
54+
# Set profiling tool based on environment variable
55+
# Default is no profiling
56+
PROFILER="${PROFILER:-none}"
57+
stdbuf -oL echo "🔍 DEBUG: Profiling with: $PROFILER"
58+
59+
# Set environment variables for the service
6160
export RUST_BACKTRACE=full
62-
# export RUST_LOG=debug
63-
export RUST_LOG=trace
64-
exec /usr/local/bin/indexer-service-rs --config /opt/config.toml
61+
export RUST_LOG="${RUST_LOG:-trace}"
62+
63+
# Create output directory if it doesn't exist
64+
mkdir -p /opt/profiling/indexer-service
65+
chmod 777 /opt/profiling
66+
chmod 777 /opt/profiling/indexer-service
67+
68+
stdbuf -oL echo "📁 DEBUG: Profiling output directory: $(ls -la /opt/profiling)"
69+
70+
case "$PROFILER" in
71+
flamegraph)
72+
stdbuf -oL echo "🔥 Starting with profiler..."
73+
74+
# Start the service in the background with output redirection
75+
stdbuf -oL echo "🚀 Starting service..."
76+
exec /usr/local/bin/indexer-service-rs --config /opt/config.toml
77+
;;
78+
strace)
79+
stdbuf -oL echo "🔍 Starting with strace..."
80+
# -f: follow child processes
81+
# -tt: print timestamps with microsecond precision
82+
# -T: show time spent in each syscall
83+
# -e trace=all: trace all system calls
84+
# -s 256: show up to 256 characters per string
85+
# -o: output file
86+
exec strace -f -tt -T -e trace=all -s 256 -o /opt/profiling/indexer-service/strace.log /usr/local/bin/indexer-service-rs --config /opt/config.toml
87+
;;
88+
valgrind)
89+
stdbuf -oL echo "🔍 Starting with Valgrind profiling..."
90+
91+
# Start with Massif memory profiler
92+
stdbuf -oL echo "🔄 Starting Valgrind Massif memory profiling..."
93+
exec valgrind --tool=massif \
94+
--massif-out-file=/opt/profiling/indexer-service/massif.out \
95+
--time-unit=B \
96+
--detailed-freq=10 \
97+
--max-snapshots=100 \
98+
--threshold=0.5 \
99+
/usr/local/bin/indexer-service-rs --config /opt/config.toml
100+
;;
101+
# Use callgrind_annotate indexer-service.callgrind.out
102+
# for human-friendly report of callgrind output
103+
# Ideally you should set:
104+
# [profile.release.package."*"]
105+
# debug = true
106+
# force-frame-pointers = true
107+
# in the Cargo.toml
108+
callgrind)
109+
stdbuf -oL echo "🔍 Starting with Callgrind CPU profiling..."
110+
exec valgrind --tool=callgrind \
111+
--callgrind-out-file=/opt/profiling/indexer-service/callgrind.out \
112+
--cache-sim=yes \
113+
--branch-sim=yes \
114+
--collect-jumps=yes \
115+
--collect-systime=yes \
116+
--collect-bus=yes \
117+
--dump-instr=yes \
118+
--dump-line=yes \
119+
--compress-strings=no \
120+
/usr/local/bin/indexer-service-rs --config /opt/config.toml
121+
;;
122+
none)
123+
stdbuf -oL echo "🔍 Starting without profiling..."
124+
exec /usr/local/bin/indexer-service-rs --config /opt/config.toml
125+
;;
126+
esac

integration-tests/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@ bip39 = { workspace = true }
2323
rand.workspace = true
2424

2525
indexer-receipt = { path = "../crates/indexer-receipt" }
26+
num_cpus = "1.16.0"
27+
clap = { version = "4.0", features = ["derive"] }

integration-tests/src/constants.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright 2023-, Edge & Node, GraphOps, and Semiotic Labs.
2+
// SPDX-License-Identifier: Apache-2.0
3+
//
4+
//
5+
//! Constants used in the integration tests for the TAP RAV generation
6+
//! their value is taken from local-network .env variable
7+
8+
pub const INDEXER_URL: &str = "http://localhost:7601";
9+
10+
pub const GATEWAY_API_KEY: &str = "deadbeefdeadbeefdeadbeefdeadbeef";
11+
pub const GATEWAY_URL: &str = "http://localhost:7700";
12+
pub const TAP_AGENT_METRICS_URL: &str = "http://localhost:7300/metrics";
13+
14+
// The deployed gateway and indexer
15+
// use this verifier contract
16+
// which must be part of the eip712 domain
17+
// and the signing key account0_secret
18+
// they must match otherwise receipts would be rejected
19+
pub const TAP_VERIFIER_CONTRACT: &str = "0x8198f5d8F8CfFE8f9C413d98a0A55aEB8ab9FbB7";
20+
pub const ACCOUNT0_SECRET: &str =
21+
"ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80";
22+
pub const CHAIN_ID: u64 = 1337;
23+
24+
pub const SUBGRAPH_ID: &str = "QmV4R5g7Go94bVFmKTVFG7vaMTb1ztUUWb45mNrsc7Yyqs";
25+
26+
pub const GRAPH_URL: &str = "http://localhost:8000/subgraphs/name/graph-network";
27+
28+
pub const GRT_DECIMALS: u8 = 18;
29+
pub const GRT_BASE: u128 = 10u128.pow(GRT_DECIMALS as u32);
30+
31+
pub const MAX_RECEIPT_VALUE: u128 = GRT_BASE / 10_000;

0 commit comments

Comments
 (0)