Smoke Tests =========== 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 separate task to support the tests. This task will run during the jenkins stage. .. code-block:: groovy 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 configured 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 on the underlying docker daemon on Jenkins. 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 gradle task ``createProxyContainer``. Local docker test setup ----------------------- As a precondition you need to build the images with ``./gradlew buildImage``. To create a small local test setup you can use ``./gradlew createDockerTestSetup``. Additionally use ``./gradlew copyReloadTestConfiguration copySmokeTestFilter`` to make smoke test filters and the reload config available in the proxy container. This setup contains the proxy docker container, two python backend containers and a corresponding docker network. The associated config can be found under the ``jenkins-pipeline`` folder and fits for the smoke tests in the BackendRoutingTest class. To remove the test setup you can use ``./gradlew removeDockerTestSetup. This should remove all docker components of the test setup. If that is not the case remove them manually. 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.