feat(scheduler-allocator-runner): seqjob allocates through the framework runner (task 4.2)

seqjob registers sched_allocator_run with seqjob_alloc_iface (no accepts
guard, plus its one-bucket plan iterator); its private my_alloc() is
gone. New fixtures pin the intended changes: a reason for every short
host, the bug-1893 shared reason, the host-stage OOM debit release, and
-EINVAL for missing inputs; seqjob's plan is asserted to be one bucket of
one slot. No other test expectation changed.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Rongsong Shen 2026-09-30 09:53:14 +00:00
parent 239bcf95cd
commit 65679285ba
Signed by untrusted user: rshen
GPG key ID: 80533536B0EB651C
7 changed files with 674 additions and 244 deletions

View file

@ -2,9 +2,8 @@
* test_alloc_equivalence_seqjob.c - scheduler-allocator-runner task 2.1:
* characterization of the sequential-job allocator (Req 4.5, 5.4, 5.8,
* 7.2), driven only through the registered plugin->job_alloc_fn of
* seqjob_allocator_new_plugin(), never the static routine by name. The
* expectations must still hold once task 4.2 replaces that routine with the
* framework runner (one more white-box include below). Each fixture asserts
* seqjob_allocator_new_plugin() (the framework runner since task 4.2),
* with the Req 2.2 and 5.5 changes of task 4.2 pinned. Each fixture asserts
* result code, hosts, per-host records, shared records, per-host and shared
* uncommitted amounts and pend reasons.
*
@ -14,11 +13,10 @@
* libxce make_host_alloc/make_job_alloc (meson.build) failing on call N.
* The host-array allocation is not injected (its origin changes; task 3.3).
*
* Kept out on purpose: multi-host pending (Req 3.7), more shared requests
* than short ones (bug-1893), COMPOUND layouts where the positional
* uncommitted read (bug-1892) matters. Values the switch changes on purpose
* (Req 5.5 host-stage debit, Req 2.2 shared reasons) sit in their own
* `_today` test functions.
* Multi-host pending (Req 3.7), more shared requests than short ones
* (bug-1893), the plan shape and missing inputs (Req 5.1) are in
* test_alloc_equivalence_seqjob_changes.c. COMPOUND layouts where the
* positional uncommitted read (bug-1892) matters are kept out.
*/
#include <errno.h>
#include <stdlib.h>
@ -34,12 +32,12 @@
#include "xcealloc.h"
#include "xstring.h"
/* White-box sources under test. Task 4.2 adds the framework runner
* ("../src/alloc_runner.c") as one more line of this list. */
/* White-box sources under test. */
#include "../src/core.c"
#include "../src/resource.c"
#include "../src/schedobj.c"
#include "../src/host_iter.c"
#include "../src/alloc_runner.c"
#include "../src/plugins/seqjob_allocator.c"
/* ---------------------------------------------------------------------- */
@ -515,18 +513,17 @@ static void test_seqjob_pending_on_short_shared_resource(void)
eq_finish(&f, &p);
}
/* 2, resource reasons, TODAY's behaviour: none. The reason loop skips
* every unmet entry because vget() returns 0 on success and the loop
* tests `rc <= 0`. Requirement 2.2 changes this in task 4.2 (one host-less
* NO_RESOURCE reason naming "licenses"). */
static void test_seqjob_pending_on_short_shared_no_reason_today(void)
/* 2, resource reasons (Req 2.2, bug-1893): exactly one host-less
* NO_RESOURCE reason (host stored as ""), naming "licenses". */
static void test_seqjob_pending_on_short_shared_names_it(void)
{
eq_fixture_t f;
eq_primary_t p;
xce_sched_worker_t* a;
TEST_ASSERT_EQUAL_INT(0, eq_run_short_shared(&f, &p, &a));
eq_assert_reason_counts(&f, 0, 0, 0);
eq_assert_reason_counts(&f, 0, 0, 1);
eq_assert_res_reason(&f, 0, "", "licenses");
eq_finish(&f, &p);
}
@ -561,7 +558,7 @@ static void test_seqjob_pending_single_host_short_of_mem(void)
}
/* 4a. Out of memory building the claimed host's allocation records
* (sched_make_allocs() call 1). Per-host debit: see the _debit_today test. */
* (sched_make_allocs() call 1). Per-host debit: see _releases_debit. */
static void test_seqjob_oom_host_records_returns_enomem(void)
{
eq_fixture_t f;
@ -578,8 +575,8 @@ static void test_seqjob_oom_host_records_returns_enomem(void)
eq_finish(&f, &p);
}
/* 4b. Out of memory in make_host_alloc(). Per-host debit: see the
* _debit_today test. */
/* 4b. Out of memory in make_host_alloc(). Per-host debit: see
* _releases_debit. */
static void test_seqjob_oom_host_alloc_returns_enomem(void)
{
eq_fixture_t f;
@ -596,10 +593,9 @@ static void test_seqjob_oom_host_alloc_returns_enomem(void)
eq_finish(&f, &p);
}
/* 4a/4b per-host debit, TODAY's behaviour: the claimed host's debit is
* left in the attempt context. Requirement 5.5 changes this in task 4.2
* (the debit of a claim not turned into a host allocation is released). */
static void test_seqjob_oom_host_stage_leaves_debit_today(void)
/* 4a/4b per-host debit (Req 5.5): the claim was not turned into a host
* allocation, so the claimed host's debit is released. */
static void test_seqjob_oom_host_stage_releases_debit(void)
{
int stage;
@ -616,8 +612,8 @@ static void test_seqjob_oom_host_stage_leaves_debit_today(void)
}
TEST_ASSERT_EQUAL_INT(-ENOMEM, eq_run_standard(&f, &p, &a));
TEST_ASSERT_EQUAL_FLOAT(2.0f, eq_host_uncomit(&f, a, f.mem));
TEST_ASSERT_EQUAL_FLOAT(1.0f, eq_host_uncomit(&f, a, f.slots));
TEST_ASSERT_EQUAL_FLOAT(0.0f, eq_host_uncomit(&f, a, f.mem));
TEST_ASSERT_EQUAL_FLOAT(0.0f, eq_host_uncomit(&f, a, f.slots));
eq_finish(&f, &p);
}
@ -780,11 +776,11 @@ int main(void)
UNITY_BEGIN();
RUN_TEST(test_seqjob_success_one_host_with_shared);
RUN_TEST(test_seqjob_pending_on_short_shared_resource);
RUN_TEST(test_seqjob_pending_on_short_shared_no_reason_today);
RUN_TEST(test_seqjob_pending_on_short_shared_names_it);
RUN_TEST(test_seqjob_pending_single_host_short_of_mem);
RUN_TEST(test_seqjob_oom_host_records_returns_enomem);
RUN_TEST(test_seqjob_oom_host_alloc_returns_enomem);
RUN_TEST(test_seqjob_oom_host_stage_leaves_debit_today);
RUN_TEST(test_seqjob_oom_host_stage_releases_debit);
RUN_TEST(test_seqjob_oom_job_alloc_returns_enomem_debit_stays);
RUN_TEST(test_seqjob_oom_shared_records_returns_enomem_debit_stays);
RUN_TEST(test_seqjob_task_count_zero_reaches_plugin);