@@ -40,6 +40,8 @@ import (
40
40
var ServiceNodePortRange = util.PortRange {Base : 30000 , Size : 2768 }
41
41
42
42
var _ = Describe ("Services" , func () {
43
+ f := NewFramework ("services" )
44
+
43
45
var c * client.Client
44
46
// Use these in tests. They're unique for each test to prevent name collisions.
45
47
var namespaces [2 ]string
@@ -336,9 +338,8 @@ var _ = Describe("Services", func() {
336
338
SkipUnlessProviderIs ("gce" , "gke" , "aws" )
337
339
338
340
serviceName := "mutability-service-test"
339
- ns := namespaces [0 ]
340
341
341
- t := NewWebserverTest (c , ns , serviceName )
342
+ t := NewWebserverTest (f . Client , f . Namespace . Name , serviceName )
342
343
defer func () {
343
344
defer GinkgoRecover ()
344
345
errs := t .Cleanup ()
@@ -371,7 +372,7 @@ var _ = Describe("Services", func() {
371
372
t .CreateWebserverRC (1 )
372
373
373
374
By ("changing service " + serviceName + " to type=NodePort" )
374
- service , err = updateService (c , ns , serviceName , func (s * api.Service ) {
375
+ service , err = updateService (f . Client , f . Namespace . Name , serviceName , func (s * api.Service ) {
375
376
s .Spec .Type = api .ServiceTypeNodePort
376
377
})
377
378
Expect (err ).NotTo (HaveOccurred ())
@@ -394,19 +395,19 @@ var _ = Describe("Services", func() {
394
395
Failf ("got unexpected len(Status.LoadBalancer.Ingresss) for NodePort service: %v" , service )
395
396
}
396
397
By ("hitting the pod through the service's NodePort" )
397
- ip := pickMinionIP (c )
398
+ ip := pickMinionIP (f . Client )
398
399
nodePort1 := port .NodePort // Save for later!
399
400
testReachable (ip , nodePort1 )
400
401
401
402
By ("changing service " + serviceName + " to type=LoadBalancer" )
402
403
service .Spec .Type = api .ServiceTypeLoadBalancer
403
- service , err = updateService (c , ns , serviceName , func (s * api.Service ) {
404
+ service , err = updateService (f . Client , f . Namespace . Name , serviceName , func (s * api.Service ) {
404
405
s .Spec .Type = api .ServiceTypeLoadBalancer
405
406
})
406
407
Expect (err ).NotTo (HaveOccurred ())
407
408
408
409
// Wait for the load balancer to be created asynchronously
409
- service , err = waitForLoadBalancerIngress (c , serviceName , ns )
410
+ service , err = waitForLoadBalancerIngress (f . Client , serviceName , f . Namespace . Name )
410
411
Expect (err ).NotTo (HaveOccurred ())
411
412
412
413
if service .Spec .Type != api .ServiceTypeLoadBalancer {
@@ -427,7 +428,7 @@ var _ = Describe("Services", func() {
427
428
Failf ("got unexpected Status.LoadBalancer.Ingresss[0] for LoadBalancer service: %v" , service )
428
429
}
429
430
By ("hitting the pod through the service's NodePort" )
430
- ip = pickMinionIP (c )
431
+ ip = pickMinionIP (f . Client )
431
432
testReachable (ip , nodePort1 )
432
433
By ("hitting the pod through the service's LoadBalancer" )
433
434
testLoadBalancerReachable (ingress1 , 80 )
@@ -438,7 +439,7 @@ var _ = Describe("Services", func() {
438
439
//Check for (unlikely) assignment at bottom of range
439
440
nodePort2 = nodePort1 + 1
440
441
}
441
- service , err = updateService (c , ns , serviceName , func (s * api.Service ) {
442
+ service , err = updateService (f . Client , f . Namespace . Name , serviceName , func (s * api.Service ) {
442
443
s .Spec .Ports [0 ].NodePort = nodePort2
443
444
})
444
445
Expect (err ).NotTo (HaveOccurred ())
@@ -462,7 +463,7 @@ var _ = Describe("Services", func() {
462
463
if providerIs ("aws" ) {
463
464
// TODO: Make this less of a hack (or fix the underlying bug)
464
465
time .Sleep (time .Second * 120 )
465
- service , err = waitForLoadBalancerIngress (c , serviceName , ns )
466
+ service , err = waitForLoadBalancerIngress (f . Client , serviceName , f . Namespace . Name )
466
467
Expect (err ).NotTo (HaveOccurred ())
467
468
468
469
// We don't want the ingress point to change, but we should verify that the new ingress point still works
@@ -480,7 +481,7 @@ var _ = Describe("Services", func() {
480
481
testNotReachable (ip , nodePort1 )
481
482
482
483
By ("changing service " + serviceName + " back to type=ClusterIP" )
483
- service , err = updateService (c , ns , serviceName , func (s * api.Service ) {
484
+ service , err = updateService (f . Client , f . Namespace . Name , serviceName , func (s * api.Service ) {
484
485
s .Spec .Type = api .ServiceTypeClusterIP
485
486
s .Spec .Ports [0 ].NodePort = 0
486
487
})
@@ -498,17 +499,17 @@ var _ = Describe("Services", func() {
498
499
}
499
500
500
501
// Wait for the load balancer to be destroyed asynchronously
501
- service , err = waitForLoadBalancerDestroy (c , serviceName , ns )
502
+ service , err = waitForLoadBalancerDestroy (f . Client , serviceName , f . Namespace . Name )
502
503
Expect (err ).NotTo (HaveOccurred ())
503
504
504
505
if len (service .Status .LoadBalancer .Ingress ) != 0 {
505
506
Failf ("got unexpected len(Status.LoadBalancer.Ingresss) for back-to-ClusterIP service: %v" , service )
506
507
}
507
508
By ("checking the NodePort (original) is closed" )
508
- ip = pickMinionIP (c )
509
+ ip = pickMinionIP (f . Client )
509
510
testNotReachable (ip , nodePort1 )
510
511
By ("checking the NodePort (updated) is closed" )
511
- ip = pickMinionIP (c )
512
+ ip = pickMinionIP (f . Client )
512
513
testNotReachable (ip , nodePort2 )
513
514
By ("checking the LoadBalancer is closed" )
514
515
testLoadBalancerNotReachable (ingress2 , 80 )
0 commit comments