forked from lei.chen/myxce
test(ha-commit-engine): RED tests for per-LSN majority evaluation (task 1.1)
commit.h umbrella-verbatim interface + inert stub commit.c (test target only); 7 Unity tests covering per-LSN vs acked_lsn>0 counting, majority median, monotonicity, append clamp, lagging standby, RETAIN immediacy. All 7 fail RED as intended. Documented 3 pre-existing masked suite failures (bug-411) and the per-group exit-code masking root cause.
This commit is contained in:
parent
06135954ff
commit
d5a0f9c64d
10 changed files with 757 additions and 283 deletions
68
src/controller/commit.c
Normal file
68
src/controller/commit.c
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
* commit.c — STUB for ha-commit-engine task 1.1 (RED phase).
|
||||
*
|
||||
* Behavioral functions are deliberately inert (-ENOSYS / no-op) so the
|
||||
* task 1.1 tests in testsuite/test_commit_engine.c compile, link, and FAIL
|
||||
* on their assertions. init/fini are real enough that tests exercise the
|
||||
* engine's behavioral contract rather than failing at fixture setup.
|
||||
*
|
||||
* The real implementation lands in task 1.2 (per-LSN majority evaluation,
|
||||
* monotonic/contiguous committed_lsn advancement).
|
||||
*/
|
||||
#include <errno.h>
|
||||
|
||||
#include "commit.h"
|
||||
|
||||
int commit_engine_init(commit_engine_t* ce, persist_t* p, int n_peers, int n_vcpus)
|
||||
{
|
||||
if (ce == NULL || p == NULL || n_peers < 0 || n_vcpus < 1) {
|
||||
return -EINVAL;
|
||||
}
|
||||
pthread_mutex_init(&ce->lock, NULL);
|
||||
pthread_cond_init(&ce->cond, NULL);
|
||||
ce->p = p;
|
||||
ce->n_peers = n_peers;
|
||||
ce->n_vcpus = n_vcpus;
|
||||
ce->inflight_waits = 0;
|
||||
ce->writable_lsn = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void commit_engine_fini(commit_engine_t* ce)
|
||||
{
|
||||
if (ce == NULL) {
|
||||
return;
|
||||
}
|
||||
pthread_cond_destroy(&ce->cond);
|
||||
pthread_mutex_destroy(&ce->lock);
|
||||
ce->p = NULL;
|
||||
}
|
||||
|
||||
int commit_submit(commit_engine_t* ce, uint64_t lsn, commit_mode_t mode,
|
||||
uint32_t timeout_ms)
|
||||
{
|
||||
(void)ce;
|
||||
(void)lsn;
|
||||
(void)mode;
|
||||
(void)timeout_ms;
|
||||
return -ENOSYS; /* stub: real WAIT/RETAIN semantics in task 1.2/2.2 */
|
||||
}
|
||||
|
||||
void commit_on_ack(commit_engine_t* ce, int standby_idx, uint64_t acked_lsn)
|
||||
{
|
||||
(void)ce;
|
||||
(void)standby_idx;
|
||||
(void)acked_lsn;
|
||||
/* stub: never advances committed_lsn */
|
||||
}
|
||||
|
||||
void commit_set_writable_lsn(commit_engine_t* ce, uint64_t noop_lsn)
|
||||
{
|
||||
(void)ce;
|
||||
(void)noop_lsn;
|
||||
}
|
||||
|
||||
void commit_on_membership_change(commit_engine_t* ce)
|
||||
{
|
||||
(void)ce;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue