@@ -30,8 +30,8 @@ import (
30
30
"k8s.io/kubernetes/test/e2e/framework"
31
31
e2elog "k8s.io/kubernetes/test/e2e/framework/log"
32
32
33
- . "github.com/onsi/ginkgo"
34
- . "github.com/onsi/gomega"
33
+ "github.com/onsi/ginkgo"
34
+ "github.com/onsi/gomega"
35
35
)
36
36
37
37
const (
@@ -41,8 +41,8 @@ const (
41
41
var _ = SIGDescribe ("LimitRange" , func () {
42
42
f := framework .NewDefaultFramework ("limitrange" )
43
43
44
- It ("should create a LimitRange with defaults and ensure pod has those defaults applied." , func () {
45
- By ("Creating a LimitRange" )
44
+ ginkgo . It ("should create a LimitRange with defaults and ensure pod has those defaults applied." , func () {
45
+ ginkgo . By ("Creating a LimitRange" )
46
46
47
47
min := getResourceList ("50m" , "100Mi" , "100Gi" )
48
48
max := getResourceList ("500m" , "500Mi" , "500Gi" )
@@ -54,24 +54,24 @@ var _ = SIGDescribe("LimitRange", func() {
54
54
defaultLimit , defaultRequest ,
55
55
maxLimitRequestRatio )
56
56
57
- By ("Setting up watch" )
57
+ ginkgo . By ("Setting up watch" )
58
58
selector := labels .SelectorFromSet (labels .Set (map [string ]string {"name" : limitRange .Name }))
59
59
options := metav1.ListOptions {LabelSelector : selector .String ()}
60
60
limitRanges , err := f .ClientSet .CoreV1 ().LimitRanges (f .Namespace .Name ).List (options )
61
- Expect (err ).NotTo (HaveOccurred (), "failed to query for limitRanges" )
62
- Expect (len (limitRanges .Items )).To (Equal (0 ))
61
+ gomega . Expect (err ).NotTo (gomega . HaveOccurred (), "failed to query for limitRanges" )
62
+ gomega . Expect (len (limitRanges .Items )).To (gomega . Equal (0 ))
63
63
options = metav1.ListOptions {
64
64
LabelSelector : selector .String (),
65
65
ResourceVersion : limitRanges .ListMeta .ResourceVersion ,
66
66
}
67
67
w , err := f .ClientSet .CoreV1 ().LimitRanges (f .Namespace .Name ).Watch (metav1.ListOptions {})
68
- Expect (err ).NotTo (HaveOccurred (), "failed to set up watch" )
68
+ gomega . Expect (err ).NotTo (gomega . HaveOccurred (), "failed to set up watch" )
69
69
70
- By ("Submitting a LimitRange" )
70
+ ginkgo . By ("Submitting a LimitRange" )
71
71
limitRange , err = f .ClientSet .CoreV1 ().LimitRanges (f .Namespace .Name ).Create (limitRange )
72
- Expect (err ).NotTo (HaveOccurred ())
72
+ gomega . Expect (err ).NotTo (gomega . HaveOccurred ())
73
73
74
- By ("Verifying LimitRange creation was observed" )
74
+ ginkgo . By ("Verifying LimitRange creation was observed" )
75
75
select {
76
76
case event , _ := <- w .ResultChan ():
77
77
if event .Type != watch .Added {
@@ -81,39 +81,39 @@ var _ = SIGDescribe("LimitRange", func() {
81
81
framework .Failf ("Timeout while waiting for LimitRange creation" )
82
82
}
83
83
84
- By ("Fetching the LimitRange to ensure it has proper values" )
84
+ ginkgo . By ("Fetching the LimitRange to ensure it has proper values" )
85
85
limitRange , err = f .ClientSet .CoreV1 ().LimitRanges (f .Namespace .Name ).Get (limitRange .Name , metav1.GetOptions {})
86
- Expect (err ).NotTo (HaveOccurred ())
86
+ gomega . Expect (err ).NotTo (gomega . HaveOccurred ())
87
87
expected := v1.ResourceRequirements {Requests : defaultRequest , Limits : defaultLimit }
88
88
actual := v1.ResourceRequirements {Requests : limitRange .Spec .Limits [0 ].DefaultRequest , Limits : limitRange .Spec .Limits [0 ].Default }
89
89
err = equalResourceRequirement (expected , actual )
90
- Expect (err ).NotTo (HaveOccurred ())
90
+ gomega . Expect (err ).NotTo (gomega . HaveOccurred ())
91
91
92
- By ("Creating a Pod with no resource requirements" )
92
+ ginkgo . By ("Creating a Pod with no resource requirements" )
93
93
pod := f .NewTestPod ("pod-no-resources" , v1.ResourceList {}, v1.ResourceList {})
94
94
pod , err = f .ClientSet .CoreV1 ().Pods (f .Namespace .Name ).Create (pod )
95
- Expect (err ).NotTo (HaveOccurred ())
95
+ gomega . Expect (err ).NotTo (gomega . HaveOccurred ())
96
96
97
- By ("Ensuring Pod has resource requirements applied from LimitRange" )
97
+ ginkgo . By ("Ensuring Pod has resource requirements applied from LimitRange" )
98
98
pod , err = f .ClientSet .CoreV1 ().Pods (f .Namespace .Name ).Get (pod .Name , metav1.GetOptions {})
99
- Expect (err ).NotTo (HaveOccurred ())
99
+ gomega . Expect (err ).NotTo (gomega . HaveOccurred ())
100
100
for i := range pod .Spec .Containers {
101
101
err = equalResourceRequirement (expected , pod .Spec .Containers [i ].Resources )
102
102
if err != nil {
103
103
// Print the pod to help in debugging.
104
104
e2elog .Logf ("Pod %+v does not have the expected requirements" , pod )
105
- Expect (err ).NotTo (HaveOccurred ())
105
+ gomega . Expect (err ).NotTo (gomega . HaveOccurred ())
106
106
}
107
107
}
108
108
109
- By ("Creating a Pod with partial resource requirements" )
109
+ ginkgo . By ("Creating a Pod with partial resource requirements" )
110
110
pod = f .NewTestPod ("pod-partial-resources" , getResourceList ("" , "150Mi" , "150Gi" ), getResourceList ("300m" , "" , "" ))
111
111
pod , err = f .ClientSet .CoreV1 ().Pods (f .Namespace .Name ).Create (pod )
112
- Expect (err ).NotTo (HaveOccurred ())
112
+ gomega . Expect (err ).NotTo (gomega . HaveOccurred ())
113
113
114
- By ("Ensuring Pod has merged resource requirements applied from LimitRange" )
114
+ ginkgo . By ("Ensuring Pod has merged resource requirements applied from LimitRange" )
115
115
pod , err = f .ClientSet .CoreV1 ().Pods (f .Namespace .Name ).Get (pod .Name , metav1.GetOptions {})
116
- Expect (err ).NotTo (HaveOccurred ())
116
+ gomega . Expect (err ).NotTo (gomega . HaveOccurred ())
117
117
// This is an interesting case, so it's worth a comment
118
118
// If you specify a Limit, and no Request, the Limit will default to the Request
119
119
// This means that the LimitRange.DefaultRequest will ONLY take affect if a container.resources.limit is not supplied
@@ -123,49 +123,49 @@ var _ = SIGDescribe("LimitRange", func() {
123
123
if err != nil {
124
124
// Print the pod to help in debugging.
125
125
e2elog .Logf ("Pod %+v does not have the expected requirements" , pod )
126
- Expect (err ).NotTo (HaveOccurred ())
126
+ gomega . Expect (err ).NotTo (gomega . HaveOccurred ())
127
127
}
128
128
}
129
129
130
- By ("Failing to create a Pod with less than min resources" )
130
+ ginkgo . By ("Failing to create a Pod with less than min resources" )
131
131
pod = f .NewTestPod (podName , getResourceList ("10m" , "50Mi" , "50Gi" ), v1.ResourceList {})
132
132
pod , err = f .ClientSet .CoreV1 ().Pods (f .Namespace .Name ).Create (pod )
133
- Expect ( err ). To ( HaveOccurred () )
133
+ framework . ExpectError ( err )
134
134
135
- By ("Failing to create a Pod with more than max resources" )
135
+ ginkgo . By ("Failing to create a Pod with more than max resources" )
136
136
pod = f .NewTestPod (podName , getResourceList ("600m" , "600Mi" , "600Gi" ), v1.ResourceList {})
137
137
pod , err = f .ClientSet .CoreV1 ().Pods (f .Namespace .Name ).Create (pod )
138
- Expect ( err ). To ( HaveOccurred () )
138
+ framework . ExpectError ( err )
139
139
140
- By ("Updating a LimitRange" )
140
+ ginkgo . By ("Updating a LimitRange" )
141
141
newMin := getResourceList ("9m" , "49Mi" , "49Gi" )
142
142
limitRange .Spec .Limits [0 ].Min = newMin
143
143
limitRange , err = f .ClientSet .CoreV1 ().LimitRanges (f .Namespace .Name ).Update (limitRange )
144
- Expect (err ).NotTo (HaveOccurred ())
144
+ gomega . Expect (err ).NotTo (gomega . HaveOccurred ())
145
145
146
- By ("Verifying LimitRange updating is effective" )
147
- Expect (wait .Poll (time .Second * 2 , time .Second * 20 , func () (bool , error ) {
146
+ ginkgo . By ("Verifying LimitRange updating is effective" )
147
+ gomega . Expect (wait .Poll (time .Second * 2 , time .Second * 20 , func () (bool , error ) {
148
148
limitRange , err = f .ClientSet .CoreV1 ().LimitRanges (f .Namespace .Name ).Get (limitRange .Name , metav1.GetOptions {})
149
- Expect (err ).NotTo (HaveOccurred ())
149
+ gomega . Expect (err ).NotTo (gomega . HaveOccurred ())
150
150
return reflect .DeepEqual (limitRange .Spec .Limits [0 ].Min , newMin ), nil
151
- })).NotTo (HaveOccurred ())
151
+ })).NotTo (gomega . HaveOccurred ())
152
152
153
- By ("Creating a Pod with less than former min resources" )
153
+ ginkgo . By ("Creating a Pod with less than former min resources" )
154
154
pod = f .NewTestPod (podName , getResourceList ("10m" , "50Mi" , "50Gi" ), v1.ResourceList {})
155
155
pod , err = f .ClientSet .CoreV1 ().Pods (f .Namespace .Name ).Create (pod )
156
- Expect (err ).NotTo (HaveOccurred ())
156
+ gomega . Expect (err ).NotTo (gomega . HaveOccurred ())
157
157
158
- By ("Failing to create a Pod with more than max resources" )
158
+ ginkgo . By ("Failing to create a Pod with more than max resources" )
159
159
pod = f .NewTestPod (podName , getResourceList ("600m" , "600Mi" , "600Gi" ), v1.ResourceList {})
160
160
pod , err = f .ClientSet .CoreV1 ().Pods (f .Namespace .Name ).Create (pod )
161
- Expect ( err ). To ( HaveOccurred () )
161
+ framework . ExpectError ( err )
162
162
163
- By ("Deleting a LimitRange" )
163
+ ginkgo . By ("Deleting a LimitRange" )
164
164
err = f .ClientSet .CoreV1 ().LimitRanges (f .Namespace .Name ).Delete (limitRange .Name , metav1 .NewDeleteOptions (30 ))
165
- Expect (err ).NotTo (HaveOccurred ())
165
+ gomega . Expect (err ).NotTo (gomega . HaveOccurred ())
166
166
167
- By ("Verifying the LimitRange was deleted" )
168
- Expect (wait .Poll (time .Second * 5 , time .Second * 30 , func () (bool , error ) {
167
+ ginkgo . By ("Verifying the LimitRange was deleted" )
168
+ gomega . Expect (wait .Poll (time .Second * 5 , time .Second * 30 , func () (bool , error ) {
169
169
selector := labels .SelectorFromSet (labels .Set (map [string ]string {"name" : limitRange .Name }))
170
170
options := metav1.ListOptions {LabelSelector : selector .String ()}
171
171
limitRanges , err := f .ClientSet .CoreV1 ().LimitRanges (f .Namespace .Name ).List (options )
@@ -190,12 +190,12 @@ var _ = SIGDescribe("LimitRange", func() {
190
190
191
191
return false , nil
192
192
193
- })).NotTo (HaveOccurred (), "kubelet never observed the termination notice" )
193
+ })).NotTo (gomega . HaveOccurred (), "kubelet never observed the termination notice" )
194
194
195
- By ("Creating a Pod with more than former max resources" )
195
+ ginkgo . By ("Creating a Pod with more than former max resources" )
196
196
pod = f .NewTestPod (podName + "2" , getResourceList ("600m" , "600Mi" , "600Gi" ), v1.ResourceList {})
197
197
pod , err = f .ClientSet .CoreV1 ().Pods (f .Namespace .Name ).Create (pod )
198
- Expect (err ).NotTo (HaveOccurred ())
198
+ gomega . Expect (err ).NotTo (gomega . HaveOccurred ())
199
199
})
200
200
201
201
})
0 commit comments