11
11
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
# See the License for the specific language governing permissions and
13
13
# limitations under the License.
14
- from ..utils .unit_test_support import get_local_queue , createClusterConfig
14
+ from ..utils .unit_test_support import (
15
+ apply_template ,
16
+ get_local_queue ,
17
+ createClusterConfig ,
18
+ get_template_variables ,
19
+ )
15
20
from unittest .mock import patch
16
21
from codeflare_sdk .ray .cluster .cluster import Cluster , ClusterConfiguration
17
22
import yaml
@@ -52,21 +57,21 @@ def test_cluster_creation_no_aw_local_queue(mocker):
52
57
config .local_queue = "local-queue-default"
53
58
cluster = Cluster (config )
54
59
assert cluster .resource_yaml == f"{ aw_dir } unit-test-cluster-kueue.yaml"
55
- assert filecmp .cmp (
56
- f"{ aw_dir } unit-test-cluster-kueue.yaml" ,
60
+ expected_rc = apply_template (
57
61
f"{ parent } /tests/test_cluster_yamls/kueue/ray_cluster_kueue.yaml" ,
58
- shallow = True ,
62
+ get_template_variables () ,
59
63
)
60
64
65
+ with open (f"{ aw_dir } unit-test-cluster-kueue.yaml" , "r" ) as f :
66
+ cluster_kueue = yaml .load (f , Loader = yaml .FullLoader )
67
+ assert cluster_kueue == expected_rc
68
+
61
69
# With resources loaded in memory, no Local Queue specified.
62
70
config = createClusterConfig ()
63
71
config .name = "unit-test-cluster-kueue"
64
72
config .write_to_file = False
65
73
cluster = Cluster (config )
66
-
67
- with open (f"{ parent } /tests/test_cluster_yamls/kueue/ray_cluster_kueue.yaml" ) as f :
68
- expected_rc = yaml .load (f , Loader = yaml .FullLoader )
69
- assert cluster .resource_yaml == expected_rc
74
+ assert cluster .resource_yaml == expected_rc
70
75
71
76
72
77
def test_aw_creation_local_queue (mocker ):
@@ -86,22 +91,23 @@ def test_aw_creation_local_queue(mocker):
86
91
config .local_queue = "local-queue-default"
87
92
cluster = Cluster (config )
88
93
assert cluster .resource_yaml == f"{ aw_dir } unit-test-aw-kueue.yaml"
89
- assert filecmp .cmp (
90
- f"{ aw_dir } unit-test-aw-kueue.yaml" ,
94
+ expected_rc = apply_template (
91
95
f"{ parent } /tests/test_cluster_yamls/kueue/aw_kueue.yaml" ,
92
- shallow = True ,
96
+ get_template_variables () ,
93
97
)
94
98
99
+ with open (f"{ aw_dir } unit-test-aw-kueue.yaml" , "r" ) as f :
100
+ aw_kueue = yaml .load (f , Loader = yaml .FullLoader )
101
+ assert aw_kueue == expected_rc
102
+
95
103
# With resources loaded in memory, no Local Queue specified.
96
104
config = createClusterConfig ()
97
105
config .name = "unit-test-aw-kueue"
98
106
config .appwrapper = True
99
107
config .write_to_file = False
100
108
cluster = Cluster (config )
101
109
102
- with open (f"{ parent } /tests/test_cluster_yamls/kueue/aw_kueue.yaml" ) as f :
103
- expected_rc = yaml .load (f , Loader = yaml .FullLoader )
104
- assert cluster .resource_yaml == expected_rc
110
+ assert cluster .resource_yaml == expected_rc
105
111
106
112
107
113
def test_get_local_queue_exists_fail (mocker ):
0 commit comments