|
22 | 22 | import org.elasticsearch.ElasticsearchException;
|
23 | 23 | import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest;
|
24 | 24 | import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
|
| 25 | +import org.elasticsearch.action.admin.cluster.settings.ClusterGetSettingsRequest; |
| 26 | +import org.elasticsearch.action.admin.cluster.settings.ClusterGetSettingsResponse; |
25 | 27 | import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest;
|
26 | 28 | import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse;
|
27 | 29 | import org.elasticsearch.cluster.health.ClusterHealthStatus;
|
|
42 | 44 | import static java.util.Collections.emptyMap;
|
43 | 45 | import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
|
44 | 46 | import static org.hamcrest.Matchers.equalTo;
|
| 47 | +import static org.hamcrest.Matchers.greaterThan; |
45 | 48 | import static org.hamcrest.Matchers.notNullValue;
|
46 | 49 | import static org.hamcrest.Matchers.nullValue;
|
47 | 50 |
|
@@ -112,6 +115,46 @@ public void testClusterUpdateSettingNonExistent() {
|
112 | 115 | "Elasticsearch exception [type=illegal_argument_exception, reason=transient setting [" + setting + "], not recognized]"));
|
113 | 116 | }
|
114 | 117 |
|
| 118 | + public void testClusterGetSettings() throws IOException { |
| 119 | + final String transientSettingKey = RecoverySettings.INDICES_RECOVERY_MAX_BYTES_PER_SEC_SETTING.getKey(); |
| 120 | + final int transientSettingValue = 10; |
| 121 | + |
| 122 | + final String persistentSettingKey = EnableAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ENABLE_SETTING.getKey(); |
| 123 | + final String persistentSettingValue = EnableAllocationDecider.Allocation.NONE.name(); |
| 124 | + |
| 125 | + Settings transientSettings = |
| 126 | + Settings.builder().put(transientSettingKey, transientSettingValue, ByteSizeUnit.BYTES).build(); |
| 127 | + Settings persistentSettings = Settings.builder().put(persistentSettingKey, persistentSettingValue).build(); |
| 128 | + clusterUpdateSettings(persistentSettings, transientSettings); |
| 129 | + |
| 130 | + ClusterGetSettingsRequest request = new ClusterGetSettingsRequest(); |
| 131 | + ClusterGetSettingsResponse response = execute( |
| 132 | + request, highLevelClient().cluster()::getSettings, highLevelClient().cluster()::getSettingsAsync); |
| 133 | + assertEquals(persistentSettings, response.getPersistentSettings()); |
| 134 | + assertEquals(transientSettings, response.getTransientSettings()); |
| 135 | + assertEquals(0, response.getDefaultSettings().size()); |
| 136 | + } |
| 137 | + |
| 138 | + public void testClusterGetSettingsWithDefault() throws IOException { |
| 139 | + final String transientSettingKey = RecoverySettings.INDICES_RECOVERY_MAX_BYTES_PER_SEC_SETTING.getKey(); |
| 140 | + final int transientSettingValue = 10; |
| 141 | + |
| 142 | + final String persistentSettingKey = EnableAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ENABLE_SETTING.getKey(); |
| 143 | + final String persistentSettingValue = EnableAllocationDecider.Allocation.NONE.name(); |
| 144 | + |
| 145 | + Settings transientSettings = |
| 146 | + Settings.builder().put(transientSettingKey, transientSettingValue, ByteSizeUnit.BYTES).build(); |
| 147 | + Settings persistentSettings = Settings.builder().put(persistentSettingKey, persistentSettingValue).build(); |
| 148 | + clusterUpdateSettings(persistentSettings, transientSettings); |
| 149 | + |
| 150 | + ClusterGetSettingsRequest request = new ClusterGetSettingsRequest().includeDefaults(true); |
| 151 | + ClusterGetSettingsResponse response = execute( |
| 152 | + request, highLevelClient().cluster()::getSettings, highLevelClient().cluster()::getSettingsAsync); |
| 153 | + assertEquals(persistentSettings, response.getPersistentSettings()); |
| 154 | + assertEquals(transientSettings, response.getTransientSettings()); |
| 155 | + assertThat(response.getDefaultSettings().size(), greaterThan(0)); |
| 156 | + } |
| 157 | + |
115 | 158 | public void testClusterHealthGreen() throws IOException {
|
116 | 159 | ClusterHealthRequest request = new ClusterHealthRequest();
|
117 | 160 | request.timeout("5s");
|
|
0 commit comments