@@ -683,3 +683,53 @@ func countNumberOfReadyParents(parents []v1.RouteParentStatus) int {
683
683
684
684
return readyCount
685
685
}
686
+
687
+ func (rm * ResourceManager ) WaitForAppsToBeReadyWithPodCount (namespace string , podCount int ) error {
688
+ ctx , cancel := context .WithTimeout (context .Background (), rm .TimeoutConfig .CreateTimeout )
689
+ defer cancel ()
690
+
691
+ return rm .WaitForAppsToBeReadyWithCtxWithPodCount (ctx , namespace , podCount )
692
+ }
693
+
694
+ func (rm * ResourceManager ) WaitForAppsToBeReadyWithCtxWithPodCount (ctx context.Context , namespace string , podCount int ) error {
695
+ if err := rm .WaitForPodsToBeReadyWithCount (ctx , namespace , podCount ); err != nil {
696
+ return err
697
+ }
698
+
699
+ if err := rm .waitForHTTPRoutesToBeReady (ctx , namespace ); err != nil {
700
+ return err
701
+ }
702
+
703
+ if err := rm .waitForGRPCRoutesToBeReady (ctx , namespace ); err != nil {
704
+ return err
705
+ }
706
+
707
+ return rm .waitForGatewaysToBeReady (ctx , namespace )
708
+ }
709
+
710
+ // WaitForPodsToBeReady waits for all Pods in the specified namespace to be ready or
711
+ // until the provided context is cancelled.
712
+ func (rm * ResourceManager ) WaitForPodsToBeReadyWithCount (ctx context.Context , namespace string , count int ) error {
713
+ return wait .PollUntilContextCancel (
714
+ ctx ,
715
+ 500 * time .Millisecond ,
716
+ true , /* poll immediately */
717
+ func (ctx context.Context ) (bool , error ) {
718
+ var podList core.PodList
719
+ if err := rm .K8sClient .List (ctx , & podList , client .InNamespace (namespace )); err != nil {
720
+ return false , err
721
+ }
722
+
723
+ var podsReady int
724
+ for _ , pod := range podList .Items {
725
+ for _ , cond := range pod .Status .Conditions {
726
+ if cond .Type == core .PodReady && cond .Status == core .ConditionTrue {
727
+ podsReady ++
728
+ }
729
+ }
730
+ }
731
+
732
+ return podsReady == count , nil
733
+ },
734
+ )
735
+ }
0 commit comments