From a044b2c1e41269075ce254a39bede716c3a9da85 Mon Sep 17 00:00:00 2001 From: Lukas Berk Date: Tue, 18 Aug 2020 17:45:41 -0400 Subject: [PATCH 1/3] Add docs on how to run conf tests against preexisting broker Also, fix being able to run conf tests against existing broker :facepalm: Fixes #3667 --- test/conformance/README.md | 12 +++++++++++- test/conformance/broker_data_plane_test.go | 4 ++-- .../helpers/broker_data_plane_test_helper.go | 10 ++++++++++ test/lib/resources/eventing.go | 6 ++++++ 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/test/conformance/README.md b/test/conformance/README.md index 968a12100c5..54fdf6e898e 100644 --- a/test/conformance/README.md +++ b/test/conformance/README.md @@ -11,10 +11,20 @@ Run test with e2e tag and optionally select conformance test > NOTE: Make sure you have built the > [test images](https://github.com/knative/eventing/tree/master/test#building-the-test-images)! -```go +```shell go test -v -tags=e2e -count=1 ./test/conformance/... go test -v -timeout 30s -tags e2e knative.dev/eventing/test/conformance -run ^TestMustPassTracingHeaders$ go test -v -timeout 30s -tags e2e knative.dev/eventing/test/conformance -run ^TestMustPassTracingHeaders$ --kubeconfig $KUBECONFIG ``` + +## Running Broker conformance tests against an existing broker + +When developing a new broker, or testings against a preexisting broker setup you can specify: + +``` shell +go test -v -tags e2e knative.dev/eventing/test/conformance -brokername=foo -brokernamespace=bar -run TestBrokerV1Beta1DataPlaneIngress + +``` + diff --git a/test/conformance/broker_data_plane_test.go b/test/conformance/broker_data_plane_test.go index 83d15c1a2b3..a0e3c3a07a1 100644 --- a/test/conformance/broker_data_plane_test.go +++ b/test/conformance/broker_data_plane_test.go @@ -26,14 +26,14 @@ import ( ) func TestBrokerV1Beta1DataPlaneIngress(t *testing.T) { - client := testlib.Setup(t, true, testlib.SetupClientOptionNoop) + client := testlib.Setup(t, true, helpers.BrokerDataPlaneNamespaceSetupOption(brokerNamespace)) defer testlib.TearDown(client) broker := helpers.BrokerDataPlaneSetupHelper(client, brokerName, brokerNamespace, brokerClass) helpers.BrokerV1Beta1IngressDataPlaneTestHelper(t, client, broker) } func TestBrokerV1Beta1DataPlaneConsumer(t *testing.T) { - client := testlib.Setup(t, true, testlib.SetupClientOptionNoop) + client := testlib.Setup(t, true, helpers.BrokerDataPlaneNamespaceSetupOption(brokerNamespace)) defer testlib.TearDown(client) broker := helpers.BrokerDataPlaneSetupHelper(client, brokerName, brokerNamespace, brokerClass) diff --git a/test/conformance/helpers/broker_data_plane_test_helper.go b/test/conformance/helpers/broker_data_plane_test_helper.go index ad5dfd4728c..61eeebe0b80 100644 --- a/test/conformance/helpers/broker_data_plane_test_helper.go +++ b/test/conformance/helpers/broker_data_plane_test_helper.go @@ -53,6 +53,15 @@ func BrokerDataPlaneSetupHelper(client *testlib.Client, brokerName, brokerNamesp return broker } +func BrokerDataPlaneNamespaceSetupOption(namespace string) testlib.SetupClientOption { + return func(client *testlib.Client) { + if namespace != "" { + client.Kube.Kube.CoreV1().Namespaces().Delete(client.Namespace, nil) + client.Namespace = namespace + } + } +} + //At ingress //Supports CE 0.3 or CE 1.0 via HTTP //Supports structured or Binary mode @@ -72,6 +81,7 @@ func BrokerV1Beta1IngressDataPlaneTestHelper( trigger := client.CreateTriggerOrFailV1Beta1( triggerName, resources.WithBrokerV1Beta1(broker.Name), + resources.WithNamespaceTriggerV1Beta1(broker.Namespace), resources.WithAttributesTriggerFilterV1Beta1(eventingv1beta1.TriggerAnyFilter, eventingv1beta1.TriggerAnyFilter, nil), resources.WithSubscriberServiceRefForTriggerV1Beta1(loggerName), ) diff --git a/test/lib/resources/eventing.go b/test/lib/resources/eventing.go index 167f0cace3e..ff790d993a9 100644 --- a/test/lib/resources/eventing.go +++ b/test/lib/resources/eventing.go @@ -321,6 +321,12 @@ func BrokerV1(name string, options ...BrokerV1Option) *eventingv1.Broker { return broker } +func WithNamespaceTriggerV1Beta1(namespace string) TriggerOptionV1Beta1 { + return func(t *eventingv1beta1.Trigger) { + t.Namespace = namespace + } +} + // WithAttributesTriggerFilter returns an option that adds a TriggerFilter with Attributes for the given Trigger. func WithAttributesTriggerFilterV1Beta1(eventSource, eventType string, extensions map[string]interface{}) TriggerOptionV1Beta1 { attrs := make(map[string]string) From 8df6ba6003c27d0c36c30b2e34844a47fc216d46 Mon Sep 17 00:00:00 2001 From: Lukas Berk Date: Tue, 18 Aug 2020 18:25:23 -0400 Subject: [PATCH 2/3] linting nits --- test/conformance/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/conformance/README.md b/test/conformance/README.md index 54fdf6e898e..5ec0bcaf37f 100644 --- a/test/conformance/README.md +++ b/test/conformance/README.md @@ -21,10 +21,10 @@ go test -v -timeout 30s -tags e2e knative.dev/eventing/test/conformance -run ^Te ## Running Broker conformance tests against an existing broker -When developing a new broker, or testings against a preexisting broker setup you can specify: +When developing a new broker, or testings against a preexisting broker setup you +can specify: -``` shell +```shell go test -v -tags e2e knative.dev/eventing/test/conformance -brokername=foo -brokernamespace=bar -run TestBrokerV1Beta1DataPlaneIngress ``` - From f19750a95fa9c8523debedd04231375eb1aa043c Mon Sep 17 00:00:00 2001 From: Lukas Berk Date: Wed, 19 Aug 2020 09:43:20 -0400 Subject: [PATCH 3/3] Drop trigger option/function not needed --- test/conformance/helpers/broker_data_plane_test_helper.go | 1 - test/lib/resources/eventing.go | 6 ------ 2 files changed, 7 deletions(-) diff --git a/test/conformance/helpers/broker_data_plane_test_helper.go b/test/conformance/helpers/broker_data_plane_test_helper.go index 61eeebe0b80..ac48ca3b1ba 100644 --- a/test/conformance/helpers/broker_data_plane_test_helper.go +++ b/test/conformance/helpers/broker_data_plane_test_helper.go @@ -81,7 +81,6 @@ func BrokerV1Beta1IngressDataPlaneTestHelper( trigger := client.CreateTriggerOrFailV1Beta1( triggerName, resources.WithBrokerV1Beta1(broker.Name), - resources.WithNamespaceTriggerV1Beta1(broker.Namespace), resources.WithAttributesTriggerFilterV1Beta1(eventingv1beta1.TriggerAnyFilter, eventingv1beta1.TriggerAnyFilter, nil), resources.WithSubscriberServiceRefForTriggerV1Beta1(loggerName), ) diff --git a/test/lib/resources/eventing.go b/test/lib/resources/eventing.go index ff790d993a9..167f0cace3e 100644 --- a/test/lib/resources/eventing.go +++ b/test/lib/resources/eventing.go @@ -321,12 +321,6 @@ func BrokerV1(name string, options ...BrokerV1Option) *eventingv1.Broker { return broker } -func WithNamespaceTriggerV1Beta1(namespace string) TriggerOptionV1Beta1 { - return func(t *eventingv1beta1.Trigger) { - t.Namespace = namespace - } -} - // WithAttributesTriggerFilter returns an option that adds a TriggerFilter with Attributes for the given Trigger. func WithAttributesTriggerFilterV1Beta1(eventSource, eventType string, extensions map[string]interface{}) TriggerOptionV1Beta1 { attrs := make(map[string]string)