Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sources metadata conformance test #3319

Closed
wants to merge 10 commits into from

Conversation

devguyio
Copy link
Contributor

@devguyio devguyio commented Jun 13, 2020

Fixes #3116

Proposed Changes

  • Add initial source conformance test for source label
  • Refactor ChannelTestRunner to a generic ComponentsTestRunner

Release Note

 - Add Eventing sources conformance test for validating required labels on Eventing source CRDs

@knative-prow-robot knative-prow-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 13, 2020
@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Jun 13, 2020
@knative-prow-robot
Copy link
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@knative-prow-robot knative-prow-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. area/test-and-release Test infrastructure, tests or release labels Jun 13, 2020
Copy link
Member

@mattmoor mattmoor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Produced via:
gofmt -s -w $(find -path './vendor' -prune -o -path './third_party' -prune -o -type f -name '*.go' -print)

Copy link
Member

@mattmoor mattmoor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Produced via:
gofmt -s -w $(find -path './vendor' -prune -o -path './third_party' -prune -o -type f -name '*.go' -print)

Copy link
Member

@mattmoor mattmoor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Produced via:
gofmt -s -w $(find -path './vendor' -prune -o -path './third_party' -prune -o -type f -name '*.go' -print)

@devguyio
Copy link
Contributor Author

/test all

@@ -39,7 +39,7 @@ import (
func BrokerV1Beta1ControlPlaneTestHelperWithChannelTestRunner(
t *testing.T,
brokerClass string,
channelTestRunner lib.ChannelTestRunner,
channelTestRunner lib.ComponentsTestRunner,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, will do

@@ -25,11 +25,16 @@ import (
"knative.dev/eventing/test/lib"
)

var channelLabels = map[string]string{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

"knative.dev/eventing/test/lib"
)

func objectHasRequiredLabels(client *lib.Client, object metav1.TypeMeta, key string, value string) (bool, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

objectHasRequiredLabel ? singular?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

// 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")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps might move the duck.knative.dev/source to a map as well ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Member

@mattmoor mattmoor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

@devguyio devguyio marked this pull request as ready for review June 15, 2020 13:49
@knative-prow-robot knative-prow-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 15, 2020
Copy link
Contributor

@antoineco antoineco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moar conformance, noice!

SourceUsage = "The names of the source type metas, separated by comma. " +
"Example: \"sources.knative.dev/v1alpha1:ApiServerSource," +
"sources.knative.dev/v1alpha1:PingSource\"."
)
// EventingFlags holds the command line flags specific to knative/eventing.
//var EventingFlags *EventingEnvironmentFlags
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is a leftover and should be removed.

test/e2e_flags.go Outdated Show resolved Hide resolved
Comment on lines +29 to +30
"messaging.knative.dev/subscribable": "true",
"duck.knative.dev/addressable": "true",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we have constants for those labels?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

none that I know of, lemme know if you know them

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test/conformance/helpers/metadata.go Outdated Show resolved Hide resolved
test/conformance/helpers/metadata.go Outdated Show resolved Hide resolved
Comment on lines 47 to 54
// 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()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

calling flag.Parse() here would fail

flag.Parse()

:trollface:

More seriously, the comment is probably outdated.

Copy link
Contributor Author

@devguyio devguyio Jun 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created #3322

return fmt.Sprint(*channels)
}

// Set converts the input string to Channels.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Appends a new Source corresponding to the input string" seems to describe the actual code better.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mixed case within the function "Channel/channel"

Copy link
Contributor Author

@devguyio devguyio Jun 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Generally I think the error messages in the test folder can use some love

@antoineco
Copy link
Contributor

/lgtm

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 15, 2020
@@ -37,7 +37,7 @@ var MessagingChannelTypeMeta = metav1.TypeMeta{
Kind: resources.ChannelKind,
}

// ChannelFeatureMap saves the channel-features mapping.
// ComponentFeatureMap saves the channel-features mapping.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Abd4llA this one remains

@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Abd4llA
To complete the pull request process, please assign chizhg
You can assign the PR to them by writing /assign @chizhg in a comment when ready.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@devguyio
Copy link
Contributor Author

Holding until refactoring is done in eventing-contrib
/hold

@knative-prow-robot knative-prow-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jun 16, 2020
@knative-prow-robot
Copy link
Contributor

@Abd4llA: PR needs rebase.

Instructions 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.

@antoineco
Copy link
Contributor

/lgtm cancel

@knative-prow-robot knative-prow-robot removed the lgtm Indicates that a PR is ready to be merged. label Jun 16, 2020
@matzew
Copy link
Member

matzew commented Jun 16, 2020

How about we split this work into two PRs ?

  • one that does the refactoring and the testlib import-alias
  • second that actually adds the first sources test

While PR 1 was merged, the same changes could already be applied to eventing-contrib, and than indepently send just the work for the sources

@devguyio
Copy link
Contributor Author

Split into two PRs:

@devguyio devguyio closed this Jun 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/test-and-release Test infrastructure, tests or release cla: yes Indicates the PR's author has signed the CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Source conformance tests - CRD label
7 participants