Commit f97da208 authored by Emmanuel Duchastenier's avatar Emmanuel Duchastenier
Browse files

chore(docker): restore Community tests

to test docker image

(+ include tests in docker image build on CI) => commented out for now,
as GOSS tool is missing on the CI slave image
parent 11ad5b8f
Bonitasoft docker images
=========================
## Build SNAPSHOT version
```
./build.sh --
```
## Build TAG version
```
docker build -t bonitasoft/bonita:<VERSION> .
```
## Test
Tests uses [goss](https://github.com/aelsabbahy/goss). It needs to be installed first.
**_Note_**: No need to build image prior to running tests
```
cd test && ./runTests.sh
```
#!/usr/bin/env bash
set -euxo pipefail
echo "GOSS: custom-init.d script $BASH_ARGV!"
#!/usr/bin/env bash
set -euxo pipefail
echo "GOSS: custom-init.d script $BASH_ARGV!"
#!/usr/bin/env bash
set -euxo pipefail
echo "GOSS: custom-init.d script $BASH_ARGV!"
#!/usr/bin/env bash
set -euxo pipefail
echo "GOSS: custom-init.d script $BASH_ARGV!"
#!/usr/bin/env bash
set -euxo pipefail
echo "GOSS: custom-init.d script $BASH_ARGV!"
group:
bonita:
# required attributes
exists: true
# optional attributes
gid: 1000
user:
bonita:
# required attributes
exists: true
# optional attributes
uid: 1000
gid: 1000
groups:
- bonita
shell: /sbin/nologin
file:
/opt/bonita:
# required attributes
exists: true
# optional attributes
owner: bonita
group: bonita
filetype: directory # file, symlink, directory
/opt/bonita_lic:
# required attributes
exists: true
# optional attributes
owner: bonita
group: bonita
filetype: directory # file, symlink, directory
/opt/custom-init.d:
# required attributes
exists: true
# optional attributes
filetype: directory # file, symlink, directory
/opt/files:
# required attributes
exists: true
# optional attributes
filetype: directory # file, symlink, directory
/opt/templates:
# required attributes
exists: true
# optional attributes
filetype: directory # file, symlink, directory
command:
# not using port command here to support both tcp and tcp6
ss -ntl | grep 8080:
title: Checking port 8080 is listening
exit-status: 0
env | sort:
title: Checking environment variables
exit-status: 0
stdout:
- BONITA_VERSION
ps -eo args | grep java:
title: Checking that Tomcat is running
exit-status: 0
stdout:
- /org.apache.catalina.startup.Bootstrap start/
ls -1 /opt/bonita/Bonita*/setup/lib/{{getEnv "DB_VENDOR"}}*:
title: Checking that JDBC driver is present
exit-status: 0
grep 'db.vendor={{getEnv "DB_VENDOR"}}' /opt/bonita/Bonita*/setup/database.properties:
title: Checking database.properties DB_VENDOR
exit-status: 0
grep 'server.name={{getEnv "DB_HOST"}}' /opt/bonita/Bonita*/setup/database.properties:
title: Checking database.properties DB_HOST
exit-status: 0
grep 'server.port={{getEnv "DB_PORT"}}' /opt/bonita/Bonita*/setup/database.properties:
title: Checking database.properties DB_PORT
exit-status: 0
find /opt/bonita/Bonita*/setup/platform_conf/initial -name *.properties | xargs -n10 grep '^userName={{getEnv "TENANT_LOGIN"}}' | [ $(wc -l) -gt 0 ]:
title: Checking custom TENANT_LOGIN
exit-status: 0
find /opt/bonita/Bonita*/setup/platform_conf/initial -name *.properties | xargs -n10 grep '^userPassword={{getEnv "TENANT_PASSWORD"}}' | [ $(wc -l) -gt 0 ]:
title: Checking custom TENANT_PASSWORD
exit-status: 0
find /opt/bonita/Bonita*/setup/platform_conf/initial -name *.properties | xargs -n10 grep '^platformAdminUsername={{getEnv "PLATFORM_LOGIN"}}' | [ $(wc -l) -gt 0 ]:
title: Checking custom PLATFORM_LOGIN
exit-status: 0
find /opt/bonita/Bonita*/setup/platform_conf/initial -name *.properties | xargs -n10 grep '^platformAdminPassword={{getEnv "PLATFORM_PASSWORD"}}' | [ $(wc -l) -gt 0 ]:
title: Checking custom PLATFORM_PASSWORD
exit-status: 0
file:
/goss/docker_output.log:
title: Checking that custom-init.d script is executed
# required attributes
exists: true
contains:
- 'GOSS: custom-init.d script /opt/custom-init.d/init-hello.sh!'
command:
cat /goss/docker_output.log | tr -d '\n' | grep -c "init-1.sh.*init-2.sh.*init-13.sh.*init-hello.sh.*_init-0.sh":
title: Checking that custom-init.d scripts are executed in order
exit-status: 0
stdout: ["1"]
http:
http://localhost:8080/bonita:
title: Checking http://localhost:8080/bonita HTTP status
# required attributes
status: 200
# optional attributes
allow-insecure: false
no-follow-redirects: false # Setting this to true will NOT follow redirects
timeout: 5000
gossfile:
goss_common.yaml: {}
command:
echo "community_env" && env | sort:
title: Checking community environment variables
exit-status: 0
stdout:
- BONITA_SHA256
- BONITA_URL
gossfile:
{{getEnv "GOSSFILE"}}: {}
file:
/goss/docker_output.log:
exists: true
contains:
- /org.apache.catalina.startup.Catalina.*Server startup in/
http:
http://localhost:8080:
status:
gt: 0
#!/usr/bin/env bash
set -euo pipefail
if [ "$#" -gt 0 ]
then
SCRIPT_NAME=$(basename "$0")
echo "Usage: $SCRIPT_NAME"
exit 1
fi
# configure trap to always stop and remove postgres container at the end
trap 'echo "Stopping postgres container"; docker stop bonita_db' INT TERM EXIT
# start postgres container
POSTGRES_VERSION=9.3
POSTGRES_PASSWORD=s3crEt
docker run --rm --name bonita_db -e POSTGRES_PASSWORD=${POSTGRES_PASSWORD} -d postgres:${POSTGRES_VERSION}
# wait for postgres
until docker run --rm --link bonita_db postgres:${POSTGRES_VERSION} pg_isready -h bonita_db -p 5432; do
>&2 echo "Postgres is unavailable - sleeping"
sleep 1
done
>&2 echo "Postgres is up!"
# start bonita container tests
: ${BONITA_VERSION:=$(grep -oP "^ENV BONITA_VERSION \K.*" "../Dockerfile" | sed 's/.*:-\(.*\)}$/\1/' | tail -1)}
DGOSS_CMD="dgoss run --rm --name bonita_${BONITA_VERSION} --link bonita_db \
-e DB_VENDOR=postgres -e DB_HOST=bonita_db -e DB_PORT=5432 -e DB_ADMIN_PASS=${POSTGRES_PASSWORD} \
-e TENANT_LOGIN=tenant_admin -e TENANT_PASSWORD=tenant_pass \
-e PLATFORM_LOGIN=platform_admin -e PLATFORM_PASSWORD=platform_pass \
-v $(pwd)/custom-init.d:/opt/custom-init.d"
export GOSS_WAIT_OPTS="-r 60s -s 2s > /dev/null"
export GOSSFILE=goss_community.yaml
goss -g goss_main.yaml render > goss.yaml && ${DGOSS_CMD} \
bonitasoft/bonita:${BONITA_VERSION}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment