Skip to content

Commit

Permalink
Fix missing index in expected output for end to end tests
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Nied <peternied@hotmail.com>
  • Loading branch information
peternied committed Oct 9, 2024
1 parent 0c58a4b commit 08e4f61
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.opensearch.migrations.commands;

import java.util.ArrayList;
import java.util.List;

import org.opensearch.migrations.MigrateOrEvaluateArgs;
import org.opensearch.migrations.MigrationMode;
Expand Down Expand Up @@ -65,13 +66,15 @@ protected Items migrateAllItems(MigrationMode migrationMode, Clusters clusters,
items.indexTemplates(indexTemplates);
items.componentTemplates(metadataResults.getComponentTemplates());

if (metadataResults.fatalIssueCount() != 0) {
log.warn("Stopping before index migration due to issues");
if (metadataResults.fatalIssueCount() == 0) {
var indexResults = migrateIndices(migrationMode, clusters, transformer, context);
items.indexes(indexResults.getIndexNames());
items.aliases(indexResults.getAliases());
} else {
items.failureMessage("Encountered " + metadataResults.fatalIssueCount() + " unrecoverable issues, details above.");
items.indexes(List.of());
items.aliases(List.of());
log.warn("Stopping before index migration due to issues");
items.failureMessage("Encountered " + metadataResults.fatalIssueCount() + " fatal issue(s) while moving global objects.");
}

return items.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ private void verifyCommandResults(
var migratedItems = result.getItems();
assertThat(getNames(migratedItems.getIndexTemplates()), containsInAnyOrder(testData.indexTemplateName));
assertThat(getNames(migratedItems.getComponentTemplates()), equalTo(sourceIsES6_8 ? List.of() : List.of(testData.compoTemplateName)));
assertThat(getNames(migratedItems.getIndexes()), containsInAnyOrder(testData.blogIndexName, testData.movieIndexName));
assertThat(getNames(migratedItems.getIndexes()), containsInAnyOrder(testData.blogIndexName, testData.movieIndexName, testData.indexThatAlreadyExists));
assertThat(getNames(migratedItems.getAliases()), containsInAnyOrder(testData.aliasInTemplate, testData.aliasName));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,20 @@
import org.opensearch.migrations.metadata.CreationResult;

import lombok.Builder;
import lombok.Data;
import lombok.Singular;

@Builder
@Data
public class IndexMetadataResults {
@Singular
private final List<CreationResult> indexNames;
@Singular
private final List<CreationResult> aliases;

public List<CreationResult> getIndexNames() {
return indexNames == null ? List.of() : indexNames;
}

public List<CreationResult> getAliases() {
return aliases == null ? List.of() : aliases;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
import lombok.Builder;
import lombok.Data;
import lombok.Getter;
import lombok.ToString;

@Builder
@Data
@ToString
public class CreationResult implements Comparable<CreationResult> {
private final String name;
private final Exception exception;
Expand Down

0 comments on commit 08e4f61

Please sign in to comment.