Skip to content

Commit

Permalink
update compose files to use env variables (#646)
Browse files Browse the repository at this point in the history
* update compose files to use env variables and improve testing logic 

---------

Co-authored-by: spatialgeobyte <[email protected]>
  • Loading branch information
NyakudyaA and spatialgeobyte authored May 18, 2024
1 parent d489ef1 commit 7bcc741
Show file tree
Hide file tree
Showing 25 changed files with 169 additions and 84 deletions.
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ ENV DEBIAN_FRONTEND=noninteractive
RUN set -eux; \
apt-get update; \
apt-get -y --no-install-recommends install \
locales gnupg2 wget ca-certificates rpl pwgen software-properties-common iputils-ping \
apt-transport-https curl gettext fonts-cantarell fonts-liberation lmodern ttf-aenigma \
locales gnupg2 wget ca-certificates software-properties-common iputils-ping \
apt-transport-https gettext fonts-cantarell fonts-liberation lmodern ttf-aenigma \
ttf-bitstream-vera ttf-sjfonts tv-fonts libapr1-dev libssl-dev git \
wget zip unzip curl xsltproc certbot cabextract gettext postgresql-client figlet gosu gdal-bin libgdal-java; \
zip unzip curl xsltproc certbot cabextract gettext postgresql-client figlet gosu gdal-bin libgdal-java; \
dpkg-divert --local --rename --add /sbin/initctl \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*; \
Expand Down
2 changes: 1 addition & 1 deletion docker-compose-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ services:
- STABLE_EXTENSIONS=${STABLE_EXTENSIONS}
- COMMUNITY_EXTENSIONS=${COMMUNITY_EXTENSIONS}
healthcheck:
test: "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"
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: 1m
timeout: 10s
retries: 3
Expand Down
2 changes: 1 addition & 1 deletion docker-compose-nginx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ services:
db:
condition: service_healthy
healthcheck:
test: "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"
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
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ services:
db:
condition: service_healthy
healthcheck:
test: "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"
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
Expand Down
6 changes: 5 additions & 1 deletion scenario_tests/clustering/docker-compose-external.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,10 @@ services:
volumes:
- geoserver-cluster-data:/opt/geoserver/data_dir
- ./tests:/tests
ports:
- "8081:8080"
healthcheck:
test: "curl --fail --silent --write-out 'HTTP CODE : %{http_code}\n' --output /dev/null -u admin:myawesomegeoserver http://localhost:8080/geoserver/rest/about/version.xml"
test: ["CMD-SHELL","curl --fail --silent --write-out 'HTTP CODE : %{http_code}\n' --output /dev/null -u admin:myawesomegeoserver http://localhost:8080/geoserver/rest/about/version.xml"]
interval: 1m30s
timeout: 10s
retries: 3
Expand Down Expand Up @@ -152,6 +154,8 @@ services:
volumes:
- geoserver-cluster-data:/opt/geoserver/data_dir
- ./tests:/tests
ports:
- "8082:8080"
healthcheck:
test: "curl --fail --silent --write-out 'HTTP CODE : %{http_code}\n' --output /dev/null -u admin:myawesomegeoserver http://localhost:8080/geoserver/rest/about/version.xml"
interval: 1m30s
Expand Down
6 changes: 5 additions & 1 deletion scenario_tests/clustering/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ services:
- GEOSERVER_ADMIN_PASSWORD=myawesomegeoserver
- GEOSERVER_ADMIN_USER=admin
- TEST_CLASS=test_clustering_master.GeoServerClusteringMaster
ports:
- "8081:8080"
restart: on-failure
depends_on:
db:
Expand Down Expand Up @@ -72,14 +74,16 @@ services:
- GEOSERVER_ADMIN_PASSWORD=myawesomegeoserver
- GEOSERVER_ADMIN_USER=admin
- TEST_CLASS=test_clustering_node.GeoServerClusteringNode
ports:
- "8082:8080"
restart: on-failure
depends_on:
master:
condition: service_started
db:
condition: service_healthy
healthcheck:
test: "curl --fail --silent --write-out 'HTTP CODE : %{http_code}\n' --output /dev/null -u admin:'myawesomegeoserver' http://localhost:8080/geoserver/rest/about/version.xml"
test: ["CMD-SHELL","curl --fail --silent --write-out 'HTTP CODE : %{http_code}\n' --output /dev/null -u admin:'myawesomegeoserver' http://localhost:8080/geoserver/rest/about/version.xml"]
interval: 1m30s
timeout: 10s
retries: 3
Expand Down
19 changes: 12 additions & 7 deletions scenario_tests/clustering/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,23 @@ fi
################################
#Test using internal jms cluster
################################
echo -e "------------------------------------------------------"
echo -e "[Unit Test] Running testing using internal: JMS plugin"

${VERSION} -f docker-compose.yml up -d

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

sleep 60

# Test Master
services=("master")

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

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

Expand All @@ -41,7 +43,7 @@ services=("node")
for service in "${services[@]}"; do

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

Expand All @@ -53,23 +55,26 @@ ${VERSION} -f docker-compose.yml down -v
#Test using external ActiveMQ
#############################

echo -e "------------------------------------------------------"
echo -e "[Unit Test] Running testing using internal: ActiveMQ"

${VERSION} -f docker-compose-external.yml up -d

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

sleep 120


# Test Master
services=("master")

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

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

done

Expand All @@ -79,7 +84,7 @@ services=("node")
for service in "${services[@]}"; do

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

Expand Down
5 changes: 5 additions & 0 deletions scenario_tests/clustering/tests/test_clustering_master.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from geo.Geoserver import Geoserver
from requests import get, post, exceptions
from requests.auth import HTTPBasicAuth
from shutil import copy


class GeoServerClusteringMaster(unittest.TestCase):
Expand Down Expand Up @@ -84,6 +85,10 @@ def test_publish_store(self):
geo.publish_featurestore(workspace='%s'
% self.geo_workspace_name, store_name='%s' % self.store_name,
pg_table='states')
copy("/usr/local/tomcat/data/styles/default_point.sld", "/usr/local/tomcat/data/styles/states.sld")
layer_sld_file = "/usr/local/tomcat/data/styles/states.sld"
geo.upload_style(path=str(layer_sld_file), workspace=self.geo_workspace_name)
geo.publish_style(layer_name='states', style_name='states', workspace=self.geo_workspace_name)
self.assertEqual(response.status_code, 200)

# Check that the layer exists
Expand Down
12 changes: 12 additions & 0 deletions scenario_tests/clustering/tests/test_clustering_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ def check_layer_exists(self, auth, layer_name):
response = get(layer_url, auth=auth)
return response.status_code == 200

def check_style_exists(self, auth, layer_name):
style_url = '%s/rest/workspaces/%s/styles/%s.json' % (
self.gs_url, self.geo_workspace_name, layer_name)
response = get(style_url, auth=auth)
return response.status_code == 200

def test_workspace_exists(self):
auth = HTTPBasicAuth('%s' % self.geo_username, '%s' % self.geo_password)
workspace_exists = self.check_workspace_exists(auth)
Expand All @@ -48,6 +54,12 @@ def test_layer_exists(self):
layer_exists = self.check_layer_exists(auth, layer_name)
self.assertTrue(layer_exists, "Layer does not exist")

def test_layer_style_exists(self):
auth = HTTPBasicAuth('%s' % self.geo_username, '%s' % self.geo_password)
layer_name = 'states'
layer_exists = self.check_style_exists(auth, layer_name)
self.assertTrue(layer_exists, "Style does not exist")


if __name__ == '__main__':
unittest.main()
4 changes: 3 additions & 1 deletion scenario_tests/context/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ services:
volumes:
- geoserver-data-dir:/opt/geoserver/data_dir
- ./tests:/tests
ports:
- "8080:8080"
environment:
GEOSERVER_ADMIN_PASSWORD: myawesomegeoserver
GEOSERVER_ADMIN_USER: admin
Expand All @@ -21,7 +23,7 @@ services:
CONTAINER_NAME: geoserver
TEST_CLASS: test_login.TestGeoServerREST
healthcheck:
test: "curl --fail --silent --write-out 'HTTP CODE : %{http_code}\n' --output /dev/null -u admin:'myawesomegeoserver' http://localhost:8080/foobar/rest/about/version.xml"
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/foobar/rest/about/version.xml"]
interval: 1m30s
timeout: 10s
retries: 3
Expand Down
17 changes: 12 additions & 5 deletions scenario_tests/context/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,37 @@ if [[ $(dpkg -l | grep "docker-compose") > /dev/null ]];then
VERSION='docker compose'
fi

####################################
#Test using default created password
#####################################
echo -e "[Unit Test] Running tests using password from env Geoserver password"

${VERSION} up -d

if [[ -n "${PRINT_TEST_LOGS}" ]]; then
${VERSION} logs -f &
fi

sleep 30



services=("geoserver")

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

# Execute tests
sleep 60
test_url_availability http://localhost:8080/foobar/rest/about/version.xml foobargeoserver
echo "Execute test for $service"
${VERSION} exec -T "${service}" /bin/bash /tests/test.sh

done

${VERSION} down -v

# Update context password
sleep 5
####################################
#Test using updated password
#####################################
echo -e "[Unit Test] Running testing using updated password from env Geoserver password"
sed -i 's/foobar/foobar#geoserver/g' docker-compose.yml
# Bring the services up again
${VERSION} up -d geoserver
Expand All @@ -45,7 +52,7 @@ services=("geoserver")
for service in "${services[@]}"; do

# Execute tests
sleep 60
test_url_availability http://localhost:8080/foobar/geoserver/rest/about/version.xml
echo "Execute test for $service"
${VERSION} exec -T "${service}" /bin/bash /tests/test.sh

Expand Down
4 changes: 3 additions & 1 deletion scenario_tests/disk-quota/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ services:
depends_on:
db:
condition: service_healthy
ports:
- "8080:8080"
healthcheck:
test: "curl --fail --silent --write-out 'HTTP CODE : %{http_code}\n' --output /dev/null -u admin:'myawesomegeoserver' http://localhost:8080/geoserver/rest/about/version.xml"
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
Expand Down
4 changes: 2 additions & 2 deletions scenario_tests/disk-quota/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ if [[ -n "${PRINT_TEST_LOGS}" ]]; then
${VERSION} -f docker-compose.yml logs -f &
fi

sleep 60



services=("geoserver")

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

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

Expand Down
4 changes: 3 additions & 1 deletion scenario_tests/gwc/docker-compose-gwc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ services:
RECREATE_DATADIR: TRUE
SAMPLE_DATA: true
TEST_CLASS: test_gwc.TestGeoServerGWC
ports:
- "8080:8080"
healthcheck:
test: "curl --fail --silent --write-out 'HTTP CODE : %{http_code}\n' --output /dev/null -u admin:'myawesomegeoserver' http://localhost:8080/geoserver/rest/about/version.xml"
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
Expand Down
4 changes: 2 additions & 2 deletions scenario_tests/gwc/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ if [[ -n "${PRINT_TEST_LOGS}" ]]; then
${VERSION} -f docker-compose-gwc.yml logs -f &
fi

sleep 60



services=("geoserver")

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

# Execute tests
sleep 60
test_url_availability http://localhost:8080/geoserver/rest/about/version.xml
${VERSION} -f docker-compose-gwc.yml ps
echo "Execute test for $service"
${VERSION} -f docker-compose-gwc.yml exec $service /bin/bash /tests/test.sh
Expand Down
8 changes: 6 additions & 2 deletions scenario_tests/login/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ services:
MAXIMUM_MEMORY: 4G
CONTAINER_NAME: geoserver
TEST_CLASS: test_login.TestGeoServerREST
ports:
- "8081:8080"
healthcheck:
test: "curl --fail --silent --write-out 'HTTP CODE : %{http_code}\n' --output /dev/null -u admin:'myawesomegeoserver' http://localhost:8080/geoserver/rest/about/version.xml"
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
Expand All @@ -38,8 +40,10 @@ services:
MAXIMUM_MEMORY: 4G
CONTAINER_NAME: server
TEST_CLASS: test_login.TestGeoServerREST
ports:
- "8082:8080"
healthcheck:
test: "curl --fail --silent --write-out 'HTTP CODE : %{http_code}\n' --output /dev/null -u admin:$$(cat /opt/geoserver/data_dir/security/pass.txt) http://localhost:8080/geoserver/rest/about/version.xml"
test: ["CMD-SHELL", "curl --fail --silent --write-out 'HTTP CODE : %{http_code}\n' --output /dev/null -u $${GEOSERVER_ADMIN_USER}:$$(cat /opt/geoserver/data_dir/security/pass.txt) http://localhost:8080/geoserver/rest/about/version.xml"]
interval: 1m30s
timeout: 10s
retries: 3
Expand Down
Loading

0 comments on commit 7bcc741

Please sign in to comment.