fix(worker): real maxswap/maxtmp detection; feat(scheduler): annotate multi-slot assigned jobs
bug-1554: init_host_attrs() replaces hardcoded placeholder stubs with real
detection -- maxswap from sysinfo()'s totalswap (reusing the same syscall
snapshot already taken for maxmem), maxtmp from a fresh statvfs("/tmp")
total-capacity measurement. No synthetic fallback on detection failure, so
a system with swap genuinely disabled correctly reports 0.
bug-1776: the scheduler simulator's "info worker" assigned-jobs listing now
annotates a job consuming more than one "slots" unit (e.g. "jobid*2"),
using per-host allocation data that was already being walked but discarded.
Falls back to the pre-existing per-job listing when jobs on the same worker
have differing slot counts, since a single suffix on a compressed range
would be ambiguous.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hb6Edtj4KbS8CrgEWYdA2E
This commit is contained in:
parent
a6b735b6f2
commit
a35f597e06
9 changed files with 660 additions and 28 deletions
|
|
@ -125,6 +125,17 @@ double hardware_monitor_get_total_memory(hardware_monitor_t* monitor)
|
|||
(void)monitor;
|
||||
return 16384.0;
|
||||
}
|
||||
double hardware_monitor_get_total_swap(hardware_monitor_t* monitor)
|
||||
{
|
||||
(void)monitor;
|
||||
return 4096.0;
|
||||
}
|
||||
bool hardware_monitor_get_disk_info(const char* path, int64_t* total_bytes)
|
||||
{
|
||||
(void)path;
|
||||
*total_bytes = 8192;
|
||||
return true;
|
||||
}
|
||||
|
||||
network_handler_t* network_handler_create(uint16_t port)
|
||||
{
|
||||
|
|
@ -358,6 +369,29 @@ static void test_no_peers_cluster_cfg_stays_empty_before_first_join(void)
|
|||
"test_no_peers_cluster_cfg_stays_empty_before_first_join: PASS\n");
|
||||
}
|
||||
|
||||
/* ════════════════════════════════════════════════════════════════════════
|
||||
* bug-1554: init_host_attrs() must source maxswap/maxtmp from real
|
||||
* detection (hardware_monitor_get_total_swap()/hardware_monitor_get_disk_
|
||||
* info(), both stubbed above) instead of the old hardcoded placeholder
|
||||
* constants (1024MB/2048MB) -- this test would have kept passing under the
|
||||
* old stub-constant code too (it doesn't assert the old magic numbers are
|
||||
* ABSENT), but it does pin that host_attrs picks up whatever these two
|
||||
* functions report, which the placeholder code structurally could not do.
|
||||
* ════════════════════════════════════════════════════════════════════════ */
|
||||
|
||||
static void test_init_host_attrs_uses_real_swap_and_tmp_detection(void)
|
||||
{
|
||||
xcecd_config_t config = base_test_config();
|
||||
|
||||
TEST_ASSERT_EQUAL_INT(0, xcecd_init(&config));
|
||||
TEST_ASSERT_EQUAL_INT(0, xcecd_start());
|
||||
|
||||
TEST_ASSERT_EQUAL_FLOAT(4096.0f, (float)host_attrs.maxswap);
|
||||
TEST_ASSERT_EQUAL_FLOAT(8192.0f, (float)host_attrs.maxtmp);
|
||||
|
||||
printf("test_init_host_attrs_uses_real_swap_and_tmp_detection: PASS\n");
|
||||
}
|
||||
|
||||
/* ════════════════════════════════════════════════════════════════════════
|
||||
* main
|
||||
* ════════════════════════════════════════════════════════════════════════ */
|
||||
|
|
@ -370,6 +404,7 @@ int main(void)
|
|||
|
||||
RUN_TEST(test_multi_candidate_cluster_cfg_populated_before_first_join);
|
||||
RUN_TEST(test_no_peers_cluster_cfg_stays_empty_before_first_join);
|
||||
RUN_TEST(test_init_host_attrs_uses_real_swap_and_tmp_detection);
|
||||
|
||||
return UNITY_END();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue