Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for jdbcstore, jdbcconfig & jndi #699

Merged
merged 6 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion build_data/plugin_download.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,22 @@ if [[ "${WAR_URL}" == *\.zip ]]; then
curl --progress-bar -fLvo "${destination}" "${WAR_URL}" || exit 1
fi

# Download Jetty Services
curl -vfLo /work/required_plugins/jetty-servlets.jar https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-servlets/11.0.9/jetty-servlets-11.0.9.jar

# Download jetty-util
curl -vfLo /work/required_plugins/jetty-util.jar https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-util/11.0.9/jetty-util-11.0.9.jar



# Download everything!
curl --progress-bar -vK /work/curl.cfg
for attempt in {1..5}; do
echo "Attempt $attempt of downloading plugins"
if curl --progress-bar -vK /work/curl.cfg; then
echo "Download successful"
break
else
echo "Download failed, retrying in 10 seconds..."
sleep 10
fi
done
2 changes: 1 addition & 1 deletion scenario_tests/clustering/docker-compose-external.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ x-common-activemq:
services:

db:
image: kartoza/postgis:16-3.4
image: kartoza/postgis:17-3.5
volumes:
- geo-db-data:/var/lib/postgresql
- ./tests/init.sql:/docker-entrypoint-initdb.d/init.sql
Expand Down
2 changes: 1 addition & 1 deletion scenario_tests/clustering/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ volumes:

services:
db:
image: kartoza/postgis:16-3.4
image: kartoza/postgis:17-3.5
volumes:
- geo-db-data:/var/lib/postgresql
- ./tests/init.sql:/docker-entrypoint-initdb.d/init.sql
Expand Down
2 changes: 1 addition & 1 deletion scenario_tests/disk-quota/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ volumes:

services:
db:
image: kartoza/postgis:16-3.4
image: kartoza/postgis:17-3.5
volumes:
- postgis-data:/var/lib/postgresql
environment:
Expand Down
57 changes: 57 additions & 0 deletions scenario_tests/jdbconfig/docker-compose-postgis-jndi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@

volumes:
geoserver-data-dir:
postgis-data:


services:
db:
image: kartoza/postgis:17-3.5
volumes:
- postgis-data:/var/lib/postgresql
environment:
- POSTGRES_DB=gis
- POSTGRES_USER=docker
- POSTGRES_PASS=docker
- ALLOW_IP_RANGE=0.0.0.0/0
- POSTGRES_MULTIPLE_EXTENSIONS=postgis,hstore,postgis_topology,postgis_raster,pgrouting
- RUN_AS_ROOT=true
restart: on-failure
healthcheck:
test: "PGPASSWORD=docker pg_isready -h 127.0.0.1 -U docker -d gis"

geoserver:
image: 'kartoza/geoserver:${TAG:-manual-build}'
restart: 'always'
volumes:
- geoserver-data-dir:/opt/geoserver/data_dir
- ./tests:/tests
environment:
GEOSERVER_ADMIN_PASSWORD: myawesomegeoserver
GEOSERVER_ADMIN_USER: admin
INITIAL_MEMORY: 2G
MAXIMUM_MEMORY: 4G
POSTGRES_JNDI: TRUE
POSTGRES_PORT: 5432
HOST: db
POSTGRES_DB: gis
POSTGRES_USER: docker
POSTGRES_PASS: docker
RECREATE_DATADIR: TRUE
CONSOLE_HANDLER_LEVEL: WARNING
SAMPLE_DATA: true
DB_BACKEND: POSTGRES
COMMUNITY_EXTENSIONS: jdbcconfig-plugin,jdbcstore-plugin
TEST_CLASS: test_jdbconfig.TestGeoServerJDBCONFIG
depends_on:
db:
condition: service_healthy
ports:
- "8080:8080"
healthcheck:
test: ["CMD-SHELL", "curl --fail --silent --write-out 'HTTP CODE : %{http_code}\n' --output /dev/null -u $${GEOSERVER_ADMIN_USER}:$${GEOSERVER_ADMIN_PASSWORD} http://localhost:8080/geoserver/rest/about/version.xml"]
interval: 1m30s
timeout: 10s
retries: 3


2 changes: 1 addition & 1 deletion scenario_tests/jdbconfig/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ volumes:

services:
db:
image: kartoza/postgis:16-3.4
image: kartoza/postgis:17-3.5
volumes:
- postgis-data:/var/lib/postgresql
environment:
Expand Down
24 changes: 24 additions & 0 deletions scenario_tests/jdbconfig/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,27 @@ for service in "${services[@]}"; do
done

${VERSION} -f docker-compose.yml down -v


#JNDI
${VERSION} -f docker-compose-postgis-jndi.yml up -d

if [[ -n "${PRINT_TEST_LOGS}" ]]; then
${VERSION} -f docker-compose-postgis-jndi.yml logs -f &
fi




services=("geoserver")

for service in "${services[@]}"; do

# Execute tests
test_url_availability http://localhost:8080/geoserver/rest/about/version.xml
echo "Execute test for $service"
${VERSION} -f docker-compose-postgis-jndi.yml exec $service /bin/bash /tests/test.sh

done

${VERSION} -f docker-compose-postgis-jndi.yml down -v
2 changes: 1 addition & 1 deletion scenario_tests/stores/docker-compose-postgis-jndi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ volumes:

services:
db:
image: kartoza/postgis:16-3.4
image: kartoza/postgis:17-3.5
volumes:
- postgis-data:/var/lib/postgresql
environment:
Expand Down
6 changes: 4 additions & 2 deletions scripts/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export CLUSTER_CONFIG_DIR MONITOR_AUDIT_PATH INSTANCE_STRING CLUSTER_CONNECTION

log CLUSTER_CONFIG_DIR="${CLUSTER_CONFIG_DIR}"
log MONITOR_AUDIT_PATH="${MONITOR_AUDIT_PATH}"
if [[ -z ${GEOSERVER_OPTS} ]];then

export GEOSERVER_OPTS="-Djava.awt.headless=true -server -Xms${INITIAL_MEMORY} -Xmx${MAXIMUM_MEMORY} \
-XX:PerfDataSamplingInterval=500 -Dorg.geotools.referencing.forceXY=true \
Expand Down Expand Up @@ -83,8 +84,9 @@ export GEOSERVER_OPTS="-Djava.awt.headless=true -server -Xms${INITIAL_MEMORY} -X
-Dsun.java2d.renderer.useThreadLocal=false \
-Dsun.java2d.renderer.pixelsize=8192 -server -XX:NewSize=300m \
-Dlog4j.configuration=${CATALINA_HOME}/log4j.properties \
--patch-module java.desktop=${CATALINA_HOME}/marlin-render.jar \
--patch-module java.desktop=${CATALINA_HOME}/lib/marlin.jar \
-Dsun.java2d.renderer=org.marlin.pisces.PiscesRenderingEngine \
-Dsun.java2d.renderer.log=true \
-Dgeoserver.login.autocomplete=${LOGIN_STATUS} \
-DUPDATE_BUILT_IN_LOGGING_PROFILES=${UPDATE_LOGGING_PROFILES} \
-DRELINQUISH_LOG4J_CONTROL=${RELINQUISH_LOG4J_CONTROL} \
Expand All @@ -96,7 +98,7 @@ export GEOSERVER_OPTS="-Djava.awt.headless=true -server -Xms${INITIAL_MEMORY} -X
-DENTITY_RESOLUTION_ALLOWLIST='"${ENTITY_RESOLUTION_ALLOWLIST}"' \
-DGEOSERVER_DISABLE_STATIC_WEB_FILES=${GEOSERVER_DISABLE_STATIC_WEB_FILES} \
${ADDITIONAL_JAVA_STARTUP_OPTIONS} "

fi
## Prepare the JVM command line arguments
export JAVA_OPTS="${JAVA_OPTS} ${GEOSERVER_OPTS}"

Expand Down
15 changes: 13 additions & 2 deletions scripts/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,13 @@ function setup_jdbc_db_config() {
envsubst < "${EXTRA_CONFIG_DIR}"/jdbcconfig.properties > "${GEOSERVER_DATA_DIR}"/jdbcconfig/jdbcconfig.properties
else
envsubst < /build_data/jdbcconfig/jdbcconfig.properties > "${GEOSERVER_DATA_DIR}"/jdbcconfig/jdbcconfig.properties
sed -i '/^jndiName=/d' "${GEOSERVER_DATA_DIR}"/jdbcconfig/jdbcconfig.properties
if [[ ${POSTGRES_JNDI} =~ [Tt][Rr][Uu][Ee] ]];then
# Set jndiName if POSTGRES_JNDI is set to true
echo "jndiName=java:comp/env/jdbc/postgres" >> "${GEOSERVER_DATA_DIR}"/jdbcconfig/jdbcconfig.properties
fi
fi

check_jdbc_config_table=$(psql -d "$POSTGRES_DB" -p "$POSTGRES_PORT" -U "$POSTGRES_USER" -h "$HOST" -tAc "SELECT EXISTS(SELECT 1 FROM information_schema.tables WHERE table_name = 'object_property')")
if [[ ${check_jdbc_config_table} = "t" ]]; then
sed -i 's/initdb=true/initdb=false/g' "${GEOSERVER_DATA_DIR}"/jdbcconfig/jdbcconfig.properties
Expand Down Expand Up @@ -586,9 +592,14 @@ function setup_jdbc_db_store() {
envsubst < /build_data/jdbcconfig/jdbcconfig.properties > "${GEOSERVER_DATA_DIR}"/jdbcconfig/jdbcconfig.properties
fi
if [[ -f "${EXTRA_CONFIG_DIR}"/jdbcstore.properties ]]; then
envsubst < "${EXTRA_CONFIG_DIR}"/jdbcstore.properties > "${GEOSERVER_DATA_DIR}"/jdbcstore/jdbcstore.propertiesproperties
envsubst < "${EXTRA_CONFIG_DIR}"/jdbcstore.properties > "${GEOSERVER_DATA_DIR}"/jdbcstore/jdbcstore.properties
else
envsubst < /build_data/jdbcstore/jdbcstore.properties > "${GEOSERVER_DATA_DIR}"/jdbcstore/jdbcstore.propertiesproperties
envsubst < /build_data/jdbcstore/jdbcstore.properties > "${GEOSERVER_DATA_DIR}"/jdbcstore/jdbcstore.properties
sed -i '/^jndiName=/d' "${GEOSERVER_DATA_DIR}"/jdbcstore/jdbcstore.properties
if [[ ${POSTGRES_JNDI} =~ [Tt][Rr][Uu][Ee] ]];then
# Set jndiName if POSTGRES_JNDI is set to true
echo "jndiName=java:comp/env/jdbc/postgres" >> "${GEOSERVER_DATA_DIR}"/jdbcstore/jdbcstore.properties
fi
fi

check_jdbc_store_table=$(psql -d "$POSTGRES_DB" -p "${POSTGRES_PORT}" -U "${POSTGRES_USER}" -h "${HOST}" -tAc "SELECT EXISTS(SELECT 1 from information_schema.tables where table_name = 'resources')")
Expand Down
22 changes: 3 additions & 19 deletions scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,32 +67,16 @@ fi


# Install Marlin render https://www.geocat.net/docs/geoserver-enterprise/2020.5/install/production/marlin.html
JAVA_VERSION=$(java -version 2>&1 | awk -F '"' '/version/ {print $2}')
java_version_major=$(echo "${JAVA_VERSION}" | cut -d '.' -f 1)
if [[ ${java_version_major} -gt 10 ]];then
if [[ -f $(find "${GEOSERVER_INSTALL_DIR}"/webapps/"${GEOSERVER_CONTEXT_ROOT}"/WEB-INF/lib -regex ".*marlin-[0-9]\.[0-9]\.[0-9].*jar") ]]; then
mv "${GEOSERVER_INSTALL_DIR}"/webapps/"${GEOSERVER_CONTEXT_ROOT}"/WEB-INF/lib/marlin-* "${GEOSERVER_INSTALL_DIR}"/webapps/"${GEOSERVER_CONTEXT_ROOT}"/WEB-INF/lib/marlin-render.jar
fi
else
if [[ -f $(find "${GEOSERVER_INSTALL_DIR}"/webapps/"${GEOSERVER_CONTEXT_ROOT}"/WEB-INF/lib -regex ".*marlin-[0-9]\.[0-9]\.[0-9].*jar") ]]; then
rm "${GEOSERVER_INSTALL_DIR}"/webapps/"${GEOSERVER_CONTEXT_ROOT}"/WEB-INF/lib/marlin-*
validate_url https://github.com/bourgesl/marlin-renderer/releases/download/v0_9_4_8/marlin-0.9.4.8-Unsafe-OpenJDK11.jar && \
mv marlin-0.9.4.8-Unsafe-OpenJDK11.jar "${GEOSERVER_INSTALL_DIR}"/webapps/"${GEOSERVER_CONTEXT_ROOT}"/WEB-INF/lib/marlin-render.jar
fi
fi
curl --progress-bar -fLvo ${CATALINA_HOME}/lib/marlin.jar https://github.com/bourgesl/marlin-renderer/releases/download/v0_9_4_8/marlin-0.9.4.8-Unsafe-OpenJDK11.jar || exit 1

# Install jetty-servlets
if [[ -f ${GEOSERVER_HOME}/start.jar ]]; then
if [[ ! -f ${GEOSERVER_HOME}/webapps/${GEOSERVER_CONTEXT_ROOT}/WEB-INF/lib/jetty-servlets.jar ]]; then
curl -vfLo "${GEOSERVER_HOME}/webapps/${GEOSERVER_CONTEXT_ROOT}/WEB-INF/lib/jetty-servlets.jar" https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-servlets/11.0.9/jetty-servlets-11.0.9.jar
fi
cp /work/required_plugins/jetty-servlets-11.0.9.jar "${GEOSERVER_HOME}"/webapps/"${GEOSERVER_CONTEXT_ROOT}"/WEB-INF/lib/
fi

# Install jetty-util
if [[ -f ${GEOSERVER_HOME}/start.jar ]]; then
if [[ ! -f ${GEOSERVER_HOME}/webapps/${GEOSERVER_CONTEXT_ROOT}/WEB-INF/lib/jetty-util.jar ]]; then
curl -vfLo "${GEOSERVER_HOME}/webapps/${GEOSERVER_CONTEXT_ROOT}/WEB-INF/lib/jetty-util.jar" https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-util/11.0.9/jetty-util-11.0.9.jar
fi
cp /work/required_plugins/jetty-util.jar "${GEOSERVER_HOME}"/webapps/"${GEOSERVER_CONTEXT_ROOT}"/WEB-INF/lib/
fi

# Overlay files and directories in resources/overlays if they exist
Expand Down
2 changes: 1 addition & 1 deletion scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ fi

fi

export JDBC_CONFIG_ENABLED JDBC_IGNORE_PATHS JDBC_STORE_ENABLED
export JDBC_CONFIG_ENABLED JDBC_IGNORE_PATHS JDBC_STORE_ENABLED POSTGRES_JNDI
# Install community modules plugins
if [[ ! -z ${COMMUNITY_EXTENSIONS} ]]; then
if [[ ${FORCE_DOWNLOAD_COMMUNITY_EXTENSIONS} =~ [Tt][Rr][Uu][Ee] ]];then
Expand Down
Loading