1111# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212# See the License for the specific language governing permissions and
1313# 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+ )
1520from unittest .mock import patch
1621from codeflare_sdk .ray .cluster .cluster import Cluster , ClusterConfiguration
1722import yaml
@@ -52,21 +57,21 @@ def test_cluster_creation_no_aw_local_queue(mocker):
5257 config .local_queue = "local-queue-default"
5358 cluster = Cluster (config )
5459 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 (
5761 f"{ parent } /tests/test_cluster_yamls/kueue/ray_cluster_kueue.yaml" ,
58- shallow = True ,
62+ get_template_variables () ,
5963 )
6064
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+
6169 # With resources loaded in memory, no Local Queue specified.
6270 config = createClusterConfig ()
6371 config .name = "unit-test-cluster-kueue"
6472 config .write_to_file = False
6573 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
7075
7176
7277def test_aw_creation_local_queue (mocker ):
@@ -86,22 +91,23 @@ def test_aw_creation_local_queue(mocker):
8691 config .local_queue = "local-queue-default"
8792 cluster = Cluster (config )
8893 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 (
9195 f"{ parent } /tests/test_cluster_yamls/kueue/aw_kueue.yaml" ,
92- shallow = True ,
96+ get_template_variables () ,
9397 )
9498
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+
95103 # With resources loaded in memory, no Local Queue specified.
96104 config = createClusterConfig ()
97105 config .name = "unit-test-aw-kueue"
98106 config .appwrapper = True
99107 config .write_to_file = False
100108 cluster = Cluster (config )
101109
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
105111
106112
107113def test_get_local_queue_exists_fail (mocker ):
0 commit comments