@@ -183,20 +183,21 @@ var _ = SIGDescribe("ReplicaSet", func() {
183
183
// image serves its hostname which is checked for each replica.
184
184
func testReplicaSetServeImageOrFail (ctx context.Context , f * framework.Framework , test string , image string ) {
185
185
name := "my-hostname-" + test + "-" + string (uuid .NewUUID ())
186
+ rsLabels := map [string ]string {"name" : name }
186
187
replicas := int32 (1 )
187
188
188
189
// Create a ReplicaSet for a service that serves its hostname.
189
190
// The source for the Docker container kubernetes/serve_hostname is
190
191
// in contrib/for-demos/serve_hostname
191
192
framework .Logf ("Creating ReplicaSet %s" , name )
192
- newRS := newRS (name , replicas , map [ string ] string { "name" : name } , name , image , []string {"serve-hostname" })
193
+ newRS := newRS (name , replicas , rsLabels , name , image , []string {"serve-hostname" })
193
194
newRS .Spec .Template .Spec .Containers [0 ].Ports = []v1.ContainerPort {{ContainerPort : 9376 }}
194
195
_ , err := f .ClientSet .AppsV1 ().ReplicaSets (f .Namespace .Name ).Create (ctx , newRS , metav1.CreateOptions {})
195
196
framework .ExpectNoError (err )
196
197
197
198
// Check that pods for the new RS were created.
198
199
// TODO: Maybe switch PodsCreated to just check owner references.
199
- pods , err := e2epod .PodsCreated (ctx , f .ClientSet , f .Namespace .Name , name , replicas )
200
+ pods , err := e2epod .PodsCreatedByLabel (ctx , f .ClientSet , f .Namespace .Name , name , replicas , labels . SelectorFromSet ( rsLabels ) )
200
201
framework .ExpectNoError (err )
201
202
202
203
// Wait for the pods to enter the running state. Waiting loops until the pods
@@ -226,7 +227,7 @@ func testReplicaSetServeImageOrFail(ctx context.Context, f *framework.Framework,
226
227
227
228
// Verify that something is listening.
228
229
framework .Logf ("Trying to dial the pod" )
229
- framework .ExpectNoError (e2epod .WaitForPodsResponding (ctx , f .ClientSet , f .Namespace .Name , name , true , 2 * time .Minute , pods ))
230
+ framework .ExpectNoError (e2epod .WaitForPodsResponding (ctx , f .ClientSet , f .Namespace .Name , name , labels . SelectorFromSet ( rsLabels ), true , 2 * time .Minute , pods ))
230
231
}
231
232
232
233
// 1. Create a quota restricting pods in the current namespace to 2.
@@ -317,13 +318,12 @@ func testReplicaSetConditionCheck(ctx context.Context, f *framework.Framework) {
317
318
318
319
func testRSAdoptMatchingAndReleaseNotMatching (ctx context.Context , f * framework.Framework ) {
319
320
name := "pod-adoption-release"
321
+ rsLabels := map [string ]string {"name" : name }
320
322
ginkgo .By (fmt .Sprintf ("Given a Pod with a 'name' label %s is created" , name ))
321
323
p := e2epod .NewPodClient (f ).CreateSync (ctx , & v1.Pod {
322
324
ObjectMeta : metav1.ObjectMeta {
323
- Name : name ,
324
- Labels : map [string ]string {
325
- "name" : name ,
326
- },
325
+ Name : name ,
326
+ Labels : rsLabels ,
327
327
},
328
328
Spec : v1.PodSpec {
329
329
Containers : []v1.Container {
@@ -337,8 +337,8 @@ func testRSAdoptMatchingAndReleaseNotMatching(ctx context.Context, f *framework.
337
337
338
338
ginkgo .By ("When a replicaset with a matching selector is created" )
339
339
replicas := int32 (1 )
340
- rsSt := newRS (name , replicas , map [ string ] string { "name" : name } , name , WebserverImage , nil )
341
- rsSt .Spec .Selector = & metav1.LabelSelector {MatchLabels : map [ string ] string { "name" : name } }
340
+ rsSt := newRS (name , replicas , rsLabels , name , WebserverImage , nil )
341
+ rsSt .Spec .Selector = & metav1.LabelSelector {MatchLabels : rsLabels }
342
342
rs , err := f .ClientSet .AppsV1 ().ReplicaSets (f .Namespace .Name ).Create (ctx , rsSt , metav1.CreateOptions {})
343
343
framework .ExpectNoError (err )
344
344
@@ -362,7 +362,7 @@ func testRSAdoptMatchingAndReleaseNotMatching(ctx context.Context, f *framework.
362
362
framework .ExpectNoError (err )
363
363
364
364
ginkgo .By ("When the matched label of one of its pods change" )
365
- pods , err := e2epod .PodsCreated (ctx , f .ClientSet , f .Namespace .Name , rs .Name , replicas )
365
+ pods , err := e2epod .PodsCreatedByLabel (ctx , f .ClientSet , f .Namespace .Name , rs .Name , replicas , labels . SelectorFromSet ( rsLabels ) )
366
366
framework .ExpectNoError (err )
367
367
368
368
p = & pods .Items [0 ]
@@ -403,8 +403,9 @@ func testRSScaleSubresources(ctx context.Context, f *framework.Framework) {
403
403
c := f .ClientSet
404
404
405
405
// Create webserver pods.
406
+ podName := "sample-pod"
406
407
rsPodLabels := map [string ]string {
407
- "name" : "sample-pod" ,
408
+ "name" : podName ,
408
409
"pod" : WebserverImageName ,
409
410
}
410
411
@@ -416,7 +417,7 @@ func testRSScaleSubresources(ctx context.Context, f *framework.Framework) {
416
417
framework .ExpectNoError (err )
417
418
418
419
// Verify that the required pods have come up.
419
- err = e2epod .VerifyPodsRunning (ctx , c , ns , "sample-pod" , false , replicas )
420
+ err = e2epod .VerifyPodsRunning (ctx , c , ns , podName , labels . SelectorFromSet ( map [ string ] string { "name" : podName }) , false , replicas )
420
421
framework .ExpectNoError (err , "error in waiting for pods to come up: %s" , err )
421
422
422
423
ginkgo .By ("getting scale subresource" )
@@ -468,8 +469,9 @@ func testRSLifeCycle(ctx context.Context, f *framework.Framework) {
468
469
zero := int64 (0 )
469
470
470
471
// Create webserver pods.
472
+ podName := "sample-pod"
471
473
rsPodLabels := map [string ]string {
472
- "name" : "sample-pod" ,
474
+ "name" : podName ,
473
475
"pod" : WebserverImageName ,
474
476
}
475
477
@@ -494,7 +496,7 @@ func testRSLifeCycle(ctx context.Context, f *framework.Framework) {
494
496
framework .ExpectNoError (err )
495
497
496
498
// Verify that the required pods have come up.
497
- err = e2epod .VerifyPodsRunning (ctx , c , ns , "sample-pod" , false , replicas )
499
+ err = e2epod .VerifyPodsRunning (ctx , c , ns , podName , labels . SelectorFromSet ( map [ string ] string { "name" : podName }) , false , replicas )
498
500
framework .ExpectNoError (err , "Failed to create pods: %s" , err )
499
501
500
502
// Scale the ReplicaSet
@@ -564,8 +566,9 @@ func listRSDeleteCollection(ctx context.Context, f *framework.Framework) {
564
566
e2eValue := rand .String (5 )
565
567
566
568
// Define ReplicaSet Labels
569
+ podName := "sample-pod"
567
570
rsPodLabels := map [string ]string {
568
- "name" : "sample-pod" ,
571
+ "name" : podName ,
569
572
"pod" : WebserverImageName ,
570
573
"e2e" : e2eValue ,
571
574
}
@@ -576,7 +579,7 @@ func listRSDeleteCollection(ctx context.Context, f *framework.Framework) {
576
579
framework .ExpectNoError (err )
577
580
578
581
ginkgo .By ("Verify that the required pods have come up" )
579
- err = e2epod .VerifyPodsRunning (ctx , c , ns , "sample-pod" , false , replicas )
582
+ err = e2epod .VerifyPodsRunning (ctx , c , ns , podName , labels . SelectorFromSet ( map [ string ] string { "name" : podName }) , false , replicas )
580
583
framework .ExpectNoError (err , "Failed to create pods: %s" , err )
581
584
r , err := rsClient .Get (ctx , rsName , metav1.GetOptions {})
582
585
framework .ExpectNoError (err , "failed to get ReplicaSets" )
@@ -603,8 +606,9 @@ func testRSStatus(ctx context.Context, f *framework.Framework) {
603
606
rsClient := c .AppsV1 ().ReplicaSets (ns )
604
607
605
608
// Define ReplicaSet Labels
609
+ podName := "sample-pod"
606
610
rsPodLabels := map [string ]string {
607
- "name" : "sample-pod" ,
611
+ "name" : podName ,
608
612
"pod" : WebserverImageName ,
609
613
}
610
614
labelSelector := labels .SelectorFromSet (rsPodLabels ).String ()
@@ -627,7 +631,7 @@ func testRSStatus(ctx context.Context, f *framework.Framework) {
627
631
framework .ExpectNoError (err )
628
632
629
633
ginkgo .By ("Verify that the required pods have come up." )
630
- err = e2epod .VerifyPodsRunning (ctx , c , ns , "sample-pod" , false , replicas )
634
+ err = e2epod .VerifyPodsRunning (ctx , c , ns , podName , labels . SelectorFromSet ( map [ string ] string { "name" : podName }) , false , replicas )
631
635
framework .ExpectNoError (err , "Failed to create pods: %s" , err )
632
636
633
637
ginkgo .By ("Getting /status" )
0 commit comments