Assert¶
The assert
operation allows you to specify conditions that should hold true for a successful test. For example, after applying certain resources, you might want to ensure that a particular pod is running or a service is accessible.
Info
Assertions in Chainsaw are based on assertion trees.
Assertion trees is a solution to declaratively represent complex conditions like partial array comparisons or complex operations against an incoming data structure.
Assertion trees are compatible with standard assertions that exist in tools like KUTTL but can do a lot more. Please see the assertion trees documentation in kyverno-json for details.
Reference documentation
The full structure of the Assert
is documented here.
Usage in Test
¶
Below is an example of using assert
in a Test
resource.
Example
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: Test
metadata:
name: example
spec:
steps:
- try:
# ...
- assert:
file: ../resources/configmap-assert.yaml
# ...
Usage in TestStep
¶
Below is an example of using assert
in a TestStep
resource.
Example
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: TestStep
metadata:
name: example
spec:
try:
# ...
- assert:
file: ../resources/configmap-assert.yaml
# ...