-
Notifications
You must be signed in to change notification settings - Fork 44
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 conformance tests for service ports #78
Conversation
Hi @tpantelis. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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-sigs/prow repository. |
/cc @MrFreezeex |
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.
Looks good although I think the conformance port tests would need a bit more edge case test on for conflicting port but this can very well be in another PR (I can do it too if you want)
/lgtm
/ok-to-test
serviceImport := t.awaitServiceImport(&clients[0], t.helloService.Name, func(serviceImport *v1alpha1.ServiceImport) bool { | ||
return len(serviceImport.Spec.Ports) == 3 | ||
}) | ||
Expect(serviceImport).NotTo(BeNil(), "ServiceImport was not found") |
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.
This returns nil if the verification function fails, doesn’t it?
Expect(serviceImport).NotTo(BeNil(), "ServiceImport was not found") | |
Expect(serviceImport).NotTo(BeNil(), "ServiceImport was not found or did not have the expected number of ports") |
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.
awaitServiceImport
only returns nil if the ServiceImport
is not found. If the verification function isn't satisfied then awaitServiceImport
times out but still succeeds and returns the ServiceImport
, enabling more granular and exact assertions by the caller with richer descriptions and avoiding vaguer description as suggested above.
serviceImport := t.awaitServiceImport(&clients[0], t.helloService.Name, func(serviceImport *v1alpha1.ServiceImport) bool { | ||
return len(serviceImport.Spec.Ports) == len(t.helloService.Spec.Ports) | ||
}) | ||
Expect(serviceImport).NotTo(BeNil(), "ServiceImport was not found") |
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.
Same comment as above.
yeah I saw your comments on the related issue. They're good points but I'm not sure we need to get that granular with these tests. Perhaps it's sufficient to just handle a simple conflict scenario to verify the conflict policy is applied correctly and leave more detailed and/or edge cases to the testing on the implementation's side. |
Well the thing is that if you are not careful when you do the union of the ports on the implementation you are likely to construct a ServiceImport with invalid ports (meaning that the API will reject a similar Service with those ports). In a state where this is not handled you would probably only see this in error logs from your controller. So I do think that it's a good thing to have those in the conformance test in some way as it would ensure that those cases are handled properly by the implementers. |
...
yeah it's a fair point and discussion to have but that seems to be more of taking on the role of exhaustive E2E tests. I think we should keep the focus on MCS API/spec compliance/conformance. Validity of service ports and edge cases/caveats thereof is more core K8s and certainly can be mentioned in the MCS spec or at least linked to in core K8s docs. |
Well to me getting the controller to produce an invalid ServiceImport is a conformance problem. I don't think that the conformance tests should only tests the happy path/easy cases. And even past that if there are potential caveat that affect most implementations why not add it there too? It helps level up all the implementations by providing them cases that they didn't necessarily think of... |
Good points, although should we assume that what constitutes a valid clusterset Anyway, we can certainly add more tests to cover cases as you suggest to conform to the spec. But, right now, the spec only talks about conflicting port names, hence why I implemented that scenario in the tests. Perhaps we should first update the spec as to exactly what scenarios constitute a |
Well the KEP state explicitly that it should be the union so I believe Submariner won't be conformant in that sense to the current KEP :/.
Yes it's true that the KEP could be updated although to me this is almost common sense that the ports in ServiceImport should respect the ports rules of regular Services. If we want to keep a test very very generic it could not even test for conflict directly but just throws a few ports at it and tests that the resulting ports are valid (aka no duplicated name and no duplicated ports with the same port number and proto). |
Well, Submariner does expose the union as per the spec wrt the
Perhaps it is common sense but I was just going by the current spec. However it may not be common knowledge what the exact ports rules are for regular services. It sounds like you performed actual testing to find that out. I still think it would be useful to update the spec to make it clear exactly what constitutes a valid |
Yes I agree the rules are not common knowledge indeed! Here is the PR clarifying that: kubernetes/enhancements#4887 |
When a service is exported from two clusters, ensure the clusterset service exposes the union of service ports declared on its constituent services. Also if port properties don't match, ensure the conflict resolution policy is properly applied. Creation of K8s resources was refactored to functions rather than defined in global vars to allow the resources to be customized when created on multiple clusters. Fixes kubernetes-sigs#71 Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
36a1076
to
a7f3510
Compare
The |
/test pull-mcs-api-e2e |
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 |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: MrFreezeex, skitt, tpantelis 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 |
When a service is exported from two clusters, ensure the clusterset service exposes the union of service ports declared on its constituent services. Also if port properties don't match, ensure the conflict resolution policy is properly applied.
Creation of K8s resources was refactored to functions rather than defined in global vars to allow the resources to be customized when created on multiple clusters.
Fixes #71