Smoke Test

As part of the jenkins CI pipeline the capability to do smoke tests where added. This includes dedicated inbound and endpoint filters, unit tests and a configured jenkins stage to run these tests. The smoke tests run against a docker container of the appsuite-proxy which is started during the CI pipeline.

Configuration

The smoke test entrypoint is described in the build.gradle file. Here you will find a seperate task to support the tests. This task will run during the jenkins stage.

task smokeTest( type: Test) {

    reports {
      html.enabled = true
      junitXml.enabled = true
    }

    testLogging {
        showStandardStreams = true
    }

    exclude 'io/ox/proxy/**'
    include 'io/ox/smoke/test/**'
}

Use the keywords include and exclude to handle future tests and to run them separately from each other.

Run locally

If not done yet, build a fresh container image:

./gradlew clean buildImage

Run the image and mount the smoke test filters accordingly. The following command assumes appsuite-proxy:0.1.0-62964cb as the current image tag, you must adjust it accordingly:

docker run -dit --rm -p 8080:8080 \
  -v "$(pwd)/src/test/groovy/io/ox/proxy/filters/inbound/SmokeTestInboundFilter.groovy":/appsuite-proxy/filters/inbound/SmokeTestInboundFilter.groovy \
  -v "$(pwd)/src/test/groovy/io/ox/proxy/filters/endpoint/SmokeTestEndpointFilter.groovy":/appsuite-proxy/filters/endpoint/SmokeTestEndpointFilter.groovy \
  --name appsuite-proxy appsuite-proxy:0.1.0-62964cb

And finally run the smoke tests:

./gradlew smokeTest

Remove the container again with:

docker kill appsuite-proxy

Testing TLS encryption

Currently the existing smoke tests are using an image that is configurated to handle TLS based requests. Therefore the docker image creates all properties and certificates automatically on container startup. To enable tls “TLS_ENABLED=true” is used as an environment variable during container startup.

If you want to use it locally just enhance the docker commands above with the following docker parameters:

-p 8443:8443 -e SMOKE_TESTS_ENABLED=true -e TLS_ENABLED=true

Jenkins Pipeline

The Jenkins pipeline has a dedicated smoke test stage, where it launches the previously built image as an own Jenkins slave running as a Kubernets Pod. For that it makes uses of a nested scripted pipeline, to pass along the current image tag.

Container log

The jenkins job writes the container logs of the docker image before and after testing. They are collected as artifacts of the build job.

Automatic config generation

As mentioned above the configuration of the smoke tests can be generated on container startup. We use the confd framework to do so. Under config/confd you will find templates for the config files. If you want to enhance them or generate other config files use this directory for more templates. Building the config files is triggered by the docker-entrypoint.sh script.

If you want to add new tests depending on new variables to the jenkins pipeline you have to add these variables to the jenkinsfile under the “Smoke Test” stage:

  - name: appsuite-proxy
  image: gitlab.open-xchange.com:4567/middleware/appsuite-proxy:@VERSION@
  env:    
  - name: SMOKE_TESTS_ENABLED
    value: true
  - name: TLS_ENABLED
    value: true
  - name: ADMIN_PORT_ENABLED
    value: true

Debug logging

If you want to change your global log level in a docker container setup there is the possibility to set it on container startup. Use the environment variable GLOBAL_LOG_LEVEL=DEBUG to enable debug logging.