Skip to content

Commit 62eba9d

Browse files
committed
feature: refactor to allow built image for setup nodes
1 parent 8d3718e commit 62eba9d

3 files changed

Lines changed: 64 additions & 33 deletions

File tree

.github/workflows/integ-tests.yml

Lines changed: 54 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,11 @@ jobs:
101101

102102
- name: Start 12-node stack (docker-compose)
103103
run: |
104-
bash setup_nodes.sh 12
104+
if [ "${{ github.event_name }}" = "pull_request" ]; then
105+
bash setup_nodes.sh 12 "trieve/threshold:pr-${{ github.event.pull_request.number }}"
106+
else
107+
bash setup_nodes.sh 12 "trieve/threshold:latest"
108+
fi
105109
106110
- name: Wait for gRPC endpoints
107111
run: |
@@ -173,22 +177,26 @@ jobs:
173177

174178
- name: Start 5-node stack (docker-compose)
175179
run: |
176-
docker compose -f docker-compose.yaml up -d
180+
if [ "${{ github.event_name }}" = "pull_request" ]; then
181+
bash setup_nodes.sh 5 "trieve/threshold:pr-${{ github.event.pull_request.number }}"
182+
else
183+
bash setup_nodes.sh 5 "trieve/threshold:latest"
184+
fi
177185
178186
- name: Wait for gRPC endpoint
179187
run: |
180-
echo "Waiting for node to expose port 50051..."
188+
echo "Waiting for node to expose port 50057-50061..."
181189
for i in {1..30}; do
182-
if nc -z localhost 50051; then
183-
echo "Port 50051 is open."
190+
if nc -z localhost {50057..50061}; then
191+
echo "Port 50057-50061 is open."
184192
break
185193
fi
186194
echo "Port not ready yet – retry #$i"
187195
sleep 5
188196
done
189197
190198
- name: Run end-to-end integration tests
191-
run: cargo run --bin integration-tests check-dkg --port-range 50051-50055
199+
run: cargo run --bin integration-tests check-dkg --port-range 50057-50061
192200

193201
end-to-end-deposit-withdrawl:
194202
runs-on: blacksmith-16vcpu-ubuntu-2204
@@ -237,22 +245,26 @@ jobs:
237245

238246
- name: Start 5-node stack (docker-compose)
239247
run: |
240-
docker compose -f docker-compose.yaml up -d
248+
if [ "${{ github.event_name }}" = "pull_request" ]; then
249+
bash setup_nodes.sh 5 "trieve/threshold:pr-${{ github.event.pull_request.number }}"
250+
else
251+
bash setup_nodes.sh 5 "trieve/threshold:latest"
252+
fi
241253
242254
- name: Wait for gRPC endpoint
243255
run: |
244-
echo "Waiting for node to expose port 50051..."
256+
echo "Waiting for node to expose port 50057-50061..."
245257
for i in {1..30}; do
246-
if nc -z localhost 50051; then
247-
echo "Port 50051 is open."
258+
if nc -z localhost {50057..50061}; then
259+
echo "Port 50057-50061 is open."
248260
break
249261
fi
250262
echo "Port not ready yet – retry #$i"
251263
sleep 5
252264
done
253265
254266
- name: Run end-to-end integration tests
255-
run: cargo run --bin integration-tests test
267+
run: cargo run --bin integration-tests test --port-range 50057-50061
256268

257269
- name: Shutdown stack & print logs
258270
run: |
@@ -309,22 +321,26 @@ jobs:
309321

310322
- name: Start 5-node stack with network chaos
311323
run: |
312-
docker compose -f docker-compose.yaml -f docker-compose.chaos-network.yaml up -d
324+
if [ "${{ github.event_name }}" = "pull_request" ]; then
325+
bash setup_nodes.sh 5 "trieve/threshold:pr-${{ github.event.pull_request.number }}"
326+
else
327+
bash setup_nodes.sh 5 "trieve/threshold:latest"
328+
fi
313329
314330
- name: Wait for gRPC endpoint
315331
run: |
316-
echo "Waiting for node to expose port 50051..."
332+
echo "Waiting for node to expose port 50057-50061..."
317333
for i in {1..30}; do
318-
if nc -z localhost 50051; then
319-
echo "Port 50051 is open."
334+
if nc -z localhost {50057..50061}; then
335+
echo "Port 50057-50061 is open."
320336
break
321337
fi
322338
echo "Port not ready yet – retry #$i"
323339
sleep 5
324340
done
325341
326342
- name: Run end-to-end integration tests with network chaos
327-
run: cargo run --bin integration-tests check-dkg --port-range 50051-50055
343+
run: cargo run --bin integration-tests check-dkg --port-range 50057-50061
328344

329345
- name: Shutdown stack & print logs
330346
run: |
@@ -378,22 +394,26 @@ jobs:
378394

379395
- name: Start 5-node stack with node chaos
380396
run: |
381-
docker compose -f docker-compose.yaml -f docker-compose.chaos-nodes.yaml up -d
397+
if [ "${{ github.event_name }}" = "pull_request" ]; then
398+
bash setup_nodes.sh 5 "trieve/threshold:pr-${{ github.event.pull_request.number }}"
399+
else
400+
bash setup_nodes.sh 5 "trieve/threshold:latest"
401+
fi
382402
383403
- name: Wait for gRPC endpoint
384404
run: |
385-
echo "Waiting for node to expose port 50051..."
405+
echo "Waiting for node to expose port 50057-50061..."
386406
for i in {1..30}; do
387-
if nc -z localhost 50051; then
388-
echo "Port 50051 is open."
407+
if nc -z localhost {50057..50061}; then
408+
echo "Port 50057-50061 is open."
389409
break
390410
fi
391411
echo "Port not ready yet – retry #$i"
392412
sleep 5
393413
done
394414
395415
- name: Run end-to-end integration tests with node chaos
396-
run: cargo run --bin integration-tests check-dkg --port-range 50051-50055
416+
run: cargo run --bin integration-tests check-dkg --port-range 50057-50061
397417

398418
- name: Shutdown stack & print logs
399419
run: |
@@ -450,22 +470,26 @@ jobs:
450470

451471
- name: Start 5-node stack with network chaos
452472
run: |
453-
docker compose -f docker-compose.yaml -f docker-compose.chaos-network.yaml up -d
473+
if [ "${{ github.event_name }}" = "pull_request" ]; then
474+
bash setup_nodes.sh 5 "trieve/threshold:pr-${{ github.event.pull_request.number }}"
475+
else
476+
bash setup_nodes.sh 5 "trieve/threshold:latest"
477+
fi
454478
455479
- name: Wait for gRPC endpoint
456480
run: |
457-
echo "Waiting for node to expose port 50051..."
481+
echo "Waiting for node to expose port 50057-50061..."
458482
for i in {1..30}; do
459-
if nc -z localhost 50051; then
460-
echo "Port 50051 is open."
483+
if nc -z localhost {50057..50061}; then
484+
echo "Port 50057-50061 is open."
461485
break
462486
fi
463487
echo "Port not ready yet – retry #$i"
464488
sleep 5
465489
done
466490
467491
- name: Run end-to-end integration tests with network chaos
468-
run: cargo run --bin integration-tests test
492+
run: cargo run --bin integration-tests test --port-range 50057-50061
469493

470494
- name: Shutdown stack & print logs
471495
run: |
@@ -523,18 +547,18 @@ jobs:
523547
524548
- name: Wait for gRPC endpoint
525549
run: |
526-
echo "Waiting for node to expose port 50051..."
550+
echo "Waiting for node to expose port 50057-50061..."
527551
for i in {1..30}; do
528-
if nc -z localhost 50051; then
529-
echo "Port 50051 is open."
552+
if nc -z localhost {50057..50061}; then
553+
echo "Port 50057-50061 is open."
530554
break
531555
fi
532556
echo "Port not ready yet – retry #$i"
533557
sleep 5
534558
done
535559
536560
- name: Run end-to-end integration tests with node chaos
537-
run: cargo run --bin integration-tests test
561+
run: cargo run --bin integration-tests test --port-range 50057-50061
538562

539563
- name: Shutdown stack & print logs
540564
run: |

setup_nodes.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ set -euo pipefail
1616

1717
# --------------------------- Configuration -----------------------------------
1818
NUM_NODES=${1:-5}
19+
IMAGE_TAG=${2:-trieve/threshold:latest}
1920
BASE_DIR="test_artifacts/"
2021

2122
CLI_CMD=(cargo run --quiet --bin cli)
@@ -137,7 +138,7 @@ for i in $(seq 1 "$NUM_NODES"); do
137138

138139
cat >> "$BASE_DIR/test_${NUM_NODES}_nodes/$DOCKER_COMPOSE_FILE" <<EOL
139140
node${i}:
140-
image: threshold-node
141+
image: $IMAGE_TAG
141142
environment:
142143
- KEY_PASSWORD=${KEY_PASSWORD}
143144
- IS_TESTNET=true
@@ -167,7 +168,10 @@ echo "Successfully generated '$BASE_DIR/test_${NUM_NODES}_nodes/$DOCKER_COMPOSE_
167168
echo -e "\nBuilding Docker image..."
168169

169170
cd "$BASE_DIR/test_${NUM_NODES}_nodes"
170-
docker build -t threshold-node -f ../../Dockerfile ../..
171+
172+
if [ -z "$2" ]; then
173+
docker build -t threshold-node -f ../../Dockerfile ../..
174+
fi
171175

172176
# ------------------- Start Docker Compose ----------------------------
173177
echo -e "\nStarting Docker Compose for $NUM_NODES nodes..."

tests/src/bin/integration-tests/main.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ enum Commands {
3535
use_testnet: bool,
3636
#[arg(short, long)]
3737
endpoint: Option<String>,
38+
#[arg(long, default_value = "50051-50055")]
39+
port_range: Option<String>,
3840
},
3941
/// Run the deposit integration flow
4042
DepositTest {
@@ -77,11 +79,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
7779
amount,
7880
endpoint,
7981
use_testnet,
82+
port_range,
8083
} => {
8184
println!("🧪 Running all integration tests...\n");
8285

8386
println!("🔄 Running dkg test...");
84-
check_if_dkg_keys_exist("50051-50055".to_string()).await?;
87+
check_if_dkg_keys_exist(port_range.unwrap_or("50051-50055".to_string())).await?;
8588
println!("✅ DKG test completed\n");
8689

8790
println!("⏳ Waiting for DKG deposit intents to settle (max 60s)...");

0 commit comments

Comments
 (0)