werkator build succeeded after 00:36
The programmatic PostgreSQLContainer was one way to ask werkdock for a database. The way most projects actually ask is a jdbc:tc URL, where Testcontainers is the JDBC driver and no Java code mentions a container at all. This adds that form, as a Spring Boot application whose application.yml holds the URLs, and leaves the programmatic test class untouched — the two take different paths through Testcontainers and are therefore two questions, not one. JdbcUrlDatabaseTest asks four of them: the configured URL connects, the init script named in it has run, the server listens on a port that is not the container's own, and a second URL is a second server. All nine tests pass against werkdock, on a developer machine and in CI on the managed webspace, and werkdock needed no change for any of it: a JDBC init script travels over the connection, so it does not want the archive endpoint werkdock has yet to grow. TC_DAEMON=true is in the URLs on purpose. Without it Testcontainers stops the database when the last connection closes, and a connection pool closes connections whenever it likes. Versions now come from Spring Boot's BOM, so Testcontainers moved from 1.19.3 to 1.21.4 — deliberately, and both test classes pass on it. A declared version does not hold against a platform constraint in Gradle; pretending otherwise in a comment would have been worse than saying which version actually runs. The Spring Boot plugin names the plain jar werkprobe-plain.jar; dist still collects it and the libraries, so the flat classpath on a managed webspace runs either main class. run-probe.sh --spring picks the new one. Squashed from branch spring-boot-jdbc-tc and pushed to main directly; the pull request was opened afterwards, not before. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
54 lines
1.4 KiB
Bash
Executable File
54 lines
1.4 KiB
Bash
Executable File
#!/bin/bash
|
|
# Run the probe on this host: start werkdock's API socket, let
|
|
# Testcontainers use it, stop it again. Meant for a host that has a JVM
|
|
# and werkdock but no build tool — a managed webspace. Lives beside the
|
|
# jars it runs (tools/deploy.sh puts it there).
|
|
#
|
|
# run-probe.sh [IMAGE] the plain Probe, container code and all
|
|
# run-probe.sh --spring the Spring Boot application, whose database
|
|
# is the jdbc:tc URL in application.yml
|
|
set -u
|
|
|
|
main=werkprobe.Probe
|
|
if [ "${1:-}" = "--spring" ]; then
|
|
main=werkprobe.WerkprobeApplication
|
|
shift
|
|
fi
|
|
|
|
here="$(cd "$(dirname "$0")" && pwd)"
|
|
export PATH="$HOME/opt/werkdock/bin:$PATH"
|
|
|
|
if ! command -v werkdock > /dev/null; then
|
|
echo "werkdock is not in PATH (looked in \$HOME/opt/werkdock/bin)" >&2
|
|
exit 1
|
|
fi
|
|
|
|
socket="${XDG_RUNTIME_DIR:-$HOME}/werkdock.sock"
|
|
log="$here/service.log"
|
|
|
|
echo "== $(werkdock version), socket $socket, main $main"
|
|
werkdock system service "$socket" > "$log" 2>&1 &
|
|
service=$!
|
|
trap 'kill $service 2> /dev/null' EXIT
|
|
|
|
for _ in $(seq 1 100); do
|
|
[ -S "$socket" ] && break
|
|
sleep 0.1
|
|
done
|
|
if [ ! -S "$socket" ]; then
|
|
echo "the service did not come up:" >&2
|
|
cat "$log" >&2
|
|
exit 1
|
|
fi
|
|
|
|
export DOCKER_HOST="unix://$socket"
|
|
export TESTCONTAINERS_RYUK_DISABLED=true
|
|
|
|
java -cp "$here/*" "$main" "$@"
|
|
status=$?
|
|
|
|
echo
|
|
echo "== what the client asked werkdock for =="
|
|
cat "$log"
|
|
exit $status
|