@@ -17,6 +17,9 @@ limitations under the License.
17
17
package e2e
18
18
19
19
import (
20
+ "crypto/tls"
21
+ "net/http"
22
+ "net/url"
20
23
"testing"
21
24
22
25
. "github.com/onsi/gomega"
@@ -221,7 +224,7 @@ func TestMNISTRayJobRayCluster(t *testing.T) {
221
224
test .Expect (err ).NotTo (HaveOccurred ())
222
225
test .T ().Logf ("Created RayJob %s/%s successfully" , rayJob .Namespace , rayJob .Name )
223
226
224
- rayDashboardURL := ExposeService (test , "ray-dashboard" , namespace .Name , "raycluster-head-svc" , "dashboard" )
227
+ rayDashboardURL := getRayDashboardURL (test , rayCluster . Namespace , rayCluster .Name )
225
228
226
229
test .T ().Logf ("Connecting to Ray cluster at: %s" , rayDashboardURL .String ())
227
230
rayClient := NewRayClusterClient (rayDashboardURL )
@@ -241,3 +244,43 @@ func TestMNISTRayJobRayCluster(t *testing.T) {
241
244
test .Expect (GetRayJob (test , rayJob .Namespace , rayJob .Name )).
242
245
To (WithTransform (RayJobStatus , Equal (rayv1 .JobStatusSucceeded )))
243
246
}
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