Skip to content

Commit c319746

Browse files
authored
GA updates and minor BWC test cleanups (#104)
Signed-off-by: Andriy Redko <andriy.redko@aiven.io>
1 parent 78a6045 commit c319746

File tree

6 files changed

+20
-20
lines changed

6 files changed

+20
-20
lines changed

.github/actions/create-bwc-build/action.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ runs:
3333
path: ${{ inputs.plugin-branch }}
3434

3535
- name: Build
36-
uses: gradle/gradle-build-action@v2
36+
uses: gradle/gradle-build-action@v3
3737
with:
3838
cache-disabled: true
3939
arguments: assemble

.github/actions/run-bwc-suite/action.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ runs:
3737
plugin-branch: ${{ inputs.plugin-next-branch }}
3838

3939
- name: Run BWC tests
40-
uses: gradle/gradle-build-action@v2
40+
uses: gradle/gradle-build-action@v3
4141
with:
4242
cache-disabled: true
4343
arguments: |

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
uses: actions/checkout@v4
2626

2727
- name: Build BWC tests
28-
uses: gradle/gradle-build-action@v2
28+
uses: gradle/gradle-build-action@v3
2929
with:
3030
cache-disabled: true
3131
arguments: |

bwc-test/build.gradle

-8
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ buildscript {
4646
ext {
4747
opensearch_version = System.getProperty("opensearch.version", "3.0.0-SNAPSHOT")
4848
opensearch_group = "org.opensearch"
49-
common_utils_version = System.getProperty("common_utils.version", '2.9.0.0-SNAPSHOT')
50-
jackson_version = System.getProperty("jackson_version", "2.16.1")
51-
http_client_version = System.getProperty("http_client_version", "4.5.14")
5249
}
5350
repositories {
5451
mavenLocal()
@@ -73,11 +70,6 @@ dependencies {
7370
testImplementation "com.google.guava:guava:${versions.guava}"
7471
testImplementation "org.opensearch.test:framework:${opensearch_version}"
7572
testImplementation "org.apache.logging.log4j:log4j-core:${versions.log4j}"
76-
testImplementation "org.opensearch:common-utils:${common_utils_version}"
77-
testImplementation "com.fasterxml.jackson.core:jackson-databind:${jackson_version}"
78-
testImplementation "com.fasterxml.jackson.core:jackson-annotations:${jackson_version}"
79-
testImplementation "org.apache.httpcomponents:httpclient:${http_client_version}"
80-
8173
}
8274

8375
loggerUsageCheck.enabled = false

bwc-test/src/test/java/org/opensearch/customcodecs/bwc/CustomCodecsBwcCompatibilityIT.java

+9-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import java.util.Objects;
1818
import javax.net.ssl.SSLEngine;
1919

20-
import com.fasterxml.jackson.databind.ObjectMapper;
2120
import org.apache.hc.client5.http.auth.AuthScope;
2221
import org.apache.hc.client5.http.auth.UsernamePasswordCredentials;
2322
import org.apache.hc.client5.http.impl.auth.BasicCredentialsProvider;
@@ -42,6 +41,8 @@
4241
import org.opensearch.common.settings.Settings;
4342
import org.opensearch.common.util.io.IOUtils;
4443
import org.opensearch.core.common.Strings;
44+
import org.opensearch.core.xcontent.MediaTypeRegistry;
45+
import org.opensearch.core.xcontent.XContentBuilder;
4546
import org.opensearch.customcodecs.bwc.helper.RestHelper;
4647
import org.opensearch.test.rest.OpenSearchRestTestCase;
4748

@@ -185,7 +186,6 @@ public void testDataIngestionAndSearchBackwardsCompatibility() throws Exception
185186
private void ingestData(String index) throws IOException {
186187
assertTrue(indexExists(index));
187188
StringBuilder bulkRequestBody = new StringBuilder();
188-
ObjectMapper objectMapper = new ObjectMapper();
189189
int numberOfRequests = Randomness.get().nextInt(10);
190190
while (numberOfRequests-- > 0) {
191191
for (int i = 0; i < Randomness.get().nextInt(100); i++) {
@@ -195,8 +195,13 @@ private void ingestData(String index) throws IOException {
195195
put("_index", index);
196196
}
197197
});
198-
bulkRequestBody.append(objectMapper.writeValueAsString(indexRequest) + "\n");
199-
bulkRequestBody.append(objectMapper.writeValueAsString(Song.randomSong().asJson()) + "\n");
198+
199+
try (final XContentBuilder contentBuilder = MediaTypeRegistry.JSON.contentBuilder()) {
200+
contentBuilder.map(indexRequest);
201+
bulkRequestBody.append(contentBuilder.toString() + "\n");
202+
}
203+
204+
bulkRequestBody.append(Song.randomSong().asJson() + "\n");
200205
}
201206
List<Response> responses = RestHelper.requestAgainstAllNodes(
202207
testUserRestClient,

bwc-test/src/test/java/org/opensearch/customcodecs/bwc/Song.java

+8-5
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
*/
1010
package org.opensearch.customcodecs.bwc;
1111

12+
import java.io.IOException;
1213
import java.util.Map;
1314
import java.util.Objects;
1415
import java.util.UUID;
1516

16-
import com.fasterxml.jackson.core.JsonProcessingException;
17-
import com.fasterxml.jackson.databind.ObjectMapper;
18-
1917
import org.opensearch.common.Randomness;
18+
import org.opensearch.core.xcontent.MediaTypeRegistry;
19+
import org.opensearch.core.xcontent.XContentBuilder;
2020

2121
public class Song {
2222

@@ -102,8 +102,11 @@ public Map<String, Object> asMap() {
102102
return Map.of(FIELD_ARTIST, artist, FIELD_TITLE, title, FIELD_LYRICS, lyrics, FIELD_STARS, stars, FIELD_GENRE, genre);
103103
}
104104

105-
public String asJson() throws JsonProcessingException {
106-
return new ObjectMapper().writeValueAsString(this.asMap());
105+
public String asJson() throws IOException {
106+
try (final XContentBuilder contentBuilder = MediaTypeRegistry.JSON.contentBuilder()) {
107+
contentBuilder.map(asMap());
108+
return contentBuilder.toString();
109+
}
107110
}
108111

109112
public static Song randomSong() {

0 commit comments

Comments
 (0)