client/vendor/knative.dev/pkg/test
knative-automation 982711e2e3
[main] Upgrade to latest dependencies (#1763)
* 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>
2023-01-19 16:42:02 +00:00
..
environment upgrade to latest dependencies (#1340) 2021-06-24 05:22:45 -07:00
helpers upgrade to latest dependencies (#1434) 2021-08-30 05:07:28 -07:00
ingress upgrade to latest dependencies (#1758) 2022-11-07 14:53:22 +00:00
logging upgrade to latest dependencies (#1565) 2022-01-14 05:06:44 -08:00
logstream [main] Upgrade to latest dependencies (#1763) 2023-01-19 16:42:02 +00:00
monitoring upgrade to latest dependencies (#1553) 2021-12-22 07:18:18 -08:00
spoof [main] Upgrade to latest dependencies (#1731) 2022-09-19 09:32:09 +00:00
zipkin upgrade to latest dependencies (#1758) 2022-11-07 14:53:22 +00:00
README.md upgrade to latest dependencies (#1330) 2021-06-01 09:53:37 -07:00
cleanup.go Update k8s dependencies to v0.20.7 (#1344) 2021-06-17 07:42:22 -07:00
clients.go upgrade to latest dependencies (#1397) 2021-07-27 10:21:51 -07:00
crd.go [Release-0.18] Pin knative deps to release-0.18 (#1025) 2020-09-23 11:58:41 -07:00
e2e_flags.go upgrade to latest dependencies (#1387) 2021-07-19 16:15:12 -07:00
kube_checks.go upgrade to latest dependencies (#1730) 2022-09-06 11:44:42 +00:00
presubmit-tests.sh upgrade to latest dependencies (#1708) 2022-07-26 08:50:24 +00:00
request.go upgrade to latest dependencies (#1519) 2021-11-16 10:24:52 -08:00
test-reconciler-codegen.sh Pin deps back to master (#1082) 2020-10-30 08:15:35 -07:00
tinterface.go upgrade to latest dependencies (#1324) 2021-05-26 08:07:28 -07:00

README.md

Test

This directory contains tests and testing docs.

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:

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.