@@ -17,6 +17,9 @@ limitations under the License.
1717package e2e
1818
1919import (
20+ "crypto/tls"
21+ "net/http"
22+ "net/url"
2023 "testing"
2124
2225 . "github.com/onsi/gomega"
@@ -221,7 +224,7 @@ func TestMNISTRayJobRayCluster(t *testing.T) {
221224 test .Expect (err ).NotTo (HaveOccurred ())
222225 test .T ().Logf ("Created RayJob %s/%s successfully" , rayJob .Namespace , rayJob .Name )
223226
224- rayDashboardURL := ExposeService (test , "ray-dashboard" , namespace .Name , "raycluster-head-svc" , "dashboard" )
227+ rayDashboardURL := getRayDashboardURL (test , rayCluster . Namespace , rayCluster .Name )
225228
226229 test .T ().Logf ("Connecting to Ray cluster at: %s" , rayDashboardURL .String ())
227230 rayClient := NewRayClusterClient (rayDashboardURL )
@@ -241,3 +244,43 @@ func TestMNISTRayJobRayCluster(t *testing.T) {
241244 test .Expect (GetRayJob (test , rayJob .Namespace , rayJob .Name )).
242245 To (WithTransform (RayJobStatus , Equal (rayv1 .JobStatusSucceeded )))
243246}
247+
248+ func getRayDashboardURL (test Test , namespace , rayClusterName string ) url.URL {
249+ dashboardName := "ray-dashboard-" + rayClusterName
250+
251+ if IsOpenShift (test ) {
252+ route := GetRoute (test , namespace , dashboardName )
253+ hostname := route .Status .Ingress [0 ].Host
254+
255+ // Wait for expected HTTP code
256+ test .T ().Logf ("Waiting for Route %s/%s to be available" , route .Namespace , route .Name )
257+ tr := & http.Transport {
258+ TLSClientConfig : & tls.Config {InsecureSkipVerify : true },
259+ }
260+ client := & http.Client {Transport : tr }
261+
262+ test .Eventually (func () (int , error ) {
263+ resp , err := client .Get ("https://" + hostname )
264+ if err != nil {
265+ return - 1 , err
266+ }
267+ return resp .StatusCode , nil
268+ }, TestTimeoutShort ).Should (Not (Equal (503 )))
269+
270+ return url.URL {
271+ Scheme : "https" ,
272+ Host : hostname ,
273+ }
274+ }
275+
276+ ingress := GetIngress (test , namespace , dashboardName )
277+
278+ test .T ().Logf ("Waiting for Ingress %s/%s to be admitted" , ingress .Namespace , ingress .Name )
279+ test .Eventually (Ingress (test , ingress .Namespace , ingress .Name ), TestTimeoutShort ).
280+ Should (WithTransform (LoadBalancerIngresses , HaveLen (1 )))
281+
282+ return url.URL {
283+ Scheme : "http" ,
284+ Host : ingress .Spec .Rules [0 ].Host ,
285+ }
286+ }
0 commit comments