feat(libxce-alloc-preason-equality): recorded dispatch fixtures carry the session-start from (task 4.2)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
6110d12e5a
commit
69112c2d22
7 changed files with 137 additions and 60 deletions
|
|
@ -460,6 +460,19 @@ void tearDown(void) { return; }
|
|||
/* Unit-level fixture helpers: hand-built xce_job_alloc_t trees. */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
/* SESSION_FROM - the `from` a DISPATCH allocation decided in a session that
|
||||
* began at `begin_ns` (epoch nanoseconds) carries: the session start in
|
||||
* whole seconds, floor division (libxce-alloc-preason-equality Decision 8;
|
||||
* scheduler.c's sched_make_primary_alloc_() stamps it, and in simulation
|
||||
* mode the session starts at the recorded beginRound). Hand-built recorded
|
||||
* DISPATCH fixtures replayed through sched_sim_driver_run() below derive
|
||||
* their `from` from the same begin_round they are recorded under. */
|
||||
#define SESSION_FROM(begin_ns) ((uint64_t)(begin_ns) / 1000000000ULL)
|
||||
|
||||
/* The recorded round-1 beginRound those DISPATCH fixtures are appended
|
||||
* under (logical nanoseconds). */
|
||||
#define ROUND1_BEGIN_NS 2000ULL
|
||||
|
||||
static xce_alloc_t* make_test_alloc(const char* resname, const char* reserve,
|
||||
uint64_t instid, double value,
|
||||
uint64_t from, int64_t duration)
|
||||
|
|
@ -1645,12 +1658,13 @@ static void test_verify_with_already_resolved_job_reports_no_mismatch(void)
|
|||
append_job_state_change_event(f, 1800ULL, 501ULL, JOB_STAT_PEND,
|
||||
JOB_STAT_RUN);
|
||||
|
||||
res[0] = make_test_alloc("slots", "run", 1, 4.0, 0, 0);
|
||||
res[0] = make_test_alloc("slots", "run", 1, 4.0,
|
||||
SESSION_FROM(ROUND1_BEGIN_NS), 0);
|
||||
host[0] = make_test_host_alloc("hostA", res, 1);
|
||||
alloc = make_test_job_alloc(501ULL, host, 1);
|
||||
|
||||
append_replay_session_with_dispatch_and_pend(f, 2000ULL, alloc, 502ULL,
|
||||
0);
|
||||
append_replay_session_with_dispatch_and_pend(f, ROUND1_BEGIN_NS, alloc,
|
||||
502ULL, 0);
|
||||
append_end_of_stream_marker(f);
|
||||
fclose(f);
|
||||
|
||||
|
|
@ -1722,18 +1736,21 @@ test_verify_with_multiple_already_resolved_jobs_across_rounds_reports_no_mismatc
|
|||
append_job_state_change_event(f, 1801ULL, 503ULL, JOB_STAT_PEND,
|
||||
JOB_STAT_RUN);
|
||||
|
||||
res_a[0] = make_test_alloc("slots", "run", 1, 4.0, 0, 0);
|
||||
res_a[0] = make_test_alloc("slots", "run", 1, 4.0,
|
||||
SESSION_FROM(ROUND1_BEGIN_NS), 0);
|
||||
host_a[0] = make_test_host_alloc("hostA", res_a, 1);
|
||||
alloc_a = make_test_job_alloc(501ULL, host_a, 1);
|
||||
|
||||
res_c[0] = make_test_alloc("slots", "run", 1, 2.0, 0, 0);
|
||||
res_c[0] = make_test_alloc("slots", "run", 1, 2.0,
|
||||
SESSION_FROM(ROUND1_BEGIN_NS), 0);
|
||||
host_c[0] = make_test_host_alloc("hostC", res_c, 1);
|
||||
alloc_c = make_test_job_alloc(503ULL, host_c, 1);
|
||||
|
||||
/* Recorded order: DISPATCH(A), PEND(B), DISPATCH(C) -- B's entry is
|
||||
* sandwiched between the two entries reconciliation consumes. */
|
||||
append_replay_session_with_two_dispatches_and_pend(f, 2000ULL, alloc_a,
|
||||
502ULL, 0, alloc_c);
|
||||
append_replay_session_with_two_dispatches_and_pend(f, ROUND1_BEGIN_NS,
|
||||
alloc_a, 502ULL, 0,
|
||||
alloc_c);
|
||||
|
||||
/* Round 2: job B (502) is still genuinely PEND (never dispatched, never
|
||||
* state-changed) so builtin_fcfs's pendJobs discipline re-offers it to
|
||||
|
|
@ -1821,7 +1838,8 @@ test_reconciliation_no_longer_masks_a_pend_jobs_dispatch_mismatch(void)
|
|||
append_queue_update_event(f, 1000ULL, "normal");
|
||||
append_jobs_push_event(f, 1500ULL, 601ULL, "normal");
|
||||
|
||||
res[0] = make_test_alloc("slots", "run", 1, 4.0, 0, 0);
|
||||
res[0] = make_test_alloc("slots", "run", 1, 4.0,
|
||||
SESSION_FROM(ROUND1_BEGIN_NS), 0);
|
||||
host[0] = make_test_host_alloc("hostA", res, 1);
|
||||
alloc = make_test_job_alloc(601ULL, host, 1);
|
||||
|
||||
|
|
@ -1832,7 +1850,7 @@ test_reconciliation_no_longer_masks_a_pend_jobs_dispatch_mismatch(void)
|
|||
* header comment) is the only thing that CAN decide it, and it always
|
||||
* PENDs. The live stream therefore produces PEND(601) against a
|
||||
* recorded DISPATCH(601) -- a genuine, correctly-reported mismatch. */
|
||||
append_replay_session_with_dispatch(f, 2000ULL, alloc);
|
||||
append_replay_session_with_dispatch(f, ROUND1_BEGIN_NS, alloc);
|
||||
|
||||
/* Round 2: job 601 is STILL a picker candidate (nothing retired it --
|
||||
* reconciliation never touched it, and the stub allocator's on_pend()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue