Add sources metadata conformance test#3319
Conversation
|
Skipping CI for Draft Pull Request. |
mattmoor
left a comment
There was a problem hiding this comment.
Produced via:
gofmt -s -w $(find -path './vendor' -prune -o -path './third_party' -prune -o -type f -name '*.go' -print)
mattmoor
left a comment
There was a problem hiding this comment.
Produced via:
gofmt -s -w $(find -path './vendor' -prune -o -path './third_party' -prune -o -type f -name '*.go' -print)
mattmoor
left a comment
There was a problem hiding this comment.
Produced via:
gofmt -s -w $(find -path './vendor' -prune -o -path './third_party' -prune -o -type f -name '*.go' -print)
|
/test all |
| t *testing.T, | ||
| brokerClass string, | ||
| channelTestRunner lib.ChannelTestRunner, | ||
| channelTestRunner lib.ComponentsTestRunner, |
There was a problem hiding this comment.
wanna change this great (IMO) rename here as well:
| "knative.dev/eventing/test/lib" | ||
| ) | ||
|
|
||
| var channelLabels = map[string]string{ |
| "knative.dev/eventing/test/lib" | ||
| ) | ||
|
|
||
| func objectHasRequiredLabels(client *lib.Client, object metav1.TypeMeta, key string, value string) (bool, error) { |
There was a problem hiding this comment.
objectHasRequiredLabel ? singular?
| // Each source MUST have the following: | ||
| // label of duck.knative.dev/source: "true" | ||
| t.Run("Source CRD has required label", func(t *testing.T) { | ||
| yes, err := objectHasRequiredLabels(client, source, "duck.knative.dev/source", "true") |
There was a problem hiding this comment.
perhaps might move the duck.knative.dev/source to a map as well ?
mattmoor
left a comment
There was a problem hiding this comment.
Produced via:
gofmt -s -w $(find -path './vendor' -prune -o -path './third_party' -prune -o -type f -name '*.go' -print)
goimports -w $(find -name '*.go' | grep -v vendor | grep -v third_party | grep -v wire_gen.go)
antoineco
left a comment
There was a problem hiding this comment.
Moar conformance, noice!
| "sources.knative.dev/v1alpha1:PingSource\"." | ||
| ) | ||
| // EventingFlags holds the command line flags specific to knative/eventing. | ||
| //var EventingFlags *EventingEnvironmentFlags |
There was a problem hiding this comment.
This line is a leftover and should be removed.
| "messaging.knative.dev/subscribable": "true", | ||
| "duck.knative.dev/addressable": "true", |
There was a problem hiding this comment.
Don't we have constants for those labels?
There was a problem hiding this comment.
none that I know of, lemme know if you know them
There was a problem hiding this comment.
Haven't found any so I created:
There was a problem hiding this comment.
subscribable is here:
pkg/apis/messaging/register.go
https://github.com/knative/eventing/blob/master/pkg/apis/messaging/register.go#L25
| // InitializeEventingFlags registers flags used by e2e tests, calling flag.Parse() here would fail in | ||
| // go1.13+, see https://github.com/knative/test-infra/issues/1329 for details | ||
| func InitializeEventingFlags() { | ||
| flag.Var(&EventingFlags.Channels, "channels", "The names of the channel type metas, separated by comma. Example: \"messaging.knative.dev/v1alpha1:InMemoryChannel,messaging.cloud.google.com/v1alpha1:Channel,messaging.knative.dev/v1alpha1:KafkaChannel\".") | ||
| flag.StringVar(&EventingFlags.BrokerClass, "brokerclass", "MTChannelBasedBroker", "Which brokerclass to test, requires the proper Broker implementation to have been installed, and only one value. brokerclass must be (for now) 'MTChannelBasedBroker'.") | ||
|
|
||
| flag.Var(&EventingFlags.Channels, "channels", ChannelUsage) | ||
| flag.StringVar(&EventingFlags.BrokerClass, "brokerclass", "MTChannelBasedBroker", BrokerUsage) | ||
| flag.Var(&EventingFlags.Sources, "sources", SourceUsage) | ||
| flag.Parse() |
There was a problem hiding this comment.
calling flag.Parse() here would fail
flag.Parse()
![]()
More seriously, the comment is probably outdated.
There was a problem hiding this comment.
I've no context of this whole comment so I'd like to keep it out of this PR scope. I'll follow up on slack on it though since I've came across it. Good catch 👍
| return fmt.Sprint(*channels) | ||
| } | ||
|
|
||
| // Set converts the input string to Channels. |
There was a problem hiding this comment.
"Appends a new Channel corresponding to the input string" seems to describe the actual code better.
| return fmt.Sprint(*sources) | ||
| } | ||
|
|
||
| // Set converts the input string to Sources. |
There was a problem hiding this comment.
"Appends a new Source corresponding to the input string" seems to describe the actual code better.
There was a problem hiding this comment.
I'll refactor this in a separate PR and actually rename the method to Append. Good catch 👍 . I'm not fully familiar with the code base so I'm not sure who's using who and I wanna limit the blast radius of this PR.
There was a problem hiding this comment.
Can we at least have an accurate comment in this PR?
| Kind: split[1], | ||
| } | ||
| if !isValidSource(tm.Kind) { | ||
| log.Fatalf("The given source name %q is invalid, tests cannot be run.\n", source) |
There was a problem hiding this comment.
Mixed case within the function "Source/source"
| Kind: split[1], | ||
| } | ||
| if !isValidChannel(tm.Kind) { | ||
| log.Fatalf("The given channel name %q is invalid, tests cannot be run.\n", channel) |
There was a problem hiding this comment.
Mixed case within the function "Channel/channel"
There was a problem hiding this comment.
👍 Generally I think the error messages in the test folder can use some love
|
/lgtm |
| } | ||
|
|
||
| // ChannelFeatureMap saves the channel-features mapping. | ||
| // ComponentFeatureMap saves the channel-features mapping. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Abd4llA The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Holding until refactoring is done in eventing-contrib |
|
@Abd4llA: PR needs rebase. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
|
/lgtm cancel |
|
How about we split this work into two PRs ?
While PR 1 was merged, the same changes could already be applied to |
Fixes #3116
Proposed Changes
Release Note