Skip to content

Commit

Permalink
Update changelog and add one more test case
Browse files Browse the repository at this point in the history
Signed-off-by: Liyun Xiu <[email protected]>
  • Loading branch information
chishui committed Aug 2, 2024
1 parent b07556c commit e16d52f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

### Fixed
- Fix constraint bug which allows more primary shards than average primary shards per index ([#14908](https://github.com/opensearch-project/OpenSearch/pull/14908))
- Fix update settings with null replica not honoring cluster setting bug ([#14948](https://github.com/opensearch-project/OpenSearch/pull/14948))
- Fix missing value of FieldSort for unsigned_long ([#14963](https://github.com/opensearch-project/OpenSearch/pull/14963))

### Security
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,7 @@ private void runTestDefaultNumberOfReplicasTest(final boolean closeIndex) {

public void testNullReplicaUpdate() {
internalCluster().ensureAtLeastNumDataNodes(2);

// cluster setting
String defaultNumberOfReplica = "3";
assertAcked(
Expand All @@ -844,7 +845,7 @@ public void testNullReplicaUpdate() {
.setPersistentSettings(Settings.builder().put("cluster.default_number_of_replicas", defaultNumberOfReplica))
.get()
);

// create index with number of replicas will ignore default value
assertAcked(
client().admin()
.indices()
Expand All @@ -858,7 +859,7 @@ public void testNullReplicaUpdate() {
.get()
.getSetting("test", IndexMetadata.SETTING_NUMBER_OF_REPLICAS);
assertEquals("2", numberOfReplicas);

// update setting with null replica will use cluster setting of replica number
assertAcked(
client().admin()
.indices()
Expand All @@ -872,12 +873,27 @@ public void testNullReplicaUpdate() {
.get()
.getSetting("test", IndexMetadata.SETTING_NUMBER_OF_REPLICAS);
assertEquals(defaultNumberOfReplica, numberOfReplicas);

// Clean up cluster setting, then update setting with null replica should pick up default value of 1
assertAcked(
client().admin()
.cluster()
.prepareUpdateSettings()
.setPersistentSettings(Settings.builder().putNull("cluster.default_number_of_replicas"))
);
assertAcked(
client().admin()
.indices()
.prepareUpdateSettings("test")
.setSettings(Settings.builder().putNull(IndexMetadata.SETTING_NUMBER_OF_REPLICAS))
);

numberOfReplicas = client().admin()
.indices()
.prepareGetSettings("test")
.get()
.getSetting("test", IndexMetadata.SETTING_NUMBER_OF_REPLICAS);
assertEquals("1", numberOfReplicas);
}

public void testNoopUpdate() {
Expand Down

0 comments on commit e16d52f

Please sign in to comment.