This commit is contained in:
Executable
+67
@@ -0,0 +1,67 @@
|
||||
#!/usr/bin/env bash
|
||||
set -Eeuo pipefail
|
||||
|
||||
ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
|
||||
WORK=$(mktemp -d)
|
||||
trap 'rm -rf "$WORK"' EXIT
|
||||
|
||||
fail() {
|
||||
printf 'Baota start fixture failed: %s\n' "$1" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
RELEASE="$WORK/release"
|
||||
mkdir -p "$RELEASE/ops" "$RELEASE/public" "$WORK/files" "$WORK/tmp"
|
||||
printf 'fixture jar\n' > "$RELEASE/app.jar"
|
||||
printf '<!doctype html>\n' > "$RELEASE/public/index.html"
|
||||
printf '1.0.0-preview.23\n' > "$RELEASE/VERSION"
|
||||
cp "$ROOT/deploy/baota-start.sh" "$RELEASE/ops/baota-start.sh"
|
||||
chmod 0755 "$RELEASE/ops/baota-start.sh"
|
||||
|
||||
cat > "$WORK/java" <<'SH'
|
||||
#!/usr/bin/env bash
|
||||
set -Eeuo pipefail
|
||||
{
|
||||
printf 'cwd=%s\n' "$PWD"
|
||||
printf 'args=%s\n' "$*"
|
||||
printf 'version=%s\n' "$APP_VERSION"
|
||||
printf 'address=%s\n' "$SERVER_ADDRESS"
|
||||
printf 'port=%s\n' "$SERVER_PORT"
|
||||
printf 'update=%s\n' "$FINANCE_UPDATE_ENABLED"
|
||||
printf 'static=%s\n' "$FINANCE_STATIC_LOCATIONS"
|
||||
} > "$MOCK_JAVA_LOG"
|
||||
SH
|
||||
chmod 0755 "$WORK/java"
|
||||
|
||||
MOCK_JAVA_LOG="$WORK/java.log" \
|
||||
KAIDI_JAVA_BIN="$WORK/java" \
|
||||
DB_URL='jdbc:mysql://db.fixture/kaidi_finance' \
|
||||
DB_USERNAME=fixture \
|
||||
DB_PASSWORD='fixture-password' \
|
||||
FIELD_ENCRYPTION_KEY='fixture-field-key' \
|
||||
FILE_STORAGE_ROOT="$WORK/files" \
|
||||
FILE_STORAGE_TEMP="$WORK/tmp" \
|
||||
"$RELEASE/ops/baota-start.sh"
|
||||
|
||||
grep -Fqx "cwd=$RELEASE" "$WORK/java.log" || fail 'launcher did not use the release working directory'
|
||||
grep -Fqx "args=-XX:MaxRAMPercentage=70 -Dfile.encoding=UTF-8 -jar $RELEASE/app.jar" "$WORK/java.log" \
|
||||
|| fail 'launcher did not execute the packaged Spring Boot jar'
|
||||
grep -Fqx 'version=1.0.0-preview.23' "$WORK/java.log" || fail 'launcher did not read VERSION'
|
||||
grep -Fqx 'address=127.0.0.1' "$WORK/java.log" || fail 'launcher did not default to loopback'
|
||||
grep -Fqx 'port=18080' "$WORK/java.log" || fail 'launcher did not default to port 18080'
|
||||
grep -Fqx 'update=false' "$WORK/java.log" || fail 'launcher did not disable the systemd updater'
|
||||
grep -Fqx "static=file:$RELEASE/public/" "$WORK/java.log" \
|
||||
|| fail 'launcher did not bind static resources to the release directory'
|
||||
|
||||
if KAIDI_JAVA_BIN="$WORK/java" \
|
||||
DB_USERNAME=fixture DB_PASSWORD=fixture FIELD_ENCRYPTION_KEY=fixture \
|
||||
FILE_STORAGE_ROOT="$WORK/files" FILE_STORAGE_TEMP="$WORK/tmp" \
|
||||
MOCK_JAVA_LOG="$WORK/missing-db.log" \
|
||||
"$RELEASE/ops/baota-start.sh" > "$WORK/missing-db.out" 2>&1; then
|
||||
fail 'launcher accepted a production configuration without DB_URL'
|
||||
fi
|
||||
grep -Fq 'DB_URL must be configured' "$WORK/missing-db.out" \
|
||||
|| fail 'launcher did not report the missing database URL'
|
||||
[ ! -e "$WORK/missing-db.log" ] || fail 'launcher started Java after configuration validation failed'
|
||||
|
||||
printf 'Baota Spring Boot launcher fixture passed\n'
|
||||
Reference in New Issue
Block a user