fix front end issues
This commit is contained in:
parent
177cf45af5
commit
d7afd72e5b
18 changed files with 345 additions and 61 deletions
99
src/frontend/apiserver/models/jobs_test.go
Normal file
99
src/frontend/apiserver/models/jobs_test.go
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
package models
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestJobStateStr(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
state int
|
||||
want string
|
||||
}{
|
||||
{
|
||||
name: "PEND",
|
||||
state: JOBSTAT["PEND"],
|
||||
want: "PEND",
|
||||
},
|
||||
{
|
||||
name: "PSUSP (PEND+PSUSP)",
|
||||
state: JOBSTAT["PEND"] | JOBSTAT["PSUSP"],
|
||||
want: "PSUSP",
|
||||
},
|
||||
{
|
||||
name: "RUN",
|
||||
state: JOBSTAT["RUN"],
|
||||
want: "RUN",
|
||||
},
|
||||
{
|
||||
name: "USUSP (RUN+USUSP)",
|
||||
state: JOBSTAT["RUN"] | JOBSTAT["USUSP"],
|
||||
want: "USUSP",
|
||||
},
|
||||
{
|
||||
name: "SSUSP (RUN+SSUSP)",
|
||||
state: JOBSTAT["RUN"] | JOBSTAT["SSUSP"],
|
||||
want: "SSUSP",
|
||||
},
|
||||
{
|
||||
name: "RUNKWN (RUN+RUNKWN — lost contact with remote cluster)",
|
||||
state: JOBSTAT["RUN"] | JOBSTAT["RUNKWN"],
|
||||
want: "RUNKWN",
|
||||
},
|
||||
{
|
||||
name: "EXIT",
|
||||
state: JOBSTAT["EXIT"],
|
||||
want: "EXIT",
|
||||
},
|
||||
{
|
||||
name: "DONE",
|
||||
state: JOBSTAT["DONE"],
|
||||
want: "DONE",
|
||||
},
|
||||
{
|
||||
name: "UNKNOWN (0x10000 — worker lost contact with controller)",
|
||||
state: JOBSTAT["UNKNOWN"],
|
||||
want: "UNKWN",
|
||||
},
|
||||
{
|
||||
name: "zero state returns ERR",
|
||||
state: 0,
|
||||
want: "ERR",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got := JobStateStr(tt.state)
|
||||
if got != tt.want {
|
||||
t.Errorf("JobStateStr(0x%X) = %q, want %q", tt.state, got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestJobStatMapValues(t *testing.T) {
|
||||
// Verify bitmask values match C JOB_STAT_* defines in src/include/xce/types.h.
|
||||
expected := map[string]int{
|
||||
"PEND": 0x01,
|
||||
"RUN": 0x02,
|
||||
"EXIT": 0x04,
|
||||
"DONE": 0x08,
|
||||
"PSUSP": 0x10,
|
||||
"USUSP": 0x20,
|
||||
"SSUSP": 0x40,
|
||||
"PDONE": 0x80,
|
||||
"PERR": 0x100,
|
||||
"WAIT": 0x200,
|
||||
"RUNKWN": 0x8000,
|
||||
"UNKNOWN": 0x10000,
|
||||
}
|
||||
for key, want := range expected {
|
||||
got, ok := JOBSTAT[key]
|
||||
if !ok {
|
||||
t.Errorf("JOBSTAT[%q] missing", key)
|
||||
continue
|
||||
}
|
||||
if got != want {
|
||||
t.Errorf("JOBSTAT[%q] = 0x%X, want 0x%X", key, got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue