github.com/oam-dev/cluster-gateway@v1.9.0/e2e/ocm/clustergateway.go (about) 1 package roundtrip 2 3 import ( 4 "context" 5 "time" 6 7 . "github.com/onsi/ginkgo/v2" 8 . "github.com/onsi/gomega" 9 apierrors "k8s.io/apimachinery/pkg/api/errors" 10 "k8s.io/apimachinery/pkg/api/meta" 11 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 12 "k8s.io/apimachinery/pkg/types" 13 addonapiv1alpha1 "open-cluster-management.io/api/addon/v1alpha1" 14 15 "github.com/oam-dev/cluster-gateway/e2e/framework" 16 "github.com/oam-dev/cluster-gateway/pkg/common" 17 ) 18 19 const ( 20 ocmTestBasename = "ocm-addon" 21 ) 22 23 var _ = Describe("Addon Manager Test", func() { 24 f := framework.NewE2EFramework(ocmTestBasename) 25 It("ClusterGateway addon installation should work", 26 func() { 27 c := f.HubRuntimeClient() 28 By("Polling addon and gateway healthiness") 29 Eventually( 30 func() (bool, error) { 31 addon := &addonapiv1alpha1.ManagedClusterAddOn{} 32 if err := c.Get(context.TODO(), types.NamespacedName{ 33 Namespace: f.TestClusterName(), 34 Name: common.AddonName, 35 }, addon); err != nil { 36 if apierrors.IsNotFound(err) { 37 return false, nil 38 } 39 return false, err 40 } 41 if addon.Status.HealthCheck.Mode != addonapiv1alpha1.HealthCheckModeCustomized { 42 return false, nil 43 } 44 addonHealthy := meta.IsStatusConditionTrue( 45 addon.Status.Conditions, 46 addonapiv1alpha1.ManagedClusterAddOnConditionAvailable) 47 gw, err := f.HubGatewayClient(). 48 ClusterV1alpha1(). 49 ClusterGateways(). 50 GetHealthiness(context.TODO(), f.TestClusterName(), metav1.GetOptions{}) 51 if err != nil { 52 return false, err 53 } 54 gwHealthy := gw.Status.Healthy 55 return addonHealthy && gwHealthy, nil 56 }). 57 WithTimeout(time.Minute). 58 Should(BeTrue()) 59 }) 60 It("Manual probe healthiness should work", 61 func() { 62 resp, err := f.HubNativeClient().Discovery(). 63 RESTClient(). 64 Get(). 65 AbsPath( 66 "apis/cluster.core.oam.dev/v1alpha1/clustergateways", 67 f.TestClusterName(), 68 "proxy", 69 "healthz", 70 ).DoRaw(context.TODO()) 71 Expect(err).NotTo(HaveOccurred()) 72 Expect(string(resp)).To(Equal("ok")) 73 }) 74 })