forked from ethpandaops/assertoor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding script to inspect kurtosis endpoints.
- Loading branch information
Showing
4 changed files
with
136 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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[*]}]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters