Skip to main content

JUnit

Standard Edition Required

JUnit check performs a Unit test, parses the JUnit test reports in a container at a specified path as defined in testResults.

apiVersion: canaries.flanksource.com/v1
kind: Canary
metadata:
name: junit-check
annotations:
trace: "true"
spec:
interval: 120
owner: DBAdmin
severity: high
spec:
junit:
- testResults: "/tmp/junit-results/"
display:
template: |
✅ {{.results.passed}} ❌ {{.results.failed}} in 🕑 {{.results.duration}}
{{ range $r := .results.suites}}
{{- if gt (conv.ToInt $r.failed) 0 }}
{{$r.name}} ✅ {{$r.passed}} ❌ {{$r.failed}} in 🕑 {{$r.duration}}
{{- end }}
{{- end }}
spec:
containers:
- name: jes
image: docker.io/tarun18/junit-test-pass
command: ["/start.sh"]
FieldDescriptionSchemeRequired
specPod specificationv1.PodSpecYes
testResultsDirectory where the results will be publishedstringYes
timeoutTimeout in minutes to wait for specified container to finish its job. Defaults to 5 minutesint
nameName of the check, must be unique within the canarystringYes
artifactsSpecify what files/folders generated by the script needs to be archived[]Artifact
descriptionDescription for the checkstring
iconIcon for overwriting default icon on the dashboardstring
labelsLabels for checkmap[string]string
testEvaluate whether a check is healthyExpression
displayExpression to change the formatting of the displayExpression
transformTransform data from a check into multiple individual checksExpression
metricsMetrics to export from[]Metrics

Test Result Variables

NameDescriptionScheme
suites[]JunitSuite
passedNumber of passing testsint
failedNumber of failed testsint
skippedNUmber of tests that were skippedint
errorNumber of errors produced when running the testsint
durationTotal time in secondsfloat64

Junit Suite

NameDescriptionScheme
namestring
tests[]JunitTest
passedNumber of passing testsint
failedNumber of failed testsint
skippedNUmber of tests that were skippedint
errorNumber of errors produced when running the testsint
durationTotal time in secondsfloat64

Junit Test

NameDescriptionScheme
namestring
classnamean additional descriptor for the hierarchy of the test.string
durationTime in secondsfloat64
statusOne of passed, skipped, failed or errorstring
messageDescription optionally included with a skipped,string
propertiesAdditional info about the testmap[string]string
errorAny errors encountered when running ateststring
stdoutStandard output produced during teststring
stderrStandard error output produced during teststring

Artifact

FieldDescriptionTypeRequired
pathPath or glob.stringtrue

See artifacts