forked from mtusi2026/mtusi2026lab2
35 lines
986 B
Bash
35 lines
986 B
Bash
#!/bin/sh
|
|
|
|
set -eu
|
|
cd "$(dirname "$0")/.."
|
|
OUT=evidence/persistence.txt
|
|
mkdir -p evidence
|
|
|
|
PY=python3
|
|
"$PY" -c 'import sys' >/dev/null 2>&1 || PY=python
|
|
|
|
hook=scripts/restart.sh
|
|
case "$(uname -s)" in
|
|
MINGW* | MSYS* | CYGWIN*) hook=scripts/restart.cmd ;;
|
|
esac
|
|
|
|
state() {
|
|
for s in api postgres valkey valkey-cache; do
|
|
id=$(docker compose --env-file .env ps -q "$s")
|
|
docker inspect -f "$s {{.State.Status}} started={{.State.StartedAt}} restarts={{.RestartCount}} mounts={{range .Mounts}}{{.Name}} {{end}}" "$id"
|
|
done
|
|
}
|
|
|
|
{
|
|
echo "# Persistence ($(date -u +%Y-%m-%dT%H:%M:%SZ)), hook: $hook -> scripts/restart.sh"
|
|
echo "## до"
|
|
state
|
|
echo "## тест"
|
|
"$PY" tests/resilience.py --mode persistence --action-script "$hook" 2>&1
|
|
echo "## после"
|
|
state
|
|
echo "## volumes"
|
|
docker volume ls --filter name=mtusi-lab2_ --format '{{.Name}}' | xargs docker volume inspect -f '{{.Name}} created={{.CreatedAt}}'
|
|
} > "$OUT"
|
|
cat "$OUT"
|