-
Notifications
You must be signed in to change notification settings - Fork 600
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:knative/eventing into deprecate-kntest
- Loading branch information
Showing
22 changed files
with
619 additions
and
253 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
Copyright 2023 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. | ||
*/ | ||
|
||
package benchmarks | ||
|
||
import ( | ||
"testing" | ||
|
||
cetest "github.com/cloudevents/sdk-go/v2/test" | ||
"knative.dev/eventing/pkg/eventfilter" | ||
"knative.dev/eventing/pkg/eventfilter/subscriptionsapi" | ||
) | ||
|
||
func BenchmarkAnyFilter(b *testing.B) { | ||
// Full event with all possible fields filled | ||
event := cetest.FullEvent() | ||
|
||
filter, _ := subscriptionsapi.NewExactFilter(map[string]string{"id": event.ID()}) | ||
prefixFilter, _ := subscriptionsapi.NewPrefixFilter(map[string]string{"type": event.Type()[0:5]}) | ||
suffixFilter, _ := subscriptionsapi.NewSuffixFilter(map[string]string{"source": event.Source()[len(event.Source())-5:]}) | ||
prefixFilterNoMatch, _ := subscriptionsapi.NewPrefixFilter(map[string]string{"type": "qwertyuiop"}) | ||
suffixFilterNoMatch, _ := subscriptionsapi.NewSuffixFilter(map[string]string{"source": "qwertyuiop"}) | ||
|
||
RunFilterBenchmarks(b, | ||
func(i interface{}) eventfilter.Filter { | ||
filters := i.([]eventfilter.Filter) | ||
return subscriptionsapi.NewAnyFilter(filters...) | ||
}, | ||
FilterBenchmark{ | ||
name: "Any filter with exact filter test", | ||
arg: []eventfilter.Filter{filter}, | ||
event: event, | ||
}, | ||
FilterBenchmark{ | ||
name: "Any filter match all subfilters", | ||
arg: []eventfilter.Filter{filter, prefixFilter, suffixFilter}, | ||
event: event, | ||
}, | ||
FilterBenchmark{ | ||
name: "Any filter no 1 match at end of array", | ||
arg: []eventfilter.Filter{prefixFilterNoMatch, suffixFilterNoMatch, filter}, | ||
event: event, | ||
}, | ||
FilterBenchmark{ | ||
name: "Any filter no 1 match at start of array", | ||
arg: []eventfilter.Filter{filter, prefixFilterNoMatch, suffixFilterNoMatch}, | ||
event: event, | ||
}, | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
//go:build e2e | ||
// +build e2e | ||
|
||
/* | ||
Copyright 2023 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. | ||
*/ | ||
|
||
package experimental | ||
|
||
import ( | ||
"testing" | ||
|
||
"knative.dev/eventing/test/experimental/features/eventtype_autocreate" | ||
|
||
"knative.dev/pkg/system" | ||
"knative.dev/reconciler-test/pkg/environment" | ||
"knative.dev/reconciler-test/pkg/k8s" | ||
"knative.dev/reconciler-test/pkg/knative" | ||
) | ||
|
||
func TestIMCEventTypeAutoCreate(t *testing.T) { | ||
t.Parallel() | ||
|
||
ctx, env := global.Environment( | ||
knative.WithKnativeNamespace(system.Namespace()), | ||
knative.WithLoggingConfig, | ||
knative.WithTracingConfig, | ||
k8s.WithEventListener, | ||
environment.Managed(t), | ||
) | ||
|
||
env.Test(ctx, t, eventtype_autocreate.AutoCreateEventTypesOnIMC()) | ||
} |
61 changes: 61 additions & 0 deletions
61
test/experimental/features/eventtype_autocreate/features.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
Copyright 2023 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. | ||
*/ | ||
|
||
package eventtype_autocreate | ||
|
||
import ( | ||
cetest "github.com/cloudevents/sdk-go/v2/test" | ||
"k8s.io/apimachinery/pkg/util/sets" | ||
"knative.dev/eventing/test/rekt/resources/channel_impl" | ||
"knative.dev/eventing/test/rekt/resources/eventtype" | ||
"knative.dev/eventing/test/rekt/resources/subscription" | ||
"knative.dev/reconciler-test/pkg/eventshub" | ||
"knative.dev/reconciler-test/pkg/eventshub/assert" | ||
"knative.dev/reconciler-test/pkg/feature" | ||
"knative.dev/reconciler-test/pkg/resources/service" | ||
) | ||
|
||
func AutoCreateEventTypesOnIMC() *feature.Feature { | ||
f := feature.NewFeature() | ||
|
||
event := cetest.FullEvent() | ||
event.SetType("test.custom.event.type") | ||
|
||
sender := feature.MakeRandomK8sName("sender") | ||
sub := feature.MakeRandomK8sName("subscription") | ||
channelName := feature.MakeRandomK8sName("channel") | ||
sink := feature.MakeRandomK8sName("sink") | ||
|
||
f.Setup("install sink", eventshub.Install(sink, eventshub.StartReceiver)) | ||
f.Setup("install channel", channel_impl.Install(channelName)) | ||
f.Setup("install subscription", subscription.Install(sub, | ||
subscription.WithChannel(channel_impl.AsRef(channelName)), | ||
subscription.WithSubscriber(service.AsKReference(sink), ""), | ||
)) | ||
|
||
f.Setup("subscription is ready", subscription.IsReady(sub)) | ||
f.Setup("channel is ready", channel_impl.IsReady(channelName)) | ||
|
||
f.Requirement("install event sender", eventshub.Install(sender, | ||
eventshub.StartSenderToResource(channel_impl.GVR(), channelName), | ||
eventshub.InputEvent(event), | ||
)) | ||
|
||
expectedTypes := sets.New(event.Type()) | ||
|
||
f.Alpha("imc"). | ||
Must("deliver events to subscriber", assert.OnStore(sink).MatchEvent(cetest.HasId(event.ID())).AtLeast(1)). | ||
Must("create event type", eventtype.WaitForEventType(eventtype.AssertPresent(expectedTypes))) | ||
|
||
return f | ||
} |
Oops, something went wrong.