feat(usable): package gui-host validation snapshot
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
79
scripts/tui/live-network-smoke.sh
Executable file
79
scripts/tui/live-network-smoke.sh
Executable file
@@ -0,0 +1,79 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
if [ "$#" -lt 2 ] || [ "$#" -gt 3 ]; then
|
||||
echo "usage: scripts/tui/live-network-smoke.sh <postgres|mysql> <binary-path> [log-path]" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if ! command -v script >/dev/null 2>&1; then
|
||||
echo "error: \`script\` command is required for TTY smoke." >&2
|
||||
exit 3
|
||||
fi
|
||||
|
||||
target="$1"
|
||||
binary_path="$2"
|
||||
log_path="${3:-/tmp/dbtool-tui-$target-live.log}"
|
||||
|
||||
if [ ! -x "$binary_path" ]; then
|
||||
echo "error: binary is not executable: $binary_path" >&2
|
||||
exit 4
|
||||
fi
|
||||
|
||||
case "$target" in
|
||||
postgres)
|
||||
down_presses=1
|
||||
endpoint='host.docker.internal:55432'
|
||||
profile_name='reporting-postgres'
|
||||
export_path='/tmp/dbtool-tui-reporting-postgres-account-ticket-summary-sql.csv'
|
||||
activation_wait=4
|
||||
;;
|
||||
mysql)
|
||||
down_presses=2
|
||||
endpoint='host.docker.internal:53306'
|
||||
profile_name='orders-mysql'
|
||||
export_path='/tmp/dbtool-tui-orders-mysql-account-ticket-summary-sql.csv'
|
||||
activation_wait=5
|
||||
;;
|
||||
*)
|
||||
echo "error: unsupported target: $target" >&2
|
||||
exit 5
|
||||
;;
|
||||
esac
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||
"$ROOT_DIR/scripts/tui/demo-stack.sh" up
|
||||
"$ROOT_DIR/scripts/tui/demo-stack.sh" seed
|
||||
|
||||
export DBTOOL_PASSWORD="${DBTOOL_PASSWORD:-dbtool}"
|
||||
|
||||
rm -f "$log_path"
|
||||
{
|
||||
sleep 1
|
||||
printf '2'
|
||||
if [ "$down_presses" -ge 1 ]; then
|
||||
printf '\033[B'
|
||||
fi
|
||||
if [ "$down_presses" -ge 2 ]; then
|
||||
printf '\033[B'
|
||||
fi
|
||||
printf '\r'
|
||||
sleep "$activation_wait"
|
||||
printf '\033'
|
||||
printf '\r'
|
||||
sleep 2
|
||||
printf 'x'
|
||||
sleep 2
|
||||
printf 'q'
|
||||
} | script -qec "stty rows 40 cols 120; \"$binary_path\"" "$log_path" >/dev/null
|
||||
|
||||
grep -aq "$profile_name" "$log_path"
|
||||
grep -aq "Validation: Connected" "$log_path"
|
||||
grep -aq "rows returned in" "$log_path"
|
||||
[ -f "$export_path" ]
|
||||
|
||||
echo "TUI live smoke passed for $target."
|
||||
echo "binary: $binary_path"
|
||||
echo "endpoint: $endpoint"
|
||||
echo "export: $export_path"
|
||||
echo "log: $log_path"
|
||||
Reference in New Issue
Block a user