@@ -37,20 +37,20 @@ import (
37
37
"github.com/onsi/gomega"
38
38
)
39
39
40
- func doPodResizeAdmissionPluginsTests (f * framework. Framework ) {
40
+ func doPodResizeAdmissionPluginsTests () {
41
41
testcases := []struct {
42
42
name string
43
- enableAdmissionPlugin func (ctx context.Context , f * framework.Framework , ns string )
43
+ enableAdmissionPlugin func (ctx context.Context , f * framework.Framework )
44
44
wantMemoryError string
45
45
wantCPUError string
46
46
}{
47
47
{
48
48
name : "pod-resize-resource-quota-test" ,
49
- enableAdmissionPlugin : func (ctx context.Context , f * framework.Framework , ns string ) {
49
+ enableAdmissionPlugin : func (ctx context.Context , f * framework.Framework ) {
50
50
resourceQuota := v1.ResourceQuota {
51
51
ObjectMeta : metav1.ObjectMeta {
52
52
Name : "resize-resource-quota" ,
53
- Namespace : ns ,
53
+ Namespace : f . Namespace . Name ,
54
54
},
55
55
Spec : v1.ResourceQuotaSpec {
56
56
Hard : v1.ResourceList {
@@ -61,19 +61,19 @@ func doPodResizeAdmissionPluginsTests(f *framework.Framework) {
61
61
}
62
62
63
63
ginkgo .By ("Creating a ResourceQuota" )
64
- _ , rqErr := f .ClientSet .CoreV1 ().ResourceQuotas (ns ).Create (ctx , & resourceQuota , metav1.CreateOptions {})
64
+ _ , rqErr := f .ClientSet .CoreV1 ().ResourceQuotas (f . Namespace . Name ).Create (ctx , & resourceQuota , metav1.CreateOptions {})
65
65
framework .ExpectNoError (rqErr , "failed to create resource quota" )
66
66
},
67
67
wantMemoryError : "exceeded quota: resize-resource-quota, requested: memory=350Mi, used: memory=700Mi, limited: memory=800Mi" ,
68
68
wantCPUError : "exceeded quota: resize-resource-quota, requested: cpu=200m, used: cpu=700m, limited: cpu=800m" ,
69
69
},
70
70
{
71
71
name : "pod-resize-limit-ranger-test" ,
72
- enableAdmissionPlugin : func (ctx context.Context , f * framework.Framework , ns string ) {
72
+ enableAdmissionPlugin : func (ctx context.Context , f * framework.Framework ) {
73
73
lr := v1.LimitRange {
74
74
ObjectMeta : metav1.ObjectMeta {
75
75
Name : "resize-limit-ranger" ,
76
- Namespace : ns ,
76
+ Namespace : f . Namespace . Name ,
77
77
},
78
78
Spec : v1.LimitRangeSpec {
79
79
Limits : []v1.LimitRangeItem {
@@ -101,7 +101,7 @@ func doPodResizeAdmissionPluginsTests(f *framework.Framework) {
101
101
}
102
102
103
103
ginkgo .By ("Creating a LimitRanger" )
104
- _ , lrErr := f .ClientSet .CoreV1 ().LimitRanges (ns ).Create (ctx , & lr , metav1.CreateOptions {})
104
+ _ , lrErr := f .ClientSet .CoreV1 ().LimitRanges (f . Namespace . Name ).Create (ctx , & lr , metav1.CreateOptions {})
105
105
framework .ExpectNoError (lrErr , "failed to create limit ranger" )
106
106
},
107
107
wantMemoryError : "forbidden: maximum memory usage per Container is 500Mi, but limit is 750Mi" ,
@@ -111,8 +111,7 @@ func doPodResizeAdmissionPluginsTests(f *framework.Framework) {
111
111
112
112
for _ , tc := range testcases {
113
113
ginkgo .It (tc .name , func (ctx context.Context ) {
114
- ns , err := f .CreateNamespace (ctx , tc .name , nil )
115
- framework .ExpectNoError (err , "failed creating Namespace" )
114
+ f := framework .NewDefaultFramework (tc .name )
116
115
117
116
containers := []e2epod.ResizableContainerInfo {
118
117
{
@@ -136,14 +135,14 @@ func doPodResizeAdmissionPluginsTests(f *framework.Framework) {
136
135
{"name":"c1", "resources":{"requests":{"cpu":"250m","memory":"750Mi"},"limits":{"cpu":"250m","memory":"750Mi"}}}
137
136
]}}`
138
137
139
- tc .enableAdmissionPlugin (ctx , f , ns . Name )
138
+ tc .enableAdmissionPlugin (ctx , f )
140
139
141
140
tStamp := strconv .Itoa (time .Now ().Nanosecond ())
142
141
e2epod .InitDefaultResizePolicy (containers )
143
142
e2epod .InitDefaultResizePolicy (expected )
144
- testPod1 := e2epod .MakePodWithResizableContainers (ns .Name , "testpod1" , tStamp , containers )
143
+ testPod1 := e2epod .MakePodWithResizableContainers (f . Namespace .Name , "testpod1" , tStamp , containers )
145
144
testPod1 = e2epod .MustMixinRestrictedPodSecurity (testPod1 )
146
- testPod2 := e2epod .MakePodWithResizableContainers (ns .Name , "testpod2" , tStamp , containers )
145
+ testPod2 := e2epod .MakePodWithResizableContainers (f . Namespace .Name , "testpod2" , tStamp , containers )
147
146
testPod2 = e2epod .MustMixinRestrictedPodSecurity (testPod2 )
148
147
149
148
ginkgo .By ("creating pods" )
@@ -189,12 +188,6 @@ func doPodResizeAdmissionPluginsTests(f *framework.Framework) {
189
188
framework .ExpectNoError (pErrEx1 , "failed to get pod post exceed CPU resize" )
190
189
e2epod .VerifyPodResources (patchedPodExceedCPU , expected )
191
190
framework .ExpectNoError (e2epod .VerifyPodStatusResources (patchedPodExceedMemory , expected ))
192
-
193
- ginkgo .By ("deleting pods" )
194
- delErr1 := e2epod .DeletePodWithWait (ctx , f .ClientSet , newPods [0 ])
195
- framework .ExpectNoError (delErr1 , "failed to delete pod %s" , newPods [0 ].Name )
196
- delErr2 := e2epod .DeletePodWithWait (ctx , f .ClientSet , newPods [1 ])
197
- framework .ExpectNoError (delErr2 , "failed to delete pod %s" , newPods [1 ].Name )
198
191
})
199
192
}
200
193
@@ -376,13 +369,13 @@ var _ = SIGDescribe(framework.WithSerial(), "Pod InPlace Resize Container (sched
376
369
})
377
370
378
371
var _ = SIGDescribe ("Pod InPlace Resize Container" , feature .InPlacePodVerticalScaling , func () {
379
- f := framework .NewDefaultFramework ("pod-resize-tests" )
380
372
ginkgo .BeforeEach (func (ctx context.Context ) {
373
+ f := framework .NewDefaultFramework ("pod-resize-tests" )
381
374
node , err := e2enode .GetRandomReadySchedulableNode (ctx , f .ClientSet )
382
375
framework .ExpectNoError (err )
383
376
if framework .NodeOSDistroIs ("windows" ) || e2enode .IsARM64 (node ) {
384
377
e2eskipper .Skipf ("runtime does not support InPlacePodVerticalScaling -- skipping" )
385
378
}
386
379
})
387
- doPodResizeAdmissionPluginsTests (f )
380
+ doPodResizeAdmissionPluginsTests ()
388
381
})
0 commit comments