Files
proxmox/scripts/run-e2e-flow-tasks-full-parallel.sh

244 lines
8.7 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# Run E2E flow tasks in Full Parallel mode (by wave).
# Ref: docs/00-meta/TASKS_TO_INCREASE_ALL_E2E_FLOWS.md
# Usage:
# ./scripts/run-e2e-flow-tasks-full-parallel.sh # run all waves (automated parts)
# ./scripts/run-e2e-flow-tasks-full-parallel.sh --dry-run # print only / validate
# ./scripts/run-e2e-flow-tasks-full-parallel.sh --wave E1 # run only wave E1
set -euo pipefail
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$REPO_ROOT"
# shellcheck source=./scripts/lib/run-summary.sh
source "$REPO_ROOT/scripts/lib/run-summary.sh"
RUN_STARTED_AT="$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
SECONDS=0
DRY_RUN=""
WAVE_FILTER=""
VALID_WAVES="E0 E1 E2 E3 E4 E5 E6 E7"
JSON_OUT=""
format_duration() {
local total="$1"
printf '%02dm:%02ds' "$((total / 60))" "$((total % 60))"
}
wave_valid() {
[[ " $VALID_WAVES " == *" $1 "* ]]
}
while [[ $# -gt 0 ]]; do
case "$1" in
--dry-run) DRY_RUN=1; shift ;;
--wave)
[[ $# -ge 2 ]] || { echo "Missing value for --wave. Valid: $VALID_WAVES" >&2; exit 1; }
WAVE_FILTER="$2"
wave_valid "$WAVE_FILTER" || { echo "Invalid wave: $WAVE_FILTER. Valid: $VALID_WAVES" >&2; exit 1; }
shift 2
;;
--json-out)
[[ $# -ge 2 ]] || { echo "Missing value for --json-out" >&2; exit 1; }
JSON_OUT="$2"
shift 2
;;
-h|--help)
sed -n '1,8p' "$0"
echo " --json-out PATH Write a machine-readable wave summary JSON."
echo "Valid waves: $VALID_WAVES"
exit 0
;;
*)
echo "Unknown argument: $1" >&2
exit 1
;;
esac
done
SMOM="${REPO_ROOT}/smom-dbis-138"
LOG_DIR="/tmp/e2e-full-parallel-$(date +%Y%m%d-%H%M%S)"
mkdir -p "$LOG_DIR"
RUN_STATUS="failed"
RUN_MODE="run"
run_summary_init "run-e2e-flow-tasks-full-parallel.sh" "$RUN_STARTED_AT" "$JSON_OUT"
trap 'run_summary_write "$RUN_STATUS" "$SECONDS" "$RUN_MODE"; run_summary_cleanup' EXIT
log() { echo "[$(date +%H:%M:%S)] $*"; }
run_wave() {
local w="$1"
if [[ -n "$WAVE_FILTER" && "$w" != "$WAVE_FILTER" ]]; then
run_summary_record_step "$w" "Wave $w" "filtered" "0"
return 1
fi
log "=== Wave $w ==="
return 0
}
# ----- E0: Gates (operator only — print checklist) -----
run_e0() {
run_wave "E0" || return 0
local step_started=$SECONDS
log "E0 (Operator): Ensure X1 RPC 2101 writable, X6 TransactionMirror deployed, X7 deployer funded on 138 and destinations, A1 Core RPC reachable."
log " See: docs/03-deployment/RPC_2101_READONLY_FIX.md, health-check-rpc-2101.sh, ADDRESS_MATRIX_AND_STATUS.md"
if [[ -n "$DRY_RUN" ]]; then
run_summary_record_step "E0" "Wave E0" "planned" "0"
return 0
fi
# Optional: run health check if script exists
if [[ -f "$REPO_ROOT/scripts/health/check-rpc-vms-health.sh" ]]; then
( "$REPO_ROOT/scripts/health/check-rpc-vms-health.sh" 2>&1 | tee "$LOG_DIR/e0-health.log" ) || true
fi
run_summary_record_step "E0" "Wave E0" "success" "$((SECONDS - step_started))"
}
# ----- E1: Flow A — PMM pools Chain 138 (parallel inside Phase 1) -----
run_e1() {
run_wave "E1" || return 0
local step_started=$SECONDS
if [[ ! -d "$SMOM" ]]; then
log "Skip E1: smom-dbis-138 not found"
run_summary_record_step "E1" "Wave E1" "skipped" "0"
return 0
fi
if [[ -n "$DRY_RUN" ]]; then
log "[DRY RUN] Would run: cd smom-dbis-138 && ./scripts/deployment/run-pmm-full-parity-all-phases.sh (RUN_PHASE2=0)"
run_summary_record_step "E1" "Wave E1" "planned" "0"
return 0
fi
( cd "$SMOM" && RUN_PHASE2=0 ./scripts/deployment/run-pmm-full-parity-all-phases.sh 2>&1 | tee "$LOG_DIR/e1-pmm-phase1.log" ) || true
run_summary_record_step "E1" "Wave E1" "success" "$((SECONDS - step_started))"
}
# ----- E2: Flow B — CCIP config + fund bridges (per-chain parallel) -----
run_e2() {
run_wave "E2" || return 0
local step_started=$SECONDS
if [[ ! -d "$SMOM" ]]; then
log "Skip E2: smom-dbis-138 not found"
run_summary_record_step "E2" "Wave E2" "skipped" "0"
return 0
fi
if [[ -n "$DRY_RUN" ]]; then
log "[DRY RUN] Would run: complete-config-ready-chains.sh, fund-ccip-bridges-with-link.sh"
run_summary_record_step "E2" "Wave E2" "planned" "0"
return 0
fi
( cd "$SMOM" && ./scripts/deployment/complete-config-ready-chains.sh 2>&1 | tee "$LOG_DIR/e2-config.log" ) || true
( cd "$SMOM" && ./scripts/deployment/fund-ccip-bridges-with-link.sh 2>&1 | tee "$LOG_DIR/e2-fund.log" ) || true
run_summary_record_step "E2" "Wave E2" "success" "$((SECONDS - step_started))"
}
# ----- E3: Code/config — token-aggregation env, bridge routes, token list -----
run_e3() {
run_wave "E3" || return 0
local step_started=$SECONDS
log "E3: Ensure .env has CHAIN_138_DODO_PMM_INTEGRATION, BRIDGE_REGISTRY_ADDRESS (see smom-dbis-138/env.additions.example)."
if [[ -f "$SMOM/.env" ]]; then
if grep -q "CHAIN_138_DODO_PMM_INTEGRATION" "$SMOM/.env" 2>/dev/null; then
log " CHAIN_138_DODO_PMM_INTEGRATION already set in .env"
else
log " Add CHAIN_138_DODO_PMM_INTEGRATION to smom-dbis-138/.env (copy from env.additions.example)"
fi
if grep -q "BRIDGE_REGISTRY_ADDRESS" "$SMOM/.env" 2>/dev/null; then
log " BRIDGE_REGISTRY_ADDRESS already set in .env"
else
log " Add BRIDGE_REGISTRY_ADDRESS for Flow C quote API (orchestration)"
fi
fi
if [[ -n "$DRY_RUN" ]]; then
run_summary_record_step "E3" "Wave E3" "planned" "0"
return 0
fi
# Validation that can run from anywhere
if [[ -f "$REPO_ROOT/scripts/validation/validate-config-files.sh" ]]; then
( "$REPO_ROOT/scripts/validation/validate-config-files.sh" 2>&1 | tee "$LOG_DIR/e3-validate.log" ) || true
fi
run_summary_record_step "E3" "Wave E3" "success" "$((SECONDS - step_started))"
}
# ----- E4: Infra/verify (operator/LAN) -----
run_e4() {
run_wave "E4" || return 0
local step_started=$SECONDS
log "E4 (Operator/LAN): X2 Blockscout verify, X3 E2E routing, X4 Explorer E2E, X5 token-aggregation health."
log " run-contract-verification-with-proxy.sh, verify-end-to-end-routing.sh, explorer e2e-test-explorer.sh"
if [[ -n "$DRY_RUN" ]]; then
run_summary_record_step "E4" "Wave E4" "planned" "0"
return 0
fi
if [[ -f "$REPO_ROOT/scripts/verify/verify-end-to-end-routing.sh" ]]; then
( "$REPO_ROOT/scripts/verify/verify-end-to-end-routing.sh" 2>&1 | tee "$LOG_DIR/e4-routing.log" ) || true
fi
run_summary_record_step "E4" "Wave E4" "success" "$((SECONDS - step_started))"
}
# ----- E5: Multichain — PMM Phase 2 (parallel per chain) -----
run_e5() {
run_wave "E5" || return 0
local step_started=$SECONDS
if [[ ! -d "$SMOM" ]]; then
log "Skip E5: smom-dbis-138 not found"
run_summary_record_step "E5" "Wave E5" "skipped" "0"
return 0
fi
if [[ -n "$DRY_RUN" ]]; then
log "[DRY RUN] Would run: run-pmm-full-parity-all-phases.sh (RUN_PHASE1=0) for L2s"
run_summary_record_step "E5" "Wave E5" "planned" "0"
return 0
fi
( cd "$SMOM" && RUN_PHASE1=0 ./scripts/deployment/run-pmm-full-parity-all-phases.sh 2>&1 | tee "$LOG_DIR/e5-pmm-phase2.log" ) || true
run_summary_record_step "E5" "Wave E5" "success" "$((SECONDS - step_started))"
}
# ----- E6: Frontend + test (code/operator) -----
run_e6() {
run_wave "E6" || return 0
local step_started=$SECONDS
log "E6: B6 Bridge UI to routes+token mapping; B7 test 138↔dest; C5C7 destination DEX, full path quote UI, E2E test."
log " See TASKS_TO_INCREASE_ALL_E2E_FLOWS.md Flow B/C."
if [[ -n "$DRY_RUN" ]]; then
run_summary_record_step "E6" "Wave E6" "planned" "0"
return 0
fi
run_summary_record_step "E6" "Wave E6" "success" "$((SECONDS - step_started))"
}
# ----- E7: Docs -----
run_e7() {
run_wave "E7" || return 0
local step_started=$SECONDS
log "E7: Update docs/11-references/PMM_DEX_ROUTING_STATUS.md when pools/liquidity live; runbooks in DEX_AND_AGGREGATORS_CHAIN138_EXPLAINER, CONFIG_READY_CHAINS."
if [[ -n "$DRY_RUN" ]]; then
run_summary_record_step "E7" "Wave E7" "planned" "0"
return 0
fi
# No automated doc edit; operator updates when state changes
run_summary_record_step "E7" "Wave E7" "success" "$((SECONDS - step_started))"
}
# ----- Run waves (E1+E2+E3 can run in parallel; E5 after E1 if both run) -----
log "E2E Full Parallel — DRY_RUN=$DRY_RUN WAVE_FILTER=$WAVE_FILTER Logs: $LOG_DIR"
log "Started (UTC): $RUN_STARTED_AT"
run_e0
# E1 and E2 are independent; E3 is config check — run E1 and E2 in parallel when not dry-run
if [[ -z "$DRY_RUN" && -z "$WAVE_FILTER" ]]; then
run_e1 & P1=$!
run_e2 & P2=$!
run_e3
wait "$P1" 2>/dev/null || true
wait "$P2" 2>/dev/null || true
else
run_e1
run_e2
run_e3
fi
run_e4
run_e5
run_e6
run_e7
log "Done. Logs in $LOG_DIR"
log "Total elapsed: $(format_duration "$SECONDS")"
RUN_MODE=$([[ -n "$DRY_RUN" ]] && echo "dry-run" || echo "run")
RUN_STATUS="success"