By: Saikrishna Madupu – Sr Devops Engineer
In this blog, we will cover what is Goss, and how to leverage it for automated server validation testing.
What is Goss:
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. You can do server validation quickly and easily with Goss and integrate with pipelines to monitor the status of any services.
I’ll be using airflow for a target test case. First, we will install airflow locally and validate the status of airflow service status using Goss.
https://github.com/aelsabbahy/goss
Goss Installation:
- OPTION 1:
curl -L https://github.com/aelsabbahy/goss/releases/download/v0.3.7/goss-linux-amd64 -o /usr/local/bin/goss
curl -L https://raw.githubusercontent.com/aelsabbahy/goss/master/extras/dgoss/dgoss -o /usr/local/bin/dgoss
chmod +rx /usr/local/bin/dgoss
- OPTION 2:
https://ports.macports.org/port/goss/
Install Macports and run
sudo port install goss
## Add the following line to your ~/.profile or .zshrc
export GOSS_PATH=/usr/local/bin/goss
Use Case:
We will deploy Apache Airflow locally and validate the status of webserver using Goss. Airflow is an open-source project used to programmatically author, schedule, and monitor workflows. You can find more about airflow here – https://airflow.apache.org/
export AIRFLOW_HOME=~/airflow
pip3 install apache-airflow
pip3 install typing_extensions
# initialize the database
airflow initdb
# start the web server, default port is 8080
airflow webserver -p 8080
# start the scheduler. I recommend opening up a separate terminal \
# window for this step
airflow scheduler
# open localhost:8080 in the browser and enable the example dag via the home page
Validation:
Goss.yaml file validates HTTP response status code and content
export GOSS_USE_ALPHA=1
goss validate goss.yaml
- As the webserver is not up and running we see the error above
After starting the airflow webserver and making sure the application is up and running by validating it (via opening the page in a browser)
- goss validate goss.yaml would return the status report as shown below.
- Goss also supports several other test cases. Some of those are listed below:
- Addr
- Command
- Dns
- Ount
- Package
- Service
Ref: https://github.com/aelsabbahy/goss/blob/master/docs/manual.md#goss-test-creation
About the Author
Saikrishna Madupu, Sr. DevOps Engineer Sai is an IT professional with experience in DevOps Automation, Configuration Management tools, Container workloads and orchestration of those workloads via Kubernetes. A self-starter, and passionate problem-solver, with a flair for innovative design, with an ability to work towards automation whenever possible. He is an experienced Linux, Cloud data center operations and infrastructure engineer. He worked as a Devops cloud consultant in the past, helping clients in migrate on-prem applications to cloud, and holds certifications for AWS, Terraform, Gitlab, and other technologies. |