Skip to content

Commit

Permalink
document id field should have testIdField as value in Integration Tests
Browse files Browse the repository at this point in the history
Signed-off-by: Maxwell Brown <[email protected]>
  • Loading branch information
Galactus22625 committed Jan 3, 2025
1 parent df7c929 commit 018857c
Showing 1 changed file with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,7 @@ public void testOutputCustomIndex() throws IOException, InterruptedException {
final String testId = "foo";
final List<Record<Event>> testRecords = Collections.singletonList(jsonStringToRecord(generateCustomRecordJson(testIdField, testId)));
Map<String, Object> metadata = initializeConfigurationMetadata(null, testIndexAlias, testTemplateFile);
metadata.put(IndexConfiguration.DOCUMENT_ID_FIELD, testId);
metadata.put(IndexConfiguration.DOCUMENT_ID_FIELD, testIdField);
final OpenSearchSinkConfig openSearchSinkConfig = generateOpenSearchSinkConfigByMetadata(metadata);
final OpenSearchSink sink = createObjectUnderTest(openSearchSinkConfig, true);
sink.output(testRecords);
Expand All @@ -858,7 +858,7 @@ public void testOpenSearchBulkActionsCreate() throws IOException, InterruptedExc
final String testId = "foo";
final List<Record<Event>> testRecords = Collections.singletonList(jsonStringToRecord(generateCustomRecordJson(testIdField, testId)));
Map<String, Object> metadata = initializeConfigurationMetadata(null, testIndexAlias, testTemplateFile);
metadata.put(IndexConfiguration.DOCUMENT_ID_FIELD, testId);
metadata.put(IndexConfiguration.DOCUMENT_ID_FIELD, testIdField);
metadata.put(IndexConfiguration.ACTION, OpenSearchBulkActions.CREATE.toString());
final OpenSearchSinkConfig openSearchSinkConfig = generateOpenSearchSinkConfigByMetadata(metadata);
final OpenSearchSink sink = createObjectUnderTest(openSearchSinkConfig, true);
Expand Down Expand Up @@ -886,7 +886,7 @@ public void testOpenSearchBulkActionsCreateWithExpression() throws IOException,
final String testId = "foo";
final List<Record<Event>> testRecords = Collections.singletonList(jsonStringToRecord(generateCustomRecordJson(testIdField, testId)));
Map<String, Object> metadata = initializeConfigurationMetadata(null, testIndexAlias, testTemplateFile);
metadata.put(IndexConfiguration.DOCUMENT_ID_FIELD, testId);
metadata.put(IndexConfiguration.DOCUMENT_ID_FIELD, testIdField);
Event event = (Event) testRecords.get(0).getData();
event.getMetadata().setAttribute("action", "create");metadata.put(IndexConfiguration.ACTION, "create");
final OpenSearchSinkConfig openSearchSinkConfig = generateOpenSearchSinkConfigByMetadata(metadata);
Expand Down Expand Up @@ -915,7 +915,7 @@ public void testOpenSearchBulkActionsCreateWithInvalidExpression() throws IOExce
final String testId = "foo";
final List<Record<Event>> testRecords = Collections.singletonList(jsonStringToRecord(generateCustomRecordJson(testIdField, testId)));
Map<String, Object> metadata = initializeConfigurationMetadata(null, testIndexAlias, testTemplateFile);
metadata.put(IndexConfiguration.DOCUMENT_ID_FIELD, testId);
metadata.put(IndexConfiguration.DOCUMENT_ID_FIELD, testIdField);
metadata.put(IndexConfiguration.ACTION, "unknown");
final OpenSearchSinkConfig openSearchSinkConfig = generateOpenSearchSinkConfigByMetadata(metadata);
assertThrows(IllegalArgumentException.class, () -> createObjectUnderTest(openSearchSinkConfig, true));
Expand All @@ -931,7 +931,7 @@ public void testBulkActionCreateWithActions() throws IOException, InterruptedExc
final List<Record<Event>> testRecords = Collections.singletonList(jsonStringToRecord(generateCustomRecordJson(testIdField, testId)));

Map<String, Object> metadata = initializeConfigurationMetadata(null, testIndexAlias, testTemplateFile);
metadata.put(IndexConfiguration.DOCUMENT_ID_FIELD, testId);
metadata.put(IndexConfiguration.DOCUMENT_ID_FIELD, testIdField);
List<Map<String, Object>> aList = new ArrayList<>();
Map<String, Object> aMap = new HashMap<>();
aMap.put("type", OpenSearchBulkActions.CREATE.toString());
Expand Down Expand Up @@ -965,7 +965,7 @@ public void testBulkActionUpdateWithActions() throws IOException, InterruptedExc
List<Record<Event>> testRecords = Collections.singletonList(jsonStringToRecord(generateCustomRecordJson2(testIdField, testId, "name", "value1")));

Map<String, Object> metadata = initializeConfigurationMetadata(null, testIndexAlias, testTemplateFile);
metadata.put(IndexConfiguration.DOCUMENT_ID_FIELD, testId);
metadata.put(IndexConfiguration.DOCUMENT_ID_FIELD, testIdField);
List<Map<String, Object>> aList = new ArrayList<>();
Map<String, Object> aMap = new HashMap<>();
aMap.put("type", OpenSearchBulkActions.CREATE.toString());
Expand Down Expand Up @@ -1025,7 +1025,7 @@ public void testBulkActionUpdateWithDocumentRootKey() throws IOException, Interr
Map<String, Object> metadata = initializeConfigurationMetadata(null, testIndexAlias, testTemplateFile);

metadata.put(IndexConfiguration.DOCUMENT_ROOT_KEY, documentRootKey);
metadata.put(IndexConfiguration.DOCUMENT_ID_FIELD, testId);
metadata.put(IndexConfiguration.DOCUMENT_ID_FIELD, testIdField);
List<Map<String, Object>> aList = new ArrayList<>();
Map<String, Object> actionMap = new HashMap<>();
actionMap.put("type", OpenSearchBulkActions.CREATE.toString());
Expand Down Expand Up @@ -1088,7 +1088,7 @@ public void testBulkActionUpsertWithActionsAndNoCreate() throws IOException, Int
aList.add(actionMap);

Map<String, Object> metadata = initializeConfigurationMetadata(null, testIndexAlias, testTemplateFile);
metadata.put(IndexConfiguration.DOCUMENT_ID_FIELD, testId);
metadata.put(IndexConfiguration.DOCUMENT_ID_FIELD, testIdField);
metadata.put(IndexConfiguration.ACTIONS, aList);
final OpenSearchSinkConfig openSearchSinkConfig = generateOpenSearchSinkConfigByMetadata(metadata);
OpenSearchSink sink = createObjectUnderTest(openSearchSinkConfig, true);
Expand All @@ -1115,7 +1115,7 @@ public void testBulkActionUpsertWithActions() throws IOException, InterruptedExc
List<Record<Event>> testRecords = Collections.singletonList(jsonStringToRecord(generateCustomRecordJson2(testIdField, testId, "name", "value1")));

Map<String, Object> metadata = initializeConfigurationMetadata(null, testIndexAlias, testTemplateFile);
metadata.put(IndexConfiguration.DOCUMENT_ID_FIELD, testId);
metadata.put(IndexConfiguration.DOCUMENT_ID_FIELD, testIdField);
List<Map<String, Object>> aList = new ArrayList<>();
Map<String, Object> aMap = new HashMap<>();
aMap.put("type", OpenSearchBulkActions.CREATE.toString());
Expand Down Expand Up @@ -1166,7 +1166,7 @@ public void testBulkActionUpsertWithoutCreate() throws IOException, InterruptedE
final String testId = "foo";
List<Record<Event>> testRecords = Collections.singletonList(jsonStringToRecord(generateCustomRecordJson3(testIdField, testId, "name", "value1", "newKey", "newValue")));
Map<String, Object> metadata = initializeConfigurationMetadata(null, testIndexAlias, testTemplateFile);
metadata.put(IndexConfiguration.DOCUMENT_ID_FIELD, testId);
metadata.put(IndexConfiguration.DOCUMENT_ID_FIELD, testIdField);
List<Map<String, Object>> aList = new ArrayList<>();
Map<String, Object> aMap = new HashMap<>();
aMap.put("type", OpenSearchBulkActions.UPSERT.toString());
Expand Down Expand Up @@ -1203,7 +1203,7 @@ public void testBulkActionDeleteWithActions() throws IOException, InterruptedExc
List<Record<Event>> testRecords = Collections.singletonList(jsonStringToRecord(generateCustomRecordJson(testIdField, testId)));

Map<String, Object> metadata = initializeConfigurationMetadata(null, testIndexAlias, testTemplateFile);
metadata.put(IndexConfiguration.DOCUMENT_ID_FIELD, testId);
metadata.put(IndexConfiguration.DOCUMENT_ID_FIELD, testIdField);
List<Map<String, Object>> aList = new ArrayList<>();
Map<String, Object> aMap = new HashMap<>();
aMap.put("type", OpenSearchBulkActions.DELETE.toString());
Expand Down Expand Up @@ -1634,7 +1634,7 @@ public void testOutputManagementDisabled() throws IOException, InterruptedExcept
metadata.put(IndexConfiguration.INDEX_TYPE, IndexType.MANAGEMENT_DISABLED.getValue());
metadata.put(USERNAME, username);
metadata.put(PASSWORD, password);
metadata.put(IndexConfiguration.DOCUMENT_ID_FIELD, testId);
metadata.put(IndexConfiguration.DOCUMENT_ID_FIELD, testIdField);
final OpenSearchSinkConfig openSearchSinkConfig = generateOpenSearchSinkConfigByMetadata(metadata);
final OpenSearchSink sink = createObjectUnderTest(openSearchSinkConfig, true);

Expand Down

0 comments on commit 018857c

Please sign in to comment.