refactor(scheduler-allocator-runner): describe the framework runner, not the removed my_alloc() (task 5.1)
Comments in scheduler sources and tests that presented the deleted my_alloc()/parjob claim helpers as current code now name sched_allocator_run() and its runner helpers; test helpers and tests named after my_alloc are renamed. No logic or expectation changes. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
65679285ba
commit
d006de3853
12 changed files with 104 additions and 103 deletions
|
|
@ -2,11 +2,11 @@
|
|||
* test_parjob_combinatorial.c - tasks 4.1 + 4.2 (scheduler-allocation
|
||||
* spec): unit tests for parjob_allocator.c's REAL combinatorial
|
||||
* xce_alloc_plan_iter_t implementation (Req 2 AC 1-6, Req 4 AC 1) AND
|
||||
* (task 4.2, this pass) the real per-bucket allocation loop
|
||||
* (my_alloc()/parjob_try_plan_()/parjob_prepare_allocation(), Req 4 AC
|
||||
* 2/4/5/6/7).
|
||||
* (task 4.2) the real per-bucket allocation loop (then my_alloc()/
|
||||
* parjob_try_plan_(); today sched_allocator_run()/sched_try_plan_() in
|
||||
* alloc_runner.c, plus parjob_prepare_allocation(), Req 4 AC 2/4/5/6/7).
|
||||
*
|
||||
* Task 4.1's own tests below never call my_alloc() -- they drive
|
||||
* Task 4.1's own tests below never call the allocator -- they drive
|
||||
* parjob_plan_iter_init()/_next()/_fini() (static, hence the white-box
|
||||
* #include) directly, and needed no fixture beyond a bare
|
||||
* xce_primary_resreq_t, since the pre-4.2 my_alloc()/parjob_prepare_
|
||||
|
|
@ -49,11 +49,11 @@
|
|||
* test_host_iter.c already established for host_iter_next().
|
||||
*
|
||||
* Covers (task 4.2, new):
|
||||
* - multi-bucket success through the real my_alloc() end to end (Req
|
||||
* - multi-bucket success through the real runner end to end (Req
|
||||
* 4 AC 2/AC 3), including per-bucket resource want scaling with that
|
||||
* bucket's own slot count, not a fixed value (Req 4 AC 5/AC 6)
|
||||
* - the descending-vs-ascending worked example from requirements.md's
|
||||
* Composition Algorithm, driven directly through parjob_try_plan_()
|
||||
* Composition Algorithm, driven directly through sched_try_plan_()
|
||||
* with a hand-built plan for each order against the identical host
|
||||
* pool (Req 4 AC 2)
|
||||
* - a mid-plan bucket failure correctly reversing the earlier
|
||||
|
|
@ -103,8 +103,8 @@
|
|||
/* plugin_register()/plugin_unregister() are referenced by
|
||||
* register_parjob_allocator() (parjob_allocator.c) and core.c
|
||||
* respectively, but no test below calls register_parjob_allocator() --
|
||||
* the plan iterator and my_alloc()/parjob_try_plan_() are exercised
|
||||
* directly. Never actually invoked by anything this file's tests
|
||||
* the plan iterator and sched_allocator_run()/sched_try_plan_() are
|
||||
* exercised directly. Never invoked by anything this file's tests
|
||||
* exercise; provided only so the TU links. */
|
||||
int plugin_register(void* sched, void* plugin)
|
||||
{
|
||||
|
|
@ -177,7 +177,7 @@ int plugin_job_rusage_update(void* s, xce_sched_job_t* j, xce_job_rusages_t* r)
|
|||
}
|
||||
|
||||
/* Avoids white-box-including the rest of scheduler.c just to build the
|
||||
* leaf xce_alloc_t records my_alloc()'s success path constructs -- same
|
||||
* leaf xce_alloc_t records the runner's success path constructs -- same
|
||||
* rationale/shape as test_seqjob_allocator.c's identical stub. This
|
||||
* file's own quantitative per-host assertions go through
|
||||
* assert_uncommitted_host_debit() (real ctx->uncomitted state, untouched
|
||||
|
|
@ -310,7 +310,7 @@ static void init_primary_obj(xce_sched_obj_t* obj,
|
|||
obj->u.primary = primary_obj;
|
||||
}
|
||||
|
||||
/* drive_my_alloc - the exact production sequence a job's allocation
|
||||
/* drive_allocator - the exact production sequence a job's allocation
|
||||
* attempt runs: sched_ctx_init() -> sched_ctx_set_primary() (the real
|
||||
* call that stages ctx->alloc_req.shared via plugin_prepare_allocation()'s
|
||||
* ctx->worker==NULL branch, exactly as sched_make_primary_allocation()
|
||||
|
|
@ -318,8 +318,8 @@ static void init_primary_obj(xce_sched_obj_t* obj,
|
|||
* sched_allocator_run(). Returns its return code; ctx is left
|
||||
* initialized (caller must sched_ctx_fini()). Identical to
|
||||
* test_seqjob_rewrap_equivalence.c's own helper. */
|
||||
static int drive_my_alloc(xce_scheduler_t* sched, xce_sched_obj_t* obj,
|
||||
xce_primary_resreq_t* primary, xce_sched_ctx_t* ctx)
|
||||
static int drive_allocator(xce_scheduler_t* sched, xce_sched_obj_t* obj,
|
||||
xce_primary_resreq_t* primary, xce_sched_ctx_t* ctx)
|
||||
{
|
||||
xce_sched_plugin_t plugin;
|
||||
|
||||
|
|
@ -665,7 +665,7 @@ static void test_next_has_a_real_cancellation_point(void)
|
|||
|
||||
/*
|
||||
* Req 4 AC 2/AC 3/AC 5/AC 6: a real multi-bucket plan, driven end to end
|
||||
* through the real my_alloc() (not parjob_try_plan_() directly). Two
|
||||
* through the real sched_allocator_run() (not sched_try_plan_()). Two
|
||||
* hosts are engineered so the outcome is deterministic REGARDLESS of
|
||||
* sched->core.workers' own hash-based iteration order: host-A has exactly
|
||||
* 2 free slots (only it can satisfy a "need 2" bucket -- host-B's 1 free
|
||||
|
|
@ -679,7 +679,7 @@ static void test_next_has_a_real_cancellation_point(void)
|
|||
* fixed-value bug would either allocate nothing or debit the wrong
|
||||
* amount, and assert_uncommitted_host_debit() below would catch either.
|
||||
*/
|
||||
static void test_multi_bucket_plan_succeeds_through_real_my_alloc(void)
|
||||
static void test_multi_bucket_plan_succeeds_through_real_runner(void)
|
||||
{
|
||||
xce_scheduler_t sched;
|
||||
xce_resource_t* slots_res;
|
||||
|
|
@ -712,7 +712,7 @@ static void test_multi_bucket_plan_succeeds_through_real_my_alloc(void)
|
|||
|
||||
init_primary_obj(&obj, &primary_obj, &primary);
|
||||
|
||||
rc = drive_my_alloc(&sched, &obj, &primary, &ctx);
|
||||
rc = drive_allocator(&sched, &obj, &primary, &ctx);
|
||||
|
||||
TEST_ASSERT_EQUAL_INT(1, rc);
|
||||
TEST_ASSERT_NOT_NULL(ctx.alloc);
|
||||
|
|
@ -749,7 +749,7 @@ static void test_multi_bucket_plan_succeeds_through_real_my_alloc(void)
|
|||
* onto the job whatever the rc). ASAN catches a double free or use after
|
||||
* free on the cleanup path.
|
||||
*/
|
||||
static void test_my_alloc_reports_enomem_when_allocs_cannot_be_built(void)
|
||||
static void test_allocator_reports_enomem_when_allocs_cannot_be_built(void)
|
||||
{
|
||||
int fail_at;
|
||||
|
||||
|
|
@ -779,7 +779,7 @@ static void test_my_alloc_reports_enomem_when_allocs_cannot_be_built(void)
|
|||
|
||||
g_make_allocs_calls = 0;
|
||||
g_make_allocs_fail_at = fail_at;
|
||||
rc = drive_my_alloc(&sched, &obj, &primary, &ctx);
|
||||
rc = drive_allocator(&sched, &obj, &primary, &ctx);
|
||||
g_make_allocs_fail_at = -1;
|
||||
|
||||
TEST_ASSERT_EQUAL_INT(-ENOMEM, rc);
|
||||
|
|
@ -803,13 +803,13 @@ static void test_my_alloc_reports_enomem_when_allocs_cannot_be_built(void)
|
|||
* for a small bucket greedily claims whatever it encounters first that
|
||||
* already satisfies it).
|
||||
*
|
||||
* Driven directly through parjob_try_plan_() (not the real plan
|
||||
* Driven directly through sched_try_plan_() (not the real plan
|
||||
* iterator, which only ever generates descending order) with a
|
||||
* hand-built xce_alloc_plan_t for each order, against the SAME
|
||||
* unmodified host pool (the descending attempt's claims are rolled back
|
||||
* before the ascending attempt runs) -- this is the seam task 4.2's own
|
||||
* bucket-loop factoring (out of my_alloc()) exists to make testable
|
||||
* without reimplementing the loop in the test.
|
||||
* before the ascending attempt runs) -- the seam the runner's
|
||||
* per-plan helper exists to make testable without reimplementing the
|
||||
* loop in the test.
|
||||
*/
|
||||
static void test_descending_bucket_order_succeeds_where_ascending_fails(void)
|
||||
{
|
||||
|
|
@ -993,7 +993,7 @@ test_mid_plan_bucket_failure_rolls_back_before_later_plan_succeeds(void)
|
|||
|
||||
init_primary_obj(&obj, &primary_obj, &primary);
|
||||
|
||||
rc = drive_my_alloc(&sched, &obj, &primary, &ctx);
|
||||
rc = drive_allocator(&sched, &obj, &primary, &ctx);
|
||||
|
||||
TEST_ASSERT_EQUAL_INT(1, rc);
|
||||
TEST_ASSERT_NOT_NULL(ctx.alloc);
|
||||
|
|
@ -1035,7 +1035,7 @@ test_mid_plan_bucket_failure_rolls_back_before_later_plan_succeeds(void)
|
|||
|
||||
/*
|
||||
* Req 4 AC 4: when every candidate plan is exhausted without a full
|
||||
* success, my_alloc() returns the same not-satisfied signal (0) the old
|
||||
* success, the runner returns the same not-satisfied signal (0) the old
|
||||
* stub always returned, unconditionally -- pend-reason handling
|
||||
* downstream is unaffected by this task's change.
|
||||
*/
|
||||
|
|
@ -1067,7 +1067,7 @@ static void test_returns_zero_when_every_plan_is_exhausted(void)
|
|||
|
||||
init_primary_obj(&obj, &primary_obj, &primary);
|
||||
|
||||
rc = drive_my_alloc(&sched, &obj, &primary, &ctx);
|
||||
rc = drive_allocator(&sched, &obj, &primary, &ctx);
|
||||
|
||||
TEST_ASSERT_EQUAL_INT(0, rc);
|
||||
TEST_ASSERT_NULL(ctx.alloc);
|
||||
|
|
@ -1081,7 +1081,7 @@ static void test_returns_zero_when_every_plan_is_exhausted(void)
|
|||
* many hosts were used." Task 4.2's fixtures only ever used a per-host
|
||||
* ("slots") resource -- this test drives a job carrying BOTH a per-host
|
||||
* resource AND a genuinely job-level/shared (XCE_RESF_GLOBAL) resource
|
||||
* through a real multi-host my_alloc() success and asserts the shared
|
||||
* through a real multi-host runner success and asserts the shared
|
||||
* resource is debited exactly ONCE at the job level, not once per claimed
|
||||
* host/bucket.
|
||||
*
|
||||
|
|
@ -1109,7 +1109,7 @@ static void test_returns_zero_when_every_plan_is_exhausted(void)
|
|||
* by direct dynamic count rather than code inspection alone, that the
|
||||
* job-level (ctx->worker == NULL) prepare pass fires exactly once for this
|
||||
* whole 4-host allocation attempt -- confirming sched_ctx_set_primary()'s
|
||||
* single call site (schedobj.c), not my_alloc()'s plan/bucket loop, is what
|
||||
* single call site (schedobj.c), not the runner's plan/bucket loop, is what
|
||||
* drives it.
|
||||
*/
|
||||
static void test_shared_resource_debited_once_regardless_of_host_count(void)
|
||||
|
|
@ -1170,7 +1170,7 @@ static void test_shared_resource_debited_once_regardless_of_host_count(void)
|
|||
init_primary_obj(&obj, &primary_obj, &primary);
|
||||
|
||||
g_job_level_prepare_calls = 0;
|
||||
rc = drive_my_alloc(&sched, &obj, &primary, &ctx);
|
||||
rc = drive_allocator(&sched, &obj, &primary, &ctx);
|
||||
|
||||
TEST_ASSERT_EQUAL_INT(1, rc);
|
||||
TEST_ASSERT_NOT_NULL(ctx.alloc);
|
||||
|
|
@ -1229,8 +1229,8 @@ int main(void)
|
|||
RUN_TEST(test_plan_generation_ignores_core_state);
|
||||
RUN_TEST(test_init_rejects_invalid_input);
|
||||
RUN_TEST(test_next_has_a_real_cancellation_point);
|
||||
RUN_TEST(test_multi_bucket_plan_succeeds_through_real_my_alloc);
|
||||
RUN_TEST(test_my_alloc_reports_enomem_when_allocs_cannot_be_built);
|
||||
RUN_TEST(test_multi_bucket_plan_succeeds_through_real_runner);
|
||||
RUN_TEST(test_allocator_reports_enomem_when_allocs_cannot_be_built);
|
||||
RUN_TEST(test_descending_bucket_order_succeeds_where_ascending_fails);
|
||||
RUN_TEST(
|
||||
test_mid_plan_bucket_failure_rolls_back_before_later_plan_succeeds);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue