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 #3363

Merged

Conversation

devguyio
Copy link
Contributor

Fixes #3116

Proposed Changes

  • Add initial source conformance test for source label
  • Add -sources e2e testing flag

Release Note

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

@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Jun 22, 2020
@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 22, 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)
goimports -w $(find -name '*.go' | grep -v vendor | grep -v third_party | grep -v wire_gen.go)

@@ -35,6 +35,9 @@ const (
BrokerUsage = "Which brokerclass to test, requires the proper Broker " +
"implementation to have been installed, and only one value. brokerclass " +
"must be (for now) 'MTChannelBasedBroker'."
SourceUsage = "The names of the source type metas, separated by comma. " +
Copy link
Member

Choose a reason for hiding this comment

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

Format Go code:

Suggested change
SourceUsage = "The names of the source type metas, separated by comma. " +
SourceUsage = "The names of the source type metas, separated by comma. " +

)

var sourceLabels = map[string]string{
"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.

until we have knative/pkg#1424 available, let's go w/ this

@aliok
Copy link
Member

aliok commented Jun 22, 2020

/assign

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.

One nit

return nil
}

// Check if the Source name is valid.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Check if the Source name is valid.
// Check if the Source kind is valid.

Comment on lines 36 to 53
for _, source := range strings.Split(value, ",") {
source := strings.TrimSpace(source)
split := strings.Split(source, ":")
if len(split) != 2 {
log.Fatalf("The given Source name %q is invalid, it needs to be in the form \"apiVersion:Kind\".", source)
}
tm := metav1.TypeMeta{
APIVersion: split[0],
Kind: split[1],
}
if !isValidSource(tm.Kind) {
log.Fatalf("The given Source name %q is invalid, tests cannot be run.\n", source)
}

*sources = append(*sources, tm)
}
return nil
}
Copy link
Member

Choose a reason for hiding this comment

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

This can be extracted into a separate function and can be reused in sources.go and channels.go. ...if you feel for it

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, on it 👍

Copy link
Member

@aliok aliok left a comment

Choose a reason for hiding this comment

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

@Abd4llA

Can you also update the test script so that it runs the conformance tests against the sources defined in knative/eventing?

I see following line in the logs:

Running tests with 'go test -v  -race -count=1 -tags=e2e -timeout=20m -parallel=12 ./test/e2e ./test/conformance -brokerclass=MTChannelBasedBroker -channels=messaging.knative.dev/v1beta1:Channel,messaging.knative.dev/v1beta1:InMemoryChannel '

no sources mentioned there.

@@ -27,28 +26,15 @@ import (
// Channels holds the Channels we want to run test against.
type Channels []metav1.TypeMeta

var objs []metav1.TypeMeta
Copy link
Member

Choose a reason for hiding this comment

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

Unused var?

@@ -35,6 +35,6 @@ initialize $@ --skip-istio-addon
install_mt_broker || fail_test "Could not install MT Channel Based Broker"

echo "Running tests with Multi Tenant Channel Based Broker"
go_test_e2e -timeout=20m -parallel=12 ./test/e2e ./test/conformance -brokerclass=MTChannelBasedBroker -channels=messaging.knative.dev/v1beta1:Channel,messaging.knative.dev/v1beta1:InMemoryChannel || fail_test
go_test_e2e -timeout=20m -parallel=12 ./test/e2e ./test/conformance -brokerclass=MTChannelBasedBroker -channels=messaging.knative.dev/v1beta1:Channel,messaging.knative.dev/v1beta1:InMemoryChannel -sources=sources.knative.dev/v1alpha2:ApiServerSource,sources.knative.dev/v1alpha2:ContainerSource,sources.knative.dev/v1alpha2:PingSource || fail_test
Copy link
Member

Choose a reason for hiding this comment

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

w00t!

Copy link
Member

@aliok aliok left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

Looks great!
Hopefully green on first pass 😎

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

@aliok aliok left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 22, 2020
@slinkydeveloper
Copy link
Contributor

/assign

Copy link
Contributor

@slinkydeveloper slinkydeveloper left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Abd4llA, aliok, slinkydeveloper

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

The pull request process is described 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

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 22, 2020
@knative-prow-robot knative-prow-robot merged commit 3d9f81b into knative:master Jun 22, 2020
@aliok aliok mentioned this pull request Sep 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/test-and-release Test infrastructure, tests or release cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. 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
8 participants