Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GA updates and minor BWC test cleanups #104

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Loading