promote HugePageStorageMediumSize to GA
This commit is contained in:
@@ -4113,9 +4113,8 @@ func TestValidateVolumes(t *testing.T) {
|
||||
|
||||
func TestHugePagesIsolation(t *testing.T) {
|
||||
testCases := map[string]struct {
|
||||
pod *core.Pod
|
||||
enableHugePageStorageMediumSize bool
|
||||
expectError bool
|
||||
pod *core.Pod
|
||||
expectError bool
|
||||
}{
|
||||
"Valid: request hugepages-2Mi": {
|
||||
pod: &core.Pod{
|
||||
@@ -4143,7 +4142,7 @@ func TestHugePagesIsolation(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
"Valid: HugePageStorageMediumSize enabled: request more than one hugepages size": {
|
||||
"Valid: request more than one hugepages size": {
|
||||
pod: &core.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "hugepages-shared", Namespace: "ns"},
|
||||
Spec: core.PodSpec{
|
||||
@@ -4170,10 +4169,9 @@ func TestHugePagesIsolation(t *testing.T) {
|
||||
DNSPolicy: core.DNSClusterFirst,
|
||||
},
|
||||
},
|
||||
enableHugePageStorageMediumSize: true,
|
||||
expectError: false,
|
||||
expectError: false,
|
||||
},
|
||||
"Invalid: HugePageStorageMediumSize disabled: request hugepages-1Gi, limit hugepages-2Mi and hugepages-1Gi": {
|
||||
"Valid: request hugepages-1Gi, limit hugepages-2Mi and hugepages-1Gi": {
|
||||
pod: &core.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "hugepages-multiple", Namespace: "ns"},
|
||||
Spec: core.PodSpec{
|
||||
@@ -4184,6 +4182,7 @@ func TestHugePagesIsolation(t *testing.T) {
|
||||
Requests: core.ResourceList{
|
||||
core.ResourceName(core.ResourceCPU): resource.MustParse("10"),
|
||||
core.ResourceName(core.ResourceMemory): resource.MustParse("10G"),
|
||||
core.ResourceName("hugepages-2Mi"): resource.MustParse("1Gi"),
|
||||
core.ResourceName("hugepages-1Gi"): resource.MustParse("2Gi"),
|
||||
},
|
||||
Limits: core.ResourceList{
|
||||
@@ -4199,7 +4198,6 @@ func TestHugePagesIsolation(t *testing.T) {
|
||||
DNSPolicy: core.DNSClusterFirst,
|
||||
},
|
||||
},
|
||||
expectError: true,
|
||||
},
|
||||
"Invalid: not requesting cpu and memory": {
|
||||
pod: &core.Pod{
|
||||
@@ -4251,40 +4249,10 @@ func TestHugePagesIsolation(t *testing.T) {
|
||||
},
|
||||
expectError: true,
|
||||
},
|
||||
"Invalid: HugePageStorageMediumSize disabled: request more than one hugepages size": {
|
||||
pod: &core.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "hugepages-shared", Namespace: "ns"},
|
||||
Spec: core.PodSpec{
|
||||
Containers: []core.Container{
|
||||
{
|
||||
Name: "ctr", Image: "image", ImagePullPolicy: "IfNotPresent", TerminationMessagePolicy: "File",
|
||||
Resources: core.ResourceRequirements{
|
||||
Requests: core.ResourceList{
|
||||
core.ResourceName(core.ResourceCPU): resource.MustParse("10"),
|
||||
core.ResourceName(core.ResourceMemory): resource.MustParse("10G"),
|
||||
core.ResourceName("hugepages-2Mi"): resource.MustParse("1Gi"),
|
||||
core.ResourceName("hugepages-1Gi"): resource.MustParse("1Gi"),
|
||||
},
|
||||
Limits: core.ResourceList{
|
||||
core.ResourceName(core.ResourceCPU): resource.MustParse("10"),
|
||||
core.ResourceName(core.ResourceMemory): resource.MustParse("10G"),
|
||||
core.ResourceName("hugepages-2Mi"): resource.MustParse("1Gi"),
|
||||
core.ResourceName("hugepages-1Gi"): resource.MustParse("1Gi"),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
RestartPolicy: core.RestartPolicyAlways,
|
||||
DNSPolicy: core.DNSClusterFirst,
|
||||
},
|
||||
},
|
||||
expectError: true,
|
||||
},
|
||||
}
|
||||
for tcName, tc := range testCases {
|
||||
t.Run(tcName, func(t *testing.T) {
|
||||
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.HugePageStorageMediumSize, tc.enableHugePageStorageMediumSize)()
|
||||
errs := ValidatePodCreate(tc.pod, PodValidationOptions{AllowMultipleHugePageResources: tc.enableHugePageStorageMediumSize})
|
||||
errs := ValidatePodCreate(tc.pod, PodValidationOptions{})
|
||||
if tc.expectError && len(errs) == 0 {
|
||||
t.Errorf("Unexpected success")
|
||||
}
|
||||
|
Reference in New Issue
Block a user