The following repository contains the application template and the InSpec profile for testing the OpenShift template.
The template may vary significantly depending on the application, so the best method for testing the template is to check whether it contains elements that are required or desired. For this purpose, the InSpec tool is used that allows testing of such application template.
The app
directory contains the file template.yaml
which can be treated as an output template for the application. In case you want to test your template, it must be located under the path app/template.yaml
.
The InSpec tool is also required for testing .
We run the tests by issuing the command inspec exec profile
~# inspec exec profile
Profile: InSpec Profile (openshift_template)
Version: 0.1.0
Target: local://
✔ health_check: Verify health checks
✔ livenessprobe check should cmp == true
✔ readinessprobe check should cmp == true
✔ resources: Verify whether container has had set resources
✔ {"requests"=>{"memory"=>"0.5G", "cpu"=>"0.2"}, "limits"=>{"memory"=>"0.5G"}} ["requests", "cpu"] should cmp >= 0.1
[...]
Profile Summary: 6 successful controls, 0 control failures, 0 controls skipped
Test Summary: 30 successful, 0 failures, 0 skipped
Inspection name | Description |
---|---|
basic |
tests whether the given file is actually a template for openshift |
health_check |
tests whether the application container contains livenessProbe and readinessProbe |
parameters |
tests whether the template contains the required parameters |
resources |
tests whether the container has the resources set that are required by the applications |
route |
tests whether the route resource contains errors |
service |
tests whether the service resource contains errors |
deploymentconfig |
tests whether the DeploymentConfig resource contains errors |
A detailed description of the InSpec profile can be found here.
Here you can find good practices, tips and tricks related to define Openshift project and run application in container.