feat(apiserver): surface human-readable job ID (fmt_jobid form) in responses
The MCP/apiserver returned the raw 64-bit job ID (e.g. 73930964699447296) while xce_test/xcecli display the dash form (e.g. 1-0-1786585485-0) that parse_jobid accepts. A user taking the numeric form into xce_test fails to parse it. The apiserver is the data-correctness owner (MCP only reads), so it now emits the controller's fmt_jobid form alongside the numeric ID: - models: JobSubmitResponse gains job_id_human; job list rows gain job_id_human (processJobData), using the existing backend.FormatJobID. - schedulerclient: URMJob.HumanID + SubmitJobResult.JobIDHuman parse it. - Tests: backend.FormatJobID (real t1 job, pre-cluster1 job, array child); processJobData adds job_id_human. Also rename the SSE permission event:subscribe → event:view so mcp_readonly stays strictly *:view (the read-only invariant test enforces). Verified live on t1: scheduler_submit returns job_id_human 1-0-1786586474-0 and scheduler_get_job returns human_id. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
3d1560d69c
commit
673f2eb792
9 changed files with 135 additions and 10 deletions
|
|
@ -916,3 +916,44 @@ func TestResolveExecUser(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestFormatJobID(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
jobID int64
|
||||
want string
|
||||
}{
|
||||
{
|
||||
name: "real job from t1",
|
||||
jobID: 73930964699447296, // cluster=1 apiserver=0 ts=1786585485 seq=0
|
||||
want: "1-0-1786585485-0",
|
||||
},
|
||||
{
|
||||
name: "pre-cluster1 job",
|
||||
// cluster=0 apiserver=7 ts=1786416651 seq=138313
|
||||
jobID: int64(uint64(0)<<56 | uint64(7)<<52 | uint64(1786416651)<<20 | uint64(138313)),
|
||||
want: "0-7-1786416651-138313",
|
||||
},
|
||||
{
|
||||
name: "zero",
|
||||
jobID: 0,
|
||||
want: "0-0-0-0",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := FormatJobID(tt.jobID); got != tt.want {
|
||||
t.Errorf("FormatJobID(%d) = %q, want %q", tt.jobID, got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestFormatJobID_ArrayChild(t *testing.T) {
|
||||
// Array child: tag 0x01 set, seq split into arrayjob(high)<<15 and idx(low).
|
||||
// cluster=1 apiserver=0 ts=1786585485, arrayjob=3<<15, idx=5.
|
||||
jobID := int64(uint64(1)<<56 | uint64(0)<<52 | uint64(1786585485)<<20 | uint64(0x01)<<62 | uint64(3)<<15 | uint64(5))
|
||||
if got, want := FormatJobID(jobID), "1-0-1786585485-98304[5]"; got != want {
|
||||
t.Errorf("FormatJobID(array) = %q, want %q", got, want)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue