Skip to content

Commit 625b59e

Browse files
karenyrxakrahdankarenx
authored
[GRPC] Adapt transport-grpc to use opensearch-protobufs 0.13.0 (#19007)
* Upgrade opensearch-protobufs dependency to 0.7.0 and update transport-grpc module compatibility - Upgrade protobufs dependency from 0.6.0 to 0.7.0 in transport-grpc module - Update all protobuf utility classes to handle API changes in 0.7.0 - Fix enum structure changes (simple enums to message with oneof fields) - Update field name changes (setIndex -> setUnderscoreIndex, etc.) - Handle new OperationContainer pattern for bulk operations - Update all corresponding unit and integration tests - Add new SHA for protobufs-0.7.0.jar and remove old 0.6.0 SHA Signed-off-by: sakrah <[email protected]> * Use 0.8.0 protos and fix transport-grpc compilation errors Signed-off-by: Karen Xu <[email protected]> * Add unit tests to improve transport-grpc module coverage Signed-off-by: sakrah <[email protected]> * Improve test coverage for search query utilities Signed-off-by: sakrah <[email protected]> * Improve unit test coverage for search query utilities Signed-off-by: sakrah <[email protected]> * transport-grpc: update to opensearch-protobufs 0.9.0 and improve FieldValue handling Signed-off-by: sakrah <[email protected]> * Update transport-grpc to opensearch-protobufs 0.10.0-SNAPSHOT Signed-off-by: sakrah <[email protected]> * use 0.10.0 Signed-off-by: Karen Xu <[email protected]> * remove map and refactor fieldvalueprotoutils.fromproto fix InnerHitBuilderProtoUtils tests Signed-off-by: Karen Xu <[email protected]> * forgot to commit spotlessApply changes Signed-off-by: Karen Xu <[email protected]> * update to 0.12.0 protos Signed-off-by: Karen Xu <[email protected]> * fix compilation Signed-off-by: Karen Xu <[email protected]> * use 0.13.0 Signed-off-by: karenx <[email protected]> --------- Signed-off-by: sakrah <[email protected]> Signed-off-by: Karen Xu <[email protected]> Signed-off-by: Karen X <[email protected]> Signed-off-by: karenx <[email protected]> Co-authored-by: sakrah <[email protected]> Co-authored-by: karenx <[email protected]>
1 parent 8999b27 commit 625b59e

File tree

81 files changed

+2184
-1323
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+2184
-1323
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
2020
- Support system generated search pipeline. ([#19128](https://github.com/opensearch-project/OpenSearch/pull/19128))
2121
- Add `epoch_micros` date format ([#14669](https://github.com/opensearch-project/OpenSearch/issues/14669))
2222
- Grok processor supports capturing multiple values for same field name ([#18799](https://github.com/opensearch-project/OpenSearch/pull/18799)
23+
- Upgrade opensearch-protobufs dependency to 0.13.0 and update transport-grpc module compatibility ([#19007](https://github.com/opensearch-project/OpenSearch/issues/19007))
2324

2425
### Changed
2526
- Refactor `if-else` chains to use `Java 17 pattern matching switch expressions`(([#18965](https://github.com/opensearch-project/OpenSearch/pull/18965))

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ woodstox = "6.4.0"
2121
kotlin = "1.7.10"
2222
antlr4 = "4.13.1"
2323
guava = "33.2.1-jre"
24-
opensearchprotobufs = "0.6.0"
24+
opensearchprotobufs = "0.13.0"
2525
protobuf = "3.25.8"
2626
jakarta_annotation = "1.3.5"
2727
google_http_client = "1.44.1"

modules/transport-grpc/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ dependencies {
3535
implementation "io.grpc:grpc-stub:${versions.grpc}"
3636
implementation "io.grpc:grpc-util:${versions.grpc}"
3737
implementation "io.perfmark:perfmark-api:0.27.0"
38-
implementation "org.opensearch:protobufs:0.6.0"
38+
implementation "org.opensearch:protobufs:${versions.opensearchprotobufs}"
3939
testImplementation project(':test:framework')
4040
}
4141

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
14c2a9be2d5e309d7511f734fd43d7d2077db4da

modules/transport-grpc/licenses/protobufs-0.6.0.jar.sha1

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
14c2a9be2d5e309d7511f734fd43d7d2077db4da

modules/transport-grpc/spi/licenses/protobufs-0.6.0.jar.sha1

Lines changed: 0 additions & 1 deletion
This file was deleted.

modules/transport-grpc/spi/src/test/java/org/opensearch/transport/grpc/spi/QueryBuilderProtoConverterTests.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ private QueryContainer createMockTermQueryContainer() {
8989
.setTerm(
9090
org.opensearch.protobufs.TermQuery.newBuilder()
9191
.setField("test_field")
92-
.setValue(org.opensearch.protobufs.FieldValue.newBuilder().setStringValue("test_value").build())
92+
.setValue(org.opensearch.protobufs.FieldValue.newBuilder().setString("test_value").build())
9393
.build()
9494
)
9595
.build();
@@ -144,8 +144,8 @@ public QueryBuilder fromProto(QueryContainer queryContainer) {
144144
org.opensearch.protobufs.FieldValue fieldValue = termQuery.getValue();
145145
Object value;
146146

147-
if (fieldValue.hasStringValue()) {
148-
value = fieldValue.getStringValue();
147+
if (fieldValue.hasString()) {
148+
value = fieldValue.getString();
149149
} else if (fieldValue.hasGeneralNumber()) {
150150
org.opensearch.protobufs.GeneralNumber number = fieldValue.getGeneralNumber();
151151
if (number.hasFloatValue()) {
@@ -159,8 +159,8 @@ public QueryBuilder fromProto(QueryContainer queryContainer) {
159159
} else {
160160
throw new IllegalArgumentException("Unsupported number type in TermQuery");
161161
}
162-
} else if (fieldValue.hasBoolValue()) {
163-
value = fieldValue.getBoolValue();
162+
} else if (fieldValue.hasBool()) {
163+
value = fieldValue.getBool();
164164
} else {
165165
throw new IllegalArgumentException("Unsupported field value type in TermQuery");
166166
}

modules/transport-grpc/src/internalClusterTest/java/org/opensearch/transport/grpc/DocumentServiceIT.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ public void testDocumentServiceBulk() throws Exception {
3737
DocumentServiceGrpc.DocumentServiceBlockingStub documentStub = DocumentServiceGrpc.newBlockingStub(channel);
3838

3939
// Create a bulk request with an index operation
40-
IndexOperation indexOp = IndexOperation.newBuilder().setIndex(indexName).setId("1").build();
40+
IndexOperation indexOp = IndexOperation.newBuilder().setXIndex(indexName).setXId("1").build();
4141

4242
BulkRequestBody requestBody = BulkRequestBody.newBuilder()
43-
.setIndex(indexOp)
44-
.setDoc(com.google.protobuf.ByteString.copyFromUtf8(DEFAULT_DOCUMENT_SOURCE))
43+
.setOperationContainer(org.opensearch.protobufs.OperationContainer.newBuilder().setIndex(indexOp).build())
44+
.setObject(com.google.protobuf.ByteString.copyFromUtf8(DEFAULT_DOCUMENT_SOURCE))
4545
.build();
4646

4747
BulkRequest bulkRequest = BulkRequest.newBuilder().addRequestBody(requestBody).build();
@@ -51,8 +51,8 @@ public void testDocumentServiceBulk() throws Exception {
5151

5252
// Verify the response
5353
assertNotNull("Bulk response should not be null", bulkResponse);
54-
assertFalse("Bulk response should not have errors", bulkResponse.getBulkResponseBody().getErrors());
55-
assertEquals("Bulk response should have one item", 1, bulkResponse.getBulkResponseBody().getItemsCount());
54+
assertFalse("Bulk response should not have errors", bulkResponse.getErrors());
55+
assertEquals("Bulk response should have one item", 1, bulkResponse.getItemsCount());
5656

5757
// Verify the document is searchable
5858
waitForSearchableDoc(indexName, "1");

modules/transport-grpc/src/internalClusterTest/java/org/opensearch/transport/grpc/SearchServiceIT.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,9 @@ public void testSearchServiceSearch() throws Exception {
5252

5353
// Verify the response
5454
assertNotNull("Search response should not be null", searchResponse);
55-
assertTrue(
56-
"Search response should have hits",
57-
searchResponse.getResponseBody().getHits().getTotal().getTotalHits().getValue() > 0
58-
);
59-
assertEquals("Search response should have one hit", 1, searchResponse.getResponseBody().getHits().getHitsCount());
60-
assertEquals("Hit should have correct ID", "1", searchResponse.getResponseBody().getHits().getHits(0).getId());
55+
assertTrue("Search response should have hits", searchResponse.getHits().getTotal().getTotalHits().getValue() > 0);
56+
assertEquals("Search response should have one hit", 1, searchResponse.getHits().getHitsCount());
57+
assertEquals("Hit should have correct ID", "1", searchResponse.getHits().getHits(0).getXId());
6158
}
6259
}
6360
}

0 commit comments

Comments
 (0)