Skip to content

Commit 040035e

Browse files
authored
BF: qstat -g d parser fix (#31)
* qstat -g d parser fix
1 parent 1c4833d commit 040035e

File tree

4 files changed

+34
-6
lines changed

4 files changed

+34
-6
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ COPY autoinstall.template /opt/helpers/
2929
COPY installer.sh /opt/helpers/
3030
COPY entrypoint.sh /entrypoint.sh
3131

32-
ARG GOLANG_VERSION=1.23.5
32+
ARG GOLANG_VERSION=1.23.6
3333

3434
RUN apt-get update && \
3535
apt-get install -y curl wget git gcc make vim libhwloc-dev hwloc software-properties-common man-db && \

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
# This Makefile is used for development and testing purposes only.
2222

2323
IMAGE_NAME = $(shell basename $(CURDIR))
24-
IMAGE_TAG = V901_TAG
24+
IMAGE_TAG = V902_TAG
2525
CONTAINER_NAME = $(IMAGE_NAME)
2626

2727
.PHONY: build

pkg/qstat/v9.0/parser.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,11 @@ job-ID prior name user state submit/start at queue
859859
func ParseJobArrayTask(out string) ([]JobArrayTask, error) {
860860
lines := strings.Split(out, "\n")
861861

862-
jobArrayTasks := make([]JobArrayTask, 0, len(lines)-3)
862+
jobArrayTasks := make([]JobArrayTask, 0, len(lines))
863+
864+
if len(lines) < 2 {
865+
return jobArrayTasks, nil
866+
}
863867

864868
for _, line := range lines[2:] {
865869
fields := strings.Fields(line)
@@ -884,7 +888,7 @@ func ParseJobArrayTask(out string) ([]JobArrayTask, error) {
884888
}
885889
var submitTime time.Time
886890
var startTime time.Time
887-
if strings.Contains(state, "qw") {
891+
if !strings.Contains(state, "qw") {
888892
startTime = jobTime
889893
} else {
890894
submitTime = jobTime

pkg/qstat/v9.0/parser_test.go

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,13 +484,37 @@ test.q 0.08 0 0 2 2 0 0
484484
Name: "sleep",
485485
User: "root",
486486
State: "r",
487-
SubmitTime: time.Date(2025, 2, 10, 16, 47, 18, 0, time.UTC),
488-
StartTime: time.Time{},
487+
StartTime: time.Date(2025, 2, 10, 16, 47, 18, 0, time.UTC),
488+
SubmitTime: time.Time{},
489489
Queue: "all.q@master",
490490
Slots: 1,
491491
JaTaskIDs: []int64{1},
492492
},
493493
}))
494+
495+
Expect(jobArrayTasks).To(ContainElement(qstat.JobArrayTask{
496+
JobInfo: qstat.JobInfo{
497+
JobID: 36,
498+
Priority: 0.605,
499+
Name: "sleep",
500+
User: "root",
501+
State: "qw",
502+
SubmitTime: time.Date(2025, 2, 10, 16, 52, 21, 0, time.UTC),
503+
StartTime: time.Time{},
504+
Queue: "",
505+
Slots: 2,
506+
JaTaskIDs: []int64{0},
507+
},
508+
}))
509+
510+
})
511+
512+
It("should parse an empty input", func() {
513+
input := ""
514+
jobArrayTasks, err := qstat.ParseJobArrayTask(input)
515+
Expect(err).NotTo(HaveOccurred())
516+
Expect(len(jobArrayTasks)).To(Equal(0))
517+
494518
})
495519

496520
})

0 commit comments

Comments
 (0)