test(scheduler-sim-decision-parity): add resource-contention replay fixture (task 1.2)

Adds a dual-use .replay fixture (3 jobs competing for insufficient worker
capacity) that later tasks need to prove capacity-aware parity under
contention: a real recorded normal-mode session (built by driving the
genuine sched_check_host_satisfy()/sched_commit_job_alloc() capacity/
accounting chain, not mocked) that is also directly replayable through the
real simulation driver. Two tests: fixture shape (job B genuinely denied
while A+C hold the full 10.0-unit capacity, verified against the decoded
recorded decision stream) and sim-driver replayability.

RED-phase proven: raising WORKER_CAPACITY to eliminate contention makes the
shape assertion fail as expected before reverting to the genuine-contention
value. 44/45 scheduler tests pass; the 1 failure is pre-existing bug-1560
(unrelated).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Rongsong Shen 2026-08-22 06:37:04 +00:00
parent 3106c82ed0
commit f11f0df3bd
No known key found for this signature in database
GPG key ID: 5BCDAAE0123E9FE2
3 changed files with 913 additions and 1 deletions

View file

@ -726,6 +726,29 @@ sched_sim_equivalence_test = executable(
dependencies: [scheduler_test_deps],
install: false)
# Resource-contention replay fixture (scheduler-sim-decision-parity spec,
# task 1.2, Req 2.1/2.2): existing fixtures in this directory never have
# scarce capacity, so none can exercise or prove capacity-check correctness.
# This file records ONE real normal-mode session (real builtin_fcfs picker +
# a capacity-aware stand-in allocator that drives the REAL
# sched_check_host_satisfy()/sched_charge_account()/sched_commit_job_alloc()
# (resource.c) against a real, finite-capacity worker) where three jobs
# compete for 10.0 units of one resource -- two dispatch, one is genuinely
# denied capacity the other two, now running, are consuming. First file in
# this directory to combine resource.c with the full driver/sim/recording
# stack (test_resource_accounting.c, task 1.1, deliberately pairs resource.c
# with only core.c -- see that file's own header comment for why). The
# resulting `.replay` file is dual-use: it IS a genuine normal-mode
# recording, and this file's own second test proves it is also directly
# replayable via the real, unmodified simulation driver -- see this file's
# own header comment for the full rationale.
sched_sim_resource_contention_test = executable(
'sched_sim_resource_contention_test',
['test_sim_resource_contention.c'],
include_directories:[incdir],
dependencies: [scheduler_test_deps],
install: false)
# Contract test for the interactive simulation REPL's execution-control slice
# (scheduler-core spec, task 12.1, Req 5 AC 22): starting simulation with
# --interactive pauses before any event is processed, and a `step N` command
@ -1050,6 +1073,9 @@ test('scheduler sim record output test',
test('scheduler sim equivalence test',
sched_sim_equivalence_test, suite: 'scheduler',
env: ['ASAN_OPTIONS=detect_leaks=0'])
test('scheduler sim resource contention test',
sched_sim_resource_contention_test, suite: 'scheduler',
env: ['ASAN_OPTIONS=detect_leaks=0'])
test('scheduler repl execution control test',
sched_repl_execution_control_test, suite: 'scheduler',
env: ['ASAN_OPTIONS=detect_leaks=0'])