-
Notifications
You must be signed in to change notification settings - Fork 30
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
Add MultiTypeMappingTransformation and test #1189
Merged
AndreKurait
merged 24 commits into
opensearch-project:main
from
AndreKurait:MetadataMultiType
Dec 11, 2024
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
ec2bb14
Reduce the number of cluster start/stops for Metadata end to end tests
peternied e375b9a
Add MultiTypeMappingTransformation and test
AndreKurait 0527ea1
Update type union equality
AndreKurait ea71e8f
Fix transformation test
AndreKurait 4d1b8a7
Disable union type conflict
AndreKurait 1e81a14
Simplify E2E tests in metadata
AndreKurait b0cca39
Add NONE multiTypeResolutionBehavior
AndreKurait 4b1b788
Add unit test for multi type resolution
AndreKurait 9a095bc
Simplify ClusterOperations
AndreKurait bfb5704
Format SearchClusterContainer
AndreKurait 50af06d
Update IndexMappingTypeRemovalTest
AndreKurait 828489e
Add hint to error due to multi type index
AndreKurait 98c6b7d
Fix formatting
AndreKurait d383fd3
Remove TestMetadataTransformationParams
AndreKurait 9a2edba
Fix spotless
AndreKurait 3511cad
Update test for metadata
AndreKurait 1b5c6a5
Merge branch 'faster-meta-e2e' into MetadataMultiType
AndreKurait 406ad78
Run formatter on EndToEndTest
AndreKurait 28eaf85
Speed up metadata EndToEndTest
AndreKurait 33d4e79
Add pre-pull to gradle task
AndreKurait c5cb306
Remove multiple mounts in MultiTypeMappingTransformationTest for GHA …
AndreKurait e501f09
Merge remote-tracking branch 'upstream/main' into MetadataMultiType
AndreKurait e9e2805
Fix GHA by disabliing MultiTypeMappingTransformationTest
AndreKurait d276695
Spotless Apply
AndreKurait File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,6 +111,44 @@ jobs: | |
with: | ||
gradle-version: ${{ env.gradle-version }} | ||
gradle-home-cache-cleanup: true | ||
- name: Generate Cache Key from Dockerfiles | ||
id: generate_cache_key | ||
run: | | ||
files=$(find . -type f \( -name 'docker-compose.yml' -o -name 'Dockerfile' \)) | ||
file_contents=$(cat $files) | ||
key=$(echo "${file_contents}" | sha1sum | awk '{print $1}') | ||
echo "key=${key}" >> "$GITHUB_OUTPUT" | ||
- name: Cache Docker Images | ||
uses: ScribeMD/[email protected] | ||
with: | ||
key: docker-${{ runner.os }}-${{ steps.generate_cache_key.outputs.key }} | ||
- name: Pre pull images | ||
run: | | ||
pull_if_not_present() { | ||
local image="$1" | ||
if docker image inspect "$image" > /dev/null 2>&1; then | ||
echo "Image '$image' already exists locally." | ||
else | ||
echo "Pulling image '$image'..." | ||
docker pull "$image" | ||
fi | ||
} | ||
images=( | ||
"opensearchproject/opensearch:1.3.16" | ||
"opensearchproject/opensearch:2.14.0" | ||
"docker.elastic.co/elasticsearch/elasticsearch:7.17.22" | ||
"docker.elastic.co/elasticsearch/elasticsearch-oss:7.10.2" | ||
"docker.elastic.co/elasticsearch/elasticsearch-oss:6.8.23" | ||
"docker.elastic.co/elasticsearch/elasticsearch:5.6.16" | ||
"httpd:alpine" | ||
"confluentinc/cp-kafka:7.5.0" | ||
"ghcr.io/shopify/toxiproxy:latest" | ||
"amazonlinux:2023" | ||
"alpine:3.16" | ||
) | ||
for image in "${images[@]}"; do | ||
pull_if_not_present "$image" | ||
done | ||
- name: Run Gradle Build | ||
run: ./gradlew build -x test -x TrafficCapture:dockerSolution:build -x spotlessCheck --stacktrace | ||
env: | ||
|
@@ -161,6 +199,7 @@ jobs: | |
uses: ScribeMD/[email protected] | ||
with: | ||
key: docker-${{ runner.os }}-${{ steps.generate_cache_key.outputs.key }} | ||
read-only: true | ||
- name: Start Docker Solution | ||
run: ./gradlew -p TrafficCapture dockerSolution:ComposeUp -x test -x spotlessCheck --info --stacktrace | ||
env: | ||
|
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
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
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
144 changes: 144 additions & 0 deletions
144
MetadataMigration/src/test/java/org/opensearch/migrations/BaseMigrationTest.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,144 @@ | ||
package org.opensearch.migrations; | ||
|
||
import java.io.File; | ||
import java.util.List; | ||
import java.util.concurrent.CompletableFuture; | ||
|
||
import org.opensearch.migrations.bulkload.common.FileSystemSnapshotCreator; | ||
import org.opensearch.migrations.bulkload.common.OpenSearchClient; | ||
import org.opensearch.migrations.bulkload.common.http.ConnectionContextTestParams; | ||
import org.opensearch.migrations.bulkload.framework.SearchClusterContainer; | ||
import org.opensearch.migrations.bulkload.http.ClusterOperations; | ||
import org.opensearch.migrations.bulkload.worker.SnapshotRunner; | ||
import org.opensearch.migrations.commands.MigrationItemResult; | ||
import org.opensearch.migrations.metadata.tracing.MetadataMigrationTestContext; | ||
import org.opensearch.migrations.snapshot.creation.tracing.SnapshotTestContext; | ||
|
||
import lombok.Getter; | ||
import lombok.SneakyThrows; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.junit.jupiter.api.io.TempDir; | ||
|
||
/** | ||
* Base test class providing shared setup and utility methods for migration tests. | ||
*/ | ||
@Slf4j | ||
abstract class BaseMigrationTest { | ||
|
||
@TempDir | ||
protected File localDirectory; | ||
|
||
@Getter | ||
protected SearchClusterContainer sourceCluster; | ||
@Getter | ||
protected SearchClusterContainer targetCluster; | ||
|
||
protected ClusterOperations sourceOperations; | ||
protected ClusterOperations targetOperations; | ||
|
||
/** | ||
* Starts the source and target clusters. | ||
*/ | ||
protected void startClusters() { | ||
CompletableFuture.allOf( | ||
CompletableFuture.runAsync(sourceCluster::start), | ||
CompletableFuture.runAsync(targetCluster::start) | ||
).join(); | ||
|
||
sourceOperations = new ClusterOperations(sourceCluster.getUrl()); | ||
targetOperations = new ClusterOperations(targetCluster.getUrl()); | ||
} | ||
|
||
/** | ||
* Sets up a snapshot repository and takes a snapshot of the source cluster. | ||
* | ||
* @param snapshotName Name of the snapshot. | ||
* @return The name of the created snapshot. | ||
*/ | ||
@SneakyThrows | ||
protected String createSnapshot(String snapshotName) { | ||
var snapshotContext = SnapshotTestContext.factory().noOtelTracking(); | ||
var sourceClient = new OpenSearchClient(ConnectionContextTestParams.builder() | ||
.host(sourceCluster.getUrl()) | ||
.insecure(true) | ||
.build() | ||
.toConnectionContext()); | ||
var snapshotCreator = new org.opensearch.migrations.bulkload.common.FileSystemSnapshotCreator( | ||
snapshotName, | ||
sourceClient, | ||
SearchClusterContainer.CLUSTER_SNAPSHOT_DIR, | ||
List.of(), | ||
snapshotContext.createSnapshotCreateContext() | ||
); | ||
org.opensearch.migrations.bulkload.worker.SnapshotRunner.runAndWaitForCompletion(snapshotCreator); | ||
sourceCluster.copySnapshotData(localDirectory.toString()); | ||
return snapshotName; | ||
} | ||
|
||
/** | ||
* Prepares migration arguments for snapshot-based migrations. | ||
* | ||
* @param snapshotName Name of the snapshot. | ||
* @return Prepared migration arguments. | ||
*/ | ||
protected MigrateOrEvaluateArgs prepareSnapshotMigrationArgs(String snapshotName) { | ||
var arguments = new MigrateOrEvaluateArgs(); | ||
arguments.fileSystemRepoPath = localDirectory.getAbsolutePath(); | ||
arguments.snapshotName = snapshotName; | ||
arguments.sourceVersion = sourceCluster.getContainerVersion().getVersion(); | ||
arguments.targetArgs.host = targetCluster.getUrl(); | ||
return arguments; | ||
} | ||
|
||
/** | ||
* Executes the migration command (either migrate or evaluate). | ||
* | ||
* @param arguments Migration arguments. | ||
* @param command The migration command to execute. | ||
* @return The result of the migration. | ||
*/ | ||
protected MigrationItemResult executeMigration(MigrateOrEvaluateArgs arguments, MetadataCommands command) { | ||
var metadataContext = MetadataMigrationTestContext.factory().noOtelTracking(); | ||
var metadata = new MetadataMigration(); | ||
|
||
if (MetadataCommands.MIGRATE.equals(command)) { | ||
return metadata.migrate(arguments).execute(metadataContext); | ||
} else { | ||
return metadata.evaluate(arguments).execute(metadataContext); | ||
} | ||
} | ||
|
||
/** | ||
* Creates an OpenSearch client for the given cluster. | ||
* | ||
* @param cluster The cluster container. | ||
* @return An OpenSearch client. | ||
*/ | ||
protected OpenSearchClient createClient(SearchClusterContainer cluster) { | ||
return new OpenSearchClient(ConnectionContextTestParams.builder() | ||
.host(cluster.getUrl()) | ||
.insecure(true) | ||
.build() | ||
.toConnectionContext()); | ||
} | ||
|
||
protected SnapshotTestContext createSnapshotContext() { | ||
return SnapshotTestContext.factory().noOtelTracking(); | ||
} | ||
|
||
protected FileSystemSnapshotCreator createSnapshotCreator(String snapshotName, OpenSearchClient client, SnapshotTestContext context) { | ||
return new FileSystemSnapshotCreator( | ||
snapshotName, | ||
client, | ||
SearchClusterContainer.CLUSTER_SNAPSHOT_DIR, | ||
List.of(), | ||
context.createSnapshotCreateContext() | ||
); | ||
} | ||
|
||
@SneakyThrows | ||
protected void runSnapshotAndCopyData(FileSystemSnapshotCreator snapshotCreator, SearchClusterContainer cluster) { | ||
SnapshotRunner.runAndWaitForCompletion(snapshotCreator); | ||
cluster.copySnapshotData(localDirectory.toString()); | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AndreKurait Can you revert the change to this file or maybe we can sync on the utility of this change?
The additional workflow complexity + extra effort to remember to sync these lists between java source and CI.yml gives me pause about including this change. It looks like this was done in an effort to speed up and issues with the test case that ended up being disabled due to an unrelated root cause.