Skip to content

Restructure the test suite (unit / contract / integration / e2e) - #450

Open
Leokaufi wants to merge 47 commits into
developmentfrom
feat/restructure-tests
Open

Leokaufi wants to merge 47 commits into
developmentfrom
feat/restructure-tests

Conversation

@Leokaufi

@Leokaufi Leokaufi commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Task

Related issue: #449

Description

This PR restructures tests/ without changing any library code (0 lines in
src/).

  • Layout: tests/unit (mirrors src/), tests/contract,
    tests/integration, tests/e2e, plus tests/support and a layout guard
    (test_layout.py).
  • Contract suites: one check per promise, run for every registered
    component (14 detectors, 6 parsers, 5 aggregators) via registry.py.
    Replaces checks that were copied into every detector file.
  • End-to-end chains (C1-C9) against golden files. They are updated on
    purpose with --update-golden (refused in CI).
  • Infrastructure: one pytest config (pyproject.toml, pytest.ini
    removed), markers (slow, cli, docs, needs_cxx, needs_mongo,
    needs_redis; skipped locally, failing in CI), each test isolated in its
    own directory, global state restored after every test.
  • Tests that asserted little or nothing were rewritten.

Before -> after: tests collected 1,152 -> 2,092; line coverage 79.6 % ->
81.7 %; branch coverage 69.8 % -> 72.6 %; default run 115 s -> 60 s; lines of
test code 18,977 -> 18,623.

Notes for reviewers:

  • 7 MongoDB tests could not run locally, so this is their first run in CI.
    I will fix them if any of them fail.
  • Anyone with open branches touching tests/ has to move their files into
    the new layout.
  • CI now runs uv run pytest -m "" --cov=detectmatelibrary --cov-branch --cov-fail-under=79 (measured combined coverage is about 80 %).

How Has This Been Tested?

Full local run (uv run pytest -m ""): 2034 passed, 15 skipped, 43 xfailed
(all pinned known bugs), 0 failures. Every golden file was checked against
what the old tests expected before the first commit.

Checklist

  • This Pull-Request goes to the development branch.
  • I have successfully run prek locally.
  • I have added tests to cover my changes.
  • I have linked the issue-id to the task-description.
  • I have performed a self-review of my own code.

Start Proof
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

pytest.ini shadowed [tool.pytest.ini_options], so the pyproject block
(--ignore=local) never applied and a bare `uv run pytest` collected the
git-ignored local/ folder and failed with collection errors.

pyproject.toml is now the only pytest configuration:
- testpaths = ["tests"], so a bare run collects only the test suite;
- --strict-config, so a shadowed or misspelled setting fails loudly;
- xfail_strict = true, for the strict xfail tests of known bugs to come;
- the `ignored` marker moves over unchanged (the conftest hooks still
  register the other two).
Tests could leak process-wide state into later tests, so results
depended on test order. For example, running tests/test_utils/test_aux.py
before the core detector/parser/aggregator tests made 7 of them fail,
because test_aux switched off the time test mode that 13 modules had
switched on at import time.

tests/conftest.py now restores, after every test:
- the time test mode (utils.aux.test_time); the 13 module-level
  time_test_mode() calls become `pytestmark =
  pytest.mark.usefixtures("frozen_timestamps")`, scoped to their module;
- the schema connector set by set_connector(), and the Verification
  connector's in-memory records (test_connectors.py left `Verification`
  set for every later test);
- NumPy's global RNG (ECVCDetector reseeds it);
- the root logger's handlers and level;
- the in-memory fsspec filesystem.

A test that leaves a PersistencySaver timer thread running now fails.

Bug B1 (components share one default config instance) is handled by a
guard that restores those shared defaults after each test and lists the
tests that changed one at the end of the run. It only stops leaks
between tests; the bug itself gets strict xfail tests later.
`ignored`, `ignored_mongo` and `ignored_redis` (with --run-ignored,
--run-ignored-mongo, --run-ignored-redis) said how to enable a test, not
why it was left out, and covered five different reasons. All 34 doc
examples needed all three flags, although only two use a database.

Markers now say why a test may not run (registered in pyproject.toml):
- slow, cli, docs: left out of the default run by addopts; `-m ""` runs
  everything, `-m slow` only the slow tests;
- needs_cxx, needs_mongo, needs_redis: the test is skipped with a hint
  when g++ / MongoDB / Redis is missing, and fails when the CI
  environment variable is set, so a broken runner can't hide it. The
  database checks time out after 0.5 s (redis-py retries disabled; with
  its default retries the check took 4 s), and each runs once per session.

Re-marked tests:
- the audit.log regression runs, DeepLog/LogBERT, the full-pipeline tests,
  the DL model training tests and test_get_timestamp's sleep(1): slow;
- the 8 new DL training tests that ran by default at 3-18 s each (62 s
  together): slow;
- the workspace CLI tests: cli, now including test_fail_if_dir_exists,
  which also starts the CLI in a subprocess;
- doc examples: docs, plus slow/needs_cxx/needs_mongo/needs_redis only
  on the examples that need it;
- the saver timer thread-safety test runs by default (30/30 stable; it
  becomes deterministic in a later commit).

The default run goes from 115 s to 23 s. CI runs `pytest -s -m ""`;
docs/development.md and docs/user_guide/installation.md show the new
commands.
tests/test_data/__init__.py made the data folder a Python package that
mixed input paths, facts about audit.log and output paths, and some tests
built repository-relative paths (`"tests/test_data/audit.log"`), so they
only worked when pytest was started from the repository root.

- tests/support/paths.py: absolute paths to everything in tests/test_data/
  (moved from tests/test_data/__init__.py); tests/test_data/ is plain data.
- tests/support/audit.py: TRAIN_UNTIL and LOG_FORMAT for audit.log.
- test_autoparser.py and test_pre_tracker_state.py use the absolute paths.
- test_from_to.py wrote dummy.{txt,json,yaml} into tests/test_data/ and
  deleted them with a home-made decorator. Its tests now run in their own
  temporary directory and write relative file names there; the decorator
  is gone.
Tests wrote into whatever directory pytest was started from: the slow
store's .temp/ CSVs (allow_fed), relative persist paths such as ./state,
and output files. A session-end hook deleted .temp/ again, which also
deleted the files of a second pytest run in the same checkout.

An autouse fixture in tests/conftest.py now changes into the test's own
tmp_path, so every relative write lands there and disappears with the
test; the session-end cleanup hook is gone.

That hook was the only caller of slow_persistency.clean_generated_path(),
so two direct tests for it replace the incidental coverage (removes the
generated CSVs and the .temp/ folder; does nothing when there is none).

Explicit exceptions:
- the doc examples change to the repository root, because they use
  repository-relative paths as the docs show them;
- test_config_example points test_config.yaml's repository-relative
  templates path to the absolute one.

test_from_to.py's own chdir fixture is now redundant and removed.
The MongoDB/Redis containers for the needs_mongo / needs_redis tests were
defined in tests/test_schemas/compose.yaml, a folder that disappears when
the tests are restructured by level. The file moves to tests/compose.yaml;
the CI steps that start, wait for and stop the containers,
docs/user_guide/installation.md, the marker descriptions and the skip
hint point to the new path.
First step of the layout by level: tests/unit/ mirrors
src/detectmatelibrary/ (src/.../<path>/<module>.py ->
tests/unit/<path>/test_<module>.py). Pure moves, no test changes:

- tests/test_schemas/ -> tests/unit/schemas/ (test_op.py and
  test_op_default_values.py under protobuf/, where _op.py lives since
  upstream moved it; test_connectors.py -> connectors/test_default.py)
- tests/test_common/ -> tests/unit/common/ (test_core_detector.py ->
  test_detector.py, test_core_parser.py -> test_parser.py, ... ;
  test_config*.py under _config/, the FitLogic/TrainBuffer/federation
  tests under _core_op/)

Files whose tests belong to several modules move whole to their main
module here and are split in a later commit.

Level markers unit / contract / integration / e2e are registered in
pyproject.toml and applied from the test's directory by a conftest hook,
so `-m unit` etc. select a level. Every test directory is a package,
because file names such as test_parser.py now repeat.
Pure moves, no test changes:
- tests/test_base_detectors/ -> tests/unit/base_detectors/
  (test_persist_config.py -> test_persist.py for base_detectors/_persist.py,
  test_deeplearning_detectors.py -> test_deeplearning_detector.py)
- tests/test_detectors/test_<x>_detector.py -> tests/unit/detectors/
- test_mismatch_warnings.py tests VariableDetector's config-coverage
  warnings, not a detector: ->
  tests/unit/base_detectors/test_variable_detector_coverage_warnings.py
- the two cross-detector files become the seeds of their contract suites:
  test_auto_config_params_survive.py -> tests/contract/test_auto_config_contract.py,
  test_persist_integration.py -> tests/contract/test_tracker_detector_contract.py
  (both are reworked into parametrized contracts later)
- test_pre_tracker_state.py (old state archives restored by real
  detectors) -> tests/integration/
Pure moves, no test changes:
- tests/test_parsers/ -> tests/unit/parsers/ (test_template_matcher.py ->
  template_matcher/test_parser.py, test_logbatcher_parser.py ->
  logbatcher/test_parser.py, mirroring the source packages)
- tests/test_alert_aggregators/ -> tests/unit/alert_aggregation/
- tests/test_base_alert_aggregators/ -> tests/unit/base_alert_aggregation/

The two aggregator folders had no __init__.py, so their modules were
imported by bare file name; every test directory is a package now.
Moves, no test changes:
- tests/test_utils/ -> tests/unit/utils/; test_log_format_utils.py tests
  TimeFormatHandler, not log_format_utils, so it becomes
  test_time_format_handler.py; test_deep_learning.py ->
  deep_learning/test_op.py and test_alertbert_utils.py ->
  alertbert/test_models.py (both split per module in a later commit)
- tests/test_persistency/ -> tests/unit/utils/persistency/, with the
  tracker and classifier tests under
  data_structures/trackers/stability/ (test_stability_tracking.py ->
  test_stability_classifier.py; the slope and time-axis files become
  test_stability_classifier_slope.py / _time.py; split later)

One blank line added in test_time_format_handler.py (E302): under its
old name the file was never linted, because the pre-commit `exclude:
'.*.log'` regex also matches "_log" inside file names.
Pure moves, no test changes:
- tests/test_helper/ -> tests/unit/helper/
- tests/test_others/test_logging.py -> tests/unit/tools/test_logging.py
- tests/test_workspace/test_utils.py -> tests/unit/tools/workspace/
- tests/test_workspace/test_create_workspace.py (the `mate` CLI in a
  subprocess) -> tests/e2e/test_workspace_cli.py
- tests/test_docs/test_doc_examples.py -> tests/e2e/
- tests/test_pipelines/test_main_pipeline.py -> tests/unit/test_pipeline.py
  (its full-pipeline tests move to e2e in a later commit)
- test_basic_pipelines.py (Dummy parser -> detector -> aggregator) ->
  tests/integration/test_dummy_chain_buffering.py
- test_bad_players.py tests CoreComponent's input handling, not
  pipelines -> tests/unit/common/test_core_inputs.py
- test_configuration_engine.py (NewValue on audit.log through
  configure/train/detect) -> tests/e2e/test_detector_regression.py
- test_dummy_methods.py tests the _testutils dummies ->
  tests/unit/_testutils/test_dummies.py

tests/ now holds only unit/, contract/, integration/, e2e/, support/ and
test_data/.
Files moved whole in the previous commits held tests for several source
modules. Their classes now sit in the file that mirrors the module they
test (no test changes):
- _config/test_config.py: ConfigMethods / params-format tests ->
  _config/test_compile.py
- template_matcher/test_parser.py: Preprocess tests -> test_matcher_op.py
- deep_learning/test_op.py: DeepLog / LogBERT model tests ->
  test_deeplog.py / test_logbert.py
- alertbert/test_models.py: preprocessing and dataset tests ->
  test_preprocessing.py / test_datasets.py
- persistency/test_event_persistency.py: slow-store and PersistencyStruct
  tests -> test_slow_persistency.py / test_basic_persistency.py
- stability/test_stability_tracker_dump_load.py: EventTracker dump/load ->
  trackers/base/test_event_tracker.py, the EventDataset ABC tests ->
  data_structures/test_base.py, PersistencyLoadError ->
  test_persistency_saver.py
- stability/test_stability_classifier.py: the tracker classes ->
  test_stability_tracker_tracking.py, Classification ->
  trackers/base/test_single_tracker.py
- the slope and time-axis classifier files: their tracker classes ->
  test_stability_tracker_slope.py / test_stability_tracker_time.py
- integration/test_dummy_chain_buffering.py: the test_config.yaml check ->
  integration/test_yaml_assembly.py

Helpers that now serve two files moved to tests/support/deep_learning.py
(model test helpers) and tests/support/stability.py (change series and
timestamps) instead of being duplicated.
No test changes; tests move to the file that mirrors what they exercise:
- CoreConfig/BasicConfig tests from test_core.py -> _config/test_config.py
  (test_get_window stays: it is a CoreComponent test)
- get_format_variables (utils/log_format_utils) from test_parser.py ->
  unit/utils/test_log_format_utils.py
- the int64 timestamp-field tests from test_detector_extract_timestamp.py
  -> unit/schemas/test_classes.py
- build_count_vec and the count-vector codec (utils/sequence_encoding)
  from the SCVS and persist files -> unit/utils/test_sequence_encoding.py
- generate_detector_config (common/_config) from the combo tests ->
  _config/test_compile.py
- the persist block's YAML serialization from test_persist.py ->
  _config/test_config.py
- ECVC's own tests from test_count_vector_detector.py and the persist file
  -> unit/detectors/test_ecvc_detector.py; SCVS's window-size warning ->
  unit/detectors/test_scvs_detector.py
- TimestampReader (base_detectors/_stability) from the time-axis tracker
  tests -> unit/base_detectors/test_stability.py; the rejected old
  AutoConfigParams fields -> unit/base_detectors/test_variable_detector.py
- detector config -> stability tracker wiring (Charset, NewValue, combo,
  ValueRange reconstruction), spread over the persistency and detector
  files -> integration/test_detector_tracker_wiring.py
- the Mongo / Redis connector tests -> integration/test_mongo_connector.py
  and test_redis_connector.py (they need a real database)
- the full Pipeline runs on audit.log -> e2e/test_pipeline.py
- the component state-API checks -> contract/test_component_contract.py

Classes created by moving single methods got names that say what they
test (e.g. TestBuildCountVec instead of TestSCVSDetector).
tests/test_layout.py turns the layout rules into tests:
- tests/ holds only unit/, contract/, integration/, e2e/, support/,
  test_data/ and the shared config files;
- every test directory is a package;
- every tests/unit/ file names the source module it tests
  (test_<module>.py or test_<module>_<topic>.py, mirroring the path);
- every source module has such a file, or an entry with a reason in
  NO_UNIT_TEST_FILE: generated/vendored/abstract code, modules tested at
  another level (connectors -> integration, the CLI -> e2e), and the
  current gaps, marked "gap:", which leave the list as tests are added
  (a stale entry fails the guard);
- every test module starts with a docstring saying what it covers.

48 test modules had no docstring; unit tests now say "Tests for
detectmatelibrary.<module>." (plus the topic for topic files), the others
name their chain or purpose.
tests/contract/registry.py lists every parser, detector and aggregator
with a minimal YAML setup (and, for detectors, training data plus a
normal and an anomalous probe). The suites parametrize over it, and each
fails when an exported class is missing from the registry.

- component: construction from defaults and YAML, unknown settings and
  wrong method_type rejected, YAML round trip, documented settings,
  context manager, update_config, state API (replaces
  TestStatelessComponents), selectComponent (strict xfail B3 for the DL
  detectors)
- parser: output fields, unique IDs, bytes in/out, input untouched,
  connector storage, log_source filter, log_format headers, unmatched
  logs (strict xfail B6 for TemplateCppTreeMatcher)
- detector: alerts on anomalous probes only, alert fields, window
  length, bytes in/out, input untouched, connector storage, parser
  filter, raw logs rejected, training phase, persist only on trackers
- aggregator: aggregates drawn from the alerts, unique IDs, bytes
  in/out, input untouched, connector storage

DeepLog and LogBERT training checks are marked slow.
The contract suites now check construction, unknown settings, bytes in
and out, documented settings, the context manager, the binary round trip
(C8), window sizes, wrong input schemas and the training phases for
every registered class, so the per-class copies go:

- CoreParser/CoreDetector/CoreAlertAggregator: initialize, invalid
  config, bytes, to_binary_and_back
- CoreComponent: context manager
- test_config: documented fields (LogBatcherParser's stays, in the
  component contract)
- the seven detector Initialization classes (EventSequence keeps its
  auto-config window defaults as one test)
- SCVS/ECVC test_window_size, RandomDetector test_full_process_pipeline
- the DeepLog/LogBERT "end2end" state tests (the detector contract
  checks the phases with tiny models)
- test_core_inputs.py (input not modified, wrong schema)

Q7: test_dummies.py becomes one small file per dummy that pins only the
behaviour other tests rely on.

The detector contract gains test_window_size_follows_the_config and
checks the Configuring phase too; BigramFrequencyDetector stays out of
the binary round trip (binary API disabled upstream).
Parametrized over the registry's TRACKER_DETECTORS, AUTO_CONFIG_DETECTORS
and SESSION_DETECTORS. The checks compare behaviour, not internals: after
a restore or a federation a detector must report exactly what a detector
trained on the same data reports.

- tracker: no saver without persist; persist saves the store on exit;
  auto_load, export_state/import_state (bytes and path), a missing path
  (PersistencyLoadError, state kept), binary round trip, federation by
  `+` and by stacking a binary, finalize_federation with and without
  allow_fed
- auto-config: the configure phase changes only events, auto_config and
  fixed_window_size (with non-default operator settings and
  auto_config_params, persist and session_variable); without auto_config
  it changes nothing; an empty phase warns
- session windows: off by default, a log without the variable raises,
  interleaved known sessions raise nothing, an unseen session start
  alerts on that event, and a configure phase replayed into training
  learns the same as training alone (DL detectors slow)

BigramFrequencyDetector stays out of the federation checks (binary API
disabled upstream). The copy in the binary round trip is told to stop
training: from_binary() restarts the config's training phase.

The old per-detector tests stay below the new ones until the next commit.
…s covered by contracts

The tracker, auto-config and session-window contracts check these for
every registered detector, so the per-detector copies go (R1, R2, R7,
R8, R8b, R9, R11, R12, Q2):

- "no saver by default" / "saver created" / "saver wraps the store" in
  NewValue, Combo, NewEvent, SCVS, ECVC, Charset, ValueRange, Bigram,
  EventSequence; the YAML persist test over all trackers
- save-and-reload and export/import trivia (bytes, path returns None,
  events seen, RuleDetector no-ops)
- "persist / classification / operator settings survive
  set_configuration" in Charset, ValueRange, Bigram, Combo,
  EventSequence, the slope and time-axis wiring and the five old
  auto-config contract tests
- finalize_federation copies in VariableDetector, NewEvent,
  EventSequence, SCVS, ECVC; the VariableDetector stack/add tests
- SCVS's session-window tests (identical to ECVC's); the default and
  missing-variable session tests of EventSequence and ECVC, and ECVC's
  interleaved-detection test

To keep what those copies covered, the contracts gain federation by
stacking a detector object, aggregate()'s returned state, and the
configure phase over data where nothing is stable (the empty-config
branch, with operator settings).

Moved, not removed: the export file layout and the two running-saver
tests go to unit/base_detectors/test_persist.py (_persist's save_state
and load_state). Kept: the tests that pin exact learned windows (ECVC,
EventSequence) and the config-object persist rejection.
- R4: ECVC's build_count_vec test was a copy of the one in
  test_sequence_encoding.py (ECVCOp.build_count_vec is the same
  function); test_count_events moves there, next to count_events
- R5, R6: the index-axis and time-axis variants of "the classification
  block reaches the configure trackers" and "auto_config_params round
  trip through YAML" become two parametrized tests
- R18: the 21 time formats of test_detector_extract_timestamp.py and
  the five single-format tests become one parametrized table for
  TimeFormatHandler.parse_timestamp, plus one test of the
  _extract_timestamp wrapper in test_detector.py
- C2: the five GlobalInstances audit.log tests become
  integration/test_global_instances.py, parsing audit.log once. They
  asserted "at least one alert"; they now assert the exact set of logs
  each detector flags, which exposed B9: NewEventDetector with a global
  instance alerts on every log (strict xfail)
R3: test_process_input_schema_not_serialized_buffer_3 built the WINDOW
mock, so it repeated the window test and BATCH mode was never run
through CoreDetector. It now uses the BATCH mock and checks that one
output covers three records and that the next batch starts over.

F12: IncompleteMockupDetector and IncompleteMockupParser were never
used.
Each test states the expected behaviour and is marked
xfail(strict=True, raises=...) with the bug's ID; a fix turns it into an
XPASS, which fails the run as a reminder to drop the marker. Details and
reproductions are in the issue drafts.

- B1: every component shares one default config instance
  (component contract), and set_configuration() on one default detector
  unconfigures every new one (auto-config contract)
- B2: Pipeline.output_schema is inverted
- B4: ECVC training reseeds NumPy's global random generator
- B7: finalize_federation() on one detector deletes the slow tables of
  all others
- B8: selectComponent instantiates LogBatcherParser once it has been
  imported, and fails without an OpenAI key

B3, B6 and B9 were pinned with the contract and integration tests that
found them; their markers now also name the expected exception.
Each rewritten test now checks the behaviour its name promises (F8, F9,
F14, Q3, Q4):

- NewValue, Charset, Bigram: test_detect_known_value_no_alert detected
  on an unconfigured EventID; renamed test_detect_ignores_unconfigured_event,
  and a real known-value test checks no alert for a trained value and an
  alert for a new one
- Bigram: a missing variable now asserts "no alert", not "returns a bool"
- ValueRange: fixed values instead of unseeded random input (F5); the
  non-numeric-ignore test (no assertion before) checks that such values
  are neither learned nor alerted on
- Combo: training asserts the learned combinations; the configuration
  workflow used data with a single stable variable, which by design
  yields no combination, while its comment expected a detection; it now
  uses two stable variables and asserts the generated instance and the
  alerts; "no stable variables" asserts the empty config and the warning
- RandomDetector: seeded draws against the threshold, threshold 0 and 1,
  unconfigured events
- FitLogic: the two process-level state-command tests become one table of
  update_state() commands on FitLogic itself (Q3)
- schemas initialize with their primary key; allow_fed set after
  construction leaves the learned state alone; YAML assembly checks what
  each component took from its entry
- removed: a re-export check of TrainBuffer (Q4) and an "is not None"
  construction test; the aggregator expectations use the schema version
  initialize() really writes (F14)
…eate in-process

The stability classifier and tracker tests now assert the verdict instead
of accepting any type; their docstrings read a change series correctly
(True = a new value appeared). The FromTo conversions compare the written
records with the yielded outputs. The workspace structure tests call the
CLI's main() in-process; only the generated-tests checks stay subprocess
tests in e2e.
The saver timer tests wait for the condition they check (tests/support/
timing.py) instead of sleeping a fixed time, and check the timer's save
before stop(), which saves as well. The syslog-year and get_timestamp tests
read a patched clock instead of the real one; the one-second slow test is
gone.
Database tests take their database from the mongo_db / redis_dbs fixtures
instead of fixed names on localhost: a fresh Mongo database per test,
dropped afterwards, and Redis databases 10-12 (away from database 0),
flushed before and after. The servers can be moved with MONGO_URL and
REDIS_URL, the Redis range with REDIS_TEST_DB.
…den files

Chain C3: each deterministic detector configures, trains and detects on
audit.log only through process() and its config, and every alert must
equal its golden file in tests/test_data/golden/audit/ (regenerate with
--update-golden, refused in CI). All nine golden files reproduce what the
per-detector tests expected. DeepLog and LogBERT get recall and
false-alarm bounds measured from one seeded run. The per-detector
audit.log runs and the configuration-engine tests they replace are gone.
Chain C2: the audit.log pipeline must give the golden outputs whether it
parses or gets parsed logs, with or without aggregation, with one or three
workers. The two-source pipeline gets a golden file per source and checks
that each source's alerts come from its own detector. B10 (configure
records trained on without post_train() when there is no training phase)
gets a strict xfail; it is why ECVC raises nothing in this pipeline.
Chain C9: TreeMatcher, Charset and LogIDCount each store their outputs
through a connector, and XSchema.from_id() must return exactly what
process() returned, for every parsed log, alert and aggregate. It runs
offline with the Verification connector by default and against MongoDB /
Redis with needs_mongo / needs_redis. It replaces the two database
pipeline tests, which only checked that three fixed IDs were not empty.
The doc-example tests were reported as example0 ... example33; they now
carry the example's path under docs/examples/, so a failure names the
file to fix.
… bytes

Chain C1: audit.log through MatcherParser, a detector and the LogIDCount
aggregator as separate components. Each detector is built from its C3
golden file; the aggregates must be its golden alerts, and passing bytes
at every hop, as DetectMateService does, must give exactly the bytes of the
object run.
Chain C4: a detector trained on audit.log through process() is saved
after training, via export_state()/import_state() or a persist: block
with auto_load, and restarted with its final config and both phases off.
On the rest of audit.log it must raise the alerts of its C3 golden file.
Chain C5: three client nodes train on a third of the audit.log training
lines each and join an untrained server node, with + or as to_binary()
bytes; the server must raise the detector's C3 golden alerts. A server is
used because any one client alone would already pass on this repetitive
log. ECVC and SCVS, which need post_train(), check that the trained state
reaches a copy or a peer. The per-detector audit.log binary and
federation runs these replace are gone.
Chain C6: FromTo.log2json with the parser, then FromTo.json2yaml with a
NewValueDetector trained through process(); the YAML file must hold the
golden alerts. It runs on a 40-line slice holding every labelled anomaly,
since FromTo rewrites its output file for every record (Q-H).
Chain C7: a Pipeline loaded from tests/test_data/audit_pipeline.yaml must
give the C2 golden outputs. A NewValueDetector configured with named
event IDs and variables from a named-templates CSV for audit.log, resolved
by compile_detector_config(), must get the positional config and find
the labelled su/sudo anomalies.
Chain C8: audit.log rewritten as JSON lines goes through JsonParser, with
a MatcherParser for the message, into a NewValueDetector set up as in
chain C3; the alerts must be its C3 golden alerts.
A deterministic generator (tests/support/sessions.py) writes a small
HDFS-style log whose blocks interleave, with three anomalous blocks after
the training part. EventSequence, ECVC and SCVS with session_variable,
driven through process() only, must alert in exactly those blocks and
match their golden files; without sessions, normal blocks alert too.
…MultiTracker their own tests

These modules were covered only through the components that use them,
and listed as gaps in the layout guard. Each now has a unit test file
that pins its behaviour, including KeyExtractor's path cache (a cached
path wins over a new top-level match) and its fallback when the
structure changes.
… selection their own tests

The last gap entries of the layout guard: EventsConfig's lookups and
to_dict() (empty events dropped, integer IDs restored), the bare
Component and SchemaPipeline, VariableHooks' defaults and _check_event,
select_connector, and the default connector's empty store and restore.
Every source module now has a unit test file or a reason in the guard.
… public imports

Pipeline.process() returns None, the single output, or a list of several;
it passes bytes through and reads a YAML dict under the pipeline's name.
get_configured_variables / get_global_variables skip what the log lacks.
DeepLearningDetector.post_train() trains the model on the collected
sequences and takes top_k from its stats. A public-API contract checks
that every name in a package's __all__ exists and that the imports the
docs show work.
Every component raises NotSupportedSchema on bytes that decode as no
schema (component contract). Template files: CSV without EventTemplate,
unsupported extension, unreadable file, optional EventId column. The
saver raises PersistencyLoadError for an unknown tracker type, a corrupt
event file or incomplete metadata; it starts outside the main thread,
stop() without start() saves nothing, and get_status() tolerates broken
metadata. B11 (store equality ignores what the trackers learned) gets a
strict xfail, and the e2e state checks compare the trackers' dumps.
How to run the tests, the four levels and the layout rules, the e2e
chains C1-C9, the markers, how to write a test (contract registry,
automatic isolation, time, databases, files), golden files and
--update-golden, and the known bugs and open questions with the tests that
pin them. The two test comments that pointed to an untracked issue file
now point to the README.
…c-example test

The guide still named tests/test_docs/, which moved to tests/e2e/ in the
test restructuring. It now also says what the default run leaves out and
where the test conventions are described.
CI runs the whole suite with branch coverage and fails below 79 %, the
combined line and branch coverage of the local full run (79.8 %, without
the g++ and database tests) rounded down. -s is gone: pytest captures
output again and shows it only for failing tests.
Each e2e chain keeps one variant of a few seconds in the default run, so
"more than 2 s" no longer described the marker; it now names what is
opt-in: DL training, full-dataset runs and further e2e variants.
@Leokaufi Leokaufi self-assigned this Nov 24, 2026

This branch has not been deployed

No deployments
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