Skip to content

Commit

Permalink
Increment version on system index settings change (elastic#84994)
Browse files Browse the repository at this point in the history
The test was failing on assertion around index settings version change
in case actual settings were changed. This change adds missing version
increment and readable messages to the related assertions.
  • Loading branch information
idegtiarenko authored Mar 16, 2022
1 parent 91379ea commit 351a410
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public ClusterState execute(ClusterState currentState) throws Exception {
boolean isHidden = indexMetadata.getSettings().getAsBoolean(IndexMetadata.SETTING_INDEX_HIDDEN, false);
if (isSystem && isHidden == false) {
builder.settings(Settings.builder().put(indexMetadata.getSettings()).put(IndexMetadata.SETTING_INDEX_HIDDEN, true));
builder.settingsVersion(builder.settingsVersion() + 1);
updated = true;
}
if (isSystem && indexMetadata.getAliases().values().stream().anyMatch(a -> Boolean.FALSE.equals(a.isHidden()))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -784,9 +784,9 @@ public synchronized void updateMetadata(final IndexMetadata currentIndexMetadata
final long currentSettingsVersion = currentIndexMetadata.getSettingsVersion();
final long newSettingsVersion = newIndexMetadata.getSettingsVersion();
if (currentSettingsVersion == newSettingsVersion) {
assert updateIndexSettings == false;
assert updateIndexSettings == false : "No index updates are expected as index settings version has not changed";
} else {
assert updateIndexSettings;
assert updateIndexSettings : "Index updates are expected as index settings version has changed";
assert currentSettingsVersion < newSettingsVersion
: "expected current settings version ["
+ currentSettingsVersion
Expand Down

0 comments on commit 351a410

Please sign in to comment.