Skip to content

Commit f1025b9

Browse files
committed
Add block producer node validation to infrastructure tests
This commit adds connectivity and API capability testing for block producer nodes to the infrastructure testing workflow, mirroring the existing tests for plain nodes.
1 parent 8ecef5a commit f1025b9

File tree

4 files changed

+151
-1
lines changed

4 files changed

+151
-1
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/bin/bash
2+
3+
# Test block producer node API capabilities
4+
# This corresponds to the test-docs-infrastructure.yaml workflow
5+
#
6+
# Usage:
7+
# ./test-block-producer-node-capabilities.sh
8+
#
9+
# This script tests API capabilities of o1Labs block producer nodes
10+
11+
echo "🔍 Testing block producer node API capabilities..."
12+
13+
# Read block producer nodes from file
14+
bp_nodes_file="website/docs/developers/scripts/infrastructure/block-producer-nodes.txt"
15+
bp_nodes=$(cat "$bp_nodes_file")
16+
17+
# Test with first available node
18+
for node_url in $bp_nodes; do
19+
graphql_url="${node_url}graphql"
20+
21+
echo "Testing API capabilities on: $graphql_url"
22+
23+
# Test network ID query using website script
24+
network_success=false
25+
if network_response=$(bash website/docs/developers/scripts/graphql-api/queries/curl/network-id.sh "$graphql_url" 2>&1); then
26+
if echo "$network_response" | jq -e '.data.networkID' > /dev/null 2>&1; then
27+
network_id=$(echo "$network_response" | jq -r '.data.networkID')
28+
echo "✅ Network ID query successful: $network_id"
29+
network_success=true
30+
else
31+
echo "⚠️ Network ID query failed or unexpected response"
32+
fi
33+
else
34+
echo "⚠️ Network ID query script failed"
35+
fi
36+
37+
# Test best chain query using website script
38+
chain_success=false
39+
if chain_response=$(bash website/docs/developers/scripts/graphql-api/queries/curl/best-chain.sh "$graphql_url" 2>&1); then
40+
if echo "$chain_response" | jq -e '.data.bestChain[0].stateHash' > /dev/null 2>&1; then
41+
state_hash=$(echo "$chain_response" | jq -r '.data.bestChain[0].stateHash')
42+
echo "✅ Best chain query successful: ${state_hash:0:16}..."
43+
chain_success=true
44+
else
45+
echo "⚠️ Best chain query failed or unexpected response"
46+
fi
47+
else
48+
echo "⚠️ Best chain query script failed"
49+
fi
50+
51+
# We only need to test one working node
52+
if [ "$network_success" = true ] && [ "$chain_success" = true ]; then
53+
echo "🎉 Block producer node API capabilities verified"
54+
break
55+
fi
56+
done
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/bin/bash
2+
3+
# Test block producer node GraphQL endpoints
4+
# This corresponds to the test-docs-infrastructure.yaml workflow
5+
#
6+
# Usage:
7+
# ./test-block-producer-node-connectivity.sh
8+
#
9+
# This script tests GraphQL connectivity to o1Labs block producer nodes
10+
11+
echo "🔍 Testing block producer node GraphQL connectivity..."
12+
13+
# Read block producer nodes from file
14+
bp_nodes_file="website/docs/developers/scripts/infrastructure/block-producer-nodes.txt"
15+
16+
if [ ! -f "$bp_nodes_file" ]; then
17+
echo "❌ Block producer nodes file not found: $bp_nodes_file"
18+
exit 1
19+
fi
20+
21+
bp_nodes=$(cat "$bp_nodes_file")
22+
failed=0
23+
24+
for node_url in $bp_nodes; do
25+
echo "Testing GraphQL endpoint: $node_url"
26+
27+
# Test basic HTTP connectivity
28+
if curl -s --connect-timeout 10 --max-time 30 "$node_url" > /dev/null 2>&1; then
29+
echo "$node_url is reachable via HTTP"
30+
else
31+
echo "$node_url is not reachable via HTTP"
32+
failed=$((failed + 1))
33+
continue
34+
fi
35+
36+
# Test GraphQL endpoint using website scripts
37+
graphql_url="${node_url}graphql"
38+
39+
# Test daemon status query using the website script
40+
if response=$(bash website/docs/developers/scripts/graphql-api/queries/curl/daemon-status.sh "$graphql_url" 2>&1); then
41+
# Check if it's valid JSON
42+
if echo "$response" | jq . > /dev/null 2>&1; then
43+
# Check for GraphQL errors
44+
if echo "$response" | jq -e '.errors' > /dev/null 2>&1; then
45+
echo "⚠️ $graphql_url returned GraphQL error:"
46+
echo "$response" | jq '.errors'
47+
# Check for valid data
48+
elif echo "$response" | jq -e '.data.daemonStatus' > /dev/null 2>&1; then
49+
echo "$graphql_url GraphQL query successful"
50+
sync_status=$(echo "$response" | jq -r '.data.daemonStatus.syncStatus // "unknown"')
51+
chain_id=$(echo "$response" | jq -r '.data.daemonStatus.chainId // "unknown"')
52+
echo " Sync Status: $sync_status, Chain ID: ${chain_id:0:16}..."
53+
else
54+
echo "⚠️ $graphql_url unexpected response format"
55+
fi
56+
else
57+
echo "⚠️ $graphql_url did not return valid JSON: $(echo "$response" | head -c 100)..."
58+
fi
59+
else
60+
echo "$graphql_url GraphQL query failed"
61+
failed=$((failed + 1))
62+
fi
63+
64+
echo "---"
65+
done
66+
67+
if [ $failed -gt 0 ]; then
68+
echo "💥 $failed block producer node tests failed"
69+
echo "Infrastructure issues detected. Please check block producer node status."
70+
exit 1
71+
else
72+
echo "🎉 All block producer nodes are healthy and responding"
73+
fi

.github/workflows/test-docs-infrastructure.yaml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ name: Test Documentation Scripts - Infrastructure
44
# This workflow validates:
55
# 1. Seed node connectivity and format verification
66
# 2. Plain node GraphQL endpoints and API capabilities
7-
# 3. Infrastructure script functionality
7+
# 3. Block producer node GraphQL endpoints and API capabilities
8+
# 4. Infrastructure script functionality
89
# Scripts can be run locally for development and debugging
910
on:
1011
schedule:
@@ -66,3 +67,21 @@ jobs:
6667
- name: Test infrastructure scripts
6768
run: ./.github/scripts/test-infrastructure-scripts.sh
6869

70+
test-block-producer-nodes:
71+
name: Test Block Producer Node Connectivity
72+
timeout-minutes: 2
73+
strategy:
74+
matrix:
75+
os: [ubuntu-latest, macos-latest]
76+
runs-on: ${{ matrix.os }}
77+
78+
steps:
79+
- name: Checkout repository
80+
uses: actions/checkout@v5
81+
82+
- name: Test block producer node GraphQL endpoints
83+
run: ./.github/scripts/test-block-producer-node-connectivity.sh
84+
85+
- name: Test block producer node API capabilities
86+
run: ./.github/scripts/test-block-producer-node-capabilities.sh
87+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
https://mina-rust-bp-1.gcp.o1test.net/
2+
https://mina-rust-bp-2.gcp.o1test.net/

0 commit comments

Comments
 (0)