test(controller): cover WAL_JOB_DISPATCH allocation persistence (bug-1678)
test_dispatch_commit.c's test_dc_success_appends_wal_job_dispatch_durably (already drove the real dispatch_a_job_() production path through a real WAL-write + persist_recover() restart cycle, previously only checking recovered state) now also asserts the recovered job.allocs matches what was dispatched -- host, resource name, value. This is the primary regression test for the user's exact acceptance criterion: "after recover the job should get the same as it's state before shutdown." Independently reproduced RED->GREEN (not just narrated): reverted the production fix with the test extension kept, rebuilt, confirmed FAIL at exactly this assertion; restored, rebuilt, confirmed PASS. test_wal_job_dispatch_fact.c: added 3 new tests exercising the richer payload directly on both apply_committed_entry and apply_wal_entry, plus a full restart-replay variant. All 3 pre-existing tests (bare wal_jobstate_t payloads, no trailing bytes) pass completely unchanged, proving backward compatibility with any WAL_JOB_DISPATCH entry written before this fix. Full controller_unit_test suite independently re-run: 1136/1136 pass, zero regressions. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AgYRU3zDTqNGV5Jk8aiKLg
This commit is contained in:
parent
db142d415f
commit
f8851353cd
2 changed files with 250 additions and 0 deletions
|
|
@ -619,6 +619,31 @@ static void test_dc_success_appends_wal_job_dispatch_durably(void)
|
|||
"WAL_JOB_DISPATCH fact appended by dispatch_a_job_()'s real "
|
||||
"success path -- no WAL_JOB_START anywhere in this log");
|
||||
|
||||
/* bug-1678: restart replay must recover not just STATE but the
|
||||
* resource allocation itself, or EXEC_HOST is permanently blank for
|
||||
* a job that was genuinely RUNNING before shutdown -- the user's
|
||||
* exact acceptance criterion ("after recover the job should get the
|
||||
* same as it's state before shutdown"). Mirrors Phase 1's real
|
||||
* dispatch: host "wkr-replay", one resource "slots" value 1.0. */
|
||||
TEST_ASSERT_NOT_NULL_MESSAGE(j2->job.allocs,
|
||||
"restart replay must recover the dispatch-time resource "
|
||||
"allocation (bug-1678), not just the RUN state");
|
||||
TEST_ASSERT_EQUAL_INT_MESSAGE(1, j2->job.allocs->nhosts,
|
||||
"recovered allocation must have exactly 1 host, matching what "
|
||||
"was dispatched in Phase 1");
|
||||
TEST_ASSERT_NOT_NULL(j2->job.allocs->allocs);
|
||||
TEST_ASSERT_NOT_NULL(j2->job.allocs->allocs[0]);
|
||||
TEST_ASSERT_EQUAL_STRING_MESSAGE("wkr-replay",
|
||||
j2->job.allocs->allocs[0]->host,
|
||||
"recovered allocation's host must match the dispatched worker");
|
||||
TEST_ASSERT_EQUAL_INT(1, j2->job.allocs->allocs[0]->nallocs);
|
||||
TEST_ASSERT_NOT_NULL(j2->job.allocs->allocs[0]->allocs);
|
||||
TEST_ASSERT_NOT_NULL(j2->job.allocs->allocs[0]->allocs[0]);
|
||||
TEST_ASSERT_EQUAL_STRING("slots",
|
||||
j2->job.allocs->allocs[0]->allocs[0]->resname);
|
||||
TEST_ASSERT_EQUAL_FLOAT(1.0f,
|
||||
j2->job.allocs->allocs[0]->allocs[0]->value);
|
||||
|
||||
xce_hook_fini(&c2.hooksys);
|
||||
if (c2.jobmgr) dereference(c2.jobmgr);
|
||||
dc_teardown_persist(p2);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue