Tests
dib can execute tests suites to make assertions on images that it just built. This is useful to prevent regressions, and ensure everything work as expected at runtime.
Goss
Goss is a YAML-based serverspec alternative tool for validating a server’s configuration. dib runs a container from the image to test, and injects the goss binary and configuration, then execute the test itself.
To get started with goss tests, follow the steps below:
-
Install goss locally (for local builds only)
Follow the procedure from the official docs
-
Ensure the goss tests are enabled in configuration:
# .dib.yaml include_tests: - goss
-
Create a
goss.yaml
file next to the Dockerfile of the image to testdebian/ ├── Dockerfile └── goss.yaml
-
Add some assertions in the
goss.yaml
Basic Example:command: 'check "hello-world" version': exec: 'hello-world --version' exit-status: 0 stdout: - '/^hello-world version [0-9]+\.[0-9]+\.[0-9]+ linux\/amd64$/'
Read the Goss documentation to learn all possible assertions.