1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-05 21:46:22 +01:00
Files
openshift-docs/modules/osdk-cli-reference-test.adoc
2019-05-13 13:57:48 +10:00

112 lines
2.6 KiB
Plaintext

[id="osdk-cli-reference-test_{context}"]
= test
The `operator-sdk test` command has subcommands that can test the Operator
locally or from within a cluster.
== local
The `local` subcommand runs Go tests built using the Operator SDK's test
framework locally.
.`test local` arguments
[options="header",cols="1,3"]
|===
|Arguments |Description
|`<test_location>` (string)
|Location of e2e test files (e.g., `./test/e2e/`).
|===
.`test local` flags
[options="header",cols="1,3"]
|===
|Flags |Description
|`--kubeconfig` (string)
|Location of `kubeconfig` for a cluster. Default: `~/.kube/config`.
|`--global-manifest` (string)
|Path to manifest for global resources. Default: `deploy/crd.yaml`.
|`--namespaced-manifest` (string)
|Path to manifest for per-test, namespaced resources. Default: combines
`deploy/service_account.yaml`, `deploy/rbac.yaml`, and `deploy/operator.yaml`.
|`--namespace` (string)
|If non-empty, a single namespace to run tests in (e.g., `operator-test`).
Default: `""`
|`--go-test-flags` (string)
|Extra arguments to pass to `go test` (e.g., `-f "-v -parallel=2"`).
|`--up-local`
|Enable running the Operator locally with `go run` instead of as an image in the
cluster.
|`--no-setup`
|Disable test resource creation.
|`--image` (string)
|Use a different Operator image from the one specified in the namespaced
manifest.
|`-h, --help`
|Usage help output.
|===
.Example output
----
$ operator-sdk test local ./test/e2e/
# Output:
ok github.com/operator-framework/operator-sdk-samples/memcached-operator/test/e2e 20.410s
----
== cluster
The `cluster` subcommand runs Go tests embedded in an Operator image built using
the Operator SDK as a Pod in the cluster.
.`test cluster` arguments
[options="header",cols="1,3"]
|===
|Arguments |Description
|`<image_name>` (string)
|The Operator image that is used to run the tests in a Pod (e.g.,
`quay.io/example/memcached-operator:v0.0.1`).
|===
.`test cluster` flags
[options="header",cols="1,3"]
|===
|Flags |Description
|`--kubeconfig` (string)
|Location of `kubeconfig` for a cluster. Default: `~/.kube/config`.
|`--image-pull-policy` (string)
|Set test Pod image pull policy. Allowed values: `Always` (default), `Never`.
|`--namespace` (string)
|Namespace to run tests in. Default: `default`.
|`--pending-timeout` (int)
|Timeout in seconds for testing Pod to stay in pending state. Default: `60s`.
|`--service-account` (string)
|Service account to run tests on. Default: `default`.
|`--help`
|Usage help output.
|===
.Example output
----
$ operator-sdk test cluster quay.io/example/memcached-operator:v0.0.1
# Output:
Test Successfully Completed
----