Skip to content

Commit

Permalink
- Test GeoServer Integration Tests running with Docker Compose
Browse files Browse the repository at this point in the history
  • Loading branch information
afabiani committed May 14, 2018
1 parent 02fbe20 commit bbaef20
Show file tree
Hide file tree
Showing 6 changed files with 224 additions and 54 deletions.
107 changes: 64 additions & 43 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,69 +20,79 @@ services:
- postgresql

addons:
hosts:
- geonode
postgresql: 9.6
apt:
packages:
- postgresql-9.6-postgis-2.3
- nginx

env:
# - BACKEND: 'geonode.geoserver'
# ON_TRAVIS: 'True'
# TEST_RUN_CORE: 'True'
# MONITORING_ENABLED: 'False'
# - BACKEND: 'geonode.geoserver'
# ON_TRAVIS: 'True'
# TEST_RUN_INTERNAL_APPS: 'True'
# MONITORING_ENABLED: 'False'
- BACKEND: 'geonode.geoserver'
ON_TRAVIS: 'True'
TEST_RUN_CORE: 'True'
MONITORING_ENABLED: 'False'
- BACKEND: 'geonode.geoserver'
ON_TRAVIS: 'True'
TEST_RUN_INTERNAL_APPS: 'True'
MONITORING_ENABLED: 'False'
- BACKEND: 'geonode.geoserver'
ON_TRAVIS: 'True'
TEST_RUN_INTEGRATION: 'True'
MONITORING_ENABLED: 'False'
- BACKEND: 'geonode.qgis_server'
DOCKER_COMPOSE_VERSION: 1.11.2
# This is qgis server address
QGIS_SERVER_URL: http://localhost:9000/
# This is the location of docker network bridge
# So QGIS server can access this address
SITEURL: http://localhost:8000/
QGIS_SERVER_PORT: 9000
ON_TRAVIS: 'True'
TEST_RUN_CORE: 'True'
MONITORING_ENABLED: 'False'
CELERY_ALWAYS_EAGER: 'True'
- BACKEND: 'geonode.qgis_server'
DOCKER_COMPOSE_VERSION: 1.11.2
# This is qgis server address
QGIS_SERVER_URL: http://localhost:9000/
# This is the location of docker network bridge
# So QGIS server can access this address
SITEURL: http://localhost:8000/
QGIS_SERVER_PORT: 9000
ON_TRAVIS: 'True'
TEST_RUN_INTERNAL_APPS: 'True'
MONITORING_ENABLED: 'False'
CELERY_ALWAYS_EAGER: 'True'
- BACKEND: 'geonode.qgis_server'
DOCKER_COMPOSE_VERSION: 1.11.2
# This is qgis server address
QGIS_SERVER_URL: http://localhost:9000/
# This is the location of docker network bridge
# So QGIS server can access this address
SITEURL: http://localhost:8000/
QGIS_SERVER_PORT: 9000
DOCKER_COMPOSE_VERSION: 1.19.0
# This is GeoServer server address
GEOSERVER_SERVER_URL: http://localhost:8080/geoserver/
GEOSERVER_SERVER_PORT: 8080
ON_TRAVIS: 'True'
TEST_RUN_INTEGRATION: 'True'
MONITORING_ENABLED: 'False'
CELERY_ALWAYS_EAGER: 'True'
# - BACKEND: 'geonode.qgis_server'
# DOCKER_COMPOSE_VERSION: 1.11.2
# # This is qgis server address
# QGIS_SERVER_URL: http://localhost:9000/
# # This is the location of docker network bridge
# # So QGIS server can access this address
# SITEURL: http://localhost:8000/
# QGIS_SERVER_PORT: 9000
# ON_TRAVIS: 'True'
# TEST_RUN_CORE: 'True'
# MONITORING_ENABLED: 'False'
# CELERY_ALWAYS_EAGER: 'True'
# - BACKEND: 'geonode.qgis_server'
# DOCKER_COMPOSE_VERSION: 1.11.2
# # This is qgis server address
# QGIS_SERVER_URL: http://localhost:9000/
# # This is the location of docker network bridge
# # So QGIS server can access this address
# SITEURL: http://localhost:8000/
# QGIS_SERVER_PORT: 9000
# ON_TRAVIS: 'True'
# TEST_RUN_INTERNAL_APPS: 'True'
# MONITORING_ENABLED: 'False'
# CELERY_ALWAYS_EAGER: 'True'
# - BACKEND: 'geonode.qgis_server'
# DOCKER_COMPOSE_VERSION: 1.11.2
# # This is qgis server address
# QGIS_SERVER_URL: http://localhost:9000/
# # This is the location of docker network bridge
# # So QGIS server can access this address
# SITEURL: http://localhost:8000/
# QGIS_SERVER_PORT: 9000
# ON_TRAVIS: 'True'
# TEST_RUN_INTEGRATION: 'True'
# MONITORING_ENABLED: 'False'
# CELERY_ALWAYS_EAGER: 'True'

branches:
only:
- master
- 2.9.x
- 2.8.0
- 2.7.x
- 2.6.x

before_install:
- scripts/misc/geoserver_server_setup.sh before_install
- scripts/misc/qgis_server_setup.sh before_install
- chmod +x scripts/misc/bdd_setup.sh
- scripts/misc/bdd_setup.sh before_install
Expand All @@ -107,19 +117,30 @@ before_script:
- psql -U postgres -c "create extension postgis"
- chmod +x scripts/misc/create_dbs_travis.sh
- scripts/misc/create_dbs_travis.sh before_script
# For GeoServer Server Travis steps
- scripts/misc/geoserver_server_setup.sh before_script
# For QGIS Server Travis steps
- scripts/misc/qgis_server_setup.sh before_script
- scripts/misc/bdd_setup.sh before_script

# Start NGINX server
- nginx -c `pwd`/scripts/misc/nginx_integration.conf

# Setup GeoNode
- paver setup

script:
- paver run_tests --coverage --local false

after_script:
# For GeoServer Server Travis steps
- scripts/misc/geoserver_server_setup.sh after_script
# For QGIS Server Travis steps
- scripts/misc/qgis_server_setup.sh after_script

# Stop NGINX server
- nginx -c `pwd`/scripts/misc/nginx_integration.conf -s stop

# Cleanup
- paver reset_hard

Expand Down
37 changes: 37 additions & 0 deletions docker-compose-geoserver-server.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
version: '2.2'
services:

data-dir-conf:
image: geonode/geoserver_data:2.13.x
restart: on-failure
container_name: gsconf4${COMPOSE_PROJECT_NAME}
labels:
org.geonode.component: conf
org.geonode.instance.name: geonode
command: /bin/true
volumes:
- geoserver-data-dir:/geoserver_data/data

geoserver:
image: geonode/geoserver:2.13.x
restart: unless-stopped
container_name: geoserver4${COMPOSE_PROJECT_NAME}
stdin_open: true
# tty: true
labels:
org.geonode.component: geoserver
org.geonode.instance.name: geonode
depends_on:
- data-dir-conf
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- geoserver-data-dir:/geoserver_data/data
env_file:
- ./scripts/docker/env/production/geoserver.env
ports:
- "${GEOSERVER_SERVER_PORT}:8080"
network_mode: "bridge"

volumes:
geoserver-data-dir:
name: ${COMPOSE_PROJECT_NAME}-gsdatadir
23 changes: 12 additions & 11 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,17 @@ services:
env_file:
- ./scripts/docker/env/production/celery.env

data-dir-conf:
image: geonode/geoserver_data:2.13.x
restart: on-failure
container_name: gsconf4${COMPOSE_PROJECT_NAME}
labels:
org.geonode.component: conf
org.geonode.instance.name: geonode
command: /bin/true
volumes:
- geoserver-data-dir:/geoserver_data/data

geoserver:
image: geonode/geoserver:2.13.x
restart: unless-stopped
Expand All @@ -68,6 +79,7 @@ services:
- db
# - elasticsearch
- rabbitmq
- data-dir-conf
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- geoserver-data-dir:/geoserver_data/data
Expand Down Expand Up @@ -110,17 +122,6 @@ services:
ports:
- "80:80"

data-dir-conf:
image: geonode/geoserver_data:2.13.x
restart: on-failure
container_name: gsconf4${COMPOSE_PROJECT_NAME}
labels:
org.geonode.component: conf
org.geonode.instance.name: geonode
command: /bin/true
volumes:
- geoserver-data-dir:/geoserver_data/data

volumes:
geoserver-data-dir:
name: ${COMPOSE_PROJECT_NAME}-gsdatadir
Expand Down
8 changes: 8 additions & 0 deletions pavement.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,10 @@ def stop_geoserver():
"""
Stop GeoServer
"""
# we use docker-compose for integration tests
if integration_tests:
return

# only start if using Geoserver backend
if 'geonode.geoserver' not in INSTALLED_APPS or OGC_SERVER['default']['BACKEND'] == 'geonode.qgis_server':
return
Expand Down Expand Up @@ -595,6 +599,10 @@ def start_geoserver(options):
"""
Start GeoServer with GeoNode extensions
"""
# we use docker-compose for integration tests
if integration_tests:
return

# only start if using Geoserver backend
if 'geonode.geoserver' not in INSTALLED_APPS or OGC_SERVER['default']['BACKEND'] == 'geonode.qgis_server':
return
Expand Down
31 changes: 31 additions & 0 deletions scripts/misc/geoserver_server_setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash

set -x

if [ "$BACKEND" = "geonode.geoserver" ]; then

case $1 in
"before_install")
echo "Before install scripts"
ifconfig
pip install docker-compose==$DOCKER_COMPOSE_VERSION
scripts/misc/docker_check.sh
;;
"before_script")
echo "Setting up GeoServer Server Backend"
echo "Start GeoServer Server docker container"
export GEONODE_PROJECT_PATH=$TRAVIS_BUILD_DIR
docker-compose -f docker-compose-geoserver-server.yml up -d geoserver
sleep 30
docker ps
docker inspect geoserver4geonode
echo "Test connection to GeoServer Server"
wget -qO- $GEOSERVER_SERVER_URL
wget -qO- ${GEOSERVER_SERVER_URL}ows?service=wms&version=1.3.0&request=GetCapabilities
;;
"after_script")
echo "Shutdown GeoServer Server docker container"
docker-compose -f docker-compose-geoserver-server.yml down
;;
esac
fi
72 changes: 72 additions & 0 deletions scripts/misc/nginx_integration.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
user nginx;
worker_processes 1;

error_log /tmp/error.log;
pid /tmp/nginx.pid;

events {
worker_connections 1024;
}


http {
client_body_temp_path /tmp/nginx_client_body;
fastcgi_temp_path /tmp/nginx_fastcgi_temp;
proxy_temp_path /tmp/nginx_proxy_temp;
scgi_temp_path /tmp/nginx_scgi_temp;
uwsgi_temp_path /tmp/nginx_uwsgi_temp;

include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /tmp/access.log main;

sendfile on;
#tcp_nopush on;

keepalive_timeout 65;

#gzip on;

server{
listen 80;
index index.html index.htm;
root /usr/share/nginx/html;

location /{
proxy_pass http://geonode:8000;

if ($request_method = OPTIONS) {
add_header Access-Control-Allow-Methods "GET, POST, PUT, PATCH, OPTIONS";
add_header Access-Control-Allow-Headers "Authorization, Content-Type, Accept";
add_header Access-Control-Allow-Credentials true;
add_header Content-Length 0;
add_header Content-Type text/plain;
add_header Access-Control-Max-Age 1728000;
return 200;
}

client_max_body_size 15M;
client_body_buffer_size 128K;
add_header Access-Control-Allow-Credentials false;
add_header Access-Control-Allow-Headers "Content-Type, Accept, Authorization, Origin, User-Agent";
add_header Access-Control-Allow-Methods "GET, POST, PUT, PATCH, OPTIONS";
proxy_set_header X-Forwarded-Protocol $scheme;
proxy_read_timeout 30;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;

error_log /tmp/error.log;
access_log /tmp/access.log;
}
}

#include /etc/nginx/conf.d/*.conf;
}

0 comments on commit bbaef20

Please sign in to comment.