|
| 1 | +/* |
| 2 | + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one |
| 3 | + * or more contributor license agreements. Licensed under the "Elastic License |
| 4 | + * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side |
| 5 | + * Public License v 1"; you may not use this file except in compliance with, at |
| 6 | + * your election, the "Elastic License 2.0", the "GNU Affero General Public |
| 7 | + * License v3.0 only", or the "Server Side Public License, v 1". |
| 8 | + */ |
| 9 | + |
| 10 | +package org.elasticsearch.action.admin.cluster.settings; |
| 11 | + |
| 12 | +import org.elasticsearch.common.settings.ClusterSettings; |
| 13 | +import org.elasticsearch.common.settings.Setting; |
| 14 | +import org.elasticsearch.common.settings.Settings; |
| 15 | +import org.elasticsearch.test.ESTestCase; |
| 16 | + |
| 17 | +import java.util.Set; |
| 18 | + |
| 19 | +import static org.hamcrest.Matchers.equalTo; |
| 20 | + |
| 21 | +public class ClusterSettingsTests extends ESTestCase { |
| 22 | + |
| 23 | + public void testWatchAfterApply() { |
| 24 | + Setting<String> clusterSetting = Setting.simpleString("cluster.setting", Setting.Property.NodeScope, Setting.Property.Dynamic); |
| 25 | + Settings nodeSettings = Settings.builder().put("cluster.setting", "initial_value").build(); |
| 26 | + |
| 27 | + ClusterSettings clusterSettings = new ClusterSettings(nodeSettings, Set.of(clusterSetting)); |
| 28 | + Settings newSettings = Settings.builder().put("cluster.setting", "updated_value").build(); |
| 29 | + clusterSettings.applySettings(newSettings); |
| 30 | + |
| 31 | + // the value should be current when initializing the consumer |
| 32 | + clusterSettings.initializeAndWatch(clusterSetting, value -> { assertThat(value, equalTo("updated_value")); }); |
| 33 | + } |
| 34 | +} |
0 commit comments