@@ -34,8 +34,8 @@ import (
34
34
"k8s.io/kubernetes/pkg/kubelet/events"
35
35
"k8s.io/kubernetes/pkg/kubelet/sysctl"
36
36
37
- . "github.com/onsi/ginkgo"
38
- . "github.com/onsi/gomega"
37
+ "github.com/onsi/ginkgo"
38
+ "github.com/onsi/gomega"
39
39
)
40
40
41
41
const DefaultPodDeletionTimeout = 3 * time .Minute
@@ -45,7 +45,7 @@ const DefaultPodDeletionTimeout = 3 * time.Minute
45
45
// node e2e test.
46
46
var ImageWhiteList sets.String
47
47
48
- // Convenience method for getting a pod client interface in the framework's namespace,
48
+ // PodClient is a convenience method for getting a pod client interface in the framework's namespace,
49
49
// possibly applying test-suite specific transformations to the pod spec, e.g. for
50
50
// node e2e pod scheduling.
51
51
func (f * Framework ) PodClient () * PodClient {
@@ -55,7 +55,7 @@ func (f *Framework) PodClient() *PodClient {
55
55
}
56
56
}
57
57
58
- // Convenience method for getting a pod client interface in an alternative namespace,
58
+ // PodClientNS is a convenience method for getting a pod client interface in an alternative namespace,
59
59
// possibly applying test-suite specific transformations to the pod spec, e.g. for
60
60
// node e2e pod scheduling.
61
61
func (f * Framework ) PodClientNS (namespace string ) * PodClient {
@@ -65,6 +65,7 @@ func (f *Framework) PodClientNS(namespace string) *PodClient {
65
65
}
66
66
}
67
67
68
+ // PodClient is a struct for pod client.
68
69
type PodClient struct {
69
70
f * Framework
70
71
v1core.PodInterface
@@ -96,15 +97,15 @@ func (c *PodClient) Create(pod *v1.Pod) *v1.Pod {
96
97
func (c * PodClient ) CreateEventually (pod * v1.Pod , opts ... interface {}) * v1.Pod {
97
98
c .mungeSpec (pod )
98
99
var ret * v1.Pod
99
- Eventually (func () error {
100
+ gomega . Eventually (func () error {
100
101
p , err := c .PodInterface .Create (pod )
101
102
ret = p
102
103
return err
103
- }, opts ... ).ShouldNot (HaveOccurred (), "Failed to create %q pod" , pod .GetName ())
104
+ }, opts ... ).ShouldNot (gomega . HaveOccurred (), "Failed to create %q pod" , pod .GetName ())
104
105
return ret
105
106
}
106
107
107
- // CreateSync creates a new pod according to the framework specifications in the given namespace, and waits for it to start.
108
+ // CreateSyncInNamespace creates a new pod according to the framework specifications in the given namespace, and waits for it to start.
108
109
func (c * PodClient ) CreateSyncInNamespace (pod * v1.Pod , namespace string ) * v1.Pod {
109
110
p := c .Create (pod )
110
111
ExpectNoError (WaitForPodNameRunningInNamespace (c .f .ClientSet , p .Name , namespace ))
@@ -127,7 +128,7 @@ func (c *PodClient) CreateBatch(pods []*v1.Pod) []*v1.Pod {
127
128
wg .Add (1 )
128
129
go func (i int , pod * v1.Pod ) {
129
130
defer wg .Done ()
130
- defer GinkgoRecover ()
131
+ defer ginkgo . GinkgoRecover ()
131
132
ps [i ] = c .CreateSync (pod )
132
133
}(i , pod )
133
134
}
@@ -171,8 +172,8 @@ func (c *PodClient) DeleteSyncInNamespace(name string, namespace string, options
171
172
if err != nil && ! errors .IsNotFound (err ) {
172
173
Failf ("Failed to delete pod %q: %v" , name , err )
173
174
}
174
- Expect (WaitForPodToDisappear (c .f .ClientSet , namespace , name , labels .Everything (),
175
- 2 * time .Second , timeout )).To (Succeed (), "wait for pod %q to disappear" , name )
175
+ gomega . Expect (WaitForPodToDisappear (c .f .ClientSet , namespace , name , labels .Everything (),
176
+ 2 * time .Second , timeout )).To (gomega . Succeed (), "wait for pod %q to disappear" , name )
176
177
}
177
178
178
179
// mungeSpec apply test-suite specific transformations to the pod spec.
@@ -181,7 +182,7 @@ func (c *PodClient) mungeSpec(pod *v1.Pod) {
181
182
return
182
183
}
183
184
184
- Expect (pod .Spec .NodeName ).To (Or (BeZero (), Equal (TestContext .NodeName )), "Test misconfigured" )
185
+ gomega . Expect (pod .Spec .NodeName ).To (gomega . Or (gomega . BeZero (), gomega . Equal (TestContext .NodeName )), "Test misconfigured" )
185
186
pod .Spec .NodeName = TestContext .NodeName
186
187
// Node e2e does not support the default DNSClusterFirst policy. Set
187
188
// the policy to DNSDefault, which is configured per node.
@@ -204,18 +205,18 @@ func (c *PodClient) mungeSpec(pod *v1.Pod) {
204
205
}
205
206
// If the image policy is not PullAlways, the image must be in the white list and
206
207
// pre-pulled.
207
- Expect (ImageWhiteList .Has (c .Image )).To (BeTrue (), "Image %q is not in the white list, consider adding it to CommonImageWhiteList in test/e2e/common/util.go or NodeImageWhiteList in test/e2e_node/image_list.go" , c .Image )
208
+ gomega . Expect (ImageWhiteList .Has (c .Image )).To (gomega . BeTrue (), "Image %q is not in the white list, consider adding it to CommonImageWhiteList in test/e2e/common/util.go or NodeImageWhiteList in test/e2e_node/image_list.go" , c .Image )
208
209
// Do not pull images during the tests because the images in white list should have
209
210
// been prepulled.
210
211
c .ImagePullPolicy = v1 .PullNever
211
212
}
212
213
}
213
214
214
- // TODO(random-liu): Move pod wait function into this file
215
215
// WaitForSuccess waits for pod to succeed.
216
+ // TODO(random-liu): Move pod wait function into this file
216
217
func (c * PodClient ) WaitForSuccess (name string , timeout time.Duration ) {
217
218
f := c .f
218
- Expect (WaitForPodCondition (f .ClientSet , f .Namespace .Name , name , "success or failure" , timeout ,
219
+ gomega . Expect (WaitForPodCondition (f .ClientSet , f .Namespace .Name , name , "success or failure" , timeout ,
219
220
func (pod * v1.Pod ) (bool , error ) {
220
221
switch pod .Status .Phase {
221
222
case v1 .PodFailed :
@@ -226,13 +227,13 @@ func (c *PodClient) WaitForSuccess(name string, timeout time.Duration) {
226
227
return false , nil
227
228
}
228
229
},
229
- )).To (Succeed (), "wait for pod %q to success" , name )
230
+ )).To (gomega . Succeed (), "wait for pod %q to success" , name )
230
231
}
231
232
232
233
// WaitForFailure waits for pod to fail.
233
234
func (c * PodClient ) WaitForFailure (name string , timeout time.Duration ) {
234
235
f := c .f
235
- Expect (WaitForPodCondition (f .ClientSet , f .Namespace .Name , name , "success or failure" , timeout ,
236
+ gomega . Expect (WaitForPodCondition (f .ClientSet , f .Namespace .Name , name , "success or failure" , timeout ,
236
237
func (pod * v1.Pod ) (bool , error ) {
237
238
switch pod .Status .Phase {
238
239
case v1 .PodFailed :
@@ -243,10 +244,10 @@ func (c *PodClient) WaitForFailure(name string, timeout time.Duration) {
243
244
return false , nil
244
245
}
245
246
},
246
- )).To (Succeed (), "wait for pod %q to fail" , name )
247
+ )).To (gomega . Succeed (), "wait for pod %q to fail" , name )
247
248
}
248
249
249
- // WaitForSuccess waits for pod to succeed or an error event for that pod.
250
+ // WaitForErrorEventOrSuccess waits for pod to succeed or an error event for that pod.
250
251
func (c * PodClient ) WaitForErrorEventOrSuccess (pod * v1.Pod ) (* v1.Event , error ) {
251
252
var ev * v1.Event
252
253
err := wait .Poll (Poll , PodStartTimeout , func () (bool , error ) {
@@ -287,6 +288,7 @@ func (c *PodClient) MatchContainerOutput(name string, containerName string, expe
287
288
return nil
288
289
}
289
290
291
+ // PodIsReady returns true if the specified pod is ready. Otherwise false.
290
292
func (c * PodClient ) PodIsReady (name string ) bool {
291
293
pod , err := c .Get (name , metav1.GetOptions {})
292
294
ExpectNoError (err )
0 commit comments