So.. What is Goss?
Note: Unless you’re familiar with Goss v0.2.0, I recommend you read this section.
Goss is a YAML based serverspec alternative tool for validating a server’s configuration. It eases the process of writing tests by allowing the user to generate tests from the current system state. Once the test suite is written they can be executed, waited-on, or served as a health endpoint.
More info can be found on the Goss webpage.
Example goss.yaml test file:
The above goss.yaml file can also be generated by using the following commands on a configured system:
goss add dns mysql# "a" is short for "add"
goss a addr mysql:3306
goss a command '/goss/checks/db_login.sh'
Once we have a test suite, we can:
- run it once
goss validate- keep running it until the system enters a valid state or we timeout
goss validate --retry-timeout 30s --sleep 1s- serve the tests as a health endpoint
goss serve &
curl localhost:8080/healthz# JSON endpoint
goss serve --format json &
curl localhost:8080/healthz