@@ -158,7 +158,20 @@ func CleanupTestImagePullCredentialFile(fileName string) {
158158 _ = os .Remove (fileName )
159159}
160160
161+ func GetE2eConfig () (* TestE2eConfig , error ) {
162+ return NewTestE2eConfig (
163+ os .Getenv ("KUBECONFIG" ),
164+ os .Getenv ("HUB_NAME" ), os .Getenv ("HUB_CTX" ),
165+ os .Getenv ("MANAGED_CLUSTER1_NAME" ), os .Getenv ("MANAGED_CLUSTER1_CTX" ))
166+ }
167+
161168func WaitClusterManagerApplied (operatorClient operatorclient.Interface ) {
169+ e2eConf , err := GetE2eConfig ()
170+ gomega .Expect (err ).NotTo (gomega .HaveOccurred ())
171+
172+ kubeClient , err := kubernetes .NewForConfig (e2eConf .Cluster ().hub .kubeConfig )
173+ gomega .Expect (err ).NotTo (gomega .HaveOccurred ())
174+
162175 gomega .Eventually (func () error {
163176 cm , err := operatorClient .OperatorV1 ().ClusterManagers ().Get (context .TODO (), "cluster-manager" , metav1.GetOptions {})
164177 if err != nil {
@@ -175,6 +188,23 @@ func WaitClusterManagerApplied(operatorClient operatorclient.Interface) {
175188 if con .Status != metav1 .ConditionFalse || con .Reason != operatorv1 .ReasonRegistrationFunctional {
176189 return fmt .Errorf ("hub registration is not functional" )
177190 }
191+
192+ deployments , err := kubeClient .AppsV1 ().Deployments (config .HubClusterNamespace ).List (context .TODO (), metav1.ListOptions {})
193+ if err != nil {
194+ return err
195+ }
196+ for _ , d := range deployments .Items {
197+ desiredReplicas := int32 (1 )
198+ if d .Spec .Replicas != nil {
199+ desiredReplicas = * (d .Spec .Replicas )
200+ }
201+
202+ if desiredReplicas > d .Status .AvailableReplicas {
203+ return fmt .Errorf ("deployment %v is available" , d .Name )
204+ }
205+
206+ }
178207 return nil
208+
179209 }, time .Second * 60 , time .Second * 2 ).Should (gomega .Succeed ())
180210}
0 commit comments