diff --git a/test/conformance/README.md b/test/conformance/README.md index 8ab09db71e4..ff42b75c67a 100644 --- a/test/conformance/README.md +++ b/test/conformance/README.md @@ -4,7 +4,7 @@ Conformance tests verifies knative eventing implementation for expected behavior described in [specification](https://github.com/knative/eventing/tree/main/docs/spec). -## Running performance tests +## Running conformance tests Run test with e2e tag and optionally select conformance test @@ -31,3 +31,25 @@ can specify: go test -v -tags e2e knative.dev/eventing/test/conformance -brokername=foo -brokernamespace=bar -run TestBrokerV1Beta1DataPlaneIngress ``` + +## Running conformance tests as a project admin + +It is possible to run the conformance tests by a user with reduced privileges, e.g. project admin. +Some tests require cluster-admin privileges and those tests are excluded from execution in this case. +Running the conformance tests then consists of these steps: +1. The cluster admin creates test namespaces and required RBAC. Each test requires a separate namespace. + By default, the namespace names consist of `eventing-e2e` prefix and numeric suffix starting from 0: + `eventing-e2e0`, `eventing-e2e1`, etc. The prefix can be configured using the EVENTING_E2E_NAMESPACE env + variable. There's a helper script in the current folder that will create all the required resources: + ```shell + NUM_NAMESPACES=40 ./create-namespace-rbac.sh + ``` + Note: The number of required namespaces might grow over time. +1. The project admin runs the test suite with specific flags: + ```shell + go test -v -tags=e2e,project_admin -count=1 ./test/conformance \ + -reusenamespace \ + -kubeconfig=$PROJECT_ADMIN_KUBECONFIG + ``` + The $PROJECT_ADMIN_KUBECONFIG's user is expected to be a project admin for all the + created namespaces. diff --git a/test/conformance/broker_tracing_test.go b/test/conformance/broker_tracing_test.go index 4c292d018b9..ad325479a96 100644 --- a/test/conformance/broker_tracing_test.go +++ b/test/conformance/broker_tracing_test.go @@ -1,4 +1,5 @@ // +build e2e +// +build !project_admin /* Copyright 2019 The Knative Authors diff --git a/test/conformance/channel_addressable_resolver_cluster_role_test.go b/test/conformance/channel_addressable_resolver_cluster_role_test.go index d8fe0afed00..139ad72a31e 100644 --- a/test/conformance/channel_addressable_resolver_cluster_role_test.go +++ b/test/conformance/channel_addressable_resolver_cluster_role_test.go @@ -1,4 +1,5 @@ // +build e2e +// +build !project_admin /* Copyright 2020 The Knative Authors diff --git a/test/conformance/channel_channelable_manipulator_cluster_role_test.go b/test/conformance/channel_channelable_manipulator_cluster_role_test.go index 8f47c0e9bde..658100693c1 100644 --- a/test/conformance/channel_channelable_manipulator_cluster_role_test.go +++ b/test/conformance/channel_channelable_manipulator_cluster_role_test.go @@ -1,4 +1,5 @@ // +build e2e +// +build !project_admin /* Copyright 2020 The Knative Authors diff --git a/test/conformance/channel_crd_metadata_test.go b/test/conformance/channel_crd_metadata_test.go index 33c3fa72106..2b5fc065b12 100644 --- a/test/conformance/channel_crd_metadata_test.go +++ b/test/conformance/channel_crd_metadata_test.go @@ -1,4 +1,5 @@ // +build e2e +// +build !project_admin /* Copyright 2020 The Knative Authors diff --git a/test/conformance/channel_tracing_test.go b/test/conformance/channel_tracing_test.go index f9f40ddf63c..69422f2b11a 100644 --- a/test/conformance/channel_tracing_test.go +++ b/test/conformance/channel_tracing_test.go @@ -1,4 +1,5 @@ // +build e2e +// +build !project_admin /* Copyright 2019 The Knative Authors diff --git a/test/conformance/create-namespace-rbac.sh b/test/conformance/create-namespace-rbac.sh new file mode 100755 index 00000000000..86aea223950 --- /dev/null +++ b/test/conformance/create-namespace-rbac.sh @@ -0,0 +1,110 @@ +#!/usr/bin/env bash + +# Copyright 2021 The Knative Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This script creates test namespaces together with ServiceAccounts, Roles, +# RoleBindings for conformance tests. This script is useful when tests are +# run with --reusenamespace option in restricted environments. See README.md +# for more information. + +set -Eeuo pipefail + +NUM_NAMESPACES=${NUM_NAMESPACES:?"Pass the NUM_NAMESPACES env variable"} +EVENTING_E2E_NAMESPACE="${EVENTING_E2E_NAMESPACE:-eventing-e2e}" + +for i in $(seq 0 "$(("$NUM_NAMESPACES" - 1))"); do + cat <