-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated the ES 7.X transformation code to handle arbitrary type names (…
…#1014) * Updated the ES 7.X transformation code to handle arbitrary type names Signed-off-by: Chris Helma <[email protected]> * Minor tweaks to transformer code Signed-off-by: Chris Helma <[email protected]> * Improved a comment Signed-off-by: Chris Helma <[email protected]> * Made Spotless happy Signed-off-by: Chris Helma <[email protected]> * Updates per PR comments and discussion Signed-off-by: Chris Helma <[email protected]> --------- Signed-off-by: Chris Helma <[email protected]>
- Loading branch information
Showing
19 changed files
with
230 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
...java/org/opensearch/migrations/bulkload/transformers/Transformer_ES_7_10_OS_2_11Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package org.opensearch.migrations.bulkload.transformers; | ||
|
||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import org.opensearch.migrations.Version; | ||
import org.opensearch.migrations.bulkload.common.FileSystemRepo; | ||
import org.opensearch.migrations.bulkload.common.TestResources; | ||
import org.opensearch.migrations.bulkload.models.GlobalMetadata; | ||
import org.opensearch.migrations.bulkload.models.IndexMetadata; | ||
import org.opensearch.migrations.bulkload.version_os_2_11.GlobalMetadataData_OS_2_11; | ||
import org.opensearch.migrations.bulkload.version_os_2_11.IndexMetadataData_OS_2_11; | ||
import org.opensearch.migrations.cluster.ClusterProviderRegistry; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
@Slf4j | ||
public class Transformer_ES_7_10_OS_2_11Test { | ||
@Test | ||
public void transformGlobalMetadata_AsExpected() throws Exception { | ||
TestResources.Snapshot snapshot = TestResources.SNAPSHOT_ES_7_10_BWC_CHECK; | ||
Version version = Version.fromString("ES 7.10"); | ||
|
||
final var repo = new FileSystemRepo(snapshot.dir); | ||
var sourceResourceProvider = ClusterProviderRegistry.getSnapshotReader(version, repo); | ||
|
||
Transformer_ES_7_10_OS_2_11 transformer = new Transformer_ES_7_10_OS_2_11(2); | ||
|
||
GlobalMetadata globalMetadata = sourceResourceProvider.getGlobalMetadata().fromRepo(snapshot.name); | ||
GlobalMetadata transformedGlobalMetadata = transformer.transformGlobalMetadata(globalMetadata); | ||
GlobalMetadataData_OS_2_11 finalMetadata = new GlobalMetadataData_OS_2_11(transformedGlobalMetadata.toObjectNode()); | ||
|
||
String expectedBwcTemplates = "{\"bwc_template\":{\"order\":0,\"index_patterns\":[\"bwc_index*\"],\"settings\":{\"number_of_shards\":\"1\",\"number_of_replicas\":\"0\"},\"mappings\":[{\"arbitrary_type\":{\"properties\":{\"title\":{\"type\":\"text\"},\"content\":{\"type\":\"text\"}}}}],\"aliases\":{\"bwc_alias\":{}}}}"; | ||
String expectedIndexTemplates = "{\"fwc_template\":{\"index_patterns\":[\"fwc_index*\"],\"template\":{\"aliases\":{\"fwc_alias\":{}}},\"composed_of\":[\"fwc_mappings\",\"fwc_settings\"]}}"; | ||
String expectedComponentTemplates = "{\"fwc_settings\":{\"template\":{\"settings\":{\"index\":{\"number_of_shards\":\"1\",\"number_of_replicas\":\"0\"}}}},\"fwc_mappings\":{\"template\":{\"mappings\":{\"properties\":{\"title\":{\"type\":\"text\"},\"content\":{\"type\":\"text\"}}}}}}"; | ||
|
||
assertEquals(expectedBwcTemplates, finalMetadata.getTemplates().toString()); | ||
assertEquals(expectedIndexTemplates, finalMetadata.getIndexTemplates().toString()); | ||
assertEquals(expectedComponentTemplates, finalMetadata.getComponentTemplates().toString()); | ||
} | ||
|
||
@Test | ||
public void transformIndexMetadata_AsExpected() throws Exception { | ||
TestResources.Snapshot snapshot = TestResources.SNAPSHOT_ES_7_10_BWC_CHECK; | ||
Version version = Version.fromString("ES 7.10"); | ||
|
||
final var repo = new FileSystemRepo(snapshot.dir); | ||
var sourceResourceProvider = ClusterProviderRegistry.getSnapshotReader(version, repo); | ||
|
||
Transformer_ES_7_10_OS_2_11 transformer = new Transformer_ES_7_10_OS_2_11(2); | ||
|
||
IndexMetadata indexMetadataBwc = sourceResourceProvider.getIndexMetadata().fromRepo(snapshot.name, "bwc_index_1"); | ||
IndexMetadata transformedIndexBwc = transformer.transformIndexMetadata(indexMetadataBwc); | ||
IndexMetadataData_OS_2_11 finalIndexBwc =new IndexMetadataData_OS_2_11(transformedIndexBwc.getRawJson(), transformedIndexBwc.getId(), transformedIndexBwc.getName()); | ||
|
||
IndexMetadata indexMetadataFwc = sourceResourceProvider.getIndexMetadata().fromRepo(snapshot.name, "fwc_index_1"); | ||
IndexMetadata transformedIndexFwc = transformer.transformIndexMetadata(indexMetadataFwc); | ||
IndexMetadataData_OS_2_11 finalIndexFwc =new IndexMetadataData_OS_2_11(transformedIndexFwc.getRawJson(), transformedIndexFwc.getId(), transformedIndexFwc.getName()); | ||
|
||
String expectedIndexBwc = "{\"version\":3,\"mapping_version\":1,\"settings_version\":1,\"aliases_version\":1,\"routing_num_shards\":1024,\"state\":\"open\",\"settings\":{\"creation_date\":\"1727285787498\",\"number_of_replicas\":1,\"number_of_shards\":\"1\",\"provided_name\":\"bwc_index_1\",\"uuid\":\"P4PDS4fFSECIprHxpKSoiQ\",\"version\":{\"created\":\"7100299\"}},\"mappings\":{\"properties\":{\"content\":{\"type\":\"text\"},\"title\":{\"type\":\"text\"}}},\"aliases\":{\"bwc_alias\":{}},\"primary_terms\":[1],\"in_sync_allocations\":{\"0\":[\"0M-gMXkNQFC02lnWJN4BVQ\"]},\"rollover_info\":{},\"system\":false}"; | ||
String expectedIndexFwc = "{\"version\":3,\"mapping_version\":1,\"settings_version\":1,\"aliases_version\":1,\"routing_num_shards\":1024,\"state\":\"open\",\"settings\":{\"creation_date\":\"1727285787822\",\"number_of_replicas\":1,\"number_of_shards\":\"1\",\"provided_name\":\"fwc_index_1\",\"uuid\":\"riC1gLlrR2eh_uAh9Zdpiw\",\"version\":{\"created\":\"7100299\"}},\"mappings\":{\"properties\":{\"content\":{\"type\":\"text\"},\"title\":{\"type\":\"text\"}}},\"aliases\":{\"fwc_alias\":{}},\"primary_terms\":[1],\"in_sync_allocations\":{\"0\":[\"8sKrVCEaSxy4yP3cx8kcYQ\"]},\"rollover_info\":{},\"system\":false}"; | ||
|
||
assertEquals(expectedIndexBwc, finalIndexBwc.getRawJson().toString()); | ||
assertEquals(expectedIndexFwc, finalIndexFwc.getRawJson().toString()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"snapshots":[{"name":"rfs-snapshot","uuid":"rNzQqxl5Qrm99ZzB44Yz0w","state":1,"index_metadata_lookup":{"rtO3hIcQREynKwRVke75sQ":"P4PDS4fFSECIprHxpKSoiQ-_na_-1-1-1","6f5_qLyfQu-MKqe5IEJGuQ":"riC1gLlrR2eh_uAh9Zdpiw-_na_-1-1-1"},"version":"7.10.2"}],"indices":{"bwc_index_1":{"id":"rtO3hIcQREynKwRVke75sQ","snapshots":["rNzQqxl5Qrm99ZzB44Yz0w"],"shard_generations":["OSYnb8w3SKmTqQ_p7m84JA"]},"fwc_index_1":{"id":"6f5_qLyfQu-MKqe5IEJGuQ","snapshots":["rNzQqxl5Qrm99ZzB44Yz0w"],"shard_generations":["73ZKrS4iTc6nKzY0E4kC1w"]}},"min_version":"7.9.0","index_metadata_identifiers":{"riC1gLlrR2eh_uAh9Zdpiw-_na_-1-1-1":"AzJBKpIBKBXpMe1tfd-g","P4PDS4fFSECIprHxpKSoiQ-_na_-1-1-1":"AjJBKpIBKBXpMe1tfd-g"}} |
Binary file not shown.
Binary file added
BIN
+479 Bytes
...ces/snapshots/ES_7_10_BWC_Check/indices/6f5_qLyfQu-MKqe5IEJGuQ/0/__7d8i9c5gTH62_a-mtjnh1g
Binary file not shown.
Binary file added
BIN
+2.68 KB
...ces/snapshots/ES_7_10_BWC_Check/indices/6f5_qLyfQu-MKqe5IEJGuQ/0/__xdhJGeuxSAGPk5gBj8PlfA
Binary file not shown.
Binary file added
BIN
+1.22 KB
...snapshots/ES_7_10_BWC_Check/indices/6f5_qLyfQu-MKqe5IEJGuQ/0/index-73ZKrS4iTc6nKzY0E4kC1w
Binary file not shown.
Binary file added
BIN
+1.13 KB
...pshots/ES_7_10_BWC_Check/indices/6f5_qLyfQu-MKqe5IEJGuQ/0/snap-rNzQqxl5Qrm99ZzB44Yz0w.dat
Binary file not shown.
Binary file added
BIN
+525 Bytes
.../snapshots/ES_7_10_BWC_Check/indices/6f5_qLyfQu-MKqe5IEJGuQ/meta-AzJBKpIBKBXpMe1tfd-g.dat
Binary file not shown.
Binary file added
BIN
+479 Bytes
...ces/snapshots/ES_7_10_BWC_Check/indices/rtO3hIcQREynKwRVke75sQ/0/__d3rngFHgRnOiALrbvS6Odg
Binary file not shown.
Binary file added
BIN
+2.68 KB
...ces/snapshots/ES_7_10_BWC_Check/indices/rtO3hIcQREynKwRVke75sQ/0/__q7cUOllVStaQMJVUtgWEPQ
Binary file not shown.
Binary file added
BIN
+1.22 KB
...snapshots/ES_7_10_BWC_Check/indices/rtO3hIcQREynKwRVke75sQ/0/index-OSYnb8w3SKmTqQ_p7m84JA
Binary file not shown.
Binary file added
BIN
+1.13 KB
...pshots/ES_7_10_BWC_Check/indices/rtO3hIcQREynKwRVke75sQ/0/snap-rNzQqxl5Qrm99ZzB44Yz0w.dat
Binary file not shown.
Binary file added
BIN
+535 Bytes
.../snapshots/ES_7_10_BWC_Check/indices/rtO3hIcQREynKwRVke75sQ/meta-AjJBKpIBKBXpMe1tfd-g.dat
Binary file not shown.
Binary file added
BIN
+717 Bytes
RFS/test-resources/snapshots/ES_7_10_BWC_Check/meta-rNzQqxl5Qrm99ZzB44Yz0w.dat
Binary file not shown.
Binary file added
BIN
+287 Bytes
RFS/test-resources/snapshots/ES_7_10_BWC_Check/snap-rNzQqxl5Qrm99ZzB44Yz0w.dat
Binary file not shown.