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
Write e2e test for PodEphemeralcontainers endpoints + 2 Endpoints #117895
Write e2e test for PodEphemeralcontainers endpoints + 2 Endpoints #117895
Conversation
/triage accepted |
4d17cf0
to
297808e
Compare
/test pull-kubernetes-node-e2e-containerd
|
/test pull-kubernetes-e2e-kind-ipv6
|
/approve leaving |
/assign @rphillips |
Thank you for the reviews and the /approve. |
ginkgo.By(fmt.Sprintf("checking pod %q has only one ephemeralcontainer", pod.Name)) | ||
podResource := schema.GroupVersionResource{Group: "", Version: "v1", Resource: "pods"} | ||
unstruct, err := f.DynamicClient.Resource(podResource).Namespace(f.Namespace.Name).Get(ctx, "ephemeral-containers-target-pod", metav1.GetOptions{}, "ephemeralcontainers") | ||
framework.ExpectNoError(err, "can't get ephermalcontainers: %#v", err) |
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.
why %#v
?
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.
Personal preference. I find the "Go-syntax representation" helps me confirm the format/types being used. Based on the feedback below I've removed it.
_, err = podClient.UpdateEphemeralContainers(context.TODO(), pod.Name, podToUpdate, metav1.UpdateOptions{}) | ||
return err | ||
}) | ||
framework.ExpectNoError(err, "Failed to update status. %v", err) |
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.
no need to have err
in both - first parameter and string substitute. It will be written twice.
Also typically context message is about something was hepenning, not starting with "Failed". In this case it will be "updating ephemeral container" or sometjing like this
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.
Thanks for catching the issue with the message context. It was from another test I've done for status endpoints. Fixed.
Name: "test-container-1", | ||
Image: imageutils.GetE2EImage(imageutils.BusyBox), | ||
Command: []string{"/bin/sleep"}, | ||
Args: []string{"10000"}, |
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.
is it intended to be an infinity? Maybe use infinity
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 part of the test was taken from the e2e test "will start an ephemeral container in an existing pod" in the same file. I'm not sure why that figure was used. As this test now covers all of the ephemeral container endpoints the current thought is the above test could be removed after this test has been promoted to conformance.
unstruct, err = f.DynamicClient.Resource(podResource).Namespace(f.Namespace.Name).Get(ctx, "ephemeral-containers-target-pod", metav1.GetOptions{}, "ephemeralcontainers") | ||
framework.ExpectNoError(err, "can't get ephermalcontainers: %#v", err) | ||
verifyPod, err = unstructuredToPod(unstruct) | ||
framework.ExpectNoError(err, "Getting the pod %q ephemeralcontainers", verifyPod.Name) |
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.
framework.ExpectNoError(err, "Getting the pod %q ephemeralcontainers", verifyPod.Name) | |
framework.ExpectNoError(err, "Getting the pod's %q ephemeralcontainers", verifyPod.Name) |
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.
Updated this as well line 133
|
||
ginkgo.By(fmt.Sprintf("checking pod %q has only one ephemeralcontainer", pod.Name)) | ||
podResource := schema.GroupVersionResource{Group: "", Version: "v1", Resource: "pods"} | ||
unstruct, err := f.DynamicClient.Resource(podResource).Namespace(f.Namespace.Name).Get(ctx, "ephemeral-containers-target-pod", metav1.GetOptions{}, "ephemeralcontainers") |
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.
for my education, why dynamic client is used here?
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.
AFAIK, there isn't way to use the standard client-go to hit the readCoreV1NamespacedPodEphemeralcontainers
endpoint which is why I've used the dynamic client. There was a GetEphemeralContainers
method but that was removed from kubernetes/typed/core/v1/pod.go
297808e
to
e347f42
Compare
|
||
ginkgo.By(fmt.Sprintf("checking pod %q has only two ephemeralcontainers", pod.Name)) | ||
unstruct, err = f.DynamicClient.Resource(podResource).Namespace(f.Namespace.Name).Get(ctx, "ephemeral-containers-target-pod", metav1.GetOptions{}, "ephemeralcontainers") | ||
framework.ExpectNoError(err, "can't get ephermalcontainers: %#v", err) |
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.
no need to have err
as a first AND third argument here. It will be part of error by having it a first argument
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.
Fixed
e2e test validates the following 2 endpoints - readCoreV1NamespacedPodEphemeralcontainers - replaceCoreV1NamespacedPodEphemeralcontainers
e347f42
to
45603ef
Compare
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
LGTM label has been added. Git tree hash: 0afef0d865798c63283c81f3a6bc6317e2b5847a
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dims, Riaankl, SergeyKanzhelev 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 |
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
This PR adds a test to test the following untested endpoints:
Which issue(s) this PR fixes:
Fixes #117894
Testgrid Link:
Testgrid
Special notes for your reviewer:
Adds +2 endpoint test coverage (good for conformance)
Does this PR introduce a user-facing change?:
Release note:
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:
/sig testing
/sig architecture
/area conformance