Files
wx-win-agent/docs/validation/raw/verify-p4-live-operations.sh

25 lines
2.3 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
file=${1:-"$(dirname "$0")/p4-live-operations.jsonl"}
trace=${2:-"$(dirname "$0")/p4-live-commands.log"}
metrics=${3:-"$(dirname "$0")/capacity-metrics.txt"}
test -s "$trace"
grep -q 'Get-FileHash' "$trace"
grep -q 'Get-Process -Name WxAgent.Tray' "$trace"
grep -q 'LOCAL_START_SERVER' "$trace"
grep -q 'capacity_metrics=' "$metrics"
jq -s -e '
map({(.event): .}) | add as $e |
($e["deployment"].source_commit != null and ($e["deployment"].tray_sha256 | length) == 64) and
($e["offline-queue"].queue.queue_pending > 0 and $e["offline-queue"].queue.queue_bytes > 0 and $e["offline-queue"].process.session == 1) and
($e["replay"].queue.queue_pending == 0 and $e["replay"].sync.state == "complete" and $e["replay"].shard.coverage == "complete" and $e["replay"].shard.integrity == "ok") and
($e["agent-restart"].process.session == 1 and $e["agent-restart"].before.confirmed_sequence == $e["agent-restart"].after.confirmed_sequence and $e["agent-restart"].after.state == "complete") and
($e["authorization-revoke"].pending_process.session == 1 and $e["authorization-revoke"].pending_queue.queue_pending > 0 and $e["authorization-revoke"].pending_queue.queue_bytes > 0 and $e["authorization-revoke"].revoke == 200 and $e["authorization-revoke"].conversations == 403 and $e["authorization-revoke"].messages == 403 and $e["authorization-revoke"].sync_status == 200 and $e["authorization-revoke"].batch_rejected == 403 and $e["authorization-revoke"].revoked_process.session == 1 and $e["authorization-revoke"].reconnect_conversations == 200 and $e["authorization-revoke"].reconnect_messages == 200 and $e["authorization-revoke"].reconnect_sync_status == 200 and $e["authorization-revoke"].reconnect_queue.queue_pending == 0) and
($e["authorization-restore"].process.session == 1 and $e["authorization-restore"].conversations == 200 and $e["authorization-restore"].messages == 200 and $e["authorization-restore"].queue.queue_pending == 0) and
($e["control-plane-restart"].before.integrity == "ok" and $e["control-plane-restart"].after.integrity == "ok" and $e["control-plane-restart"].before.messages == $e["control-plane-restart"].after.messages and $e["control-plane-restart"].before.batches == $e["control-plane-restart"].after.batches)
' "$file" >/dev/null
printf 'P4 live operation invariants: PASS\n'