|
30 | 30 | get_ray_obj_with_status,
|
31 | 31 | get_aw_obj_with_status,
|
32 | 32 | patch_cluster_with_dynamic_client,
|
| 33 | + route_list_retrieval, |
33 | 34 | )
|
34 | 35 | from codeflare_sdk.ray.cluster.cluster import _is_openshift_cluster
|
35 | 36 | from pathlib import Path
|
@@ -148,6 +149,39 @@ def test_cluster_apply_with_file(mocker):
|
148 | 149 | cluster.down()
|
149 | 150 |
|
150 | 151 |
|
| 152 | +def test_cluster_apply_without_appwrapper(mocker): |
| 153 | + # Mock Kubernetes client and dynamic client methods |
| 154 | + mocker.patch("kubernetes.client.ApisApi.get_api_versions") |
| 155 | + mocker.patch("kubernetes.config.load_kube_config", return_value="ignore") |
| 156 | + mock_dynamic_client = mocker.Mock() |
| 157 | + mocker.patch("codeflare_sdk.ray.cluster.cluster.Cluster._throw_for_no_raycluster") |
| 158 | + mocker.patch( |
| 159 | + "kubernetes.dynamic.DynamicClient.resources", new_callable=mocker.PropertyMock |
| 160 | + ) |
| 161 | + mocker.patch( |
| 162 | + "codeflare_sdk.ray.cluster.cluster.Cluster.create_resource", |
| 163 | + return_value="./tests/test_cluster_yamls/ray/default-ray-cluster.yaml", |
| 164 | + ) |
| 165 | + mocker.patch("kubernetes.config.load_kube_config", return_value="ignore") |
| 166 | + |
| 167 | + # Create a cluster configuration with appwrapper set to False |
| 168 | + cluster = create_cluster(mocker, 1, write_to_file=False) |
| 169 | + cluster.config.appwrapper = None |
| 170 | + patch_cluster_with_dynamic_client(mocker, cluster, mock_dynamic_client) |
| 171 | + |
| 172 | + # Mock listing RayCluster to simulate it doesn't exist |
| 173 | + mocker.patch( |
| 174 | + "kubernetes.client.CustomObjectsApi.list_namespaced_custom_object", |
| 175 | + return_value=get_obj_none("ray.io", "v1", "ns", "rayclusters"), |
| 176 | + ) |
| 177 | + |
| 178 | + # Call the apply method |
| 179 | + cluster.apply() |
| 180 | + |
| 181 | + # Assertions |
| 182 | + print("Cluster applied without AppWrapper.") |
| 183 | + |
| 184 | + |
151 | 185 | def test_cluster_up_down_no_mcad(mocker):
|
152 | 186 | mocker.patch("codeflare_sdk.ray.cluster.cluster.Cluster._throw_for_no_raycluster")
|
153 | 187 | mocker.patch("kubernetes.config.load_kube_config", return_value="ignore")
|
@@ -223,6 +257,52 @@ def test_cluster_uris(mocker):
|
223 | 257 | == "Dashboard not available yet, have you run cluster.up()?"
|
224 | 258 | )
|
225 | 259 |
|
| 260 | + mocker.patch( |
| 261 | + "codeflare_sdk.ray.cluster.cluster._is_openshift_cluster", return_value=True |
| 262 | + ) |
| 263 | + mocker.patch( |
| 264 | + "kubernetes.client.CustomObjectsApi.list_namespaced_custom_object", |
| 265 | + return_value={ |
| 266 | + "items": [ |
| 267 | + { |
| 268 | + "metadata": { |
| 269 | + "name": "ray-dashboard-unit-test-cluster", |
| 270 | + }, |
| 271 | + "spec": { |
| 272 | + "host": "ray-dashboard-unit-test-cluster-ns.apps.cluster.awsroute.org", |
| 273 | + "tls": {}, # Indicating HTTPS |
| 274 | + }, |
| 275 | + } |
| 276 | + ] |
| 277 | + }, |
| 278 | + ) |
| 279 | + cluster = create_cluster(mocker) |
| 280 | + assert ( |
| 281 | + cluster.cluster_dashboard_uri() |
| 282 | + == "http://ray-dashboard-unit-test-cluster-ns.apps.cluster.awsroute.org" |
| 283 | + ) |
| 284 | + mocker.patch( |
| 285 | + "kubernetes.client.CustomObjectsApi.list_namespaced_custom_object", |
| 286 | + return_value={ |
| 287 | + "items": [ |
| 288 | + { |
| 289 | + "metadata": { |
| 290 | + "name": "ray-dashboard-unit-test-cluster", |
| 291 | + }, |
| 292 | + "spec": { |
| 293 | + "host": "ray-dashboard-unit-test-cluster-ns.apps.cluster.awsroute.org", |
| 294 | + "tls": {"termination": "passthrough"}, # Indicating HTTPS |
| 295 | + }, |
| 296 | + } |
| 297 | + ] |
| 298 | + }, |
| 299 | + ) |
| 300 | + cluster = create_cluster(mocker) |
| 301 | + assert ( |
| 302 | + cluster.cluster_dashboard_uri() |
| 303 | + == "https://ray-dashboard-unit-test-cluster-ns.apps.cluster.awsroute.org" |
| 304 | + ) |
| 305 | + |
226 | 306 |
|
227 | 307 | def test_ray_job_wrapping(mocker):
|
228 | 308 | import ray
|
|
0 commit comments