diff --git a/.github/actions/create-bwc-build/action.yaml b/.github/actions/create-bwc-build/action.yaml index 24a674c..e09a6ec 100644 --- a/.github/actions/create-bwc-build/action.yaml +++ b/.github/actions/create-bwc-build/action.yaml @@ -33,7 +33,7 @@ runs: path: ${{ inputs.plugin-branch }} - name: Build - uses: gradle/gradle-build-action@v2 + uses: gradle/gradle-build-action@v3 with: cache-disabled: true arguments: assemble diff --git a/.github/actions/run-bwc-suite/action.yaml b/.github/actions/run-bwc-suite/action.yaml index f4c54d5..d66b7bc 100644 --- a/.github/actions/run-bwc-suite/action.yaml +++ b/.github/actions/run-bwc-suite/action.yaml @@ -37,7 +37,7 @@ runs: plugin-branch: ${{ inputs.plugin-next-branch }} - name: Run BWC tests - uses: gradle/gradle-build-action@v2 + uses: gradle/gradle-build-action@v3 with: cache-disabled: true arguments: | diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 15bf998..2acc0a1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,7 +24,7 @@ jobs: uses: actions/checkout@v4 - name: Build BWC tests - uses: gradle/gradle-build-action@v2 + uses: gradle/gradle-build-action@v3 with: cache-disabled: true arguments: | diff --git a/bwc-test/build.gradle b/bwc-test/build.gradle index ed37fd0..0820afe 100644 --- a/bwc-test/build.gradle +++ b/bwc-test/build.gradle @@ -46,9 +46,6 @@ buildscript { ext { opensearch_version = System.getProperty("opensearch.version", "2.12.0-SNAPSHOT") opensearch_group = "org.opensearch" - common_utils_version = System.getProperty("common_utils.version", '2.9.0.0-SNAPSHOT') - jackson_version = System.getProperty("jackson_version", "2.16.1") - http_client_version = System.getProperty("http_client_version", "4.5.14") } repositories { mavenLocal() @@ -73,11 +70,6 @@ dependencies { testImplementation "com.google.guava:guava:${versions.guava}" testImplementation "org.opensearch.test:framework:${opensearch_version}" testImplementation "org.apache.logging.log4j:log4j-core:${versions.log4j}" - testImplementation "org.opensearch:common-utils:${common_utils_version}" - testImplementation "com.fasterxml.jackson.core:jackson-databind:${jackson_version}" - testImplementation "com.fasterxml.jackson.core:jackson-annotations:${jackson_version}" - testImplementation "org.apache.httpcomponents:httpclient:${http_client_version}" - } loggerUsageCheck.enabled = false diff --git a/bwc-test/src/test/java/org/opensearch/customcodecs/bwc/CustomCodecsBwcCompatibilityIT.java b/bwc-test/src/test/java/org/opensearch/customcodecs/bwc/CustomCodecsBwcCompatibilityIT.java index b3434fb..c9dd426 100644 --- a/bwc-test/src/test/java/org/opensearch/customcodecs/bwc/CustomCodecsBwcCompatibilityIT.java +++ b/bwc-test/src/test/java/org/opensearch/customcodecs/bwc/CustomCodecsBwcCompatibilityIT.java @@ -17,7 +17,6 @@ import java.util.Objects; import javax.net.ssl.SSLContext; -import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.http.HttpHost; import org.apache.http.auth.AuthScope; import org.apache.http.auth.UsernamePasswordCredentials; @@ -38,6 +37,8 @@ import org.opensearch.common.settings.Settings; import org.opensearch.common.util.io.IOUtils; import org.opensearch.core.common.Strings; +import org.opensearch.core.xcontent.MediaTypeRegistry; +import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.customcodecs.bwc.helper.RestHelper; import org.opensearch.test.rest.OpenSearchRestTestCase; @@ -161,7 +162,6 @@ public void testDataIngestionAndSearchBackwardsCompatibility() throws Exception private void ingestData(String index) throws IOException { assertTrue(indexExists(index)); StringBuilder bulkRequestBody = new StringBuilder(); - ObjectMapper objectMapper = new ObjectMapper(); int numberOfRequests = Randomness.get().nextInt(10); while (numberOfRequests-- > 0) { for (int i = 0; i < Randomness.get().nextInt(100); i++) { @@ -171,8 +171,13 @@ private void ingestData(String index) throws IOException { put("_index", index); } }); - bulkRequestBody.append(objectMapper.writeValueAsString(indexRequest) + "\n"); - bulkRequestBody.append(objectMapper.writeValueAsString(Song.randomSong().asJson()) + "\n"); + + try (final XContentBuilder contentBuilder = MediaTypeRegistry.JSON.contentBuilder()) { + contentBuilder.map(indexRequest); + bulkRequestBody.append(contentBuilder.toString() + "\n"); + } + + bulkRequestBody.append(Song.randomSong().asJson() + "\n"); } List responses = RestHelper.requestAgainstAllNodes( testUserRestClient, diff --git a/bwc-test/src/test/java/org/opensearch/customcodecs/bwc/Song.java b/bwc-test/src/test/java/org/opensearch/customcodecs/bwc/Song.java index 273fefc..768f815 100644 --- a/bwc-test/src/test/java/org/opensearch/customcodecs/bwc/Song.java +++ b/bwc-test/src/test/java/org/opensearch/customcodecs/bwc/Song.java @@ -9,14 +9,14 @@ */ package org.opensearch.customcodecs.bwc; +import java.io.IOException; import java.util.Map; import java.util.Objects; import java.util.UUID; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; - import org.opensearch.common.Randomness; +import org.opensearch.core.xcontent.MediaTypeRegistry; +import org.opensearch.core.xcontent.XContentBuilder; public class Song { @@ -102,8 +102,11 @@ public Map asMap() { return Map.of(FIELD_ARTIST, artist, FIELD_TITLE, title, FIELD_LYRICS, lyrics, FIELD_STARS, stars, FIELD_GENRE, genre); } - public String asJson() throws JsonProcessingException { - return new ObjectMapper().writeValueAsString(this.asMap()); + public String asJson() throws IOException { + try (final XContentBuilder contentBuilder = MediaTypeRegistry.JSON.contentBuilder()) { + contentBuilder.map(asMap()); + return contentBuilder.toString(); + } } public static Song randomSong() {