mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 02:41:25 +00:00
Move NewTestPod() to e2e/scheduling
because the function is called in e2e/scheduling tests.
This commit is contained in:
parent
0641e0c6d8
commit
d1361d10fe
@ -1583,27 +1583,6 @@ func DescribeIng(ns string) {
|
|||||||
Logf(desc)
|
Logf(desc)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewTestPod returns a pod that has the specified requests and limits
|
|
||||||
func (f *Framework) NewTestPod(name string, requests v1.ResourceList, limits v1.ResourceList) *v1.Pod {
|
|
||||||
return &v1.Pod{
|
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
|
||||||
Name: name,
|
|
||||||
},
|
|
||||||
Spec: v1.PodSpec{
|
|
||||||
Containers: []v1.Container{
|
|
||||||
{
|
|
||||||
Name: "pause",
|
|
||||||
Image: imageutils.GetPauseImageName(),
|
|
||||||
Resources: v1.ResourceRequirements{
|
|
||||||
Requests: requests,
|
|
||||||
Limits: limits,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewAgnhostPod returns a pod that uses the agnhost image. The image's binary supports various subcommands
|
// NewAgnhostPod returns a pod that uses the agnhost image. The image's binary supports various subcommands
|
||||||
// that behave the same, no matter the underlying OS.
|
// that behave the same, no matter the underlying OS.
|
||||||
func (f *Framework) NewAgnhostPod(name string, args ...string) *v1.Pod {
|
func (f *Framework) NewAgnhostPod(name string, args ...string) *v1.Pod {
|
||||||
|
@ -35,6 +35,7 @@ import (
|
|||||||
watchtools "k8s.io/client-go/tools/watch"
|
watchtools "k8s.io/client-go/tools/watch"
|
||||||
"k8s.io/kubernetes/test/e2e/framework"
|
"k8s.io/kubernetes/test/e2e/framework"
|
||||||
e2eservice "k8s.io/kubernetes/test/e2e/framework/service"
|
e2eservice "k8s.io/kubernetes/test/e2e/framework/service"
|
||||||
|
imageutils "k8s.io/kubernetes/test/utils/image"
|
||||||
|
|
||||||
"github.com/onsi/ginkgo"
|
"github.com/onsi/ginkgo"
|
||||||
"github.com/onsi/gomega"
|
"github.com/onsi/gomega"
|
||||||
@ -129,7 +130,7 @@ var _ = SIGDescribe("LimitRange", func() {
|
|||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
|
|
||||||
ginkgo.By("Creating a Pod with no resource requirements")
|
ginkgo.By("Creating a Pod with no resource requirements")
|
||||||
pod := f.NewTestPod("pod-no-resources", v1.ResourceList{}, v1.ResourceList{})
|
pod := newTestPod("pod-no-resources", v1.ResourceList{}, v1.ResourceList{})
|
||||||
pod, err = f.ClientSet.CoreV1().Pods(f.Namespace.Name).Create(context.TODO(), pod, metav1.CreateOptions{})
|
pod, err = f.ClientSet.CoreV1().Pods(f.Namespace.Name).Create(context.TODO(), pod, metav1.CreateOptions{})
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
|
|
||||||
@ -146,7 +147,7 @@ var _ = SIGDescribe("LimitRange", func() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ginkgo.By("Creating a Pod with partial resource requirements")
|
ginkgo.By("Creating a Pod with partial resource requirements")
|
||||||
pod = f.NewTestPod("pod-partial-resources", getResourceList("", "150Mi", "150Gi"), getResourceList("300m", "", ""))
|
pod = newTestPod("pod-partial-resources", getResourceList("", "150Mi", "150Gi"), getResourceList("300m", "", ""))
|
||||||
pod, err = f.ClientSet.CoreV1().Pods(f.Namespace.Name).Create(context.TODO(), pod, metav1.CreateOptions{})
|
pod, err = f.ClientSet.CoreV1().Pods(f.Namespace.Name).Create(context.TODO(), pod, metav1.CreateOptions{})
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
|
|
||||||
@ -167,12 +168,12 @@ var _ = SIGDescribe("LimitRange", func() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ginkgo.By("Failing to create a Pod with less than min resources")
|
ginkgo.By("Failing to create a Pod with less than min resources")
|
||||||
pod = f.NewTestPod(podName, getResourceList("10m", "50Mi", "50Gi"), v1.ResourceList{})
|
pod = newTestPod(podName, getResourceList("10m", "50Mi", "50Gi"), v1.ResourceList{})
|
||||||
_, err = f.ClientSet.CoreV1().Pods(f.Namespace.Name).Create(context.TODO(), pod, metav1.CreateOptions{})
|
_, err = f.ClientSet.CoreV1().Pods(f.Namespace.Name).Create(context.TODO(), pod, metav1.CreateOptions{})
|
||||||
framework.ExpectError(err)
|
framework.ExpectError(err)
|
||||||
|
|
||||||
ginkgo.By("Failing to create a Pod with more than max resources")
|
ginkgo.By("Failing to create a Pod with more than max resources")
|
||||||
pod = f.NewTestPod(podName, getResourceList("600m", "600Mi", "600Gi"), v1.ResourceList{})
|
pod = newTestPod(podName, getResourceList("600m", "600Mi", "600Gi"), v1.ResourceList{})
|
||||||
_, err = f.ClientSet.CoreV1().Pods(f.Namespace.Name).Create(context.TODO(), pod, metav1.CreateOptions{})
|
_, err = f.ClientSet.CoreV1().Pods(f.Namespace.Name).Create(context.TODO(), pod, metav1.CreateOptions{})
|
||||||
framework.ExpectError(err)
|
framework.ExpectError(err)
|
||||||
|
|
||||||
@ -191,12 +192,12 @@ var _ = SIGDescribe("LimitRange", func() {
|
|||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
|
|
||||||
ginkgo.By("Creating a Pod with less than former min resources")
|
ginkgo.By("Creating a Pod with less than former min resources")
|
||||||
pod = f.NewTestPod(podName, getResourceList("10m", "50Mi", "50Gi"), v1.ResourceList{})
|
pod = newTestPod(podName, getResourceList("10m", "50Mi", "50Gi"), v1.ResourceList{})
|
||||||
_, err = f.ClientSet.CoreV1().Pods(f.Namespace.Name).Create(context.TODO(), pod, metav1.CreateOptions{})
|
_, err = f.ClientSet.CoreV1().Pods(f.Namespace.Name).Create(context.TODO(), pod, metav1.CreateOptions{})
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
|
|
||||||
ginkgo.By("Failing to create a Pod with more than max resources")
|
ginkgo.By("Failing to create a Pod with more than max resources")
|
||||||
pod = f.NewTestPod(podName, getResourceList("600m", "600Mi", "600Gi"), v1.ResourceList{})
|
pod = newTestPod(podName, getResourceList("600m", "600Mi", "600Gi"), v1.ResourceList{})
|
||||||
_, err = f.ClientSet.CoreV1().Pods(f.Namespace.Name).Create(context.TODO(), pod, metav1.CreateOptions{})
|
_, err = f.ClientSet.CoreV1().Pods(f.Namespace.Name).Create(context.TODO(), pod, metav1.CreateOptions{})
|
||||||
framework.ExpectError(err)
|
framework.ExpectError(err)
|
||||||
|
|
||||||
@ -235,7 +236,7 @@ var _ = SIGDescribe("LimitRange", func() {
|
|||||||
framework.ExpectNoError(err, "kubelet never observed the termination notice")
|
framework.ExpectNoError(err, "kubelet never observed the termination notice")
|
||||||
|
|
||||||
ginkgo.By("Creating a Pod with more than former max resources")
|
ginkgo.By("Creating a Pod with more than former max resources")
|
||||||
pod = f.NewTestPod(podName+"2", getResourceList("600m", "600Mi", "600Gi"), v1.ResourceList{})
|
pod = newTestPod(podName+"2", getResourceList("600m", "600Mi", "600Gi"), v1.ResourceList{})
|
||||||
_, err = f.ClientSet.CoreV1().Pods(f.Namespace.Name).Create(context.TODO(), pod, metav1.CreateOptions{})
|
_, err = f.ClientSet.CoreV1().Pods(f.Namespace.Name).Create(context.TODO(), pod, metav1.CreateOptions{})
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
})
|
})
|
||||||
@ -307,3 +308,24 @@ func newLimitRange(name, value string, limitType v1.LimitType,
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// newTestPod returns a pod that has the specified requests and limits
|
||||||
|
func newTestPod(name string, requests v1.ResourceList, limits v1.ResourceList) *v1.Pod {
|
||||||
|
return &v1.Pod{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: name,
|
||||||
|
},
|
||||||
|
Spec: v1.PodSpec{
|
||||||
|
Containers: []v1.Container{
|
||||||
|
{
|
||||||
|
Name: "pause",
|
||||||
|
Image: imageutils.GetPauseImageName(),
|
||||||
|
Resources: v1.ResourceRequirements{
|
||||||
|
Requests: requests,
|
||||||
|
Limits: limits,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user