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

Write e2e test for PodEphemeralcontainers endpoints + 2 Endpoints #117895

Merged
merged 1 commit into from May 18, 2023

Conversation

riaankleinhans
Copy link
Contributor

@riaankleinhans riaankleinhans commented May 9, 2023

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:

  • readCoreV1NamespacedPodEphemeralcontainers
  • replaceCoreV1NamespacedPodEphemeralcontainers

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?:

NONE

Release note:

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

NONE

/sig testing
/sig architecture
/area conformance

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. sig/testing Categorizes an issue or PR as relevant to SIG Testing. sig/architecture Categorizes an issue or PR as relevant to SIG Architecture. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. area/conformance Issues or PRs related to kubernetes conformance tests needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. area/test sig/node Categorizes an issue or PR as relevant to SIG Node. labels May 9, 2023
@riaankleinhans
Copy link
Contributor Author

/triage accepted
/cc @heyste

@k8s-ci-robot k8s-ci-robot requested a review from heyste May 9, 2023 22:47
@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels May 9, 2023
@riaankleinhans riaankleinhans added this to In Progress /Active Issues in conformance-definition May 9, 2023
@riaankleinhans riaankleinhans moved this from In Progress /Active Issues to PRs Needing Review in conformance-definition May 9, 2023
@heyste heyste force-pushed the create-ephemeralcontainer-test branch 2 times, most recently from 4d17cf0 to 297808e Compare May 10, 2023 01:22
@heyste
Copy link
Member

heyste commented May 10, 2023

/test pull-kubernetes-node-e2e-containerd
unrelated flake: e2e.go: Node Tests

I0510 01:47:44.252] Master not detected. Is the cluster up?
I0510 01:47:47.377] Dumping logs from nodes locally to '/workspace/_artifacts'
I0510 01:47:47.377] Detecting nodes in the cluster
I0510 01:47:47.377] No nodes found! 

@heyste
Copy link
Member

heyste commented May 10, 2023

/test pull-kubernetes-e2e-kind-ipv6
unrelated flake: [sig-node] Pods [It] should run through the lifecycle of Pods and PodStatus [Conformance]

  May 10 01:48:08.104: INFO: observed event type MODIFIED
  May 10 01:48:38.933: INFO: failed to see DELETED event: timed out waiting for the condition
  [FAILED] in [It] - test/e2e/common/node/pods.go:1070 @ 05/10/23 01:48:38.937
  May 10 01:48:38.937: INFO: Waiting up to 7m0s for all (but 0) nodes to be ready 

@bart0sh bart0sh added this to Triage in SIG Node PR Triage May 10, 2023
@bart0sh
Copy link
Contributor

bart0sh commented May 10, 2023

/priority important-longterm
/cc @pohly @dims

@k8s-ci-robot k8s-ci-robot requested review from dims and pohly May 10, 2023 09:43
@k8s-ci-robot k8s-ci-robot added priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. and removed needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels May 10, 2023
@dims
Copy link
Member

dims commented May 10, 2023

/approve

leaving /lgtm for @heyste

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 10, 2023
@dims
Copy link
Member

dims commented May 10, 2023

cc @verb @mrunalp @SergeyKanzhelev

@SergeyKanzhelev
Copy link
Member

/assign @rphillips

@SergeyKanzhelev SergeyKanzhelev moved this from Triage to PRs - Needs Reviewer in SIG Node CI/Test Board May 10, 2023
@riaankleinhans
Copy link
Contributor Author

Thank you for the reviews and the /approve.
We would appriciate a /lgtm from SIG Node folks.

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)
Copy link
Member

Choose a reason for hiding this comment

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

why %#v?

Copy link
Member

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)
Copy link
Member

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

Copy link
Member

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"},
Copy link
Member

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

Copy link
Member

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)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
framework.ExpectNoError(err, "Getting the pod %q ephemeralcontainers", verifyPod.Name)
framework.ExpectNoError(err, "Getting the pod's %q ephemeralcontainers", verifyPod.Name)

Copy link
Member

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")
Copy link
Member

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?

Copy link
Member

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

@heyste heyste force-pushed the create-ephemeralcontainer-test branch from 297808e to e347f42 Compare May 14, 2023 22:22

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)
Copy link
Member

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

Copy link
Member

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
@heyste heyste force-pushed the create-ephemeralcontainer-test branch from e347f42 to 45603ef Compare May 16, 2023 18:31
Copy link
Member

@SergeyKanzhelev SergeyKanzhelev left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 18, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 0afef0d865798c63283c81f3a6bc6317e2b5847a

@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit e3db923 into kubernetes:master May 18, 2023
13 checks passed
conformance-definition automation moved this from PRs Needing Review to Done May 18, 2023
SIG Node CI/Test Board automation moved this from PRs - Needs Reviewer to Done May 18, 2023
SIG Node PR Triage automation moved this from Needs Reviewer to Done May 18, 2023
@k8s-ci-robot k8s-ci-robot added this to the v1.28 milestone May 18, 2023
@riaankleinhans riaankleinhans moved this from Done to Promotion PRs Needing Two Weeks (flake free) in conformance-definition May 18, 2023
@riaankleinhans riaankleinhans moved this from Promotion PRs Needing Two Weeks (flake free) to Done in conformance-definition Jul 31, 2023
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/conformance Issues or PRs related to kubernetes conformance tests area/test cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. release-note-none Denotes a PR that doesn't merit a release note. sig/architecture Categorizes an issue or PR as relevant to SIG Architecture. sig/node Categorizes an issue or PR as relevant to SIG Node. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Development

Successfully merging this pull request may close these issues.

Write e2e test for PodEphemeralcontainers endpoints + 2 Endpoints
7 participants