Skip to content

Add sources metadata conformance test#3363

Merged
knative-prow-robot merged 7 commits into
knative:masterfrom
devguyio:3116-src-conf-crd-labels-test
Jun 22, 2020
Merged

Add sources metadata conformance test#3363
knative-prow-robot merged 7 commits into
knative:masterfrom
devguyio:3116-src-conf-crd-labels-test

Conversation

@devguyio
Copy link
Copy Markdown
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
Copy Markdown
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)

Comment thread test/e2e_flags.go Outdated
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

aliok commented Jun 22, 2020

/assign

Copy link
Copy Markdown
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

Comment thread test/flags/sources.go Outdated
return nil
}

// Check if the Source name is valid.
Copy link
Copy Markdown
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 thread test/flags/sources.go Outdated
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

Comment thread test/flags/channels.go Outdated
// Channels holds the Channels we want to run test against.
type Channels []metav1.TypeMeta

var objs []metav1.TypeMeta
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Unused var?

Comment thread test/e2e-tests.sh

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
Copy Markdown
Member

Choose a reason for hiding this comment

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

w00t!

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

/assign

Copy link
Copy Markdown
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
Copy Markdown
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

Details 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