-
Notifications
You must be signed in to change notification settings - Fork 604
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
Add source status conformance test and run it for ApiServerSource #3605
Conversation
@slinkydeveloper check out the |
@@ -38,10 +44,11 @@ func TestMain(m *testing.M) { | |||
ComponentsToTest: test.EventingFlags.Channels, | |||
} | |||
sourcesTestRunner = testlib.ComponentsTestRunner{ | |||
ComponentFeatureMap: testlib.SourceFeatureMap, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kn conformance run ...
? Anyone?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
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]...) |
There was a problem hiding this comment.
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 😄
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
d0efc76
to
87ebaf6
Compare
/retest |
/retest |
/test pull-knative-eventing-unit-tests |
/retest |
1 similar comment
/retest |
/retest |
1 similar comment
/retest |
Signed-off-by: Ahmed Abdalla <aabdelre@redhat.com>
Signed-off-by: Ahmed Abdalla <aabdelre@redhat.com>
Signed-off-by: Ahmed Abdalla <aabdelre@redhat.com>
@devguyio do we want to merge this one and do the refactoring later or create the structure as per the discussions above? |
@devguyio can you rebase ? |
8dd333a
to
37e16e6
Compare
/retest |
/retest |
There was a problem hiding this 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.
/lgtm |
[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 |
The following jobs failed:
Failed non-flaky tests preventing automatic retry of pull-knative-eventing-integration-tests:
|
related: knative/pkg#1509 |
Proposed Changes