Skip to content

feat(pit): Elasticsearch _pit support with engine-aware gating, plus integration and request-building test coverage#32

Open
marevol wants to merge 3 commits into
mainfrom
feat/pit-engine-support-and-test-coverage
Open

feat(pit): Elasticsearch _pit support with engine-aware gating, plus integration and request-building test coverage#32
marevol wants to merge 3 commits into
mainfrom
feat/pit-engine-support-and-test-coverage

Conversation

@marevol

@marevol marevol commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Makes the Point-In-Time (PIT) actions work across engines and closes the biggest
regression-prevention gap found while reviewing the recent action work: the new
actions' request-building had no unit or integration coverage.

Stacked on #31 — this branch builds on fix/action-request-param-correctness;
please merge #31 first (the base retargets to main automatically once it merges).

Engine-aware PIT

  • Elasticsearch 7.10+/8.x: CreatePit/DeletePit now use POST /{index}/_pit and
    DELETE /_pit, mapping the {"id":...} / {"succeeded":...} responses to the
    OpenSearch CreatePitResponse / DeletePitResponse types.
  • OpenSearch 2.x+: unchanged (/_search/point_in_time).
  • Clear failures where a backend has no equivalent (via UnsupportedOperationException
    on the listener): PIT on OpenSearch 1.x; GetAllPits and delete-all on Elasticsearch;
    and multi-id delete on Elasticsearch (the _pit endpoint takes a single id).
  • The ES _pit endpoint rejects allow_partial_search_results (HTTP 400), so it is not
    sent. The ES response parsers now surface error bodies as failures instead of
    returning an empty/negative response — the HTTP layer routes non-2xx through the success
    path, so an unguarded parser would otherwise swallow the error.

Test coverage

  • Unit (offline): per-engine request-serialization tests for the PIT actions, and
    getCurlRequest param/body regression guards for reindex, update_by_query,
    delete_by_query, resolve_index and get_mappings — these previously had only
    response-parsing tests, leaving the request-building logic (endpoints,
    wait_for_completion, conflicts, keep_alive, PIT body, …) unguarded.
    ActionTestUtils gains a per-engine testClient(EngineType) stub of getEngineInfo()
    and a url(...) accessor.
  • Integration (Docker): end-to-end tests across all five backends (OpenSearch 1/2/3,
    Elasticsearch 7/8) for reindex, update_by_query, delete_by_query, resolve_index
    and the PIT lifecycle, including the unsupported-engine assertions.

Verification

  • Unit suite: 333 tests pass (mvn test excluding the *ClientTest containers).
  • The new integration tests were run locally against real containers for all five
    engines
    (OS1/2/3, ES7/8) and pass; the ES _pit request/response contract was
    confirmed against a live Elasticsearch 7.17 instance.

marevol added 3 commits July 7, 2026 23:39
…hards serialization

Correctness fixes to existing HTTP actions, verified against the OpenSearch
REST layer. No new dependencies and no API changes.

- HttpOpenIndexAction: serialize wait_for_active_shards ActiveShardCount.ALL as
  "all" (was "ALL", which the server rejects with HTTP 400) and forward indices
  options. This was the remaining call site still using ActiveShardCount.toString().
- HttpCloseIndexAction: forward wait_for_active_shards and indices options
  (both were dropped, so close could return before shards were ready).
- HttpUpdateAction: remove version/version_type params. The _update endpoint
  rejects internal versioning (it uses if_seq_no/if_primary_term, already sent),
  and UpdateRequest's version setters throw UnsupportedOperationException, so the
  removed block was unreachable.
- HttpIndicesAliasesAction: build the request body via the request's own
  toXContent so is_write_index/is_hidden/must_exist/routing are emitted and a
  remove_index action no longer emits an empty "aliases".
- HttpRefreshAction, HttpFlushAction, HttpForceMergeAction, HttpDeleteIndexAction,
  HttpGetMappingsAction: forward indices options (ignore_unavailable,
  allow_no_indices, expand_wildcards).
- HttpForceMergeAction: also forward primary_only.

Adds unit tests asserting the emitted query params / body for each fix.
… later

primary_only is unknown to OpenSearch 1.x and Elasticsearch 7/8, which reject
unrecognized query parameters with HTTP 400 (the test_force_merge integration
tests failed on those engines). Gate the parameter on the detected engine type,
matching the version-conditional pattern already used by HttpGetMappingsAction.

ActionTestUtils now stubs getEngineInfo() (with a per-engine-type overload) so
version-conditional serialization can be asserted offline; HttpForceMergeActionTest
covers both the OpenSearch 2.x/3.x (sent) and legacy (omitted) branches.
…ntegration and request-building test coverage

Make the Point-In-Time actions engine-aware so they work on both OpenSearch 2.x+
and Elasticsearch 7.10+/8.x, and fail clearly where a backend has no equivalent:

- CreatePit/DeletePit use POST/DELETE /_pit on Elasticsearch (mapping the
  {"id":...} and {"succeeded":...} bodies to the OpenSearch response types) and keep
  /_search/point_in_time on OpenSearch.
- Unsupported combinations fail the listener with a clear UnsupportedOperationException:
  PIT on OpenSearch 1.x; GetAllPits and delete-all on Elasticsearch (no equivalent
  endpoint); and deleting multiple PIT ids in one request on Elasticsearch (the _pit
  endpoint accepts a single id, sent as {"id":"..."} rather than an array).
- The Elasticsearch _pit endpoint rejects allow_partial_search_results, so it is not
  sent; the Elasticsearch response parsers now surface error bodies as failures instead
  of returning an empty/negative response (the HTTP layer routes non-2xx through the
  success path).

Test coverage for the previously unguarded request-building surface:
- Per-engine request-serialization unit tests for the PIT actions, and getCurlRequest
  param/body tests for reindex, update_by_query, delete_by_query, resolve_index and
  get_mappings. ActionTestUtils can now stub the reported engine type and read the
  request URL.
- End-to-end integration tests across all five backends (OpenSearch 1/2/3,
  Elasticsearch 7/8) for reindex, update_by_query, delete_by_query, resolve_index and
  the PIT lifecycle, including the unsupported-engine assertions.
@marevol marevol changed the base branch from fix/action-request-param-correctness to main July 7, 2026 20:43
@marevol marevol closed this Jul 7, 2026
@marevol marevol reopened this Jul 7, 2026
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