Skip to content

Commit

Permalink
Adding script to inspect kurtosis endpoints.
Browse files Browse the repository at this point in the history
  • Loading branch information
jer117 committed Nov 16, 2024
1 parent 69969d6 commit 994d200
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 16 deletions.
16 changes: 16 additions & 0 deletions .github/consensus_synced.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
endpoints:
- name: "local"
executionUrl: http://127.0.0.1:32773
consensusUrl: http://127.0.0.1:32786

tests:
- name: "basic"
timeout: 48h
tasks:
- name: check_clients_are_healthy
title: "Consensus client is healthy"
config:
skipExecutionCheck: true

- name: check_consensus_sync_status
title: consensus is synced
35 changes: 35 additions & 0 deletions .github/geth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import http from 'k6/http';
import { check, sleep } from 'k6';

// Define the execution and consensus URLs
const executionUrl = 'http://127.0.0.1:32773'; // Replace with your actual execution URL
const consensusUrl = 'http://127.0.0.1:32786'; // Replace with your actual consensus URL

export default function () {
// Test the execution endpoint
let execRes = http.get(`${executionUrl}/health`); // Adjust the endpoint as needed
check(execRes, {
'Execution service is up': (r) => r.status === 200,
});

// Test the consensus endpoint
let consRes = http.get(`${consensusUrl}/health`); // Adjust the endpoint as needed
check(consRes, {
'Consensus service is up': (r) => r.status === 200,
});

// Optional: Add more specific checks based on your application's API responses
if (execRes.status === 200) {
check(execRes, {
'Execution response contains expected data': (r) => r.json().status === 'synced', // Example check
});
}

if (consRes.status === 200) {
check(consRes, {
'Consensus response contains expected data': (r) => r.json().status === 'synced', // Example check
});
}

sleep(1); // Pause for a second between iterations
}
72 changes: 57 additions & 15 deletions .github/scripts/inspect_cluster.sh
Original file line number Diff line number Diff line change
@@ -1,27 +1,69 @@
#!/bin/bash

# Inspect the Kurtosis enclave
# Inspect the Kurtosis enclave and capture the output
output=$(kurtosis enclave inspect my-testnet)

# Extract relevant information
services=$(echo "$output" | awk '/User Services/,/Search results:/ {if(NR>4) print $0}')
# Check if the command succeeded
if [[ $? -ne 0 ]]; then
echo "Error: Failed to inspect the enclave 'my-testnet'."
exit 1
fi

# Prepare an array to hold service details
declare -a service_details
# Prepare an array to hold endpoint configurations
declare -a endpoints

# Loop through each service entry
# Extract the "User Services" section from the output
services_section=$(echo "$output" | awk '/User Services:/,0' | sed '1d')

# Debugging: Output the services section for inspection
echo "Services section extracted:"
echo "$services_section"

# Loop through each line in the services section
while IFS= read -r line; do
# Skip empty lines
[[ -z "$line" ]] && continue
# Skip empty or invalid lines
[[ -z "$line" || "$line" =~ ^Search\ results: ]] && continue

# Extract UUID, Name, and Ports
# Debugging: Output each line being processed
echo "Processing line: $line"

# Extract UUID, Name, and Ports using awk
uuid=$(echo "$line" | awk '{print $1}')
name=$(echo "$line" | awk '{print $2}')
ports=$(echo "$line" | awk '{for(i=3;i<=NF;i++) printf $i " "; print ""}' | sed 's/ *$//') # Join all remaining fields as ports
ports=$(echo "$line" | awk '{for(i=3;i<=NF;i++) printf $i " "; print ""}' | sed 's/ *$//')

# Debugging: Output the extracted UUID, Name, and Ports
echo "UUID: $uuid"
echo "Name: $name"
echo "Ports: $ports"

# Check if the service is related to an execution client (e.g., Geth, Lodestar, Prysm)
if [[ "$name" == *"geth"* || "$name" == *"lodestar"* || "$name" == *"prysm"* ]]; then
# Extract RPC and Metrics ports using regex
rpc_port=$(echo "$ports" | grep -oP 'rpc: \K[0-9]+' | head -1)
metrics_port=$(echo "$ports" | grep -oP 'metrics: \K[0-9]+' | head -1)

# Debugging: Output the extracted RPC and Metrics ports
echo "RPC Port: $rpc_port"
echo "Metrics Port: $metrics_port"

# Check if both RPC and Metrics ports are found
if [[ -n "$rpc_port" && -n "$metrics_port" ]]; then
# Construct the endpoint JSON object and add it to the array
endpoints+=("{\"name\": \"$name\", \"executionUrl\": \"http://localhost:$rpc_port\", \"consensusUrl\": \"http://localhost:$metrics_port\"}")
fi
fi
done <<< "$services_section"

# Print the array in a usable format
echo "Endpoints array:"
for endpoint in "${endpoints[@]}"; do
echo "$endpoint"
done

# Format the output for Assertor
service_details+=("{\"uuid\": \"$uuid\", \"name\": \"$name\", \"ports\": \"$ports\"}")
done <<< "$services"
# If you want to return the array to be used later in the script:
# You can access the array like this:
# for endpoint in "${endpoints[@]}"; do
# echo "$endpoint"
# done

# Print the extracted service details in JSON format for Assertor
echo "[${service_details[*]}]"
29 changes: 28 additions & 1 deletion .github/workflows/on_release_consensus_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,31 @@ jobs:
- name: Load Network Params and Run Ethereum Package
run: |
# Create a local network_params.yaml file from the repository or use an existing one
curl --location --request POST '127.0.0.1:63588' --header 'Content-Type: application/json' --data-raw '{"jsonrpc": "2.0", "method": "eth_blockNumber", "params": [], "id": 83}'
kurtosis enclave inspect my-testnet
- name: Download and build assertoor
run: |
# Run assertoor in pipeline
git clone https://github.com/ethpandaops/assertoor.git && cd assertoor && make build
- name: List all files in repo
run: |
# Run assertoor in pipeline
ls -a
# - name: Run basic eth syncing test
# run: |
# # Run assertoor in pipeline
# ./bin/assertoor --config=https://raw.githubusercontent.com/axol-io/assert-in-prod/refs/heads/Add_Nethermind_All_Consenus_clients_tests/.github/consensus_synced.yaml

- name: Checkout
uses: actions/checkout@v2

- name: Setup K6
uses: grafana/setup-k6-action@v1

- name: Run local k6 test
uses: grafana/run-k6-action@v1
with:
path: https://raw.githubusercontent.com/axol-io/assert-in-prod/refs/heads/Add_Nethermind_All_Consenus_clients_tests/.github/geth.js
flags: --vus 50 --duration 30s # Adjust VUs and duration as needed

0 comments on commit 994d200

Please sign in to comment.