vela def test
Run CUE definition tests.
Synopsis
Run the *_test.cue files at PATH, a file or a directory searched recursively; PATH defaults to the current directory.
A test file imports "vela/test" and declares each case with one of its functions: #ComponentRender and #TraitRender check what a definition renders from given parameters and context; #ComponentStatus and #TraitStatus check its health, message and details given the state the cluster reports for the rendered objects; #PolicyRender and #ApplicationPolicyRender render a policy; #AddonRender renders an addon as enabling it would; #WorkflowStepExec runs a workflow step and #SourceExec resolves a source. A case's definition is the path of its .cue file, relative to the test file, with ".cue" optional.
A case passes when its expectation subsumes the result. Label cases with @label(...) and select them with the Ginkgo-compatible --label-filter, --focus, --skip and --focus-file. A case marked @pending(reason) is not run, and is counted as pending; --check-pending runs it too, and fails it if it passes, since its marker is then stale.
Definitions are tested as written; --upgrade first applies every rewrite of KubeVela's CUE upgrader, to see whether it would rescue one. A case marked @upgrade(reason=...) is a known dependency on the upgrader: if it fails as written it is retried upgraded and counted as upgraded, and if it passes as written it fails until the marker is removed.
Render, status, policy and addon cases contact no cluster. Step and source cases run against a local API server with no controllers, started on first use and stopped on exit: its etcd and kube-apiserver binaries come from --envtest-assets or KUBEBUILDER_ASSETS, and its CRDs from --crds or, by default, the vela-core chart found above the test files.
vela def test [PATH] [flags]
Examples
# Run every definition test under ./definitions
> vela def test ./definitions
# List passing cases too
> vela def test ./definitions -v
# Machine-readable results
> vela def test ./definitions --json
# Status tests that are not labelled slow, or one case by line
> vela def test --label-filter 'status && !slow'
> vela def test --focus-file webservice_test.cue:12
# Step and source cases, with envtest's binaries installed by setup-envtest
> vela def test ./workflowsteps --envtest-assets "$(setup-envtest use -p path)"
Options
--check-pending run @pending cases too, and fail any that now pass, since their marker is stale
--crds stringArray CRD file or directory to install for step and source cases (default: the vela-core chart's, when found); repeatable
--envtest-assets string directory holding etcd and kube-apiserver for step and source cases (default: KUBEBUILDER_ASSETS)
--fail-on-pending fail if any selected case is @pending
--fail-on-upgrade fail @upgrade cases that fail as written, instead of retrying them upgraded
--focus stringArray run only cases whose full text ('<file> <definition> / <case>') matches this regexp; repeatable
--focus-file stringArray run only cases in files matching this regexp, optionally with lines: file:12, file:3,9 or file:1-20; repeatable
-h, --help help for test
--json print results as JSON
--label-filter string run only cases whose labels match this Ginkgo label query, e.g. 'status && !slow'
--skip stringArray skip cases whose full text matches this regexp; repeatable
--upgrade run definitions through KubeVela's CUE upgrader, with every rewrite pass on, instead of testing them as written
-v, --verbose list passing cases as well as failures
Options inherited from parent commands
-V, --verbosity Level number for the log level verbosity
-y, --yes Assume yes for all user prompts
SEE ALSO
- vela def - Manage definitions.