From a033cbb38d49d9f271e1386bfc3478f607c32dfb Mon Sep 17 00:00:00 2001 From: Leo Li Date: Mon, 28 Aug 2023 12:45:26 -0400 Subject: [PATCH] Add the all filter rekt test Signed-off-by: Leo Li --- .../features/new_trigger_filters/feature.go | 44 +++++++++++++++++++ test/experimental/new_trigger_filters_test.go | 16 +++++++ 2 files changed, 60 insertions(+) diff --git a/test/experimental/features/new_trigger_filters/feature.go b/test/experimental/features/new_trigger_filters/feature.go index ccb4958a11b..cdedb652ded 100644 --- a/test/experimental/features/new_trigger_filters/feature.go +++ b/test/experimental/features/new_trigger_filters/feature.go @@ -202,3 +202,47 @@ func AnyFilterFeature(brokerName string) *feature.Feature { return f } + +func AllFilterFeature(brokerName string) *feature.Feature { + f := feature.NewFeature() + + eventContexts := []CloudEventsContext{ + { + eventType: "exact.prefix.suffix.event.type", + shouldDeliver: true, + }, + { + eventType: "not.event.type", + shouldDeliver: false, + }, + } + + filters := []eventingv1.SubscriptionsAPIFilter{ + { + All: []eventingv1.SubscriptionsAPIFilter{ + { + Exact: map[string]string{ + "type": "exact.prefix.suffix.event.type", + }, + }, + { + Prefix: map[string]string{ + "type": "exact.prefix", + }, + }, + { + Suffix: map[string]string{ + "type": "suffix.event.type", + }, + }, + { + CESQL: "type LIKE 'exact.prefix.suffix%'", + }, + }, + }, + } + + f = newEventFilterFeature(eventContexts, filters, f, brokerName) + + return f +} diff --git a/test/experimental/new_trigger_filters_test.go b/test/experimental/new_trigger_filters_test.go index af55a53089c..55e3b702e67 100644 --- a/test/experimental/new_trigger_filters_test.go +++ b/test/experimental/new_trigger_filters_test.go @@ -65,6 +65,22 @@ func TestMTChannelBrokerAnyTriggerFilters(t *testing.T) { env.Test(ctx, t, newfilters.AnyFilterFeature(brokerName)) } +func TestMTChannelBrokerAllTriggerFilters(t *testing.T) { + t.Parallel() + + ctx, env := global.Environment( + knative.WithKnativeNamespace(system.Namespace()), + knative.WithLoggingConfig, + knative.WithTracingConfig, + k8s.WithEventListener, + environment.Managed(t), + ) + brokerName := "default" + + env.Prerequisite(ctx, t, InstallMTBroker(brokerName)) + env.Test(ctx, t, newfilters.AllFilterFeature(brokerName)) +} + func InstallMTBroker(name string) *feature.Feature { f := feature.NewFeatureNamed("Multi-tenant channel-based broker") f.Setup(fmt.Sprintf("Install broker %q", name), broker.Install(name, broker.WithEnvConfig()...))