Skip to content

Commit

Permalink
GA updates and minor BWC test cleanups
Browse files Browse the repository at this point in the history
Signed-off-by: Andriy Redko <andriy.redko@aiven.io>
  • Loading branch information
reta committed Jan 29, 2024
1 parent 78a6045 commit de591b1
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/actions/create-bwc-build/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/run-bwc-suite/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,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: |
Expand Down
8 changes: 0 additions & 8 deletions bwc-test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ buildscript {
ext {
opensearch_version = System.getProperty("opensearch.version", "3.0.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()
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import java.util.Objects;
import javax.net.ssl.SSLEngine;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.hc.client5.http.auth.AuthScope;
import org.apache.hc.client5.http.auth.UsernamePasswordCredentials;
import org.apache.hc.client5.http.impl.auth.BasicCredentialsProvider;
Expand All @@ -42,6 +41,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;

Expand Down Expand Up @@ -185,7 +186,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++) {
Expand All @@ -195,8 +195,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<Response> responses = RestHelper.requestAgainstAllNodes(
testUserRestClient,
Expand Down
13 changes: 8 additions & 5 deletions bwc-test/src/test/java/org/opensearch/customcodecs/bwc/Song.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -102,8 +102,11 @@ public Map<String, Object> 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() {
Expand Down

0 comments on commit de591b1

Please sign in to comment.