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 Jul 25, 2023
1 parent 2c4bb79 commit 7972ad3
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 13 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased 2.x]
### Added
- Add server version as REST response header [#6583](https://github.com/opensearch-project/OpenSearch/issues/6583)
- Start replication checkpointTimers on primary before segments upload to remote store. ([#8221]()https://github.com/opensearch-project/OpenSearch/pull/8221)
- Add server version as REST response header ([#6583](https://github.com/opensearch-project/OpenSearch/issues/6583))
- Start replication checkpointTimers on primary before segments upload to remote store. ([#8221](https://github.com/opensearch-project/OpenSearch/pull/8221))
- 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 7972ad3

Please sign in to comment.