Skip to content

Commit

Permalink
add changelog
Browse files Browse the repository at this point in the history
Signed-off-by: Poojita Raj <poojiraj@amazon.com>
  • Loading branch information
Poojita-Raj committed Aug 4, 2023
1 parent 365936f commit abc517a
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- [distribution/archives] [Linux] [x64] Provide the variant of the distributions bundled with JRE ([#8195]()https://github.com/opensearch-project/OpenSearch/pull/8195)
- Add configuration for file cache size to max remote data ratio to prevent oversubscription of file cache ([#8606](https://github.com/opensearch-project/OpenSearch/pull/8606))
- Disallow compression level to be set for default and best_compression index codecs ([#8737]()https://github.com/opensearch-project/OpenSearch/pull/8737)
- Prioritize replica shard movement during shard relocation ([#8875](https://github.com/opensearch-project/OpenSearch/pull/8875))

### Dependencies
- Bump `org.apache.logging.log4j:log4j-core` from 2.17.1 to 2.20.0 ([#8307](https://github.com/opensearch-project/OpenSearch/pull/8307))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,43 @@ protected void createAndIndex(String index, int replicaCount, int shardCount) {
flushAndRefresh(index);
}

public void testClusterGreenAfterPartialRelocationPrimaryFirstShardMovementStrategy() throws InterruptedException {
testClusterGreenAfterPartialRelocation(BalancedShardsAllocator.ShardMovementStrategy.PRIMARY_FIRST);
private static Settings.Builder getSettings(
BalancedShardsAllocator.ShardMovementStrategy shardMovementStrategy,
boolean movePrimaryFirst
) {
return Settings.builder()
.put("cluster.routing.allocation.shard_movement_strategy", shardMovementStrategy)
.put("cluster.routing.allocation.move.primary_first", movePrimaryFirst);
}

public void testClusterGreenAfterPartialRelocationReplicaFirstShardMovementStrategy() throws InterruptedException {
testClusterGreenAfterPartialRelocation(BalancedShardsAllocator.ShardMovementStrategy.REPLICA_FIRST);
public void testClusterGreenAfterPartialRelocationPrimaryFirstShardMovementMovePrimarySettingEnabled() throws InterruptedException {
testClusterGreenAfterPartialRelocation(BalancedShardsAllocator.ShardMovementStrategy.PRIMARY_FIRST, true);
}

public void testClusterGreenAfterPartialRelocationPrimaryFirstShardMovementMovePrimarySettingDisabled() throws InterruptedException {
testClusterGreenAfterPartialRelocation(BalancedShardsAllocator.ShardMovementStrategy.PRIMARY_FIRST, false);
}

public void testClusterGreenAfterPartialRelocationReplicaFirstShardMovementPrimaryFirstEnabled() throws InterruptedException {
testClusterGreenAfterPartialRelocation(BalancedShardsAllocator.ShardMovementStrategy.REPLICA_FIRST, true);
}

public void testClusterGreenAfterPartialRelocationReplicaFirstShardMovementPrimaryFirstDisabled() throws InterruptedException {
testClusterGreenAfterPartialRelocation(BalancedShardsAllocator.ShardMovementStrategy.REPLICA_FIRST, false);
}

public void testClusterGreenAfterPartialRelocationNoPreferenceShardMovementPrimaryFirstEnabled() throws InterruptedException {
testClusterGreenAfterPartialRelocation(BalancedShardsAllocator.ShardMovementStrategy.NO_PREFERENCE, true);
}

private boolean shouldMovePrimaryShardsFirst(
BalancedShardsAllocator.ShardMovementStrategy shardMovementStrategy,
boolean movePrimaryFirst
) {
if (shardMovementStrategy == BalancedShardsAllocator.ShardMovementStrategy.NO_PREFERENCE && movePrimaryFirst) {
return true;
}
return shardMovementStrategy == BalancedShardsAllocator.ShardMovementStrategy.PRIMARY_FIRST;
}

/**
Expand All @@ -64,8 +95,10 @@ public void testClusterGreenAfterPartialRelocationReplicaFirstShardMovementStrat
* nodes in zone1. Depending on the shard movement strategy, we check whether the
* primary or replica shards are moved first, and zone2 nodes have all the shards
*/
private void testClusterGreenAfterPartialRelocation(BalancedShardsAllocator.ShardMovementStrategy shardMovementStrategy)
throws InterruptedException {
private void testClusterGreenAfterPartialRelocation(
BalancedShardsAllocator.ShardMovementStrategy shardMovementStrategy,
boolean movePrimaryFirst
) throws InterruptedException {
internalCluster().startClusterManagerOnlyNodes(1);
final String z1 = "zone-1", z2 = "zone-2";
final int primaryShardCount = 6;
Expand All @@ -83,9 +116,7 @@ private void testClusterGreenAfterPartialRelocation(BalancedShardsAllocator.Shar
// zone nodes excluded to prevent any shard relocation
ClusterUpdateSettingsRequest settingsRequest = new ClusterUpdateSettingsRequest();
settingsRequest.persistentSettings(
Settings.builder()
.put("cluster.routing.allocation.shard_movement_strategy", shardMovementStrategy)
.put("cluster.routing.allocation.exclude.zone", z2)
getSettings(shardMovementStrategy, movePrimaryFirst).put("cluster.routing.allocation.exclude.zone", z2)
);
client().admin().cluster().updateSettings(settingsRequest).actionGet();

Expand All @@ -107,8 +138,7 @@ private void testClusterGreenAfterPartialRelocation(BalancedShardsAllocator.Shar
for (ShardRouting shardEntry : routingNode) {
// If shard movement strategy is primary first, asserting that primary shards are moved first; else assert
// shards are replicas
if ((shardEntry
.primary() == (shardMovementStrategy == BalancedShardsAllocator.ShardMovementStrategy.PRIMARY_FIRST))
if ((shardEntry.primary() == shouldMovePrimaryShardsFirst(shardMovementStrategy, movePrimaryFirst))
&& shardEntry.state() == ShardRoutingState.STARTED) {
count++;
}
Expand Down

0 comments on commit abc517a

Please sign in to comment.