Skip to content

test(cpdaemon,cpgolib): check cpm config mapping, buffer sizing, sync state and handshake - #316

Merged
timmy21 merged 1 commit into
0.9.xfrom
fix/243-go-test-efficacy
Oct 13, 2026
Merged

timmy21 merged 1 commit into
0.9.xfrom
fix/243-go-test-efficacy

Conversation

@timmy21

@timmy21 timmy21 commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Problem

gremlins left many mutants alive in cpdaemon/pkg/cpm and cpgolib/cpworker (#243 item 6): the tests run these branches but never check their result. Re-measured on 0.9.x (c4e1a8e9), test efficacy was 63.4% for pkg/cpm (79 surviving mutants) and 76.0% for cpgolib/cpworker (6 surviving). Among the gaps:

  • which VXLAN tag format (vni1/vni2) a CPM strategy produces, and the 0xFFFFFF fallback without a service tag;
  • how the NIC buffer and pipeline buffer are sized from the memory limit;
  • what happens when CPM returns a new daemon id or the strategy sync keeps failing;
  • whether a rejected control-socket handshake is noticed by the client.

Change

Tests only, no product code changes.

  • worker_task_builder: the VXLAN tag format follows apiVersion (docs/VXLAN-WIRE-FORMAT.md §5, §8, §9): vni1 carries the service tag, or 0xFFFFFF without one; vni2 carries domain, point and extension flag, falling back to domain 1 and point 1. A rate limit of 0 is left unset. The vxlan port, zmq service tag and file dump interval reach the output. packetSplitBytes 0 is accepted. --nofilter without bind_device is rejected.
  • worker_mgr: auto_nic_buffer splits the memory limit over the tasks. CPM memLimit overrides the default only when > 0. Too little memory is an error. The pipeline section gets the memory left after the libpcap buffers, but at least MinBufferSizeMb. cpu_affinity is passed through. The control socket directory is created before the worker starts.
  • syncer: register sends the start time as seconds plus microseconds. A new daemon id stops the worker and resets the sync state. A failing strategy sync is retried SyncStrategyMaxRetries times. The metrics sampling microseconds stay below 1e6. The uuid file is reused, and an empty one is refilled. IncludingNICs limits the registered interfaces.
  • client: SetDefaults keeps values that are set. Register sends labels and networkInterfaces as [], and fails on a non-2xx status or a body code >= 400.
  • models, utils, synclog: HasInstances; splitArgs drops empty arguments; the log level threshold; log entry microseconds.
  • cpgolib/cpworker: Dial fails when the handshake reply is not OK or not JSON. A timeout of 0 falls back to DefaultTimeout.

Not changed, as discussed in #243:

  • Error branches that only log, CPU/memory figures read from the live process, and log-only formatting: low value, or nondeterministic.
  • Omitting an empty arguments field in cpgolib requests: cpworker never reads arguments (unix-manager.c), so a test would pin serialization without a behaviour behind it.

Tests

gremlins v0.5.0 test efficacy, before → after:

  • cpdaemon/pkg/cpm: 63.4% → 83.3% (measured before the last vni2 fallback case). The rest are the categories above plus equivalent mutants.
  • cpgolib/cpworker: 76.0% → 85.7%. The rest are 3 equivalent mutants plus the arguments case.

gremlins copies the module to a temporary directory, which breaks cpdaemon's relative replace => ../cpgolib: every mutant then fails to compile and is counted as killed. The numbers above come from a copy with an absolute replace.

Suites run:

  • go vet ./... and go test ./... for cpdaemon and cpgolib on macOS: pass.
  • pkg/cpm and cpgolib/cpworker on Ubuntu 24.04: pass.

Refs #243

… state and handshake

gremlins left many mutants alive in cpdaemon/pkg/cpm and cpgolib/cpworker
(#243 item 6): branches the tests run but whose result they never check.

New and extended tests:

- worker_task_builder: the VXLAN tag format follows apiVersion (vni1 with
  the service tag or 0xFFFFFF; vni2 with domain/point/extension flag,
  VXLAN-WIRE-FORMAT.md sections 5, 8, 9); rate limit 0 left unset; vxlan
  port, zmq service tag and file dump interval reach the output;
  packetSplitBytes 0 accepted; --nofilter without bind_device rejected.
- worker_mgr: auto_nic_buffer splits the memory limit over the tasks,
  CPM memLimit overrides the default only when > 0, too little memory is
  an error; the pipeline section gets the memory left after the libpcap
  buffers but at least MinBufferSizeMb; cpu_affinity passed through; the
  control socket directory is created before the worker starts.
- syncer: register sends start seconds plus microseconds; a new daemon
  id stops the worker and resets the sync state; a failing strategy sync
  is retried SyncStrategyMaxRetries times; metrics sampling microseconds
  stay below 1e6; the uuid file is reused and an empty one refilled;
  IncludingNICs limits the registered interfaces.
- client: SetDefaults keeps set values; Register sends labels and
  networkInterfaces as [] and fails on a non-2xx status or a body code
  >= 400. models: HasInstances. utils: splitArgs drops empty arguments.
  synclog: level threshold, entry microseconds.
- cpgolib: Dial fails when the handshake reply is not OK or not JSON;
  a timeout of 0 falls back to DefaultTimeout.

gremlins test efficacy (v0.5.0, before -> after):
- cpdaemon/pkg/cpm: 63.4% -> 83.3%. The rest are error branches that
  only log, CPU/memory figures read from the live process, log-only
  formatting, and equivalent mutants.
- cpgolib/cpworker: 76.0% -> 85.7%. The rest are equivalent mutants and
  the omitted empty "arguments" field, which cpworker never reads.

Refs #243
@timmy21
timmy21 merged commit 0ace1c5 into 0.9.x Oct 13, 2026
1 check passed
@timmy21
timmy21 deleted the fix/243-go-test-efficacy branch October 13, 2026 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant