Skip to content

Commit 116282d

Browse files
committed
[Subnet Prioritization] Update unit test of generate_fleet_config_file
Signed-off-by: Hanxuan Zhang <[email protected]>
1 parent a794f7d commit 116282d

File tree

3 files changed

+56
-13
lines changed

3 files changed

+56
-13
lines changed

test/unit/slurm/test_fleet_config_generator.py

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,22 @@
4646
CriticalError,
4747
"Unable to find key 'Networking' in the configuration file. Queue: q1",
4848
),
49+
(
50+
{
51+
"Scheduling": {
52+
"SlurmQueues": [
53+
{
54+
"Name": "q1",
55+
"CapacityType": "SPOT",
56+
"ComputeResources": [{"Instances": []}],
57+
"Networking": {"SubnetIds": ["123"]},
58+
}
59+
]
60+
}
61+
},
62+
CriticalError,
63+
"Unable to find key 'EnableSingleAvailabilityZone' in the configuration file. Queue: q1",
64+
),
4965
(
5066
{
5167
"Scheduling": {
@@ -54,7 +70,7 @@
5470
"Name": "q1",
5571
"CapacityType": "SPOT",
5672
"ComputeResources": [{"Instances": []}],
57-
"Networking": {"SubnetIds": ["123"]},
73+
"Networking": {"SubnetIds": ["123"], "EnableSingleAvailabilityZone": None},
5874
}
5975
]
6076
}
@@ -70,7 +86,7 @@
7086
"Name": "q1",
7187
"CapacityType": "ONDEMAND",
7288
"ComputeResources": [{"Name": "cr1", "Instances": []}],
73-
"Networking": {"SubnetIds": ["123"]},
89+
"Networking": {"SubnetIds": ["123"], "EnableSingleAvailabilityZone": None},
7490
}
7591
]
7692
}
@@ -89,7 +105,7 @@
89105
{"Name": "cr1", "Instances": [{"InstanceType": "test"}]},
90106
{"Name": "cr2", "InstanceType": "test"},
91107
],
92-
"Networking": {"SubnetIds": ["123"]},
108+
"Networking": {"SubnetIds": ["123"], "EnableSingleAvailabilityZone": None},
93109
}
94110
]
95111
}
@@ -108,7 +124,7 @@
108124
{"Name": "cr1", "Instances": [{"InstanceType": "test"}, {"InstanceType": "test-2"}]},
109125
{"Name": "cr2", "InstanceType": "test"},
110126
],
111-
"Networking": {"SubnetIds": ["123", "456", "789"]},
127+
"Networking": {"SubnetIds": ["123", "456", "789"], "EnableSingleAvailabilityZone": None},
112128
}
113129
]
114130
}
@@ -131,7 +147,7 @@
131147
},
132148
{"Name": "cr2", "InstanceType": "test", "SpotPrice": "10"},
133149
],
134-
"Networking": {"SubnetIds": ["123", "456", "789"]},
150+
"Networking": {"SubnetIds": ["123", "456", "789"], "EnableSingleAvailabilityZone": None},
135151
}
136152
]
137153
}
@@ -147,7 +163,7 @@
147163
"Name": "q1",
148164
"CapacityType": "SPOT",
149165
"ComputeResources": [{"Name": "cr1", "Instances": [{"InstanceType": "test"}]}],
150-
"Networking": {"SubnetIds": ["123"]},
166+
"Networking": {"SubnetIds": ["123"], "EnableSingleAvailabilityZone": None},
151167
}
152168
]
153169
}
@@ -165,7 +181,7 @@
165181
"ComputeResources": [
166182
{"Name": "cr1", "Instances": [{"InstanceType": "test"}], "SpotPrice": 10}
167183
],
168-
"Networking": {"SubnetIds": ["123"]},
184+
"Networking": {"SubnetIds": ["123"], "EnableSingleAvailabilityZone": None},
169185
}
170186
]
171187
}
@@ -208,6 +224,24 @@
208224
CriticalError,
209225
"Unable to find key 'SubnetIds' in the configuration file. Queue: q1",
210226
),
227+
(
228+
{
229+
"Scheduling": {
230+
"SlurmQueues": [
231+
{
232+
"Name": "q1",
233+
"CapacityType": "SPOT",
234+
"ComputeResources": [
235+
{"Name": "cr1", "Instances": [{"InstanceType": "test"}], "SpotPrice": 10}
236+
],
237+
"Networking": {"SubnetIds": ["123"]},
238+
}
239+
]
240+
}
241+
},
242+
CriticalError,
243+
"Unable to find key 'EnableSingleAvailabilityZone' in the configuration file. Queue: q1",
244+
),
211245
(
212246
{
213247
"Scheduling": {
@@ -231,7 +265,7 @@
231265
},
232266
},
233267
],
234-
"Networking": {"SubnetIds": ["123"]},
268+
"Networking": {"SubnetIds": ["123"], "EnableSingleAvailabilityZone": None},
235269
}
236270
]
237271
}

test/unit/slurm/test_fleet_config_generator/test_generate_fleet_config_file/expected_outputs/fleet-config.json

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
"Networking": {
2828
"SubnetIds": [
2929
"subnet-0230367ab0e5123a4"
30-
]
30+
],
31+
"SingleAvailabilityZone": true
3132
},
3233
"AllocationStrategy": "lowest-price"
3334
}
@@ -57,7 +58,8 @@
5758
"SubnetIds": [
5859
"subnet-0230367ab0e5123a4",
5960
"subnet-0b903123096649662"
60-
]
61+
],
62+
"SingleAvailabilityZone": false
6163
},
6264
"AllocationStrategy": "lowest-price"
6365
}
@@ -84,7 +86,8 @@
8486
"Networking": {
8587
"SubnetIds": [
8688
"subnet-0230367ab0e5123a4"
87-
]
89+
],
90+
"SingleAvailabilityZone": null
8891
},
8992
"AllocationStrategy": "capacity-optimized",
9093
"MaxPrice": 10
@@ -100,7 +103,8 @@
100103
"Networking": {
101104
"SubnetIds": [
102105
"subnet-0230367ab0e5123a4"
103-
]
106+
],
107+
"SingleAvailabilityZone": null
104108
},
105109
"AllocationStrategy": "capacity-optimized"
106110
}
@@ -131,7 +135,8 @@
131135
"Networking": {
132136
"SubnetIds": [
133137
"subnet-0230367ab0e5123a4"
134-
]
138+
],
139+
"SingleAvailabilityZone": null
135140
}
136141
}
137142
}

test/unit/slurm/test_fleet_config_generator/test_generate_fleet_config_file/sample_input.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ Scheduling:
6262
SecurityGroups: null
6363
SubnetIds:
6464
- subnet-0230367ab0e5123a4
65+
EnableSingleAvailabilityZone: true
6566
# queue ondemand without capacity reservations and with multiple subnets
6667
- AllocationStrategy: lowest-price
6768
CapacityReservationTarget: null
@@ -121,6 +122,7 @@ Scheduling:
121122
SubnetIds:
122123
- subnet-0230367ab0e5123a4
123124
- subnet-0b903123096649662
125+
EnableSingleAvailabilityZone: false
124126
# queue spot
125127
- AllocationStrategy: capacity-optimized
126128
CapacityReservationTarget: null
@@ -191,6 +193,7 @@ Scheduling:
191193
SecurityGroups: null
192194
SubnetIds:
193195
- subnet-0230367ab0e5123a4
196+
EnableSingleAvailabilityZone: null
194197
# queue for capacity-block
195198
- CapacityReservationTarget:
196199
CapacityReservationId: cr-987654
@@ -250,6 +253,7 @@ Scheduling:
250253
SecurityGroups: null
251254
SubnetIds:
252255
- subnet-0230367ab0e5123a4
256+
EnableSingleAvailabilityZone: null
253257
SlurmSettings:
254258
Dns:
255259
DisableManagedDns: false

0 commit comments

Comments
 (0)