Files
open-cluster-management/test/framework/clustermanager.go
xuezhao 6c4292b1bc Refactor tester to e2e framework. (#565)
Signed-off-by: xuezhaojun <zxue@redhat.com>
2024-07-24 01:31:58 +00:00

35 lines
1.1 KiB
Go

package framework
import (
"context"
"fmt"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
operatorapiv1 "open-cluster-management.io/api/operator/v1"
)
func (hub *Hub) GetCluserManager() (*operatorapiv1.ClusterManager, error) {
return hub.OperatorClient.OperatorV1().ClusterManagers().Get(context.TODO(), hub.ClusterManagerName, metav1.GetOptions{})
}
func CheckClusterManagerStatus(cm *operatorapiv1.ClusterManager) error {
if meta.IsStatusConditionFalse(cm.Status.Conditions, "Applied") {
return fmt.Errorf("components of cluster manager are not all applied")
}
if meta.IsStatusConditionFalse(cm.Status.Conditions, "ValidFeatureGates") {
return fmt.Errorf("feature gates are not all valid")
}
if !meta.IsStatusConditionFalse(cm.Status.Conditions, "HubRegistrationDegraded") {
return fmt.Errorf("HubRegistration is degraded")
}
if !meta.IsStatusConditionFalse(cm.Status.Conditions, "HubPlacementDegraded") {
return fmt.Errorf("HubPlacement is degraded")
}
if !meta.IsStatusConditionFalse(cm.Status.Conditions, "Progressing") {
return fmt.Errorf("ClusterManager is still progressing")
}
return nil
}