Skip to content

Commit

Permalink
Build tests
Browse files Browse the repository at this point in the history
Signed-off-by: Mohit Godwani <mgodwan@amazon.com>
  • Loading branch information
mgodwan committed Aug 23, 2024
1 parent 6a6b51f commit 2f9a2cd
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeOptionalString(indexEntry.getValue());
}

if (out.getVersion().before(Version.V_3_0_0)) {
if (out.getVersion().onOrAfter(Version.V_3_0_0)) {
out.writeVInt(contexts.size());
for (final Map.Entry<String, Context> indexEntry : contexts.entrySet()) {
out.writeString(indexEntry.getKey());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
import org.opensearch.index.shard.PrimaryShardClosedException;
import org.opensearch.index.shard.ShardNotInPrimaryModeException;
import org.opensearch.indices.IndexTemplateMissingException;
import org.opensearch.indices.InvalidIndexContextException;
import org.opensearch.indices.InvalidIndexTemplateException;
import org.opensearch.indices.recovery.PeerRecoveryNotFound;
import org.opensearch.indices.recovery.RecoverFilesRecoveryException;
Expand Down Expand Up @@ -896,6 +897,7 @@ public void testIds() {
ids.put(171, CryptoRegistryException.class);
ids.put(172, ViewNotFoundException.class);
ids.put(173, ViewAlreadyExistsException.class);
ids.put(174, InvalidIndexContextException.class);
ids.put(10001, IndexCreateBlockException.class);

Map<Class<? extends OpenSearchException>, Integer> reverse = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.opensearch.action.admin.indices.alias.get.GetAliasesResponseTests;
import org.opensearch.action.admin.indices.mapping.get.GetMappingsResponseTests;
import org.opensearch.cluster.metadata.AliasMetadata;
import org.opensearch.cluster.metadata.Context;
import org.opensearch.cluster.metadata.MappingMetadata;
import org.opensearch.common.settings.IndexScopedSettings;
import org.opensearch.common.settings.Settings;
Expand Down Expand Up @@ -66,6 +67,7 @@ protected GetIndexResponse createTestInstance() {
Map<String, Settings> settings = new HashMap<>();
Map<String, Settings> defaultSettings = new HashMap<>();
Map<String, String> dataStreams = new HashMap<>();
Map<String, Context> contexts = new HashMap<>();
IndexScopedSettings indexScopedSettings = IndexScopedSettings.DEFAULT_SCOPED_SETTINGS;
boolean includeDefaults = randomBoolean();
for (String index : indices) {
Expand All @@ -90,7 +92,10 @@ protected GetIndexResponse createTestInstance() {
if (randomBoolean()) {
dataStreams.put(index, randomAlphaOfLength(5).toLowerCase(Locale.ROOT));
}
if (randomBoolean()) {
contexts.put(index, new Context(randomAlphaOfLength(5).toLowerCase(Locale.ROOT)));
}
}
return new GetIndexResponse(indices, mappings, aliases, settings, defaultSettings, dataStreams);
return new GetIndexResponse(indices, mappings, aliases, settings, defaultSettings, dataStreams, contexts);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1704,7 +1704,8 @@ public void testBuildIndexMetadata() {
4,
sourceIndexMetadata,
false,
new HashMap<>()
new HashMap<>(),
null
);

assertThat(indexMetadata.getAliases().size(), is(1));
Expand Down

0 comments on commit 2f9a2cd

Please sign in to comment.