Testing images

Testing images

goss is a tool for validating server configuration

Easy alternative to serverspec

Test expressed in YAML

Native support for containers

Supports multiple output formats (including rspecish, json, junit)

Integration with Ansible, packer and kitchen

Demo: Testing images

Add goss and test definition to existing image:

docker build --tag nginx-goss test/

Run container:

docker run -d --name nginx-goss nginx-goss

Validate container:

docker exec -it nginx-goss /goss validate

Do not change behaviour specially entrypoint, commands and parameters

Demo: Using dgoss

dgoss is a wrapper for docker

It runs a container, mounts goss and executes tests

Run dgoss using ./goss.yaml:

dgoss run nginx

Demo: Creating tests

Easily create tests using dgoss

Edit tests created in container (run goss autoadd nginx):

dgoss edit nginx

Run tests against container:

dgoss run nginx

Check the manual for syntax and available tests

Demo: Health endpoint

goss can provide test results and health endpoint

Build image with health endpoint:

docker build --tag nginx-healthz healthz

Run container:

docker run -d --name nginx-healthz nginx-healthz

Check health endpoint:

docker inspect \
    --format '' \
    nginx-healthz \
    | xargs -I '{}' curl http://{}:8080/healthz