Skip to content

Instantly share code, notes, and snippets.

@theghostmac
Last active September 22, 2024 04:03
Show Gist options
  • Save theghostmac/62e8ffaef3a72ed97135dcf61e16297a to your computer and use it in GitHub Desktop.
Save theghostmac/62e8ffaef3a72ed97135dcf61e16297a to your computer and use it in GitHub Desktop.
The setup for initializing and managing the network is really sophisticated. Noticing some opened issues from last year on the `stride` repo, I thought it could be useful to verify each step of the setup process. Something like this:
#!/bin/bash
# This script verifies key aspects of the Stride network setup:
# 1. Namespace Creation: Ensures the Kubernetes namespace exists.
# 2. Pod Creation: Checks if all validator pods for each chain are running.
# 3. Chain Health: Verifies that each chain is synced and not catching up.
# 4. Relayer Health: Confirms that the IBC relayer path is set up correctly.
# 5. IBC Transfer: (TODO) Will test IBC transfer functionality between chains.
# 6. Send Notification: (TODO) Sends notification after checks are completed, to inform the team about the result.
#
# The script uses kubectl commands to interact with the Kubernetes cluster,
# and provides a quick check of the network's operational status.
set -eu
source config.sh
source utils.sh
test_namespace_creation() {
echo "Testing namespace creation..."
if kubectl get namespace $NAMESPACE &> /dev/null; then
echo "Namespace $NAMESPACE exists"
else
echo "ERROR: Namespace $NAMESPACE does not exist"
exit 1
fi
}
test_pod_creation() {
echo "Testing pod creation..."
for chain in $CHAIN_NAME $HOST_CHAIN_NAME; do
for (( i=0; i<$NUM_VALIDATORS; i++ )); do
pod_name="${chain}-validator-$i"
if kubectl get pod $pod_name -n $NAMESPACE &> /dev/null; then
echo "Pod $pod_name exists"
else
echo "ERROR: Pod $pod_name does not exist"
exit 1
fi
done
done
}
test_chain_health() {
echo "Testing chain health..."
for chain in $CHAIN_NAME $HOST_CHAIN_NAME; do
wait_for_node $chain
if $($BINARY status | jq -e '.SyncInfo.catching_up == false' &> /dev/null); then # TODO: audit.
echo "$chain is synced"
else
echo "ERROR: $chain is not synced"
exit 1
fi
done
}
test_relayer_health() {
echo "Testing relayer health..."
relayer_pod=$(kubectl get pods -n $NAMESPACE | grep relayer | awk '{print $1}')
if kubectl exec $relayer_pod -n $NAMESPACE -- rly paths list | grep -q $PATH_NAME; then
echo "Relayer path $PATH_NAME exists"
else
echo "ERROR: Relayer path $PATH_NAME does not exist"
exit 1
fi
}
test_ibc_transfer() {
echo "Testing IBC transfer..."
# TODO: Implement a test IBC transfer between chains.
}
send_notification() {
echo "Sending verification status..."
# TODO: Implement logic to notify the team of the verification results.
}
main() {
test_namespace_creation
test_pod_creation
test_chain_health
test_relayer_health
test_ibc_transfer
echo "All integration tests passed successfully"
send_notification
}
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment