@@ -171,7 +171,7 @@ var _ = Describe("lifecycle", func() {
171171
172172 It ("pods" , func () {
173173 pod := pods [0 ]
174- lifecycle , err := New (namespace , clusterName , compName , lifecycleActions , nil , nil , pods )
174+ lifecycle , err := New (namespace , clusterName , compName , lifecycleActions , nil , pod , pods )
175175 Expect (err ).Should (BeNil ())
176176
177177 Expect (lifecycle ).ShouldNot (BeNil ())
@@ -188,7 +188,7 @@ var _ = Describe("lifecycle", func() {
188188
189189 Context ("call action" , func () {
190190 It ("not defined" , func () {
191- lifecycle , err := New (namespace , clusterName , compName , lifecycleActions , nil , nil , pods )
191+ lifecycle , err := New (namespace , clusterName , compName , lifecycleActions , nil , pods [ 0 ] , pods )
192192 Expect (err ).Should (BeNil ())
193193 Expect (lifecycle ).ShouldNot (BeNil ())
194194
@@ -198,7 +198,7 @@ var _ = Describe("lifecycle", func() {
198198 })
199199
200200 It ("action request" , func () {
201- lifecycle , err := New (namespace , clusterName , compName , lifecycleActions , nil , nil , pods )
201+ lifecycle , err := New (namespace , clusterName , compName , lifecycleActions , nil , pods [ 0 ] , pods )
202202 Expect (err ).Should (BeNil ())
203203 Expect (lifecycle ).ShouldNot (BeNil ())
204204
@@ -228,7 +228,7 @@ var _ = Describe("lifecycle", func() {
228228 })
229229
230230 It ("succeed" , func () {
231- lifecycle , err := New (namespace , clusterName , compName , lifecycleActions , nil , nil , pods )
231+ lifecycle , err := New (namespace , clusterName , compName , lifecycleActions , nil , pods [ 0 ] , pods )
232232 Expect (err ).Should (BeNil ())
233233 Expect (lifecycle ).ShouldNot (BeNil ())
234234
@@ -243,7 +243,7 @@ var _ = Describe("lifecycle", func() {
243243 })
244244
245245 It ("succeed and stdout" , func () {
246- lifecycle , err := New (namespace , clusterName , compName , lifecycleActions , nil , nil , pods )
246+ lifecycle , err := New (namespace , clusterName , compName , lifecycleActions , nil , pods [ 0 ] , pods )
247247 Expect (err ).Should (BeNil ())
248248 Expect (lifecycle ).ShouldNot (BeNil ())
249249
@@ -261,7 +261,7 @@ var _ = Describe("lifecycle", func() {
261261 })
262262
263263 It ("fail - error code" , func () {
264- lifecycle , err := New (namespace , clusterName , compName , lifecycleActions , nil , nil , pods )
264+ lifecycle , err := New (namespace , clusterName , compName , lifecycleActions , nil , pods [ 0 ] , pods )
265265 Expect (err ).Should (BeNil ())
266266 Expect (lifecycle ).ShouldNot (BeNil ())
267267
@@ -330,7 +330,7 @@ var _ = Describe("lifecycle", func() {
330330 })
331331
332332 It ("fail - error msg" , func () {
333- lifecycle , err := New (namespace , clusterName , compName , lifecycleActions , nil , nil , pods )
333+ lifecycle , err := New (namespace , clusterName , compName , lifecycleActions , nil , pods [ 0 ] , pods )
334334 Expect (err ).Should (BeNil ())
335335 Expect (lifecycle ).ShouldNot (BeNil ())
336336
@@ -350,7 +350,7 @@ var _ = Describe("lifecycle", func() {
350350 })
351351
352352 It ("parameters" , func () {
353- lifecycle , err := New (namespace , clusterName , compName , lifecycleActions , nil , nil , pods )
353+ lifecycle , err := New (namespace , clusterName , compName , lifecycleActions , nil , pods [ 0 ] , pods )
354354 Expect (err ).Should (BeNil ())
355355 Expect (lifecycle ).ShouldNot (BeNil ())
356356
@@ -394,7 +394,7 @@ var _ = Describe("lifecycle", func() {
394394 key := "TEMPLATE_VAR1"
395395 val := "template-vars1"
396396
397- lifecycle , err := New (namespace , clusterName , compName , lifecycleActions , map [string ]string {key : val }, nil , pods )
397+ lifecycle , err := New (namespace , clusterName , compName , lifecycleActions , map [string ]string {key : val }, pods [ 0 ] , pods )
398398 Expect (err ).Should (BeNil ())
399399 Expect (lifecycle ).ShouldNot (BeNil ())
400400
@@ -418,7 +418,7 @@ var _ = Describe("lifecycle", func() {
418418 clusterReady := appsv1 .ClusterReadyPreConditionType
419419 lifecycleActions .PostProvision .PreCondition = & clusterReady
420420
421- lifecycle , err := New (namespace , clusterName , compName , lifecycleActions , nil , nil , pods )
421+ lifecycle , err := New (namespace , clusterName , compName , lifecycleActions , nil , pods [ 0 ] , pods )
422422 Expect (err ).Should (BeNil ())
423423 Expect (lifecycle ).ShouldNot (BeNil ())
424424
@@ -451,7 +451,7 @@ var _ = Describe("lifecycle", func() {
451451 clusterReady := appsv1 .ClusterReadyPreConditionType
452452 lifecycleActions .PostProvision .PreCondition = & clusterReady
453453
454- lifecycle , err := New (namespace , clusterName , compName , lifecycleActions , nil , nil , pods )
454+ lifecycle , err := New (namespace , clusterName , compName , lifecycleActions , nil , pods [ 0 ] , pods )
455455 Expect (err ).Should (BeNil ())
456456 Expect (lifecycle ).ShouldNot (BeNil ())
457457
@@ -516,7 +516,7 @@ var _ = Describe("lifecycle", func() {
516516 },
517517 }
518518
519- lifecycle , err := New (namespace , clusterName , compName , lifecycleActions , nil , nil , pods )
519+ lifecycle , err := New (namespace , clusterName , compName , lifecycleActions , nil , pods [ 0 ] , pods )
520520 Expect (err ).Should (BeNil ())
521521 Expect (lifecycle ).ShouldNot (BeNil ())
522522
@@ -526,7 +526,34 @@ var _ = Describe("lifecycle", func() {
526526 })
527527
528528 It ("pod selector - all" , func () {
529- // TODO: impl
529+ lifecycleActions .PostProvision .Exec .TargetPodSelector = appsv1 .AllReplicas
530+ pods = []* corev1.Pod {
531+ {
532+ ObjectMeta : metav1.ObjectMeta {
533+ Namespace : namespace ,
534+ Name : "pod-0" ,
535+ },
536+ },
537+ {
538+ ObjectMeta : metav1.ObjectMeta {
539+ Namespace : namespace ,
540+ Name : "pod-1" ,
541+ },
542+ },
543+ }
544+
545+ lifecycle , err := New (namespace , clusterName , compName , lifecycleActions , nil , pods [0 ], pods )
546+ Expect (err ).Should (BeNil ())
547+ Expect (lifecycle ).ShouldNot (BeNil ())
548+
549+ mockKBAgentClient (func (recorder * kbacli.MockClientMockRecorder ) {
550+ recorder .Action (gomock .Any (), gomock .Any ()).DoAndReturn (func (ctx context.Context , req proto.ActionRequest ) (proto.ActionResponse , error ) {
551+ return proto.ActionResponse {}, nil
552+ }).Times (2 )
553+ })
554+
555+ err = lifecycle .PostProvision (ctx , k8sClient , nil )
556+ Expect (err ).Should (BeNil ())
530557 })
531558
532559 It ("pod selector - role" , func () {
@@ -577,7 +604,7 @@ var _ = Describe("lifecycle", func() {
577604 },
578605 }
579606
580- lifecycle , err := New (namespace , clusterName , compName , lifecycleActions , nil , nil , pods )
607+ lifecycle , err := New (namespace , clusterName , compName , lifecycleActions , nil , pods [ 0 ] , pods )
581608 Expect (err ).Should (BeNil ())
582609 Expect (lifecycle ).ShouldNot (BeNil ())
583610
@@ -610,7 +637,7 @@ var _ = Describe("lifecycle", func() {
610637 },
611638 }
612639
613- lifecycle , err := New (namespace , clusterName , compName , lifecycleActions , nil , nil , pods )
640+ lifecycle , err := New (namespace , clusterName , compName , lifecycleActions , nil , pods [ 0 ] , pods )
614641 Expect (err ).Should (BeNil ())
615642 Expect (lifecycle ).ShouldNot (BeNil ())
616643
0 commit comments