-
Notifications
You must be signed in to change notification settings - Fork 5k
Update service tests to use discoveryv1.EndpointSlice instead of deprecated core.Endpoints #20679
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
base: master
Are you sure you want to change the base?
Conversation
discoveryv1.EndpointSlice instead of deprecated core.Endpoints This PR addresses the deprecation warnings for core.Endpoints which is deprecated in Kubernetes v1.33+ in favor of discoveryv1.EndpointSlice. Changes: - Replaced all core.Endpoints references with discoveryv1.EndpointSlice - Updated mock interfaces and test data structures to use the new API - Maintained all existing test functionality and assertions - No behavioral changes - just API modernization Fixes kubernetes#20677
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Victorthedev The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Welcome @Victorthedev! |
Hi @Victorthedev. Thanks for your PR. I'm waiting for a kubernetes 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. |
Can one of the admins verify this patch? |
/ok-to-test |
This comment has been minimized.
This comment has been minimized.
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.
@Victorthedev thank you for this PR, do you mind fixing the lint issue ?
you can run "make lint" to see the errors
pkg/minikube/service/service.go:1: : # k8s.io/minikube/pkg/minikube/service [k8s.io/minikube/pkg/minikube/service.test]
Error: pkg/minikube/service/service_test.go:191:9: cannot use &MockDiscoveryV1Interface{…} (value of type *MockDiscoveryV1Interface) as "k8s.io/client-go/kubernetes/typed/discovery/v1".DiscoveryV1Interface value in return statement: *MockDiscoveryV1Interface does not implement "k8s.io/client-go/kubernetes/typed/discovery/v1".DiscoveryV1Interface (wrong type for method RESTClient)
have RESTClient() interface{}
want RESTClient() "k8s.io/client-go/rest".Interface
Error: pkg/minikube/service/service_test.go:339:3: unknown field endpointsMap in struct literal of type MockCoreClient
Error: pkg/minikube/service/service_test.go:339:17: undefined: endpointNamespaces
Error: pkg/minikube/service/service_test.go:5[14](https://github.com/kubernetes/minikube/actions/runs/14724184141/job/41444930650?pr=20679#step:6:15):5: unknown field endpointsMap in struct literal of type MockClientGetter
Error: pkg/minikube/service/service_test.go:514:19: undefined: endpointNamespaces
Error: pkg/minikube/service/service_test.go:582:5: unknown field endpointsMap in struct literal of type MockClientGetter
Error: pkg/minikube/service/service_test.go:582:19: undefined: endpointNamespaces
Error: pkg/minikube/service/service_test.go:719:5: unknown field endpointsMap in struct literal of type MockClientGetter
Error: pkg/minikube/service/service_test.go:719:19: undefined: endpointNamespaces
Error: pkg/minikube/service/service_test.go:769:19: undefined: endpointNamespaces
Error: pkg/minikube/service/service_test.go:769:[19](https://github.com/kubernetes/minikube/actions/runs/14724184141/job/41444930650?pr=20679#step:6:20): too many errors (typecheck)
@medyagh on it! |
- make lint now runs without error
…lient initialization This commit addresses a series of nil pointer dereference panics in the test suite for pkg/minikube/service, ensuring all tests pass reliably. The changes focus on improving the initialization of mock Kubernetes clients to prevent nil pointer dereferences in the fake client's `Invokes` method. The fixes include: 1. **TestPrintURLsForService/throw_error_without_template Panic**: - Issue: A panic occurred due to an uninitialized `FakeCoreV1` field in `MockCoreClient`, causing a nil pointer dereference when `Services().Get` was called. - Fix: Initialized `FakeCoreV1` with `Fake: &testing_fake.Fake{}` in the `TestPrintURLsForService` setup, ensuring the fake client is properly configured. 2. **TestGetServiceURLs/correctly_return_serviceURLs Panic**: - Issue: A similar panic occurred in `GetServiceURLs` due to the `FakeCoreV1` field not being initialized in `MockCoreClient` returned by `MockClientGetter`. - Fix: Updated `MockClientGetter.GetCoreClient` to initialize `FakeCoreV1` with `Fake: &testing_fake.Fake{}`, ensuring all tests using `MockClientGetter` have a properly initialized client. 3. **TestDeleteSecret/ok Panic**: - Issue: A panic occurred in `DeleteSecret` when calling `secrets.Delete` for the `foo` namespace, as `secretsNamespaces` lacked an entry for `foo`, returning a nil interface. - Fix: Added a `MockSecretInterface` for the `foo` namespace to `secretsNamespaces`, ensuring `client.Secrets("foo")` returns a valid interface. Updated `initializeMockObjects` to verify the `Fake` field for the new entry. Additional improvements: - Ensured `initializeMockObjects` consistently initializes `Fake` fields across all mock interfaces (`serviceNamespaces`, `serviceNamespaceOther`, `endpointSliceNamespaces`, and `secretsNamespaces`). - Verified that all test setups align with mock configurations, preventing similar issues in other tests (e.g., `TestCreateSecret`, `TestWaitAndMaybeOpenService`). - Confirmed no linting issues with `make lint` and validated all tests pass with `go test -v ./pkg/minikube/service/...`.
Keywords which can automatically close issues and at(@) or hashtag(#) mentions are not allowed in commit messages. The list of commits with invalid commit messages:
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. I understand the commands that are listed here. |
@medyagh fixed the lint issue and nil pointer dereference panics in the test suite for pkg/minikube/service |
kvm2 driver with docker runtime
Times for minikube start: 56.0s 54.3s 54.9s 53.2s 54.1s Times for minikube ingress: 18.7s 19.1s 20.7s 20.1s 19.2s docker driver with docker runtime
Times for minikube start: 26.5s 24.3s 24.1s 26.6s 26.8s Times for minikube ingress: 12.4s 13.4s 13.4s 13.4s 13.4s docker driver with containerd runtime
Times for minikube start: 22.2s 26.4s 23.0s 22.5s 22.9s Times for minikube ingress: 22.9s 22.9s 22.8s 23.9s 22.9s |
This PR addresses the deprecation warnings for core.Endpoints which is deprecated in Kubernetes v1.33+ in favor of discoveryv1.EndpointSlice.
Changes:
Fixes #20677