mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 06:54:01 +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.
|
||||
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.
|
||||
|
@ -124,8 +124,7 @@ type containerPatch struct {
|
||||
|
||||
type patchSpec struct {
|
||||
Spec struct {
|
||||
Containers []containerPatch `json:"containers"`
|
||||
InitContainers []containerPatch `json:"initcontainers"`
|
||||
Containers []containerPatch `json:"containers"`
|
||||
} `json:"spec"`
|
||||
}
|
||||
|
||||
@ -186,24 +185,10 @@ func MakePodWithResizableContainers(ns, name, timeStamp string, tcInfo []Resizab
|
||||
|
||||
func VerifyPodResizePolicy(gotPod *v1.Pod, wantCtrs []ResizableContainerInfo) {
|
||||
ginkgo.GinkgoHelper()
|
||||
containers := gotPod.Spec.Containers
|
||||
if len(gotPod.Spec.InitContainers) != 0 {
|
||||
containers = append(containers, gotPod.Spec.InitContainers...)
|
||||
}
|
||||
gomega.Expect(gotPod.Spec.Containers).To(gomega.HaveLen(len(wantCtrs)), "number of containers in pod spec should match")
|
||||
|
||||
gomega.Expect(containers).To(gomega.HaveLen(len(wantCtrs)), "number of containers in pod spec should match")
|
||||
|
||||
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
|
||||
}
|
||||
for i, wantCtr := range wantCtrs {
|
||||
gotCtr := &gotPod.Spec.Containers[i]
|
||||
ctr := makeResizableContainer(wantCtr)
|
||||
gomega.Expect(gotCtr.Name).To(gomega.Equal(ctr.Name))
|
||||
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) {
|
||||
ginkgo.GinkgoHelper()
|
||||
containers := gotPod.Spec.Containers
|
||||
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")
|
||||
gomega.Expect(gotPod.Spec.Containers).To(gomega.HaveLen(len(wantCtrs)), "number of containers in pod spec should match")
|
||||
|
||||
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
|
||||
}
|
||||
for i, wantCtr := range wantCtrs {
|
||||
gotCtr := &gotPod.Spec.Containers[i]
|
||||
ctr := makeResizableContainer(wantCtr)
|
||||
gomega.Expect(gotCtr.Name).To(gomega.Equal(ctr.Name))
|
||||
gomega.Expect(gotCtr.Resources).To(gomega.Equal(ctr.Resources))
|
||||
@ -239,25 +211,13 @@ func VerifyPodStatusResources(gotPod *v1.Pod, wantCtrs []ResizableContainerInfo)
|
||||
ginkgo.GinkgoHelper()
|
||||
|
||||
var errs []error
|
||||
containerStatuses := gotPod.Status.ContainerStatuses
|
||||
if len(gotPod.Status.InitContainerStatuses) != 0 {
|
||||
containerStatuses = append(containerStatuses, gotPod.Status.InitContainerStatuses...)
|
||||
}
|
||||
if len(containerStatuses) != len(wantCtrs) {
|
||||
if len(gotPod.Status.ContainerStatuses) != len(wantCtrs) {
|
||||
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 {
|
||||
if wantCtr.IsRestartableInitCtr {
|
||||
gotCtrStatus = &gotPod.Status.InitContainerStatuses[initIdx]
|
||||
initIdx += 1
|
||||
} else {
|
||||
gotCtrStatus = &gotPod.Status.ContainerStatuses[idx]
|
||||
idx += 1
|
||||
}
|
||||
gotCtrStatus := &gotPod.Status.ContainerStatuses[i]
|
||||
ctr := makeResizableContainer(wantCtr)
|
||||
if 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{}
|
||||
containerStatuses := pod.Status.ContainerStatuses
|
||||
if len(pod.Status.InitContainerStatuses) != 0 {
|
||||
containerStatuses = append(containerStatuses, pod.Status.InitContainerStatuses...)
|
||||
}
|
||||
for _, cs := range containerStatuses {
|
||||
for _, cs := range pod.Status.ContainerStatuses {
|
||||
expectedRestarts := expectContainerRestarts[cs.Name]
|
||||
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))
|
||||
@ -416,11 +372,7 @@ func ResizeContainerPatch(containers []ResizableContainerInfo) (string, error) {
|
||||
cPatch.Resources.Requests.Memory = container.Resources.MemReq
|
||||
cPatch.Resources.Limits.CPU = container.Resources.CPULim
|
||||
cPatch.Resources.Limits.Memory = container.Resources.MemLim
|
||||
if container.IsRestartableInitCtr {
|
||||
patch.Spec.InitContainers = append(patch.Spec.InitContainers, cPatch)
|
||||
} else {
|
||||
patch.Spec.Containers = append(patch.Spec.Containers, cPatch)
|
||||
}
|
||||
patch.Spec.Containers = append(patch.Spec.Containers, cPatch)
|
||||
}
|
||||
|
||||
patchBytes, err := json.Marshal(patch)
|
||||
|
Loading…
Reference in New Issue
Block a user