Skip to content

Commit a24944f

Browse files
authored
fix(justfile): resolve .env file issues for integration tests (#800)
Add setup-integration-env rule to create a symlink to local-network/.env dependency.
1 parent 4e8f654 commit a24944f

File tree

1 file changed

+40
-25
lines changed

1 file changed

+40
-25
lines changed

justfile

Lines changed: 40 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,26 @@
44
# # print the help
55
help:
66
just -l
7-
87
deps:
98
cargo install sqlx-cli --no-default-features --features native-tls,postgres
10-
119
url:
1210
@echo export DATABASE_URL=postgresql://postgres:postgres@127.0.0.1:5432
13-
1411
clippy:
1512
cargo +nightly clippy --all-targets --all-features
16-
1713
# run everything that is needed for ci to pass
1814
ci:
1915
just fmt
2016
just clippy
2117
just test
2218
just sqlx-prepare
23-
24-
2519
test:
2620
RUST_LOG=debug cargo nextest run
27-
2821
review:
2922
RUST_LOG=debug cargo insta review
30-
3123
fmt:
3224
cargo +nightly fmt
33-
3425
sqlx-prepare:
3526
cargo sqlx prepare --workspace -- --all-targets --all-features
36-
3727
psql-up:
3828
@docker run -d --name indexer-rs-psql -p 5432:5432 -e POSTGRES_PASSWORD=postgres postgres
3929
@sleep 5
@@ -42,24 +32,34 @@ psql-up:
4232
psql-down:
4333
docker stop indexer-rs-psql
4434
docker rm indexer-rs-psql
45-
4635
migrate:
4736
sqlx migrate run --database-url postgresql://postgres:postgres@127.0.0.1:5432
4837

38+
# Creates symlink to contrib/local-network/.env file
39+
# Required for scripts that need to read contract addresses and network config
40+
# Assumes the local-network submodule is present (run 'just setup' if missing)
41+
setup-integration-env:
42+
@if [ ! -f integration-tests/.env ]; then \
43+
ln -sf ../contrib/local-network/.env integration-tests/.env; \
44+
echo "Symlink to local-network .env created"; \
45+
else \
46+
echo "Integration tests .env already exists"; \
47+
fi
4948

5049
# Development workflow commands
5150
# -----------------------------
52-
53-
# Full setup for testing
54-
# using a local network
51+
# Full setup for testing using a local network
52+
# This deploys all containers, contracts, and funds escrow
5553
setup:
5654
./setup-test-network.sh
5755

5856
# Rebuild binaries and restart services after code changes
59-
reload:
57+
# Assumes local network is already running (run 'just setup' if not)
58+
reload: setup-integration-env
6059
./dev-reload.sh
6160

6261
# Watch log output from services
62+
# Assumes local network is already running (run 'just setup' if not)
6363
logs:
6464
@cd contrib && docker compose -f docker-compose.dev.yml logs -f
6565

@@ -69,32 +69,35 @@ down:
6969
@cd contrib/local-network && docker compose down
7070
docker rm -f indexer-service tap-agent gateway block-oracle indexer-agent graph-node redpanda tap-aggregator tap-escrow-manager 2>/dev/null || true
7171

72-
7372
# Profiling commands
7473
# -----------------------------
75-
7674
# Profile indexer-service with flamegraph
77-
profile-flamegraph:
75+
# Assumes local network is already running (run 'just setup' if not)
76+
profile-flamegraph: setup-integration-env
7877
@mkdir -p contrib/profiling/output
7978
./prof-reload.sh flamegraph
8079

8180
# Profile indexer-service with valgrind
82-
profile-valgrind:
81+
# Assumes local network is already running (run 'just setup' if not)
82+
profile-valgrind: setup-integration-env
8383
@mkdir -p contrib/profiling/output
8484
./prof-reload.sh valgrind
8585

8686
# Profile indexer-service with strace
87-
profile-strace:
87+
# Assumes local network is already running (run 'just setup' if not)
88+
profile-strace: setup-integration-env
8889
@mkdir -p contrib/profiling/output
8990
./prof-reload.sh strace
9091

91-
profile-callgrind:
92+
# Profile indexer-service with callgrind
93+
# Assumes local network is already running (run 'just setup' if not)
94+
profile-callgrind: setup-integration-env
9295
@mkdir -p contrib/profiling/output
9396
./prof-reload.sh callgrind
9497

9598
# Stop the running indexer-service (useful after profiling)
9699
# This sends SIGTERM, allowing the trap in start-perf.sh to handle cleanup (e.g., generate flamegraph)
97-
stop-profiling: # <-- New Rule Added Here
100+
stop-profiling:
98101
@echo "🛑 Stopping the indexer-service container (allowing profiling data generation)..."
99102
cd contrib && docker compose -f docker-compose.prof.yml stop indexer-service tap-agent
100103
@echo "✅ Service stop signal sent. Check profiling output directory."
@@ -105,15 +108,27 @@ profile-restore:
105108
cd contrib && docker compose -f docker-compose.prof.yml up -d --force-recreate indexer-service tap-agent
106109
@echo "✅ Normal service restored"
107110

111+
# Integration test commands (assume local network is already running)
112+
# For fresh setup, run 'just setup' first to deploy all infrastructure
113+
# -----------------------------------------------------------------------------
108114

109-
test-local:
115+
# Test RAV v1 receipts (legacy TAP)
116+
# Assumes local network is running - run 'just setup' if services are not available
117+
test-local: setup-integration-env
118+
@echo "Running RAV v1 integration tests (assumes local network is running)..."
110119
@cd integration-tests && ./fund_escrow.sh
111120
@cd integration-tests && cargo run -- rav1
112121

113-
test-local-v2:
122+
# Test RAV v2 receipts (Horizon TAP)
123+
# Assumes local network is running - run 'just setup' if services are not available
124+
test-local-v2: setup-integration-env
125+
@echo "Running RAV v2 integration tests (assumes local network is running)..."
114126
@cd integration-tests && ./fund_escrow.sh
115127
@cd integration-tests && cargo run -- rav2
116128

117-
load-test-v2 num_receipts="1000":
129+
# Load test with v2 receipts
130+
# Assumes local network is running - run 'just setup' if services are not available
131+
load-test-v2 num_receipts="1000": setup-integration-env
132+
@echo "Running load test with {{num_receipts}} receipts (assumes local network is running)..."
118133
@cd integration-tests && ./fund_escrow.sh
119134
@cd integration-tests && cargo run -- load-v2 --num-receipts {{num_receipts}}

0 commit comments

Comments
 (0)