Skip to content

Commit 590cdb9

Browse files
committed
Adding coverage for the case of an openshift cluster
1 parent c343953 commit 590cdb9

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

.coveragerc

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[run]
2+
omit =
3+
src/**/test_*.py,,src/codeflare_sdk/common/utils/unit_test_support.py
4+
5+
[report]
6+
exclude_lines =
7+
pragma: no cover

src/codeflare_sdk/ray/cluster/test_cluster.py

+47
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
get_ray_obj_with_status,
3131
get_aw_obj_with_status,
3232
patch_cluster_with_dynamic_client,
33+
route_list_retrieval,
3334
)
3435
from codeflare_sdk.ray.cluster.cluster import _is_openshift_cluster
3536
from pathlib import Path
@@ -223,6 +224,52 @@ def test_cluster_uris(mocker):
223224
== "Dashboard not available yet, have you run cluster.up()?"
224225
)
225226

227+
mocker.patch(
228+
"codeflare_sdk.ray.cluster.cluster._is_openshift_cluster", return_value=True
229+
)
230+
mocker.patch(
231+
"kubernetes.client.CustomObjectsApi.list_namespaced_custom_object",
232+
return_value={
233+
"items": [
234+
{
235+
"metadata": {
236+
"name": "ray-dashboard-unit-test-cluster",
237+
},
238+
"spec": {
239+
"host": "ray-dashboard-unit-test-cluster-ns.apps.cluster.awsroute.org",
240+
"tls": {}, # Indicating HTTPS
241+
},
242+
}
243+
]
244+
},
245+
)
246+
cluster = create_cluster(mocker)
247+
assert (
248+
cluster.cluster_dashboard_uri()
249+
== "http://ray-dashboard-unit-test-cluster-ns.apps.cluster.awsroute.org"
250+
)
251+
mocker.patch(
252+
"kubernetes.client.CustomObjectsApi.list_namespaced_custom_object",
253+
return_value={
254+
"items": [
255+
{
256+
"metadata": {
257+
"name": "ray-dashboard-unit-test-cluster",
258+
},
259+
"spec": {
260+
"host": "ray-dashboard-unit-test-cluster-ns.apps.cluster.awsroute.org",
261+
"tls": {"termination": "passthrough"}, # Indicating HTTPS
262+
},
263+
}
264+
]
265+
},
266+
)
267+
cluster = create_cluster(mocker)
268+
assert (
269+
cluster.cluster_dashboard_uri()
270+
== "https://ray-dashboard-unit-test-cluster-ns.apps.cluster.awsroute.org"
271+
)
272+
226273

227274
def test_ray_job_wrapping(mocker):
228275
import ray

0 commit comments

Comments
 (0)