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 source status conformance test and run it for ApiServerSource #3605

Merged
merged 6 commits into from
Jul 27, 2020

Conversation

devguyio
Copy link
Contributor

@devguyio devguyio commented Jul 16, 2020

Proposed Changes

  • Introduce component specific client options
  • Initialize ApiServerSource for the conformance tests
  • Add SourceStatusConformanceTest
Eventing conformance tests now can validate Sources status conformance

@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 Jul 16, 2020
@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Jul 16, 2020
@knative-prow-robot knative-prow-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. area/test-and-release Test infrastructure, tests or release labels Jul 16, 2020
@devguyio
Copy link
Contributor Author

devguyio commented Jul 16, 2020

@slinkydeveloper check out the test_runner.go and conformance/main_test.go

@@ -38,10 +44,11 @@ func TestMain(m *testing.M) {
ComponentsToTest: test.EventingFlags.Channels,
}
sourcesTestRunner = testlib.ComponentsTestRunner{
ComponentFeatureMap: testlib.SourceFeatureMap,
Copy link
Contributor

Choose a reason for hiding this comment

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

If from a project outside this repo (eg eventing-contrib) i want to run these conformance tests, i need to create this "main" file and populate that ComponentFeatureMap manually right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct.

Copy link
Member

Choose a reason for hiding this comment

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

kn conformance run ... ? Anyone?

Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be possible to restructure this so that something like this:
https://github.com/knative/eventing/pull/3531/files#diff-9cd17936c8cf7a4c529c64712ffa54abR37

Since these are conformance tests it would be nice if the user doesn't have to manually modify the test code to test their source for conformance. Ideally the creation of the resource would be separate from the tests and for tests, all you'd need to do is to give a namespace/name to test and the test would run against it. I've been advocating for this pattern for all of the conformance tests to make them easier to test. I further believe this to be even more important for sources as there are going to be more sources than channels / brokers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So it is my understanding that the "reusable" conformance tests package should not create any sources and should be "reusable" by other repos that want to run them against their sources, and that is the role of conformance/helpers package. Which is the case in this PR.

The repo specific tests that reuse the helpers (in our case test/conformance/main_tests.go & source_crd_metadata_test.go ) are the ones that inject the source creation tests. In eventing-contrib we'll do the same, inject the initializer that creates the KafkaSource etc and just reuse the conformance helper function.

@vaikas is the above different from what you want?

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, Ideally I guess I'd like, just like today I can run E2E tests against my own cluster so I can push custom bits into it. I create my cluster, then ko apply my bits into it and then execute:
go test ./test/... -tags=e2e

I do not have to change any of the e2e tests to point to different cluster, nor have the tests have any knowledge how my bits got to the cluster.

Ideally what I think I'd like is the following experience for a user:
create their sources however they want (kubectl apply for example)
take the NS/Name of the above
then run something like:
go test ./test/... -tags=source-conformance -sourceNamespace=myns -sourceName=mysource
(or some shell script that executes that)

So, to run the tests I wouldn't have to modify the code at all. Maybe I'm missing why the helpers need to create these instead of having tests that take the namespace / name and execute the tests against it instead of creating the "units under test" in our repo being a requirement.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As agreed I'll do the cmd args in a separate PR

test/conformance/sources_conf_test.go Outdated Show resolved Hide resolved
test/conformance/main_test.go Show resolved Hide resolved
features, present := tr.ComponentFeatureMap[component]
if !present || contains(features, feature) {
t.Run(fmt.Sprintf("%s-%s", component.Kind, component.APIVersion), func(st *testing.T) {
testFunc(st, component, tr.componentOptions[component]...)
Copy link
Contributor

Choose a reason for hiding this comment

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

Wait but you don't run the setup function here right? I lost where that function runs 😄

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 totally feel ya 😞 . The idea is, since ComponentTestRunner is just a selector of components, it includes components and their related ClientSetupOptions, and when running the tests, it passes the component and its ClientSetupOptions to the test function since the test function has the env context (the client it needs to inject those ClientSetupOptions with). I'm not a big fan of how convoluted the code ends up but that's the tension I've identified before between the helpers and the assumptions they make on those helpers consumers.

If you have a cleaner way in mind to do this I'd gladly do it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok so the setup function of the source is a ClientSetupOption, which is ran when the client is brought up right?

Copy link
Contributor

Choose a reason for hiding this comment

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

what really confuses me is that you're using the ClientSetupOption to setup the source. For me [T]Option fn in golang is a function that setups T, not that uses it... Maybe these setup functions should be run as "post client setup" functions?

@devguyio devguyio force-pushed the 3117-src-status-conf branch from d0efc76 to 87ebaf6 Compare July 22, 2020 06:45
@devguyio devguyio changed the title [WIP] Introduce component specific client options Add source status conformance test and run it for ApiServerSource Jul 22, 2020
@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 Jul 22, 2020
@devguyio
Copy link
Contributor Author

/retest

@knative-prow-robot knative-prow-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jul 22, 2020
@devguyio
Copy link
Contributor Author

/retest

@devguyio
Copy link
Contributor Author

/test pull-knative-eventing-unit-tests

@devguyio
Copy link
Contributor Author

/retest

1 similar comment
@devguyio
Copy link
Contributor Author

/retest

@devguyio
Copy link
Contributor Author

/retest

1 similar comment
@devguyio
Copy link
Contributor Author

/retest

@knative-prow-robot knative-prow-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 23, 2020
@aliok
Copy link
Member

aliok commented Jul 24, 2020

@devguyio do we want to merge this one and do the refactoring later or create the structure as per the discussions above?

@matzew
Copy link
Member

matzew commented Jul 24, 2020

@devguyio can you rebase ?

@devguyio devguyio force-pushed the 3117-src-status-conf branch from 8dd333a to 37e16e6 Compare July 24, 2020 14:01
@knative-prow-robot knative-prow-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 24, 2020
@devguyio
Copy link
Contributor Author

/retest

@devguyio
Copy link
Contributor Author

/retest

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

Let's move forward with this IMO and then we can refactor.

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

/lgtm
/approve

@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: aliok, devguyio, 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 Jul 27, 2020
@knative-test-reporter-robot

The following jobs failed:

Test name Triggers Retries
pull-knative-eventing-integration-tests 0/3

Failed non-flaky tests preventing automatic retry of pull-knative-eventing-integration-tests:

test/e2e.TestEventTransformationForTriggerV1BrokerV1
test/e2e.TestEventTransformationForTriggerV1BrokerV1/InMemoryChannel-messaging.knative.dev/v1
test/e2e.TestEventTransformationForTriggerV1Beta1BrokerV1/Channel-messaging.knative.dev/v1beta1

@pierDipi
Copy link
Member

Internal error occurred: failed calling webhook "webhook.eventing.knative.dev": Post https://eventing-webhook.knative-eventing-b7hnzjxjsb.svc:443/defaulting?timeout=2s: EOF

related: knative/pkg#1509
/retest

@devguyio
Copy link
Contributor Author

/uncc @yt3liu
/uncc @chizhg

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.

10 participants