* upgrade to latest dependencies bumping knative.dev/networking c037e29...e9d3a55: > e9d3a55 adjust domain validation in kcert (# 755) > dd05ffd upgrade to latest dependencies (# 753) > 3ad2fdc Update actions (# 752) > fe0ac7d Update community files (# 751) > 68f0fa7 add new field 'Domain' to kcert spec (# 747) > a51817e upgrade to latest dependencies (# 750) > bc7a7e5 Update community files (# 749) > eee5118 upgrade to latest dependencies (# 748) > f1db313 upgrade to latest dependencies (# 746) > 383bb2f Update community files (# 745) > 891aac2 upgrade to latest dependencies (# 740) > 5be75f2 upgrade to latest dependencies (# 739) bumping knative.dev/serving cd1cd1a...6b7e09a: > 6b7e09a upgrade to latest dependencies (# 13616) > 2338826 Don't default Revision values when BYO name is unchanged. (# 13565) > f2147ef Stream logs from system and test namespace in upgrade tests (# 13587) > b989439 Ensure the autoscaler only has a single elector (# 13585) > 873eb5c Advance pvc e2e test to beta (# 13535) > 5cb43ab Update net-gateway-api nightly (# 13615) > 8064f6b Update net-gateway-api nightly (# 13614) > 52e79f7 show an error when curling the istio release (# 13612) > a5d0384 Update net-contour nightly (# 13613) > 2c117e8 Update net-gateway-api nightly (# 13607) > 06f59e3 Update net-kourier nightly (# 13608) > aa744ae Update net-certmanager nightly (# 13606) > cd2ad0c Update actions (# 13604) > 162b8fb consistent label selector for Service - include app label (# 13265) > 76005a0 upgrade to latest dependencies (# 13594) > ff959e4 Update net-kourier nightly (# 13599) > fc1cf65 Update net-contour nightly (# 13597) > 3db1864 Update net-istio nightly (# 13596) > bab961f Update net-certmanager nightly (# 13595) > e6db06e Update net-gateway-api nightly (# 13598) > 10a8e38 Update community files (# 13593) > b421efb Update net-kourier nightly (# 13590) > 288e59a Update net-contour nightly (# 13578) > 6d70f59 Update net-gateway-api nightly (# 13577) > b9d0952 Update net-certmanager nightly (# 13588) > 7b5c641 upgrade to latest dependencies (# 13573) > 4ad830a add fetch depth so we can fetch the tags (# 13586) > fb0c4bd Add setup script for internal-encryption e2e test (# 13559) > 11d88db Update community files (# 13584) > aaa992e upgrade to latest dependencies (# 13564) > 3b8f17c Update net-kourier nightly (# 13561) > 35abde0 Update net-istio nightly (# 13556) > 88ccb50 Update net-certmanager nightly (# 13557) > 3812acf Update net-contour nightly (# 13555) > cd50d85 Update net-gateway-api nightly (# 13554) > 01676d5 Update net-kourier nightly (# 13547) > f1b45e6 Update net-istio nightly (# 13549) > f0379ef Update net-certmanager nightly (# 13548) > 114bebe Update net-contour nightly (# 13550) > 38fa7c0 Update community files (# 13545) > 017bb66 Update net-istio nightly (# 13538) > a4f6edc Update net-contour nightly (# 13534) > 442877d Update net-certmanager nightly (# 13533) > b4198e7 Update net-kourier nightly (# 13532) > ceb505d Update net-gateway-api nightly (# 13530) > 99c3d5a Update net-gateway-api nightly (# 13527) > 95a6492 upgrade to latest dependencies (# 13526) > 7f217bb Use ubuntu 20.04 for kind e2e tests (# 13528) > 327bf91 Update net-istio nightly (# 13524) > 1beadbd Update net-gateway-api nightly (# 13523) > 0ea12f4 Update net-contour nightly (# 13520) > bcef4be Update net-contour nightly (# 13514) > b7492cc Update net-certmanager nightly (# 13509) > 5b217ef Update net-istio nightly (# 13510) > 2ba4499 Don't set seccomp profile in the queue proxy (# 13507) > e17e4d1 Update net-contour nightly (# 13502) > 05a28e0 Ensure probes from the autoscaler are not passed to the user-container (# 13501) bumping knative.dev/hack c12c1bf...c7cfcb0: > c7cfcb0 Update community files (# 263) > af8745e Update community files (# 262) > cf3796d Upload attestations and print cosign version (# 261) > b9801b4 Update community files (# 260) > 7233e77 No more sugar controller in upstream eventing (# 259) Signed-off-by: Knative Automation <automation@knative.team> * Fix broker test Signed-off-by: Knative Automation <automation@knative.team> Co-authored-by: David Simansky <dsimansk@redhat.com> |
||
|---|---|---|
| .. | ||
| environment | ||
| helpers | ||
| ingress | ||
| logging | ||
| logstream | ||
| monitoring | ||
| spoof | ||
| zipkin | ||
| README.md | ||
| cleanup.go | ||
| clients.go | ||
| crd.go | ||
| e2e_flags.go | ||
| kube_checks.go | ||
| presubmit-tests.sh | ||
| request.go | ||
| test-reconciler-codegen.sh | ||
| tinterface.go | ||
README.md
Test
This directory contains tests and testing docs.
- Test library contains code you can use in your
knativetests - Flags added by the test library
- Unit tests currently reside in the codebase alongside the code they test
Running unit tests
To run all unit tests:
go test ./...
Test library
You can use the test library in this dir to:
Use common test flags
These flags are useful for running against an existing cluster, making use of your existing environment setup.
By importing knative.dev/pkg/test you get access to a global variable called
test.Flags which holds the values of
the command line flags.
logger.Infof("Using namespace %s", test.Flags.Namespace)
See e2e_flags.go.
Output logs
When tests are run with --logverbose option,
debug logs will be emitted to stdout.
We are using a generic
FormatLogger
that can be passed in any existing logger that satisfies it. Test can use the
generic logging methods to log info and
error logs. All the common methods accept generic FormatLogger as a parameter
and tests can pass in t.Logf like this:
_, err = pkgTest.WaitForEndpointState(
kubeClient,
t.Logf,
...),
See logging.go.
Check Knative Serving resources
WARNING: this code also exists in
knative/serving.
After creating Knative Serving resources or making changes to them, you will need to wait for the system to realize those changes. You can use the Knative Serving CRD check and polling methods to check the resources are either in or reach the desired state.
The WaitFor* functions use the kubernetes
wait package. To poll
they use
PollImmediate
and the return values of the function you provide behave the same as
ConditionFunc:
a bool to indicate if the function should stop or continue polling, and an
error to indicate if there has been an error.
For example, you can poll a Configuration object to find the name of the
Revision that was created for it:
var revisionName string
err := test.WaitForConfigurationState(
clients.ServingClient, configName, func(c *v1alpha1.Configuration) (bool, error) {
if c.Status.LatestCreatedRevisionName != "" {
revisionName = c.Status.LatestCreatedRevisionName
return true, nil
}
return false, nil
}, "ConfigurationUpdatedWithRevision")
See kube_checks.go.
Ensure test cleanup
To ensure your test is cleaned up, you should defer cleanup to execute after your test completes and also ensure the cleanup occurs if the test is interrupted:
defer tearDown(clients)
test.CleanupOnInterrupt(func() { tearDown(clients) })
See cleanup.go.
Flags
Importing the test library adds flags that are useful for end to end tests that need to run against a cluster.
Tests importing knative.dev/pkg/test recognize these flags:
--kubeconfig--cluster--namespace--logverbose--ingressendpoint--dockerrepo--tag--imagetemplate
Specifying kubeconfig
By default the tests will use the
kubeconfig file
at ~/.kube/config. If there is an error getting the current user, it will use
kubeconfig instead as the default value. You can specify a different config
file with the argument --kubeconfig.
To run tests with a non-default kubeconfig file:
go test ./test --kubeconfig /my/path/kubeconfig
Specifying cluster
The --cluster argument lets you use a different cluster than
your specified kubeconfig's active context.
go test ./test --cluster your-cluster-name
The current cluster names can be obtained by running:
kubectl config get-clusters
Specifying ingress endpoint
The --ingressendpoint argument lets you specify a static url to use as the
ingress server during tests. This is useful for Kubernetes configurations which
do not provide external IPs.
go test ./test --ingressendpoint <k8s-controller-ip>:32380
Specifying namespace
The --namespace argument lets you specify the namespace to use for the tests.
By default, tests will use serving-tests.
go test ./test --namespace your-namespace-name
Output verbose logs
The --logverbose argument lets you see verbose test logs and k8s logs.
go test ./test --logverbose
Specifying docker repo
The --dockerrepo argument lets you specify a uri of the docker repo where you
have uploaded the test image to using uploadtestimage.sh. Defaults to
$KO_DOCKER_REPO
go test ./test --dockerrepo myspecialdockerrepo
Specifying tag
The --tag argument lets you specify the version tag for the test images.
go test ./test --tag v1.0
Specifying image template
The --imagetemplate argument lets you specify a template to generate the
reference to an image from the test. Defaults to
{{.Repository}}/{{.Name}}:{{.Tag}}
go test ./test --imagetemplate {{.Repository}}/{{.Name}}:{{.Tag}}
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License.