myxce/src/lib/meson.build
Rongsong Shen fd9cfce1c1 feat: P2.5-5/6 add --peers/--ca-cert parsing to worker+scheduler with validation
Worker (P2.5-5):
- Added parse_peers() static helper to src/worker/src/main.c
- Switched getopt to getopt_long to support --peers and --ca-cert long options
- When --peers is given: parses into xce_cluster_config_t, calls
  xce_cluster_config_validate(), logs INFO with candidate count/identity/ca_cert
- If validation fails: prints clear error and exits(1)
- WARN logged when candidates_count > 3
- Backward compatible: no --peers falls back to existing single-controller path

Scheduler (P2.5-6):
- Added parse_peers() static helper to src/scheduler/src/main.c
- Extended argp struct with --peers (-P) and --ca-cert (-C) options
- Same validation/logging pattern as worker
- Backward compatible: no --peers falls back to existing single-controller path

Tests (new):
- src/lib/testsuite/test_cluster_parse.c: 8 unit tests for parse_peers logic
  (single entry, multiple entries, no-name format, empty/null/missing-port errors,
  name-stripped correctly, MAX_HA_CANDIDATES cap respected)
- Registered in test.c and meson.build
- All 8 tests GREEN; 3 pre-existing failures in unrelated GC/CSE tests unchanged
2026-05-08 02:32:56 +00:00

181 lines
5.3 KiB
Meson

capnp = find_program('capnp')
packcc = find_program('packcc')
schema_dir = meson.current_source_dir() / '..' / 'schema'
gen_srcs = custom_target(
'controllercapnp.[ch]',
output:['controller.capnp.c', 'controller.capnp.h'],
input: '../schema/controller.capnp',
command: [capnp, 'compile','-o' ,'c:lib', '-I', schema_dir, '--src-prefix', schema_dir, '@INPUT@']
)
section_parser = custom_target(
'xce resreq section parser',
output: ['section.c', 'section.h'],
input: ['section.peg'],
command: [
packcc,
'-l',
'-o',
'lib/section',
'@INPUT@'
],
build_by_default: true)
rusage_parser = custom_target(
'xce resreq rusage parser',
output: ['rusage.c', 'rusage.h'],
input: ['rusage.peg'],
command: [
packcc,
'-l',
'-o',
'lib/rusage',
'@INPUT@'
],
build_by_default: true)
xce_resreq_parser = custom_target(
'xce resreq xce_resreq parser',
output: ['xce_resreq.c', 'xce_resreq.h'],
input: ['xce_resreq.peg'],
command: [
packcc,
'-l',
'-o',
'lib/xce_resreq',
'@INPUT@'
],
build_by_default: true)
xce_select_parser = custom_target(
'xce select expression parser',
output: ['xce_select_peg.c', 'xce_select_peg.h'],
input: ['xce_select.peg'],
command: [
packcc,
'-l',
'-o',
'lib/xce_select_peg',
'@INPUT@'
],
build_by_default: true)
libxce_src = [ gen_srcs[0],
section_parser[0],
rusage_parser[0],
xce_resreq_parser[0],
xce_select_parser[0],
'client.c',
'dataq.c',
'hook.c',
'htab.c',
'kvmgr.c',
'mylock.c',
'netio.c',
'request.c',
'threshold.c',
'utils.c',
'vtaskmgr.c',
'window.c',
'xceapi.c',
'xcectx.c',
'xlist.c',
'xstring.c',
'zarray.c',
'wrap.c',
'idgen.c',
'delay.c',
'ordq.c',
'preason.c',
'xcealloc.c',
'misc.c',
'group.c',
'xcelimit.c',
'xvec.c',
'helper.c',
'resreq.c',
'xce_select.c',
'bitset.c',
'kv.c',
'jobj.c',
'qobj.c',
'resobj.c',
'wobj.c',
'configobj.c',
'cluster.c',
]
incdir = include_directories('../include')
build_inc = include_directories('.')
capnpc_c_prog = find_program('capnpc-c')
# debug('capnpc_c_prog %s\n', capnpc_c_prog)
thread_dep = dependency('threads')
c_capnproto_dep = dependency('c-capnproto')
tinylog_dep = dependency('tinylog')
unity_dep = dependency('unity')
ssl_dep = dependency('openssl')
libxce_deps = [c_capnproto_dep, ssl_dep, tinylog_dep, thread_dep]
#libxce_shared = shared_library('xce',
# libxce_src,
# include_directories: [incdir, build_inc],
# dependencies: libxce_deps,
# install: true)
libxce = static_library('xce',
libxce_src,
include_directories: [incdir, build_inc],
dependencies: libxce_deps,
install: true)
libxce_dep = declare_dependency(link_with: libxce)
# libxce_shared_dep = declare_dependency(link_with: libxce_shared)
libxce_test_src = ['testsuite/test.c',
'testsuite/test_error.c',
'testsuite/test_htab.c',
'testsuite/test_htab_int.c',
'testsuite/test_utils.c',
'testsuite/test_xstring.c',
'testsuite/test_zarray.c',
'testsuite/test_config.c',
'testsuite/test_idgen.c',
'testsuite/test_delay.c',
'testsuite/test_ordq.c',
'testsuite/test_preason.c',
'testsuite/test_kvmgr.c',
'testsuite/test_group.c',
'testsuite/test_xlist.c',
'testsuite/test_limit.c',
'testsuite/test_xvec.c',
'testsuite/test_resreq.c',
'testsuite/test_resmgr_fixture.c',
'testsuite/test_select.c',
'testsuite/test_bitset.c',
'testsuite/test_kv.c',
'testsuite/test_jobj.c',
'testsuite/test_wobj.c',
'testsuite/test_qobj.c',
'testsuite/test_request.c',
'testsuite/test_zarray_cow.c',
'testsuite/test_kvmgr_capture.c',
'testsuite/test_hooks.c',
'testsuite/test_cluster.c',
'testsuite/test_cluster_parse.c',
]
libxce_test_deps = [libxce_deps, librtti_dep, unity_dep, libxce_dep]
libxce_test = executable('xcelib_test',
libxce_test_src,
include_directories: [incdir, build_inc],
dependencies: libxce_test_deps,
install: true)
test('libxce test', libxce_test, timeout: 120)