test(opensearch3): expand HttpClient action coverage and fix 3 latent bugs#34
Merged
Merged
Conversation
… bugs
Add integration tests to OpenSearch3ClientTest for previously untested
registered actions (list/get/cancel tasks, nodes usage, remote info,
upgrade status, snapshot/repository lifecycle, engine detection), plus
depth improvements (PIT-backed search, stats XContent assertion).
Exercising these actions end-to-end surfaced three latent bugs, now fixed:
- HttpPutRepositoryAction never sent the request body, so PUT
/_snapshot/{name} failed with 400 "request body is required". It now
serializes the repository type/settings via request.toXContent, matching
HttpCreateSnapshotAction. Adds HttpPutRepositoryActionTest.
- HttpUpgradeStatusAction.fromXContent looked for a _shards section the
_upgrade response never emits and always wrote zero shards, so the
response was always empty; it also wrote the broadcast header with
writeInt where the wire format reads writeVInt. It now parses the
per-index aggregate byte counts and reconstructs the response so
getTotalBytes and the per-index sizes are correct (per-shard routing is
synthetic because the API exposes none). Adds HttpUpgradeStatusActionTest.
- HttpSearchAction emitted ccs_minimize_roundtrips and index options
unconditionally, which OpenSearch rejects together with a point-in-time
search (400), manifesting as an indefinite hang over HTTP. It now omits
both when the request carries a PIT. Extends HttpSearchActionTest.
Verified: OpenSearch3ClientTest 88/88 green (Docker) and the offline unit
suite 340/340 green.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
OpenSearch3ClientTestwas already the most complete of the five backend integration suites, so this PR closes the remaining gap against the registered-action API surface: severalHttp*Actions wired inHttpClienthad no coverage anywhere. Adding end-to-end tests for them (against a real OpenSearch 3.7 Testcontainer) surfaced three latent, previously-untested production bugs, which are fixed here.New / enhanced tests (
OpenSearch3ClientTest)test_list_tasks,test_get_task,test_cancel_tasks,test_nodes_usage,test_remote_info,test_upgrade_status.test_crud_snapshot_repository(put → verify → get → delete) andtest_snapshot_lifecycle(create → status → get → restore → delete, asserting the restored doc is searchable).startServer()now setspath.reposo anfsrepository can be registered; teardown uses two independent delete blocks so one cleanup failure cannot leak the other resource.test_engine_infoasserts the live client detectsOPENSEARCH3.test_pit_lifecyclenow runs a PIT-backed search and asserts it reads the captured documents;test_statsnow asserts the serializedNodesStatsResponseXContent is non-empty;test_upgrade_statusasserts real (non-zero) byte totals.Bug fixes surfaced by the new coverage
1.
HttpPutRepositoryActionsent no request body.PUT /_snapshot/{name}was issued without a body, so the server rejected it with400 parse_exception: request body is required— the action never worked. It now serializes the repositorytype/settingsviarequest.toXContent(...), mirroringHttpCreateSnapshotAction. AddsHttpPutRepositoryActionTest.2.
HttpUpgradeStatusActionalways returned empty data.fromXContentlooked for a top-level_shardsobject that the_upgraderesponse never emits and always serialized zeroShardUpgradeStatusentries, sogetIndices()was always empty and all byte/shard counts were0. It also wrote theBroadcastResponseheader withwriteIntwhere the wire format readswriteVInt(only "worked" because every value was zero). It now parses the per-index aggregate byte counts (size_in_bytes/size_to_upgrade_in_bytes/size_to_upgrade_ancient_in_bytes) and reconstructs the response sogetTotalBytes()and the per-index sizes are correct. Because the_upgradeAPI exposes no per-shard routing (detailed=trueis rejected on 3.7), the reconstruction synthesizes one shard per index; the shard routing is therefore artificial and only the byte totals are meaningful — this is documented in the code. AddsHttpUpgradeStatusActionTest.3.
HttpSearchActionhung on point-in-time searches.It emitted
ccs_minimize_roundtripsand the index options (ignore_unavailable/allow_no_indices/expand_wildcards) unconditionally. OpenSearch rejects both together with a point-in-time search (400 "... cannot be used with point in time"), and over this HTTP client a400on a request that carries a body manifests as an indefinite hang. It now omits both when the request carries a PIT (a PIT already binds its own indices). Non-PIT searches are byte-identical, so all other engines are unaffected. ExtendsHttpSearchActionTest.Testing
OpenSearch3ClientTest: 88/88 green (Docker, OpenSearch 3.7.0).mvn formatter:format license:formatapplied.Notes / out of scope
HttpUpgradeAction(thePOST /_upgradeaction, no integration coverage here) has the samewriteInt-vs-writeVIntheader issue; left untouched to keep this change scoped.