diff --git a/test/README.md b/test/README.md index 31fb4946b862..5c4219bc6830 100644 --- a/test/README.md +++ b/test/README.md @@ -45,7 +45,7 @@ To run [the e2e tests](./e2e) and [the conformance tests](./conformance), you ne ```bash go test -v -tags=e2e -count=1 ./test/conformance -go test -v -tags=e2e -count=1 ./test/e2e +go test -v -tags=e2e -count=1 -parallel=4 ./test/e2e ``` ### One test case @@ -77,13 +77,14 @@ These tests require: enabled is recommended (`-v`). * Using [`--logverbose`](#output-verbose-log) to see the verbose log output from test as well as from k8s libraries. * Using `-count=1` is [the idiomatic way to disable test caching](https://golang.org/doc/go1.10#test) +* Using `-parallel=4` to run upto 4 [parallel test functions](https://golang.org/pkg/testing/#T.Parallel) from the test package in [parallel](https://golang.org/cmd/go/#hdr-Testing_flags) You can [use test flags](#flags) to control the environment your tests run against, i.e. override [your environment variables](/DEVELOPMENT.md#environment-setup): ```bash go test -v -tags=e2e -count=1 ./test/conformance --kubeconfig ~/special/kubeconfig --cluster myspecialcluster --dockerrepo myspecialdockerrepo -go test -v -tags=e2e -count=1 ./test/e2e --kubeconfig ~/special/kubeconfig --cluster myspecialcluster --dockerrepo myspecialdockerrepo +go test -v -tags=e2e -count=1 -parallel=4 ./test/e2e --kubeconfig ~/special/kubeconfig --cluster myspecialcluster --dockerrepo myspecialdockerrepo ``` If you are running against an environment with no loadbalancer for the ingress, at the moment @@ -92,7 +93,7 @@ your only option is to use a domain which will resolve to the IP of the running ```bash go test -v -tags=e2e -count=1 ./test/conformance --resolvabledomain -go test -v -tags=e2e -count=1 ./test/e2e --resolvabledomain +go test -v -tags=e2e -count=1 -parallel=4 ./test/e2e --resolvabledomain ``` ## Test images @@ -149,7 +150,7 @@ To run the tests with a non-default kubeconfig file: ```bash go test -v -tags=e2e -count=1 ./test/conformance --kubeconfig /my/path/kubeconfig -go test -v -tags=e2e -count=1 ./test/e2e --kubeconfig /my/path/kubeconfig +go test -v -tags=e2e -count=1 -parallel=4 ./test/e2e --kubeconfig /my/path/kubeconfig ``` ### Specifying cluster @@ -161,7 +162,7 @@ if not specified. ```bash go test -v -tags=e2e -count=1 ./test/conformance --cluster your-cluster-name -go test -v -tags=e2e -count=1 ./test/e2e --cluster your-cluster-name +go test -v -tags=e2e -count=1 -parallel=4 ./test/e2e --cluster your-cluster-name ``` The current cluster names can be obtained by running: @@ -177,7 +178,7 @@ tests. By default, tests will use `serving-tests`. ```bash go test -v -tags=e2e -count=1 ./test/conformance --namespace your-namespace-name -go test -v -tags=e2e -count=1 ./test/e2e --namespace your-namespace-name +go test -v -tags=e2e -parallel=4 -count=1 ./test/e2e --namespace your-namespace-name ``` ### Overridding docker repo @@ -189,7 +190,7 @@ if not specified. ```bash go test -v -tags=e2e -count=1 ./test/conformance --dockerrepo gcr.myhappyproject -go test -v -tags=e2e -count=1 ./test/e2e --dockerrepo gcr.myhappyproject +go test -v -tags=e2e -count=1 -parallel=4 ./test/e2e --dockerrepo gcr.myhappyproject ``` ### Using a resolvable domain @@ -212,7 +213,7 @@ If you have configured your cluster to use a resolvable domain, you can use the The `--logverbose` argument lets you see verbose test logs and k8s logs. ```bash -go test -v -tags=e2e -count=1 ./test/e2e --logverbose +go test -v -tags=e2e -count=1 -parallel=4 ./test/e2e --logverbose ``` ### Emit metrics diff --git a/test/e2e/autoscale_test.go b/test/e2e/autoscale_test.go index e87388ff31e5..d44727d8bdb5 100644 --- a/test/e2e/autoscale_test.go +++ b/test/e2e/autoscale_test.go @@ -86,7 +86,7 @@ func setScaleToZeroThreshold(clients *test.Clients, threshold string) error { } func setup(t *testing.T, logger *zap.SugaredLogger) *test.Clients { - clients := Setup(t) + clients := Setup(t, false) configMap, err := getAutoscalerConfigMap(clients) if err != nil { diff --git a/test/e2e/build_test.go b/test/e2e/build_test.go index fdaf4fb8ae26..f5b44f2d5dfb 100644 --- a/test/e2e/build_test.go +++ b/test/e2e/build_test.go @@ -30,7 +30,7 @@ import ( ) func TestBuildAndServe(t *testing.T) { - clients := Setup(t) + clients := Setup(t, true) // Add test case specific name to its own logger. logger := test.GetContextLogger("TestBuildAndServe") @@ -101,7 +101,7 @@ func TestBuildAndServe(t *testing.T) { } func TestBuildFailure(t *testing.T) { - clients := Setup(t) + clients := Setup(t, true) // Add test case specific name to its own logger. logger := test.GetContextLogger("TestBuildFailure") diff --git a/test/e2e/e2e.go b/test/e2e/e2e.go index 963f08d51561..cc647f4315b1 100644 --- a/test/e2e/e2e.go +++ b/test/e2e/e2e.go @@ -20,12 +20,17 @@ const ( defaultNamespaceName = "serving-tests" ) -// Setup creates the client objects needed in the e2e tests. -func Setup(t *testing.T) *test.Clients { +// Setup creates the client objects needed in the e2e tests. If parallel is true, +// the test will be marked so as to run in parallel with other parallel tests. +func Setup(t *testing.T, parallel bool) *test.Clients { if test.Flags.Namespace == "" { test.Flags.Namespace = defaultNamespaceName } + if parallel { + t.Parallel() + } + clients, err := test.NewClients( test.Flags.Kubeconfig, test.Flags.Cluster, diff --git a/test/e2e/errorcondition_test.go b/test/e2e/errorcondition_test.go index c89a0cfa861d..df27f1c6e495 100644 --- a/test/e2e/errorcondition_test.go +++ b/test/e2e/errorcondition_test.go @@ -41,7 +41,7 @@ const ( func TestContainerErrorMsg(t *testing.T) { //t.Skip("Skipping until https://github.com/knative/serving/issues/1240 is closed") - clients := Setup(t) + clients := Setup(t, true) //add test case specific name to its own logger logger := test.GetContextLogger("TestContainerErrorMsg") diff --git a/test/e2e/helloworld_test.go b/test/e2e/helloworld_test.go index 713281a7ba50..22d0fd22137d 100644 --- a/test/e2e/helloworld_test.go +++ b/test/e2e/helloworld_test.go @@ -32,7 +32,7 @@ const ( ) func TestHelloWorld(t *testing.T) { - clients := Setup(t) + clients := Setup(t, true) //add test case specific name to its own logger logger := test.GetContextLogger("TestHelloWorld")