|
13 | 13 | # limitations under the License.
|
14 | 14 | from collections import namedtuple
|
15 | 15 | import sys
|
16 |
| -from .build_ray_cluster import gen_names, update_image |
| 16 | +from .build_ray_cluster import gen_names, update_image, build_ray_cluster |
17 | 17 | import uuid
|
| 18 | +from codeflare_sdk.ray.cluster.cluster import ClusterConfiguration, Cluster |
18 | 19 |
|
19 | 20 |
|
20 | 21 | def test_gen_names_with_name(mocker):
|
@@ -65,3 +66,45 @@ def test_update_image_without_supported_python_version(mocker):
|
65 | 66 |
|
66 | 67 | # Assert that no image was set since the Python version is not supported
|
67 | 68 | assert image is None
|
| 69 | + |
| 70 | + |
| 71 | +def test_build_ray_cluster_with_gcs_ft(mocker): |
| 72 | + mocker.patch("kubernetes.config.load_kube_config", return_value="ignore") |
| 73 | + mocker.patch("kubernetes.client.CustomObjectsApi.list_namespaced_custom_object") |
| 74 | + |
| 75 | + cluster = Cluster( |
| 76 | + ClusterConfiguration( |
| 77 | + name="test", |
| 78 | + namespace="ns", |
| 79 | + enable_gcs_ft=True, |
| 80 | + redis_address="redis:6379", |
| 81 | + redis_password_secret={"name": "redis-password-secret", "key": "password"}, |
| 82 | + external_storage_namespace="new-ns", |
| 83 | + ) |
| 84 | + ) |
| 85 | + |
| 86 | + mocker.patch("codeflare_sdk.ray.cluster.build_ray_cluster.config_check") |
| 87 | + mocker.patch( |
| 88 | + "codeflare_sdk.ray.cluster.build_ray_cluster.get_api_client", return_value=None |
| 89 | + ) |
| 90 | + mocker.patch( |
| 91 | + "codeflare_sdk.ray.cluster.build_ray_cluster.update_image", return_value=None |
| 92 | + ) |
| 93 | + |
| 94 | + resource = build_ray_cluster(cluster) |
| 95 | + |
| 96 | + assert "spec" in resource |
| 97 | + assert "gcsFaultToleranceOptions" in resource["spec"] |
| 98 | + |
| 99 | + gcs_ft_options = resource["spec"]["gcsFaultToleranceOptions"] |
| 100 | + |
| 101 | + assert gcs_ft_options["redisAddress"] == "redis:6379" |
| 102 | + assert gcs_ft_options["externalStorageNamespace"] == "new-ns" |
| 103 | + assert ( |
| 104 | + gcs_ft_options["redisPassword"]["valueFrom"]["secretKeyRef"]["name"] |
| 105 | + == "redis-password-secret" |
| 106 | + ) |
| 107 | + assert ( |
| 108 | + gcs_ft_options["redisPassword"]["valueFrom"]["secretKeyRef"]["key"] |
| 109 | + == "password" |
| 110 | + ) |
0 commit comments