|
20 | 20 | )
|
21 | 21 | from codeflare_sdk.common.utils.unit_test_support import (
|
22 | 22 | createClusterWithConfig,
|
| 23 | + createClusterWithConfigAndNumWorkers, |
23 | 24 | arg_check_del_effect,
|
24 | 25 | ingress_retrieval,
|
25 | 26 | arg_check_apply_effect,
|
@@ -67,11 +68,49 @@ def test_cluster_up_down(mocker):
|
67 | 68 | "kubernetes.client.CustomObjectsApi.list_namespaced_custom_object",
|
68 | 69 | return_value=get_local_queue("kueue.x-k8s.io", "v1beta1", "ns", "localqueues"),
|
69 | 70 | )
|
70 |
| - cluster = cluster = createClusterWithConfig(mocker) |
| 71 | + cluster = createClusterWithConfig(mocker) |
71 | 72 | cluster.up()
|
72 | 73 | cluster.down()
|
73 | 74 |
|
74 | 75 |
|
| 76 | +def test_cluster_apply_scale_up_scale_down(mocker): |
| 77 | + mocker.patch("kubernetes.client.ApisApi.get_api_versions") |
| 78 | + mocker.patch("kubernetes.config.load_kube_config", return_value="ignore") |
| 79 | + mocker.patch("codeflare_sdk.ray.cluster.cluster.Cluster._throw_for_no_raycluster") |
| 80 | + mocker.patch( |
| 81 | + "kubernetes.client.CustomObjectsApi.get_cluster_custom_object", |
| 82 | + return_value={"spec": {"domain": ""}}, |
| 83 | + ) |
| 84 | + mocker.patch( |
| 85 | + "kubernetes.client.CustomObjectsApi.create_namespaced_custom_object", |
| 86 | + side_effect=arg_check_apply_effect, |
| 87 | + ) |
| 88 | + mocker.patch( |
| 89 | + "kubernetes.client.CustomObjectsApi.delete_namespaced_custom_object", |
| 90 | + side_effect=arg_check_del_effect, |
| 91 | + ) |
| 92 | + mocker.patch( |
| 93 | + "kubernetes.client.CustomObjectsApi.list_cluster_custom_object", |
| 94 | + return_value={"items": []}, |
| 95 | + ) |
| 96 | + mocker.patch( |
| 97 | + "kubernetes.client.CustomObjectsApi.list_namespaced_custom_object", |
| 98 | + return_value=get_local_queue("kueue.x-k8s.io", "v1beta1", "ns", "localqueues"), |
| 99 | + ) |
| 100 | + initial_num_workers = 1 |
| 101 | + scaled_up_num_workers = 2 |
| 102 | + cluster = createClusterWithConfigAndNumWorkers(mocker, initial_num_workers) |
| 103 | + cluster.apply() |
| 104 | + cluster.wait_ready(timeout=5) |
| 105 | + cluster = createClusterWithConfigAndNumWorkers(mocker, scaled_up_num_workers) |
| 106 | + cluster.apply() |
| 107 | + cluster.wait_ready(timeout=5) |
| 108 | + cluster = createClusterWithConfigAndNumWorkers(mocker, initial_num_workers) |
| 109 | + cluster.apply() |
| 110 | + cluster.wait_ready(timeout=5) |
| 111 | + cluster.down() |
| 112 | + |
| 113 | + |
75 | 114 | def test_cluster_up_down_no_mcad(mocker):
|
76 | 115 | mocker.patch("codeflare_sdk.ray.cluster.cluster.Cluster._throw_for_no_raycluster")
|
77 | 116 | mocker.patch("kubernetes.config.load_kube_config", return_value="ignore")
|
@@ -117,7 +156,7 @@ def test_cluster_uris(mocker):
|
117 | 156 | "kubernetes.client.CustomObjectsApi.list_namespaced_custom_object",
|
118 | 157 | return_value=get_local_queue("kueue.x-k8s.io", "v1beta1", "ns", "localqueues"),
|
119 | 158 | )
|
120 |
| - cluster = cluster = createClusterWithConfig(mocker) |
| 159 | + cluster = createClusterWithConfig(mocker) |
121 | 160 | mocker.patch(
|
122 | 161 | "kubernetes.client.NetworkingV1Api.list_namespaced_ingress",
|
123 | 162 | return_value=ingress_retrieval(
|
@@ -159,7 +198,7 @@ def ray_addr(self, *args):
|
159 | 198 | "kubernetes.client.CustomObjectsApi.list_namespaced_custom_object",
|
160 | 199 | return_value=get_local_queue("kueue.x-k8s.io", "v1beta1", "ns", "localqueues"),
|
161 | 200 | )
|
162 |
| - cluster = cluster = createClusterWithConfig(mocker) |
| 201 | + cluster = createClusterWithConfig(mocker) |
163 | 202 | mocker.patch(
|
164 | 203 | "ray.job_submission.JobSubmissionClient._check_connection_and_version_with_url",
|
165 | 204 | return_value="None",
|
|
0 commit comments