docker-atlassian-confluence.../DEVELOPMENT.md
Nasser Ghazali-Beiklar 2a28ea5182 Merged in DCKUBE-136-RunSmoketestsInReleasePipeline (pull request #83)
DCKUBE-135, DCKUBE-136, DCKUBE_137, and DCKUBE-138: Add Smoke tests in Confluence Pipeline
This PR contains code change for three tickets which are related and should merge to master together.

KUBEDCKUBE-135:
Applied security scan to bitbucket pipeline for branch builds in confluence - for releases, the test script will run by run.py for releases and for branch builds and custom releases will directly runs snyk scanner
Created a smoke testing suite via REST and included these scenarios: Create a space, Create a page, Search for the page, View page, Add attachments, Delete the page, and Delete the space

KUBEDCKUBE-136:
Added a separated docker for confluence to based on the docker image to copy confluence home directory
Injected target confluence image to Dockerfile
set the number of concurrent builds to one in pipeline
clean docker-compose before start and force to recreate the containers
Modified the script in order to install netcat-openbsd using apkfor Alpine (apt-getis not available in Alpine)
Replaced colfuence-home directory and postgres scripts with confluence 6.0.1 compatible to avoid downgrade version in release images
Increased database connection numbers to 125
Addressed some review points, replaced the confluence home directory and sql with version 6.0.1
Addressed a review points, renamed CONFLUENCE_USER to CONFLUENCE_ADMIN
divided pipeline into batches to avoid pipeline timeout

KUBEDCKUBE-137:
Run smoketests in branch builds after each commit
Completed smoketests and also addressed some review points

KUBEDCKUBE-138:
Added development document

Approved-by: Adam Brokes
2021-03-12 03:30:51 +00:00

3.5 KiB

Developing Docker images

Setting up for development

After cloning the repository you will need to clone the submodule:

git submodule update --init --recursive

You should also add the local githooks, which include checks for the generated Bitbucket Pipelines configuration. This can be done with:

git config core.hooksPath .githooks

Testing

The repository contains a smoke-test suite run on branch/PR builds and as part of the release process. It uses docker-compose to run the image in production mode with predefined database, and then run a suite of basic tests. NOTE: The tests are not intended to test every aspect of the product, but to ensure basic functionality works to a degree that we can be confident that there are no regressions. See func-tests/smoketests/tests/ for the actual tests run.

The default database was generated with the default sample project, but has had the license elided for security reasons. See below for how to inject it.

Pre-requisites

To run the functional testing, you are required to define several variables.

# String with full Confluence DC license, don't forget the quotes as the license 
can contain special characters that would render the license unusable
CONFLUENCE_TEST_LICENSE='license_string' 

# The user and passwords used to access the product. These are stored in lastpass.
CONFLUENCE_ADMIN='xxx'
CONFLUENCE_ADMIN_PWD='xxx'

Run the smoke test functional suite

This will build a local image based on the latest Confluence version and run the func-tests against it:

export CONFLUENCE_VERSION=`curl -s https://marketplace.atlassian.com/rest/2/products/key/confluence/versions/latest | jq -r .name`
docker build --build-arg CONFLUENCE_VERSION=${CONFLUENCE_VERSION} -t confluence-test-image .
docker-compose build --build-arg TEST_TARGET_IMAGE=confluence-test-image ./func-tests/docker-compose.yaml
./func-tests/run-functests confluence-test-image

Develop tests

Make sure CONFLUENCE_TEST_LICENSE, CONFLUENCE_ADMIN, and CONFLUENCE_ADMIN_PWD environment variables already are set. Extract confluence home directory and inject the license:

cd func-tests
unzip -o confluence-home-6.0.1.zip -d confluence
TEST_TARGET_IMAGE='xxx' ./confluence/inject-license

Run the smoke tests

cd func-tests
TEST_TARGET_IMAGE='xxx' docker-compose up --force-recreate --always-recreate-deps --abort-on-container-exit --exit-code-from smoketests

Release process

Releases occur automatically; see bitbucket-pipelines.yml. Due to the large amount of images that are built and tested the pipelines file is generated from a template that parallelises the builds. It includes a self-check for out-of-date pipelines config. To avoid committing stale config it is recommended you add the supplied pre-commit hook; see the setup section above.

It should be noted that a change to this repository will result in all published images being regenerated with the latest version of the Dockerfile. As part of the release process the following happens:

  • A Snyk scan is run against the generated container image.
  • The image dependencies are registered with Snyk for periodic scanning.
  • The above func-test suite is run against the image.

This is all performed by the docker-release-maker tool/image. See the README in that repository for more information.