mirror of
https://github.com/logos-blockchain/logos-blockchain-testing.git
synced 2026-01-02 13:23:13 +00:00
Add scripts/checks environment sanity checker
This commit is contained in:
parent
2d388ba131
commit
ca2f2785ad
165
scripts/checks
Executable file
165
scripts/checks
Executable file
@ -0,0 +1,165 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
|
||||
say() { printf "%s\n" "$*"; }
|
||||
section() { printf "\n==> %s\n" "$*"; }
|
||||
|
||||
have() { command -v "$1" >/dev/null 2>&1; }
|
||||
|
||||
bytes_to_human() {
|
||||
local bytes="${1:-0}"
|
||||
local kib=$((1024))
|
||||
local mib=$((1024 * 1024))
|
||||
local gib=$((1024 * 1024 * 1024))
|
||||
if [ "$bytes" -ge "$gib" ]; then
|
||||
awk -v b="$bytes" 'BEGIN{printf "%.1fGiB", b/1024/1024/1024}'
|
||||
elif [ "$bytes" -ge "$mib" ]; then
|
||||
awk -v b="$bytes" 'BEGIN{printf "%.1fMiB", b/1024/1024}'
|
||||
elif [ "$bytes" -ge "$kib" ]; then
|
||||
awk -v b="$bytes" 'BEGIN{printf "%.1fKiB", b/1024}'
|
||||
else
|
||||
printf "%sB" "$bytes"
|
||||
fi
|
||||
}
|
||||
|
||||
warn() { say "WARN: $*"; }
|
||||
ok() { say "OK: $*"; }
|
||||
|
||||
section "Workspace"
|
||||
say "root: ${ROOT_DIR}"
|
||||
if [ -f "${ROOT_DIR}/versions.env" ]; then
|
||||
# shellcheck disable=SC1091
|
||||
. "${ROOT_DIR}/versions.env"
|
||||
ok "versions.env present"
|
||||
say "VERSION=${VERSION:-<unset>}"
|
||||
say "NOMOS_NODE_REV=${NOMOS_NODE_REV:-<unset>}"
|
||||
if [ -n "${NOMOS_NODE_PATH:-}" ]; then
|
||||
say "NOMOS_NODE_PATH=${NOMOS_NODE_PATH}"
|
||||
fi
|
||||
else
|
||||
warn "versions.env missing (scripts depend on it)"
|
||||
fi
|
||||
|
||||
if [ -f "${ROOT_DIR}/paths.env" ]; then
|
||||
# shellcheck disable=SC1091
|
||||
. "${ROOT_DIR}/paths.env"
|
||||
ok "paths.env present"
|
||||
fi
|
||||
|
||||
section "Disk Space"
|
||||
if have df; then
|
||||
df -h "${ROOT_DIR}" | sed -n '1,2p'
|
||||
fi
|
||||
|
||||
tmp_dir="${ROOT_DIR}/.tmp"
|
||||
if [ -d "${tmp_dir}" ]; then
|
||||
if have du; then
|
||||
say ".tmp size: $(du -sh "${tmp_dir}" 2>/dev/null | awk '{print $1}')"
|
||||
fi
|
||||
else
|
||||
say ".tmp: <absent>"
|
||||
fi
|
||||
|
||||
if [ -d "${ROOT_DIR}/target" ] && have du; then
|
||||
say "target size: $(du -sh "${ROOT_DIR}/target" 2>/dev/null | awk '{print $1}')"
|
||||
fi
|
||||
|
||||
section "KZG Params"
|
||||
KZG_DIR_REL="${NOMOS_KZG_DIR_REL:-testing-framework/assets/stack/kzgrs_test_params}"
|
||||
KZG_FILE="${NOMOS_KZG_FILE:-kzgrs_test_params}"
|
||||
KZG_CONTAINER_PATH="${NOMOS_KZG_CONTAINER_PATH:-/kzgrs_test_params/kzgrs_test_params}"
|
||||
HOST_KZG_PATH="${ROOT_DIR}/${KZG_DIR_REL}/${KZG_FILE}"
|
||||
say "host: ${HOST_KZG_PATH}"
|
||||
say "container: ${KZG_CONTAINER_PATH}"
|
||||
if [ -f "${HOST_KZG_PATH}" ]; then
|
||||
ok "KZG params file exists"
|
||||
else
|
||||
warn "KZG params file missing (DA workloads will fail); run: scripts/run-examples.sh <mode> (auto) or scripts/setup-nomos-circuits.sh"
|
||||
fi
|
||||
|
||||
section "Rust Toolchain"
|
||||
if have rustup; then
|
||||
ok "rustup: $(rustup --version | head -n1)"
|
||||
if [ -f "${ROOT_DIR}/rust-toolchain.toml" ]; then
|
||||
channel="$(awk -F '\"' '/^[[:space:]]*channel[[:space:]]*=/{print $2; exit}' "${ROOT_DIR}/rust-toolchain.toml" 2>/dev/null || true)"
|
||||
say "rust-toolchain.toml channel: ${channel:-<unknown>}"
|
||||
fi
|
||||
elif have rustc; then
|
||||
ok "rustc: $(rustc --version)"
|
||||
else
|
||||
warn "rust toolchain not found (rustup/rustc missing)"
|
||||
fi
|
||||
|
||||
section "Docker (compose/k8s image + linux bundle builds)"
|
||||
if have docker; then
|
||||
ok "docker client: $(docker version --format '{{.Client.Version}}' 2>/dev/null || docker --version)"
|
||||
server_arch="$(docker version --format '{{.Server.Os}}/{{.Server.Arch}}' 2>/dev/null || true)"
|
||||
if [ -n "${server_arch}" ]; then
|
||||
say "docker engine: ${server_arch}"
|
||||
else
|
||||
warn "could not query docker engine arch (is Docker running?)"
|
||||
fi
|
||||
|
||||
bundle_platform="${NOMOS_BUNDLE_DOCKER_PLATFORM:-${NOMOS_BIN_PLATFORM:-linux/amd64}}"
|
||||
say "NOMOS_BUNDLE_DOCKER_PLATFORM=${bundle_platform}"
|
||||
|
||||
if [[ "${server_arch}" == *"linux/arm64"* ]] && [ "${bundle_platform}" = "linux/amd64" ]; then
|
||||
warn "Docker engine is linux/arm64 but bundle platform is linux/amd64 (emulation). If builds are slow/flaky, set: NOMOS_BUNDLE_DOCKER_PLATFORM=linux/arm64"
|
||||
fi
|
||||
|
||||
image="${NOMOS_TESTNET_IMAGE:-logos-blockchain-testing:local}"
|
||||
say "NOMOS_TESTNET_IMAGE=${image}"
|
||||
if docker image inspect "${image}" >/dev/null 2>&1; then
|
||||
ok "testnet image present locally"
|
||||
else
|
||||
warn "testnet image not present locally (compose/k8s runs will rebuild or fail if NOMOS_SKIP_IMAGE_BUILD=1)"
|
||||
fi
|
||||
else
|
||||
warn "docker not found (compose/k8s unavailable; linux bundle build on macOS requires docker)"
|
||||
fi
|
||||
|
||||
section "Docker Compose"
|
||||
if have docker; then
|
||||
if docker compose version >/dev/null 2>&1; then
|
||||
ok "docker compose available"
|
||||
else
|
||||
warn "docker compose not available"
|
||||
fi
|
||||
fi
|
||||
|
||||
section "Kubernetes (k8s runner)"
|
||||
if have kubectl; then
|
||||
ok "kubectl: $(kubectl version --client=true --short 2>/dev/null || true)"
|
||||
ctx="$(kubectl config current-context 2>/dev/null || true)"
|
||||
if [ -n "${ctx}" ]; then
|
||||
say "current-context: ${ctx}"
|
||||
fi
|
||||
if kubectl cluster-info >/dev/null 2>&1; then
|
||||
ok "cluster reachable"
|
||||
kubectl get nodes -o wide 2>/dev/null | sed -n '1,3p' || true
|
||||
else
|
||||
warn "cluster not reachable (k8s runner will skip with ClientInit error)"
|
||||
fi
|
||||
else
|
||||
warn "kubectl not found (k8s runner unavailable)"
|
||||
fi
|
||||
|
||||
if have helm; then
|
||||
ok "helm: $(helm version --short 2>/dev/null || true)"
|
||||
else
|
||||
warn "helm not found (k8s runner uses helm)"
|
||||
fi
|
||||
|
||||
section "Runner Debug Flags (optional)"
|
||||
say "SLOW_TEST_ENV=${SLOW_TEST_ENV:-<unset>} (if true: doubles readiness timeouts)"
|
||||
say "NOMOS_SKIP_IMAGE_BUILD=${NOMOS_SKIP_IMAGE_BUILD:-<unset>} (compose/k8s)"
|
||||
say "COMPOSE_RUNNER_PRESERVE=${COMPOSE_RUNNER_PRESERVE:-<unset>} (compose)"
|
||||
say "K8S_RUNNER_PRESERVE=${K8S_RUNNER_PRESERVE:-<unset>} (k8s)"
|
||||
say "K8S_RUNNER_DEBUG=${K8S_RUNNER_DEBUG:-<unset>} (k8s helm debug)"
|
||||
say "COMPOSE_RUNNER_HOST=${COMPOSE_RUNNER_HOST:-<unset>} (compose readiness host override)"
|
||||
say "K8S_RUNNER_NODE_HOST=${K8S_RUNNER_NODE_HOST:-<unset>} (k8s NodePort host override)"
|
||||
|
||||
section "Done"
|
||||
say "If something looks off, start with: scripts/run-examples.sh <mode> -t 60 -v 1 -e 1"
|
||||
Loading…
x
Reference in New Issue
Block a user