@@ -547,8 +547,14 @@ def test_list_sacct(self, run: MagicMock) -> None:
547
547
548
548
@patch ("subprocess.run" )
549
549
def test_list_squeue (self , run : MagicMock ) -> None :
550
+ # First job is patched with a string-type job state
550
551
run .return_value .stdout = b"""{
551
552
"jobs": [
553
+ {
554
+ "job_id": 1233,
555
+ "name": "bar",
556
+ "job_state": "FAILED"
557
+ },
552
558
{
553
559
"job_id": 1234,
554
560
"name": "foo",
@@ -588,6 +594,7 @@ def test_list_squeue(self, run: MagicMock) -> None:
588
594
}"""
589
595
scheduler = create_scheduler ("foo" )
590
596
expected_apps = [
597
+ ListAppResponse (app_id = "1233" , state = AppState .FAILED , name = "bar" ),
591
598
ListAppResponse (app_id = "1234" , state = AppState .FAILED , name = "foo" ),
592
599
ListAppResponse (app_id = "1235" , state = AppState .FAILED , name = "foo" ),
593
600
ListAppResponse (app_id = "1236" , state = AppState .RUNNING , name = "foo-0" ),
@@ -1128,3 +1135,30 @@ def test_describe_squeue_nodes_as_string(self) -> None:
1128
1135
1129
1136
assert result is not None
1130
1137
assert result .roles_statuses [0 ].replicas [0 ].hostname == "compute-node-123"
1138
+
1139
+ def test_describe_squeue_handles_string_state (self ) -> None :
1140
+ """Test that describe handles job state as string (i.e. for SLURM <= 23.02)."""
1141
+
1142
+ # Mock legacy slurm response with job_state as a string
1143
+ mock_job_data = {
1144
+ "jobs" : [
1145
+ {
1146
+ "name" : "test-job-0" ,
1147
+ "job_state" : "TIMEOUT" ,
1148
+ "job_resources" : {"nodes" : "compute-node-123" },
1149
+ "command" : "/bin/echo" ,
1150
+ "current_working_directory" : "/tmp" ,
1151
+ }
1152
+ ]
1153
+ }
1154
+
1155
+ with patch ("subprocess.check_output" ) as mock_subprocess :
1156
+ mock_subprocess .return_value = json .dumps (mock_job_data )
1157
+
1158
+ scheduler = SlurmScheduler ("test" )
1159
+ result = scheduler ._describe_squeue ("123" )
1160
+
1161
+ assert result is not None
1162
+ assert result .app_id == "123"
1163
+ # should have a valid parsed state
1164
+ assert result .state == AppState .FAILED
0 commit comments