diff options
author | Jason Tedor <jason@tedor.me> | 2017-06-28 22:18:46 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-28 22:18:46 -0400 |
commit | da59c178e2cd39ac141c8e738ad692b94813eecd (patch) | |
tree | 8bfca2838afcc1e312ddf9f2c6992dbf5df87d85 /core/src/test | |
parent | 9714c77c842a616c3c97289ad43afe218d605c81 (diff) |
Emit settings deprecation logging at most once
When a setting is deprecated, if that setting is used repeatedly we
currently emit a deprecation warning every time the setting is used. In
cases like hitting settings endpoints over and over against a node with
a lot of deprecated settings, this can lead to excessive deprecation
warnings which can crush a node. This commit ensures that a given
setting only sees deprecation logging at most once.
Relates #25457
Diffstat (limited to 'core/src/test')
-rw-r--r-- | core/src/test/java/org/elasticsearch/common/settings/SettingTests.java | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/core/src/test/java/org/elasticsearch/common/settings/SettingTests.java b/core/src/test/java/org/elasticsearch/common/settings/SettingTests.java index 0bb1abb37a..1ac94b6caa 100644 --- a/core/src/test/java/org/elasticsearch/common/settings/SettingTests.java +++ b/core/src/test/java/org/elasticsearch/common/settings/SettingTests.java @@ -154,6 +154,22 @@ public class SettingTests extends ESTestCase { assertNull(ab2.get()); } + public void testDeprecatedSetting() { + final Setting<Boolean> deprecatedSetting = Setting.boolSetting("deprecated.foo.bar", false, Property.Deprecated); + final Settings settings = Settings.builder().put("deprecated.foo.bar", true).build(); + final int iterations = randomIntBetween(0, 128); + for (int i = 0; i < iterations; i++) { + deprecatedSetting.get(settings); + } + if (iterations > 0) { + /* + * This tests that we log the deprecation warning exactly one time, otherwise we would have to assert the deprecation warning + * for each usage of the setting. + */ + assertSettingDeprecationsAndWarnings(new Setting[]{deprecatedSetting}); + } + } + public void testDefault() { TimeValue defaultValue = TimeValue.timeValueMillis(randomIntBetween(0, 1000000)); Setting<TimeValue> setting = |