- cluster_def.h: add struct tag `cluster_s` to cluster_t to resolve
conflicting typedef with persist.h forward declaration
- cluster_def.h: add HOOK_DETAIL_JOB_STOP and HOOK_DETAIL_JOB_RESUME enum
values after HOOK_DETAIL_JOB_RUSAGE_UPDATE
- job.c on_job_stop(): replace mark_job_update() call with direct
xce_run_hooks(BEFORE/AFTER, HOOK_DETAIL_JOB_STOP) so WAL writer
records stop events with the correct detail value
- job.c on_job_resume(): same pattern with HOOK_DETAIL_JOB_RESUME
- job.c do_clr_preason(): fix typo — second hook call was HOOK_BEFORE_EVENT
instead of HOOK_AFTER_EVENT (double-before, zero-after bug)
- join.c handle_worker_join(): move xce_reply() to after HOOK_AFTER_EVENT
so client ACK is not sent before WAL write completes (durability fix)
- testsuite/test_hooks.c: new TDD tests for JOB_STOP/RESUME enum values
- testsuite/controller_test.c + meson.build: register test_hooks suite
Reply ordering audit results:
job.c handle_jobsubmit: reply before AFTER_EVENT — intentional (jobid
returned to client before scheduler notification; WAL hook belongs in
BEFORE_EVENT for this path, handled in Task 13)
job.c do_set_preason: reply before set_preason() loop — intentional
fire-and-forget (no AFTER_EVENT hook at top level)
job.c do_clr_preason: reply before loop — same fire-and-forget pattern
job.c do_jobcontrol_op: no AFTER_EVENT hook, reply only — OK
join.c handle_worker_join: FIXED (reply moved after AFTER_EVENT)
worker.c on_worker_update/dead: reply after all hooks — OK
cluster.c: AFTER_EVENT hooks are internal (no reply) — OK
40 lines
1.2 KiB
C
40 lines
1.2 KiB
C
#include <stdio.h>
|
|
|
|
#include <unity/unity.h>
|
|
|
|
#include "xce/cluster_def.h"
|
|
|
|
static void test_hook_detail_job_stop_exists(void)
|
|
{
|
|
/* HOOK_DETAIL_JOB_STOP must be defined and distinct from JOB_UPDATE */
|
|
int stop_val = (int)HOOK_DETAIL_JOB_STOP;
|
|
int update_val = (int)HOOK_DETAIL_JOB_UPDATE;
|
|
TEST_ASSERT_TRUE(stop_val != 0);
|
|
TEST_ASSERT_TRUE(stop_val != update_val);
|
|
printf("test_hook_detail_job_stop_exists: PASS\n");
|
|
}
|
|
|
|
static void test_hook_detail_job_resume_exists(void)
|
|
{
|
|
int resume_val = (int)HOOK_DETAIL_JOB_RESUME;
|
|
int update_val = (int)HOOK_DETAIL_JOB_UPDATE;
|
|
TEST_ASSERT_TRUE(resume_val != 0);
|
|
TEST_ASSERT_TRUE(resume_val != update_val);
|
|
TEST_ASSERT_TRUE(resume_val != (int)HOOK_DETAIL_JOB_STOP);
|
|
printf("test_hook_detail_job_resume_exists: PASS\n");
|
|
}
|
|
|
|
static void test_hook_detail_job_stop_and_resume_are_distinct(void)
|
|
{
|
|
TEST_ASSERT_NOT_EQUAL((int)HOOK_DETAIL_JOB_STOP, (int)HOOK_DETAIL_JOB_RESUME);
|
|
printf("test_hook_detail_job_stop_and_resume_are_distinct: PASS\n");
|
|
}
|
|
|
|
void test_hooks(void)
|
|
{
|
|
printf("\n>> hook detail enum tests\n\n");
|
|
|
|
RUN_TEST(test_hook_detail_job_stop_exists);
|
|
RUN_TEST(test_hook_detail_job_resume_exists);
|
|
RUN_TEST(test_hook_detail_job_stop_and_resume_are_distinct);
|
|
}
|