diff --git a/.github/workflows/opensearch-sink-opendistro-integration-tests.yml b/.github/workflows/opensearch-sink-opendistro-integration-tests.yml
index cfaca4a330..45c477e12f 100644
--- a/.github/workflows/opensearch-sink-opendistro-integration-tests.yml
+++ b/.github/workflows/opensearch-sink-opendistro-integration-tests.yml
@@ -40,7 +40,7 @@ jobs:
- name: Run Open Distro tests
run: |
./gradlew :data-prepper-plugins:opensearch:integrationTest --tests "org.opensearch.dataprepper.plugins.sink.opensearch.OpenSearchIT" -Dtests.opensearch.host=localhost:9200 -Dtests.opensearch.user=admin -Dtests.opensearch.password=admin
- ./gradlew :data-prepper-plugins:opensearch:integrationTest -Dtests.opensearch.host=localhost:9200 -Dtests.opensearch.user=admin -Dtests.opensearch.password=admin -Dtests.opensearch.bundle=true
+ ./gradlew :data-prepper-plugins:opensearch:integrationTest -Dtests.opensearch.host=localhost:9200 -Dtests.opensearch.user=admin -Dtests.opensearch.password=admin -Dtests.opensearch.bundle=true -Dtests.opensearch.version=opendistro:${{ matrix.opendistro }}
- name: Upload Unit Test Results
if: always()
uses: actions/upload-artifact@v3
diff --git a/.github/workflows/opensearch-sink-opensearch-integration-tests.yml b/.github/workflows/opensearch-sink-opensearch-integration-tests.yml
index 925086127d..5e34350303 100644
--- a/.github/workflows/opensearch-sink-opensearch-integration-tests.yml
+++ b/.github/workflows/opensearch-sink-opensearch-integration-tests.yml
@@ -40,7 +40,7 @@ jobs:
- name: Run OpenSearch tests
run: |
./gradlew :data-prepper-plugins:opensearch:integrationTest --tests "org.opensearch.dataprepper.plugins.sink.opensearch.OpenSearchIT" -Dtests.opensearch.host=localhost:9200 -Dtests.opensearch.user=admin -Dtests.opensearch.password=admin
- ./gradlew :data-prepper-plugins:opensearch:integrationTest -Dtests.opensearch.host=localhost:9200 -Dtests.opensearch.user=admin -Dtests.opensearch.password=admin -Dtests.opensearch.bundle=true
+ ./gradlew :data-prepper-plugins:opensearch:integrationTest -Dtests.opensearch.host=localhost:9200 -Dtests.opensearch.user=admin -Dtests.opensearch.password=admin -Dtests.opensearch.bundle=true -Dtests.opensearch.version=opensearch:${{ matrix.opensearch }}
- name: Upload Unit Test Results
if: always()
uses: actions/upload-artifact@v3
diff --git a/data-prepper-plugins/opensearch/README.md b/data-prepper-plugins/opensearch/README.md
index 0ccfc39d33..edc297e3c0 100644
--- a/data-prepper-plugins/opensearch/README.md
+++ b/data-prepper-plugins/opensearch/README.md
@@ -129,6 +129,8 @@ Default is null.
* This index name can also be a plain string plus a date-time pattern as a suffix, such as `application-%{yyyy.MM.dd}`, `my-index-name-%{yyyy.MM.dd.HH}`. When OpenSearch Sink is sending data to OpenSearch, the date-time pattern will be replaced by actual UTC time. The pattern supports all the symbols that represent one hour or above and are listed in [Java DateTimeFormatter](https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html). For example, with an index pattern like `my-index-name-%{yyyy.MM.dd}`, a new index is created for each day such as `my-index-name-2022.01.25`. For another example, with an index pattern like `my-index-name-%{yyyy.MM.dd.HH}`, a new index is created for each hour such as `my-index-name-2022.01.25.13`.
* This index name can also be a formatted string (with or without date-time pattern suffix), such as `my-${index}-name`. When OpenSearchSink is sending data to OpenSearch, the format portion "${index}" will be replaced by it's value in the event that is being processed. The format may also be like "${index1/index2/index3}" in which case the field "index1/index2/index3" is searched in the event and replaced by its value.
+- `template_type`(optional): Defines what type of OpenSearch template to use. The available options are `v1` and `index-template`. The default value is `v1`, which uses the original OpenSearch templates available at the `_template` API endpoints. Select `index-template` to use composable index templates which are available at OpenSearch's `_index_template` endpoint.
+
- `template_file`(optional): A json file path or AWS S3 URI to be read as index template for custom data ingestion. The json file content should be the json value of
`"template"` key in the json content of OpenSearch [Index templates API](https://opensearch.org/docs/latest/opensearch/index-templates/),
e.g. [otel-v1-apm-span-index-template.json](https://github.com/opensearch-project/data-prepper/blob/main/data-prepper-plugins/opensearch/src/main/resources/otel-v1-apm-span-index-template.json)
diff --git a/data-prepper-plugins/opensearch/build.gradle b/data-prepper-plugins/opensearch/build.gradle
index e77cbc3815..40ecb6b2c7 100644
--- a/data-prepper-plugins/opensearch/build.gradle
+++ b/data-prepper-plugins/opensearch/build.gradle
@@ -64,9 +64,11 @@ task integrationTest(type: Test) {
systemProperty 'tests.opensearch.bundle', System.getProperty('tests.opensearch.bundle')
systemProperty 'tests.opensearch.user', System.getProperty('tests.opensearch.user')
systemProperty 'tests.opensearch.password', System.getProperty('tests.opensearch.password')
+ systemProperty 'tests.opensearch.version', System.getProperty('tests.opensearch.version')
filter {
includeTestsMatching '*IT'
+ includeTestsMatching '*Test'
}
}
diff --git a/data-prepper-plugins/opensearch/src/integrationTest/java/org/opensearch/dataprepper/plugins/sink/opensearch/DeclaredOpenSearchVersion.java b/data-prepper-plugins/opensearch/src/integrationTest/java/org/opensearch/dataprepper/plugins/sink/opensearch/DeclaredOpenSearchVersion.java
new file mode 100644
index 0000000000..ff79a0f555
--- /dev/null
+++ b/data-prepper-plugins/opensearch/src/integrationTest/java/org/opensearch/dataprepper/plugins/sink/opensearch/DeclaredOpenSearchVersion.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright OpenSearch Contributors
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package org.opensearch.dataprepper.plugins.sink.opensearch;
+
+import org.opensearch.Version;
+
+/**
+ * An interface for letting the test declare what OpenSearch version is being
+ * tested against.
+ */
+class DeclaredOpenSearchVersion implements Comparable {
+ private static final DeclaredOpenSearchVersion DEFAULT = new DeclaredOpenSearchVersion(Distribution.OPENSEARCH, "1.0.0");
+ public static final DeclaredOpenSearchVersion OPENDISTRO_1_9 = new DeclaredOpenSearchVersion(Distribution.OPENDISTRO, "1.9.0");
+
+ enum Distribution {
+ OPENDISTRO,
+ OPENSEARCH
+ }
+
+ private final Distribution distribution;
+ private final String version;
+ private final Version internalVersion;
+
+ private DeclaredOpenSearchVersion(final Distribution distribution, final String version) {
+ this.distribution = distribution;
+ this.version = version;
+
+ internalVersion = Version.fromString(version);
+ }
+
+ static DeclaredOpenSearchVersion parse(final String versionString) {
+ if(versionString == null) {
+ return DEFAULT;
+ }
+
+ final String[] parts = versionString.split(":");
+
+ if(parts.length != 2) {
+ throw new IllegalArgumentException("Invalid version string provided.");
+ }
+
+ final Distribution distribution = Distribution.valueOf(parts[0].toUpperCase());
+
+ return new DeclaredOpenSearchVersion(distribution, parts[1]);
+ }
+
+ @Override
+ public int compareTo(final DeclaredOpenSearchVersion other) {
+ final int distributionCompareTo = distribution.compareTo(other.distribution);
+
+ if(distributionCompareTo != 0) {
+ return distributionCompareTo;
+ }
+
+ return internalVersion.compareTo(other.internalVersion);
+ }
+
+ Distribution getDistribution() {
+ return distribution;
+ }
+
+ String getVersion() {
+ return version;
+ }
+}
diff --git a/data-prepper-plugins/opensearch/src/integrationTest/java/org/opensearch/dataprepper/plugins/sink/opensearch/DeclaredOpenSearchVersionTest.java b/data-prepper-plugins/opensearch/src/integrationTest/java/org/opensearch/dataprepper/plugins/sink/opensearch/DeclaredOpenSearchVersionTest.java
new file mode 100644
index 0000000000..820c39b820
--- /dev/null
+++ b/data-prepper-plugins/opensearch/src/integrationTest/java/org/opensearch/dataprepper/plugins/sink/opensearch/DeclaredOpenSearchVersionTest.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright OpenSearch Contributors
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package org.opensearch.dataprepper.plugins.sink.opensearch;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.CsvSource;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+class DeclaredOpenSearchVersionTest {
+ @ParameterizedTest
+ @CsvSource({
+ "opensearch:1.2.4,OPENSEARCH,1.2.4",
+ "opensearch:1.3.9,OPENSEARCH,1.3.9",
+ "opensearch:2.2.1,OPENSEARCH,2.2.1",
+ "opensearch:2.6.0,OPENSEARCH,2.6.0",
+ "opendistro:1.3.0,OPENDISTRO,1.3.0",
+ "opendistro:1.13.3,OPENDISTRO,1.13.3"
+ })
+ void parse_should_return_expected(final String versionString, final DeclaredOpenSearchVersion.Distribution expectedDistribution, final String expectedVersion) {
+ final DeclaredOpenSearchVersion version = DeclaredOpenSearchVersion.parse(versionString);
+
+ assertThat(version, notNullValue());
+ assertThat(version.getDistribution(), equalTo(expectedDistribution));
+ assertThat(version.getVersion(), equalTo(expectedVersion));
+ }
+
+ @Test
+ void parse_with_null_should_return_minimum_version() {
+ final DeclaredOpenSearchVersion version = DeclaredOpenSearchVersion.parse(null);
+
+ assertThat(version, notNullValue());
+ assertThat(version.getDistribution(), equalTo(DeclaredOpenSearchVersion.Distribution.OPENSEARCH));
+ assertThat(version.getVersion(), equalTo("1.0.0"));
+ }
+
+ @ParameterizedTest
+ @CsvSource({
+ "opensearch:1.2.4,opensearch:1.2.4,0",
+ "opendistro:1.13.3,opendistro:1.13.3,0",
+ "opensearch:1.2.4,opensearch:1.2.3,1",
+ "opensearch:1.2.3,opensearch:1.2.4,-1",
+ "opensearch:2.6.0,opensearch:1.2.3,1",
+ "opensearch:1.2.3,opensearch:2.6.0,-1",
+ "opensearch:1.3.9,opendistro:1.13.3,1",
+ "opendistro:1.13.3,opensearch:1.3.9,-1"
+ })
+ void compareTo_returns_correct_value(final String versionStringToTest, final String otherVersionString, final int expectedCompareTo) {
+ final DeclaredOpenSearchVersion objectUnderTest = DeclaredOpenSearchVersion.parse(versionStringToTest);
+ final DeclaredOpenSearchVersion otherVersion = DeclaredOpenSearchVersion.parse(otherVersionString);
+
+ assertThat(objectUnderTest.compareTo(otherVersion), equalTo(expectedCompareTo));
+ }
+}
\ No newline at end of file
diff --git a/data-prepper-plugins/opensearch/src/integrationTest/java/org/opensearch/dataprepper/plugins/sink/opensearch/OpenSearchIntegrationHelper.java b/data-prepper-plugins/opensearch/src/integrationTest/java/org/opensearch/dataprepper/plugins/sink/opensearch/OpenSearchIntegrationHelper.java
index 43103636c5..b44562909d 100644
--- a/data-prepper-plugins/opensearch/src/integrationTest/java/org/opensearch/dataprepper/plugins/sink/opensearch/OpenSearchIntegrationHelper.java
+++ b/data-prepper-plugins/opensearch/src/integrationTest/java/org/opensearch/dataprepper/plugins/sink/opensearch/OpenSearchIntegrationHelper.java
@@ -92,6 +92,10 @@ static List getHosts() {
.map(ip -> String.format("https://%s", ip)).collect(Collectors.toList());
}
+ static DeclaredOpenSearchVersion getVersion() {
+ return DeclaredOpenSearchVersion.parse(System.getProperty("tests.opensearch.version"));
+ }
+
/**
* Copied from OpenSearch test framework
* TODO: Consolidate in OpenSearch
diff --git a/data-prepper-plugins/opensearch/src/integrationTest/java/org/opensearch/dataprepper/plugins/sink/opensearch/OpenSearchSinkIT.java b/data-prepper-plugins/opensearch/src/integrationTest/java/org/opensearch/dataprepper/plugins/sink/opensearch/OpenSearchSinkIT.java
index 57fe7320d0..f437c0c62c 100644
--- a/data-prepper-plugins/opensearch/src/integrationTest/java/org/opensearch/dataprepper/plugins/sink/opensearch/OpenSearchSinkIT.java
+++ b/data-prepper-plugins/opensearch/src/integrationTest/java/org/opensearch/dataprepper/plugins/sink/opensearch/OpenSearchSinkIT.java
@@ -5,17 +5,6 @@
package org.opensearch.dataprepper.plugins.sink.opensearch;
-import org.mockito.Mock;
-import org.opensearch.dataprepper.aws.api.AwsCredentialsSupplier;
-import org.opensearch.dataprepper.metrics.MetricNames;
-import org.opensearch.dataprepper.metrics.MetricsTestUtil;
-import org.opensearch.dataprepper.model.configuration.PluginSetting;
-import org.opensearch.dataprepper.model.event.Event;
-import org.opensearch.dataprepper.model.event.EventType;
-import org.opensearch.dataprepper.model.event.EventHandle;
-import org.opensearch.dataprepper.model.event.JacksonEvent;
-import org.opensearch.dataprepper.model.plugin.PluginFactory;
-import org.opensearch.dataprepper.model.record.Record;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -28,19 +17,34 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
+import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.ValueSource;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.ArgumentsProvider;
+import org.junit.jupiter.params.provider.ArgumentsSource;
import org.junit.jupiter.params.provider.CsvSource;
+import org.junit.jupiter.params.provider.ValueSource;
+import org.mockito.Mock;
import org.opensearch.client.Request;
import org.opensearch.client.Response;
import org.opensearch.client.RestClient;
import org.opensearch.common.Strings;
import org.opensearch.common.xcontent.XContentFactory;
import org.opensearch.common.xcontent.XContentType;
+import org.opensearch.dataprepper.aws.api.AwsCredentialsSupplier;
+import org.opensearch.dataprepper.metrics.MetricNames;
+import org.opensearch.dataprepper.metrics.MetricsTestUtil;
+import org.opensearch.dataprepper.model.configuration.PluginSetting;
+import org.opensearch.dataprepper.model.event.Event;
+import org.opensearch.dataprepper.model.event.EventHandle;
+import org.opensearch.dataprepper.model.event.EventType;
+import org.opensearch.dataprepper.model.event.JacksonEvent;
+import org.opensearch.dataprepper.model.plugin.PluginFactory;
+import org.opensearch.dataprepper.model.record.Record;
import org.opensearch.dataprepper.plugins.sink.opensearch.bulk.BulkAction;
+import org.opensearch.dataprepper.plugins.sink.opensearch.index.AbstractIndexManager;
import org.opensearch.dataprepper.plugins.sink.opensearch.index.IndexConfiguration;
import org.opensearch.dataprepper.plugins.sink.opensearch.index.IndexConstants;
-import org.opensearch.dataprepper.plugins.sink.opensearch.index.AbstractIndexManager;
import org.opensearch.dataprepper.plugins.sink.opensearch.index.IndexType;
import javax.ws.rs.HttpMethod;
@@ -53,6 +57,7 @@
import java.nio.file.Files;
import java.nio.file.Paths;
import java.text.SimpleDateFormat;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
@@ -64,43 +69,48 @@
import java.util.StringJoiner;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
-import java.util.stream.Collectors;
+import java.util.function.BiFunction;
import java.util.function.Predicate;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
import static org.apache.http.HttpStatus.SC_OK;
import static org.awaitility.Awaitility.await;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.hasItems;
import static org.hamcrest.CoreMatchers.hasItem;
+import static org.hamcrest.CoreMatchers.hasItems;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.Matchers.closeTo;
+import static org.junit.jupiter.params.provider.Arguments.arguments;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.lenient;
+import static org.mockito.Mockito.mock;
import static org.opensearch.dataprepper.plugins.sink.opensearch.OpenSearchIntegrationHelper.createContentParser;
import static org.opensearch.dataprepper.plugins.sink.opensearch.OpenSearchIntegrationHelper.createOpenSearchClient;
import static org.opensearch.dataprepper.plugins.sink.opensearch.OpenSearchIntegrationHelper.getHosts;
import static org.opensearch.dataprepper.plugins.sink.opensearch.OpenSearchIntegrationHelper.isOSBundle;
import static org.opensearch.dataprepper.plugins.sink.opensearch.OpenSearchIntegrationHelper.waitForClusterStateUpdatesToFinish;
import static org.opensearch.dataprepper.plugins.sink.opensearch.OpenSearchIntegrationHelper.wipeAllTemplates;
-import static org.mockito.Mockito.mock;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.lenient;
public class OpenSearchSinkIT {
- private static final String PLUGIN_NAME = "opensearch";
- private static final String PIPELINE_NAME = "integTestPipeline";
- private static final String TEST_CUSTOM_INDEX_POLICY_FILE = "test-custom-index-policy-file.json";
- private static final String TEST_TEMPLATE_V1_FILE = "test-index-template.json";
- private static final String TEST_TEMPLATE_V2_FILE = "test-index-template-v2.json";
- private static final String DEFAULT_RAW_SPAN_FILE_1 = "raw-span-1.json";
- private static final String DEFAULT_RAW_SPAN_FILE_2 = "raw-span-2.json";
- private static final String DEFAULT_SERVICE_MAP_FILE = "service-map-1.json";
-
- private RestClient client;
- private EventHandle eventHandle;
-
- @Mock
- private PluginFactory pluginFactory;
+ private static final String PLUGIN_NAME = "opensearch";
+ private static final String PIPELINE_NAME = "integTestPipeline";
+ private static final String TEST_CUSTOM_INDEX_POLICY_FILE = "test-custom-index-policy-file.json";
+ private static final String TEST_TEMPLATE_V1_FILE = "test-index-template.json";
+ private static final String TEST_TEMPLATE_V2_FILE = "test-index-template-v2.json";
+ private static final String TEST_INDEX_TEMPLATE_V1_FILE = "test-composable-index-template.json";
+ private static final String TEST_INDEX_TEMPLATE_V2_FILE = "test-composable-index-template-v2.json";
+ private static final String DEFAULT_RAW_SPAN_FILE_1 = "raw-span-1.json";
+ private static final String DEFAULT_RAW_SPAN_FILE_2 = "raw-span-2.json";
+ private static final String DEFAULT_SERVICE_MAP_FILE = "service-map-1.json";
+
+ private RestClient client;
+ private EventHandle eventHandle;
+
+ @Mock
+ private PluginFactory pluginFactory;
@Mock
private AwsCredentialsSupplier awsCredentialsSupplier;
@@ -113,866 +123,906 @@ public OpenSearchSink createObjectUnderTest(PluginSetting pluginSetting, boolean
return sink;
}
- @BeforeEach
- public void setup() {
- eventHandle = mock(EventHandle.class);
- lenient().doAnswer(a -> {
+ @BeforeEach
+ public void setup() {
+ eventHandle = mock(EventHandle.class);
+ lenient().doAnswer(a -> {
return null;
- }).when(eventHandle).release(any(Boolean.class));
- }
-
- @BeforeEach
- public void metricsInit() throws IOException {
- MetricsTestUtil.initMetrics();
-
- client = createOpenSearchClient();
- }
-
- @AfterEach
- public void cleanOpenSearch() throws Exception {
- wipeAllOpenSearchIndices();
- wipeAllTemplates();
- waitForClusterStateUpdatesToFinish();
- }
-
- @Test
- public void testInstantiateSinkRawSpanDefault() throws IOException {
- final PluginSetting pluginSetting = generatePluginSetting(IndexType.TRACE_ANALYTICS_RAW.getValue(), null, null);
- OpenSearchSink sink = createObjectUnderTest(pluginSetting, true);
- final String indexAlias = IndexConstants.TYPE_TO_DEFAULT_ALIAS.get(IndexType.TRACE_ANALYTICS_RAW);
- Request request = new Request(HttpMethod.HEAD, indexAlias);
- Response response = client.performRequest(request);
- MatcherAssert.assertThat(response.getStatusLine().getStatusCode(), equalTo(SC_OK));
- final String index = String.format("%s-000001", indexAlias);
- final Map mappings = getIndexMappings(index);
- MatcherAssert.assertThat(mappings, notNullValue());
- MatcherAssert.assertThat((boolean) mappings.get("date_detection"), equalTo(false));
- sink.shutdown();
-
- if (isOSBundle()) {
- // Check managed index
- await().atMost(1, TimeUnit.SECONDS).untilAsserted(() -> {
- MatcherAssert.assertThat(getIndexPolicyId(index), equalTo(IndexConstants.RAW_ISM_POLICY));
- }
- );
- }
-
- // roll over initial index
- request = new Request(HttpMethod.POST, String.format("%s/_rollover", indexAlias));
- request.setJsonEntity("{ \"conditions\" : { } }\n");
- response = client.performRequest(request);
- MatcherAssert.assertThat(response.getStatusLine().getStatusCode(), equalTo(SC_OK));
-
- // Instantiate sink again
- sink = createObjectUnderTest(pluginSetting, true);
- // Make sure no new write index *-000001 is created under alias
- final String rolloverIndexName = String.format("%s-000002", indexAlias);
- request = new Request(HttpMethod.GET, rolloverIndexName + "/_alias");
- response = client.performRequest(request);
- MatcherAssert.assertThat(checkIsWriteIndex(EntityUtils.toString(response.getEntity()), indexAlias, rolloverIndexName), equalTo(true));
- sink.shutdown();
-
- if (isOSBundle()) {
- // Check managed index
- MatcherAssert.assertThat(getIndexPolicyId(rolloverIndexName), equalTo(IndexConstants.RAW_ISM_POLICY));
+ }).when(eventHandle).release(any(Boolean.class));
}
- }
-
- @Test
- public void testInstantiateSinkRawSpanReservedAliasAlreadyUsedAsIndex() throws IOException {
- final String reservedIndexAlias = IndexConstants.TYPE_TO_DEFAULT_ALIAS.get(IndexType.TRACE_ANALYTICS_RAW);
- final Request request = new Request(HttpMethod.PUT, reservedIndexAlias);
- client.performRequest(request);
- final PluginSetting pluginSetting = generatePluginSetting(IndexType.TRACE_ANALYTICS_RAW.getValue(), null, null);
- OpenSearchSink sink = createObjectUnderTest(pluginSetting, false);
- Assert.assertThrows(String.format(AbstractIndexManager.INDEX_ALIAS_USED_AS_INDEX_ERROR, reservedIndexAlias),
- RuntimeException.class, () -> sink.doInitialize());
- }
-
- @Test
- public void testOutputRawSpanDefault() throws IOException, InterruptedException {
- final String testDoc1 = readDocFromFile(DEFAULT_RAW_SPAN_FILE_1);
- final String testDoc2 = readDocFromFile(DEFAULT_RAW_SPAN_FILE_2);
- final ObjectMapper mapper = new ObjectMapper();
- @SuppressWarnings("unchecked") final Map expData1 = mapper.readValue(testDoc1, Map.class);
- @SuppressWarnings("unchecked") final Map expData2 = mapper.readValue(testDoc2, Map.class);
-
- final List> testRecords = Arrays.asList(jsonStringToRecord(testDoc1), jsonStringToRecord(testDoc2));
- final PluginSetting pluginSetting = generatePluginSetting(IndexType.TRACE_ANALYTICS_RAW.getValue(), null, null);
- final OpenSearchSink sink = createObjectUnderTest(pluginSetting, true);
- sink.output(testRecords);
-
- final String expIndexAlias = IndexConstants.TYPE_TO_DEFAULT_ALIAS.get(IndexType.TRACE_ANALYTICS_RAW);
- final List