dotCMS / dotCMS/core

[TASK] Phase-aware routing integration tests for @IndexRouter classes

Open
#35,279 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

OpenSearch stale Team : Scout
Dominant language
Java
Stars
970
Forks
486
Avg merge
3d 33m
Merged PRs (30d)
170

Description

Description

ESContentFactoryImpl, ESMappingAPIImpl, and IndexAPIImpl are annotated @IndexRouter — they act as coordinators that dispatch to ES and/or OS delegates depending on the active MigrationPhase.

The existing integration test suites (ESContentFactoryImplTest, ESMappingAPITest, ContentletIndexAPIImplTest) cover ES-only behaviour (Phase 0 implicitly). There are no tests that verify routing decisions across the 4 migration phases.

Routing table under test
Phase Read provider Write providers
0 — not started ES [ES]
1 — dual-write, ES reads ES [ES, OS]
2 — dual-write, OS reads OS [ES, OS]
3 — OS only OS [OS]
Acceptance Criteria
  • Extend existing tests where feasible; do not rewrite full test classes.
  • For each router class, select the public methods that most clearly exercise routing (e.g. indexing a document, querying by index name) and parameterize them over all 4 phases.
  • Each test scenario must:
    1. Set the active MigrationPhase to the target phase (via feature-flag override).
    2. Use two indices with different names (e.g. live_<runId> and working_<runId>).
    3. Call a public method that accepts one of the valid index names.
    4. Assert that the correct delegate(s) received the operation (spy/verify or count-based assertion on each index).
  • Dual-write phases (1 and 2) must confirm the operation was applied to both indices.
  • Read phases: confirm that the query result originates from the expected provider (ES in phases 0/1, OS in phases 2/3).
  • Phase teardown must restore the original phase value and clean up test indices.
  • Tests that require a live OS instance must be registered in OpenSearchUpgradeSuite; tests that can run ES-only belong in the standard suite.
Additional Context
  • IndexConfigHelper.MigrationPhase.current() reads from a feature flag — use Config overrides or a test-only setter to control the phase in tests.

  • Target classes: ESContentFactoryImpl (lines ~132, ~233-263), ESMappingAPIImpl, IndexAPIImpl.

  • Related issues: #34931 (routing logic task), #35278 (OS delegate coverage).

  • Run command:
    ```

    Phase 0/1-only scenarios (ES suite):

    ./mvnw verify -pl :dotcms-integration -Dcoreit.test.skip=false -Dit.test=ESContentFactoryImplTest

    Phases 1-3 (requires OS container):

    ./mvnw verify -pl :dotcms-integration -Dcoreit.test.skip=false -Dopensearch.upgrade.test=true
    ```

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with ESContentFactoryImplTest, ESMappingAPITest, and ContentletIndexAPIImplTest, then inspect ESContentFactoryImpl, ESMappingAPIImpl, and IndexAPIImpl at the referenced routing points. Run the listed integration-test commands and use the feature-flag phase override while parameterizing scenarios across all four MigrationPhase values. Done means delegate reads and writes match the routing table, dual writes reach both indices, teardown restores the phase, and OS-dependent tests are registered in OpenSearchUpgradeSuite.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend, testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.