diff --git a/pkg/controllers/support.go b/pkg/controllers/support.go index 7871e66a8..344e6215f 100644 --- a/pkg/controllers/support.go +++ b/pkg/controllers/support.go @@ -146,9 +146,6 @@ func (r *RayClusterReconciler) getIngressHost(ctx context.Context, clientset *ku } else { return "", fmt.Errorf("missing IngressDomain configuration in ConfigMap 'codeflare-operator-config'") } - if ingressDomain == "kind" { - return ingressDomain, nil - } return fmt.Sprintf("%s-%s.%s", ingressNameFromCluster, cluster.Namespace, ingressDomain), nil } diff --git a/test/e2e/mnist_rayjob_raycluster_test.go b/test/e2e/mnist_rayjob_raycluster_test.go index 46f37d7a5..b3cee102c 100644 --- a/test/e2e/mnist_rayjob_raycluster_test.go +++ b/test/e2e/mnist_rayjob_raycluster_test.go @@ -17,6 +17,9 @@ limitations under the License. package e2e import ( + "crypto/tls" + "net/http" + "net/url" "testing" . "github.com/onsi/gomega" @@ -221,7 +224,7 @@ func TestMNISTRayJobRayCluster(t *testing.T) { test.Expect(err).NotTo(HaveOccurred()) test.T().Logf("Created RayJob %s/%s successfully", rayJob.Namespace, rayJob.Name) - rayDashboardURL := ExposeService(test, "ray-dashboard", namespace.Name, "raycluster-head-svc", "dashboard") + rayDashboardURL := getRayDashboardURL(test, rayCluster.Namespace, rayCluster.Name) test.T().Logf("Connecting to Ray cluster at: %s", rayDashboardURL.String()) rayClient := NewRayClusterClient(rayDashboardURL) @@ -241,3 +244,43 @@ func TestMNISTRayJobRayCluster(t *testing.T) { test.Expect(GetRayJob(test, rayJob.Namespace, rayJob.Name)). To(WithTransform(RayJobStatus, Equal(rayv1.JobStatusSucceeded))) } + +func getRayDashboardURL(test Test, namespace, rayClusterName string) url.URL { + dashboardName := "ray-dashboard-" + rayClusterName + + if IsOpenShift(test) { + route := GetRoute(test, namespace, dashboardName) + hostname := route.Status.Ingress[0].Host + + // Wait for expected HTTP code + test.T().Logf("Waiting for Route %s/%s to be available", route.Namespace, route.Name) + tr := &http.Transport{ + TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, + } + client := &http.Client{Transport: tr} + + test.Eventually(func() (int, error) { + resp, err := client.Get("https://" + hostname) + if err != nil { + return -1, err + } + return resp.StatusCode, nil + }, TestTimeoutShort).Should(Not(Equal(503))) + + return url.URL{ + Scheme: "https", + Host: hostname, + } + } + + ingress := GetIngress(test, namespace, dashboardName) + + test.T().Logf("Waiting for Ingress %s/%s to be admitted", ingress.Namespace, ingress.Name) + test.Eventually(Ingress(test, ingress.Namespace, ingress.Name), TestTimeoutShort). + Should(WithTransform(LoadBalancerIngresses, HaveLen(1))) + + return url.URL{ + Scheme: "http", + Host: ingress.Spec.Rules[0].Host, + } +}