sless-primer/POSTGRES/stress_destroy_apply.sh.disabled
Naeel 4b04cde84b chore(examples): remove stale examples, keep only POSTGRES
- Deleted: TNAR, demo-event-log, demo-managed-functions, hello-go, hello-node,
  k8s, notes-python, pg-list-python, simple-node, simple-python
- POSTGRES: removed luceUNDnode.tf (commented-out legacy), stress_log_1.txt,
  funcs_list.py; disabled stress_destroy_apply.sh (PG lifecycle stress has
  delete_user bug); added README.md
- examples/README.md: updated to reflect current state (sless_service + sless_job)
2026-03-21 07:49:23 +03:00

47 lines
1.5 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.

#!/bin/bash
# 2026-03-20
# stress_destroy_apply.sh — 5 итераций terraform destroy + apply для проверки lifecycle PG.
# Запускать вручную с VM: bash stress_destroy_apply.sh
# Логи каждой итерации пишутся в stress_log_N.txt
set -e
ITERATIONS=5
DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$DIR"
echo "=== Старт stress-теста: $ITERATIONS итераций destroy+apply ==="
echo "Workdir: $DIR"
echo ""
for i in $(seq 1 $ITERATIONS); do
LOG="stress_log_${i}.txt"
echo "--- Итерация $i/$ITERATIONS ---"
echo "Лог: $LOG"
echo "[$i] DESTROY — $(date)" | tee "$LOG"
terraform destroy -auto-approve 2>&1 | tee -a "$LOG"
DESTROY_CODE=${PIPESTATUS[0]}
if [ $DESTROY_CODE -ne 0 ]; then
echo "[!] destroy завершился с ошибкой (код $DESTROY_CODE), итерация $i. Прерывание." | tee -a "$LOG"
exit $DESTROY_CODE
fi
echo "" | tee -a "$LOG"
echo "[$i] APPLY — $(date)" | tee -a "$LOG"
terraform apply -auto-approve 2>&1 | tee -a "$LOG"
APPLY_CODE=${PIPESTATUS[0]}
if [ $APPLY_CODE -ne 0 ]; then
echo "[!] apply завершился с ошибкой (код $APPLY_CODE), итерация $i. Прерывание." | tee -a "$LOG"
exit $APPLY_CODE
fi
echo "" | tee -a "$LOG"
echo "[$i] Итерация завершена успешно — $(date)" | tee -a "$LOG"
echo ""
done
echo "=== Все $ITERATIONS итераций прошли успешно ==="