#!/usr/bin/env bash # Shows why the tests pin -Duser.timezone=UTC. pgjdbc sends the JVM's default zone to Postgres as # the TimeZone startup parameter. A JVM whose zone is the legacy id Asia/Calcutta then fails with # FATAL: invalid value for parameter "TimeZone": "Asia/Calcutta" # on a Postgres whose tzdata lacks the legacy alias. Needs psql and a database reachable with # IDEM_DB_* (defaults match application.yml). Writes output/00-timezone-trap.txt. set -uo pipefail cd "$(dirname "$0")/.." mkdir -p output export PGPASSWORD="${IDEM_DB_PASSWORD:-idem}" P=(psql -h "${IDEM_DB_HOST:-localhost}" -U "${IDEM_DB_USER:-idem}" "${IDEM_DB_NAME:-idem}") { echo "\$ psql -c \"SHOW server_version\"" "${P[@]}" -t -A -c "SHOW server_version" 2>&1 echo echo "\$ psql -c \"SET timezone='Asia/Calcutta'\"" "${P[@]}" -c "SET timezone='Asia/Calcutta'" 2>&1 echo echo "\$ psql -c \"SET timezone='Asia/Kolkata'\"" "${P[@]}" -c "SET timezone='Asia/Kolkata'" 2>&1 echo echo "\$ ls /usr/share/zoneinfo/Asia | grep -E 'Calcutta|Kolkata'" ls /usr/share/zoneinfo/Asia | grep -E 'Calcutta|Kolkata' echo echo "\$ dpkg -l tzdata | tail -1" dpkg -l tzdata | tail -1 | awk '{print $2, $3}' } > output/00-timezone-trap.txt cat output/00-timezone-trap.txt