mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 17:30:00 +00:00
Revert e2e tests added for sidecar
This commit is contained in:
parent
3885d2f8ab
commit
5d5e903e27
@ -271,21 +271,6 @@ func (c *PodClient) mungeSpec(pod *v1.Pod) {
|
|||||||
// been prepulled.
|
// been prepulled.
|
||||||
c.ImagePullPolicy = v1.PullNever
|
c.ImagePullPolicy = v1.PullNever
|
||||||
}
|
}
|
||||||
for i := range pod.Spec.InitContainers {
|
|
||||||
c := &pod.Spec.InitContainers[i]
|
|
||||||
if c.ImagePullPolicy == v1.PullAlways {
|
|
||||||
// If the image pull policy is PullAlways, the image doesn't need to be in
|
|
||||||
// the allow list or pre-pulled, because the image is expected to be pulled
|
|
||||||
// in the test anyway.
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
// If the image policy is not PullAlways, the image must be in the pre-pull list and
|
|
||||||
// pre-pulled.
|
|
||||||
gomega.Expect(ImagePrePullList.Has(c.Image)).To(gomega.BeTrueBecause("Image %q is not in the pre-pull list, consider adding it to PrePulledImages in test/e2e/common/util.go or NodePrePullImageList in test/e2e_node/image_list.go", c.Image))
|
|
||||||
// Do not pull images during the tests because the images in pre-pull list should have
|
|
||||||
// been prepulled.
|
|
||||||
c.ImagePullPolicy = v1.PullNever
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// WaitForSuccess waits for pod to succeed.
|
// WaitForSuccess waits for pod to succeed.
|
||||||
|
@ -124,8 +124,7 @@ type containerPatch struct {
|
|||||||
|
|
||||||
type patchSpec struct {
|
type patchSpec struct {
|
||||||
Spec struct {
|
Spec struct {
|
||||||
Containers []containerPatch `json:"containers"`
|
Containers []containerPatch `json:"containers"`
|
||||||
InitContainers []containerPatch `json:"initcontainers"`
|
|
||||||
} `json:"spec"`
|
} `json:"spec"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,24 +185,10 @@ func MakePodWithResizableContainers(ns, name, timeStamp string, tcInfo []Resizab
|
|||||||
|
|
||||||
func VerifyPodResizePolicy(gotPod *v1.Pod, wantCtrs []ResizableContainerInfo) {
|
func VerifyPodResizePolicy(gotPod *v1.Pod, wantCtrs []ResizableContainerInfo) {
|
||||||
ginkgo.GinkgoHelper()
|
ginkgo.GinkgoHelper()
|
||||||
containers := gotPod.Spec.Containers
|
gomega.Expect(gotPod.Spec.Containers).To(gomega.HaveLen(len(wantCtrs)), "number of containers in pod spec should match")
|
||||||
if len(gotPod.Spec.InitContainers) != 0 {
|
|
||||||
containers = append(containers, gotPod.Spec.InitContainers...)
|
|
||||||
}
|
|
||||||
|
|
||||||
gomega.Expect(containers).To(gomega.HaveLen(len(wantCtrs)), "number of containers in pod spec should match")
|
for i, wantCtr := range wantCtrs {
|
||||||
|
gotCtr := &gotPod.Spec.Containers[i]
|
||||||
idx, initIdx := 0, 0
|
|
||||||
var gotCtr *v1.Container
|
|
||||||
|
|
||||||
for _, wantCtr := range wantCtrs {
|
|
||||||
if wantCtr.IsRestartableInitCtr {
|
|
||||||
gotCtr = &gotPod.Spec.InitContainers[initIdx]
|
|
||||||
initIdx += 1
|
|
||||||
} else {
|
|
||||||
gotCtr = &gotPod.Spec.Containers[idx]
|
|
||||||
idx += 1
|
|
||||||
}
|
|
||||||
ctr := makeResizableContainer(wantCtr)
|
ctr := makeResizableContainer(wantCtr)
|
||||||
gomega.Expect(gotCtr.Name).To(gomega.Equal(ctr.Name))
|
gomega.Expect(gotCtr.Name).To(gomega.Equal(ctr.Name))
|
||||||
gomega.Expect(gotCtr.ResizePolicy).To(gomega.Equal(ctr.ResizePolicy))
|
gomega.Expect(gotCtr.ResizePolicy).To(gomega.Equal(ctr.ResizePolicy))
|
||||||
@ -212,23 +197,10 @@ func VerifyPodResizePolicy(gotPod *v1.Pod, wantCtrs []ResizableContainerInfo) {
|
|||||||
|
|
||||||
func VerifyPodResources(gotPod *v1.Pod, wantCtrs []ResizableContainerInfo) {
|
func VerifyPodResources(gotPod *v1.Pod, wantCtrs []ResizableContainerInfo) {
|
||||||
ginkgo.GinkgoHelper()
|
ginkgo.GinkgoHelper()
|
||||||
containers := gotPod.Spec.Containers
|
gomega.Expect(gotPod.Spec.Containers).To(gomega.HaveLen(len(wantCtrs)), "number of containers in pod spec should match")
|
||||||
if len(gotPod.Spec.InitContainers) != 0 {
|
|
||||||
containers = append(containers, gotPod.Spec.InitContainers...)
|
|
||||||
}
|
|
||||||
gomega.Expect(containers).To(gomega.HaveLen(len(wantCtrs)), "number of containers in pod spec should match")
|
|
||||||
|
|
||||||
idx, initIdx := 0, 0
|
for i, wantCtr := range wantCtrs {
|
||||||
var gotCtr *v1.Container
|
gotCtr := &gotPod.Spec.Containers[i]
|
||||||
|
|
||||||
for _, wantCtr := range wantCtrs {
|
|
||||||
if wantCtr.IsRestartableInitCtr {
|
|
||||||
gotCtr = &gotPod.Spec.InitContainers[initIdx]
|
|
||||||
initIdx += 1
|
|
||||||
} else {
|
|
||||||
gotCtr = &gotPod.Spec.Containers[idx]
|
|
||||||
idx += 1
|
|
||||||
}
|
|
||||||
ctr := makeResizableContainer(wantCtr)
|
ctr := makeResizableContainer(wantCtr)
|
||||||
gomega.Expect(gotCtr.Name).To(gomega.Equal(ctr.Name))
|
gomega.Expect(gotCtr.Name).To(gomega.Equal(ctr.Name))
|
||||||
gomega.Expect(gotCtr.Resources).To(gomega.Equal(ctr.Resources))
|
gomega.Expect(gotCtr.Resources).To(gomega.Equal(ctr.Resources))
|
||||||
@ -239,25 +211,13 @@ func VerifyPodStatusResources(gotPod *v1.Pod, wantCtrs []ResizableContainerInfo)
|
|||||||
ginkgo.GinkgoHelper()
|
ginkgo.GinkgoHelper()
|
||||||
|
|
||||||
var errs []error
|
var errs []error
|
||||||
containerStatuses := gotPod.Status.ContainerStatuses
|
if len(gotPod.Status.ContainerStatuses) != len(wantCtrs) {
|
||||||
if len(gotPod.Status.InitContainerStatuses) != 0 {
|
|
||||||
containerStatuses = append(containerStatuses, gotPod.Status.InitContainerStatuses...)
|
|
||||||
}
|
|
||||||
if len(containerStatuses) != len(wantCtrs) {
|
|
||||||
return fmt.Errorf("expectation length mismatch: got %d statuses, want %d",
|
return fmt.Errorf("expectation length mismatch: got %d statuses, want %d",
|
||||||
len(containerStatuses), len(wantCtrs))
|
len(gotPod.Status.ContainerStatuses), len(wantCtrs))
|
||||||
}
|
}
|
||||||
|
|
||||||
idx, initIdx := 0, 0
|
|
||||||
var gotCtrStatus *v1.ContainerStatus
|
|
||||||
for i, wantCtr := range wantCtrs {
|
for i, wantCtr := range wantCtrs {
|
||||||
if wantCtr.IsRestartableInitCtr {
|
gotCtrStatus := &gotPod.Status.ContainerStatuses[i]
|
||||||
gotCtrStatus = &gotPod.Status.InitContainerStatuses[initIdx]
|
|
||||||
initIdx += 1
|
|
||||||
} else {
|
|
||||||
gotCtrStatus = &gotPod.Status.ContainerStatuses[idx]
|
|
||||||
idx += 1
|
|
||||||
}
|
|
||||||
ctr := makeResizableContainer(wantCtr)
|
ctr := makeResizableContainer(wantCtr)
|
||||||
if gotCtrStatus.Name != ctr.Name {
|
if gotCtrStatus.Name != ctr.Name {
|
||||||
errs = append(errs, fmt.Errorf("container status %d name %q != expected name %q", i, gotCtrStatus.Name, ctr.Name))
|
errs = append(errs, fmt.Errorf("container status %d name %q != expected name %q", i, gotCtrStatus.Name, ctr.Name))
|
||||||
@ -340,11 +300,7 @@ func verifyContainerRestarts(pod *v1.Pod, expectedContainers []ResizableContaine
|
|||||||
}
|
}
|
||||||
|
|
||||||
errs := []error{}
|
errs := []error{}
|
||||||
containerStatuses := pod.Status.ContainerStatuses
|
for _, cs := range pod.Status.ContainerStatuses {
|
||||||
if len(pod.Status.InitContainerStatuses) != 0 {
|
|
||||||
containerStatuses = append(containerStatuses, pod.Status.InitContainerStatuses...)
|
|
||||||
}
|
|
||||||
for _, cs := range containerStatuses {
|
|
||||||
expectedRestarts := expectContainerRestarts[cs.Name]
|
expectedRestarts := expectContainerRestarts[cs.Name]
|
||||||
if cs.RestartCount != expectedRestarts {
|
if cs.RestartCount != expectedRestarts {
|
||||||
errs = append(errs, fmt.Errorf("unexpected number of restarts for container %s: got %d, want %d", cs.Name, cs.RestartCount, expectedRestarts))
|
errs = append(errs, fmt.Errorf("unexpected number of restarts for container %s: got %d, want %d", cs.Name, cs.RestartCount, expectedRestarts))
|
||||||
@ -416,11 +372,7 @@ func ResizeContainerPatch(containers []ResizableContainerInfo) (string, error) {
|
|||||||
cPatch.Resources.Requests.Memory = container.Resources.MemReq
|
cPatch.Resources.Requests.Memory = container.Resources.MemReq
|
||||||
cPatch.Resources.Limits.CPU = container.Resources.CPULim
|
cPatch.Resources.Limits.CPU = container.Resources.CPULim
|
||||||
cPatch.Resources.Limits.Memory = container.Resources.MemLim
|
cPatch.Resources.Limits.Memory = container.Resources.MemLim
|
||||||
if container.IsRestartableInitCtr {
|
patch.Spec.Containers = append(patch.Spec.Containers, cPatch)
|
||||||
patch.Spec.InitContainers = append(patch.Spec.InitContainers, cPatch)
|
|
||||||
} else {
|
|
||||||
patch.Spec.Containers = append(patch.Spec.Containers, cPatch)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
patchBytes, err := json.Marshal(patch)
|
patchBytes, err := json.Marshal(patch)
|
||||||
|
Loading…
Reference in New Issue
Block a user