Skip to content

test(search): add SearchAPIImpl phase-routing and permission-filtering integration tests #35669

@fabrizzio-dotCMS

Description

@fabrizzio-dotCMS

Context

PR #35609 introduced SearchAPIImpl (the phase-aware router) and OSSearchAPIImpl. The existing OSSearchAPIImplIntegrationTest tests the OS implementation directly against empty indices. The following coverage gaps were identified in the PR review and deferred to this issue.

Missing test coverage

1. Phase routing selects the correct provider

  • Phase 0 / 1 → ESSearchAPIImpl is used
  • Phase 2 / 3 → OSSearchAPIImpl is used
  • Requires injecting SearchAPIImpl (not OSSearchAPIImpl directly) and setting Config.setProperty(MigrationPhase.FLAG_KEY, ...) per test, cleaning up in @After.

2. ES fallback in Phase 2

  • When OSSearchAPIImpl throws, PhaseRouter.readChecked retries against ES.
  • Requires simulating an OS failure (e.g. wrong index name) while ES is healthy.

3. searchRaw permission injection filters results for non-admin users

  • Needs at least one indexed document + a non-admin user with explicit role/permission setup.
  • executeSearch() lines 263–300 inject a permission filter; today this is untested end-to-end against OS.

Reference files

  • SearchAPIImpl: dotCMS/src/main/java/com/dotcms/content/index/SearchAPIImpl.java
  • PhaseRouter: dotCMS/src/main/java/com/dotcms/content/index/PhaseRouter.java
  • OSSearchAPIImpl: dotCMS/src/main/java/com/dotcms/content/index/opensearch/OSSearchAPIImpl.java
  • Phase config in tests: MigrationPhaseTest.javaConfig.setProperty(MigrationPhase.FLAG_KEY, ...)
  • Document indexing pattern: ContentletIndexOperationsOSIntegrationTest.java

Suggested class name

SearchAPIImplPhaseRoutingIT (requires both ES + OS containers, or a shared cluster with phase-switching)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions