Skip to content

test: apply production-parity Elasticsearch mappings in the test harness#35

Merged
turegjorup merged 2 commits into
developfrom
test/prod-parity-mappings
Jul 8, 2026
Merged

test: apply production-parity Elasticsearch mappings in the test harness#35
turegjorup merged 2 commits into
developfrom
test/prod-parity-mappings

Conversation

@turegjorup

Copy link
Copy Markdown
Contributor

The test harness created Elasticsearch indexes with no mappings, so Elasticsearch dynamic mapping (analysed text + .keyword subfields) silently drove filter behaviour. Production indexes (created by event-database-imports) use dynamic: strict with explicit per-field types and no normalizer. As a result several filter tests were green for semantics production does not have — most starkly tag filtering: ?tags=itkdev matched under dynamic mapping, but tags is an exact, case-sensitive keyword in production (fixtures store "ITKDev").

Changes

  • tests/resources/mappings/*.json — production-parity mappings (dynamic: strict), hand-kept copies of the importer's src/Model/Indexing/Mappings/*, covering all 7 indexes.
  • src/Fixtures/FixtureLoader.phpcreateIndex() applies the mapping for the index and fails loudly if the mapping file is missing (never silently creates a dynamic index). Injected $mappingsDir via config/services.yaml.
  • Taskfile.yml — dropped ignore_error: true from the fixture targets (the entityId warning it masked is already gone), so fixture-load failures now surface.
  • Reconciled tag filter expectations to keyword semantics — EventsFilterTest/OccurrencesFilterTest/DailyOccurrencesFilterTest: ITKDev→2, itkdev→0 (case-sensitive), aros→3, for-boern→1 (whole-value, not substring), boern→0. The two @todo blocks guessing at "contains-word" tag behaviour are deleted — this is their answer. Only the tag cases needed changing; every other filter/contract/pagination test was already production-accurate.
  • Automation — the index-contract Stop hook now also watches tests/resources/mappings/; the filter-provider-reviewer brief checks the mapped field type (keyword = exact, text = tokenised).

Verification

  • All docs index cleanly under dynamic: strict; a doc with an unmapped field is rejected (strict_dynamic_mapping_exception, verified against a throwaway index).
  • task fixtures:load:test --yes + task api:test166 tests, 447 assertions, 4 skipped (the pre-existing FilterErrorTest skips). php-cs-fixer, PHPStan level 8, and prettier/markdownlint all clean.
  • CollectionContractTest/ItemContractTest unchanged (raw _source passthrough — a control group proving the harness change altered query semantics only).

Note

Tag matching is now pinned as exact, case-sensitive (production reality). If case-insensitive tag search is the desired product contract, that is a lowercase normalizer on the keyword mappings in event-database-imports (plus a reindex), not a change here.

The fixture loader created indexes with no mappings, so Elasticsearch dynamic
mapping (analysed text + .keyword subfields) drove filter behaviour. Production
indexes (event-database-imports) use `dynamic: strict` with explicit types and
no normalizer, so several filter tests passed for semantics production does not
have — most starkly tag filtering (`?tags=itkdev` matched under dynamic mapping
but `tags` is an exact, case-sensitive `keyword` in production).

- Add production-parity mappings at tests/resources/mappings/*.json (dynamic:
  strict), hand-kept copies of the importer's src/Model/Indexing/Mappings.
- FixtureLoader::createIndex() applies the mapping and fails loudly if missing;
  drop the now-obsolete `ignore_error` from the fixture Taskfile targets.
- Reconcile the tag filter expectations to keyword semantics (ITKDev→2,
  itkdev→0, for-boern→1 whole-value, boern→0); only these cases needed changing
  — the rest of the suite was already production-accurate.
- Index-contract Stop hook now also watches tests/resources/mappings/; the
  filter-provider-reviewer brief checks the mapped field type.
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

No changes detected in API specification

@turegjorup turegjorup self-assigned this Jul 8, 2026
@turegjorup turegjorup merged commit 6ac008d into develop Jul 8, 2026
12 checks passed
@turegjorup turegjorup deleted the test/prod-parity-mappings branch July 8, 2026 08:17
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