49
49
import java .util .HashMap ;
50
50
import java .util .List ;
51
51
import java .util .Map ;
52
+ import java .util .function .BiConsumer ;
52
53
53
54
import static java .util .Collections .emptyMap ;
54
55
import static org .elasticsearch .test .hamcrest .ElasticsearchAssertions .assertAcked ;
@@ -73,11 +74,13 @@ public void testClusterPutSettings() throws IOException {
73
74
ClusterUpdateSettingsRequest setRequest = new ClusterUpdateSettingsRequest ();
74
75
setRequest .transientSettings (transientSettings );
75
76
setRequest .persistentSettings (map );
77
+ RequestOptions options = RequestOptions .DEFAULT .toBuilder ().setWarningsHandler (WarningsHandler .PERMISSIVE ).build ();
76
78
77
79
ClusterUpdateSettingsResponse setResponse = execute (
78
80
setRequest ,
79
81
highLevelClient ().cluster ()::putSettings ,
80
- highLevelClient ().cluster ()::putSettingsAsync
82
+ highLevelClient ().cluster ()::putSettingsAsync ,
83
+ options
81
84
);
82
85
83
86
assertAcked (setResponse );
@@ -104,7 +107,8 @@ public void testClusterPutSettings() throws IOException {
104
107
ClusterUpdateSettingsResponse resetResponse = execute (
105
108
resetRequest ,
106
109
highLevelClient ().cluster ()::putSettings ,
107
- highLevelClient ().cluster ()::putSettingsAsync
110
+ highLevelClient ().cluster ()::putSettingsAsync ,
111
+ options
108
112
);
109
113
110
114
assertThat (resetResponse .getTransientSettings ().get (transientSettingKey ), equalTo (null ));
@@ -119,11 +123,22 @@ public void testClusterPutSettings() throws IOException {
119
123
assertThat (persistentResetValue , equalTo (null ));
120
124
}
121
125
122
- public void testClusterUpdateSettingNonExistent () {
126
+ public void testClusterUpdateTransientSettingNonExistent () {
127
+ testClusterUpdateSettingNonExistent ((settings , request ) -> request .transientSettings (settings ), "transient" );
128
+ }
129
+
130
+ public void testClusterUpdatePersistentSettingNonExistent () {
131
+ testClusterUpdateSettingNonExistent ((settings , request ) -> request .persistentSettings (settings ), "persistent" );
132
+ }
133
+
134
+ private void testClusterUpdateSettingNonExistent (
135
+ final BiConsumer <Settings .Builder , ClusterUpdateSettingsRequest > consumer ,
136
+ String label
137
+ ) {
123
138
String setting = "no_idea_what_you_are_talking_about" ;
124
139
int value = 10 ;
125
140
ClusterUpdateSettingsRequest clusterUpdateSettingsRequest = new ClusterUpdateSettingsRequest ();
126
- clusterUpdateSettingsRequest . transientSettings (Settings .builder ().put (setting , value ). build () );
141
+ consumer . accept (Settings .builder ().put (setting , value ), clusterUpdateSettingsRequest );
127
142
128
143
ElasticsearchException exception = expectThrows (
129
144
ElasticsearchException .class ,
@@ -136,7 +151,9 @@ public void testClusterUpdateSettingNonExistent() {
136
151
assertThat (exception .status (), equalTo (RestStatus .BAD_REQUEST ));
137
152
assertThat (
138
153
exception .getMessage (),
139
- equalTo ("Elasticsearch exception [type=illegal_argument_exception, reason=transient setting [" + setting + "], not recognized]" )
154
+ equalTo (
155
+ "Elasticsearch exception [type=illegal_argument_exception, reason=" + label + " setting [" + setting + "], not recognized]"
156
+ )
140
157
);
141
158
}
142
159
@@ -331,13 +348,13 @@ public void testRemoteInfo() throws Exception {
331
348
ClusterGetSettingsResponse settingsResponse = highLevelClient ().cluster ().getSettings (settingsRequest , RequestOptions .DEFAULT );
332
349
333
350
List <String > seeds = SniffConnectionStrategy .REMOTE_CLUSTER_SEEDS .getConcreteSettingForNamespace (clusterAlias )
334
- .get (settingsResponse .getTransientSettings ());
335
- int connectionsPerCluster = SniffConnectionStrategy .REMOTE_CONNECTIONS_PER_CLUSTER .get (settingsResponse .getTransientSettings ());
351
+ .get (settingsResponse .getPersistentSettings ());
352
+ int connectionsPerCluster = SniffConnectionStrategy .REMOTE_CONNECTIONS_PER_CLUSTER .get (settingsResponse .getPersistentSettings ());
336
353
TimeValue initialConnectionTimeout = RemoteClusterService .REMOTE_INITIAL_CONNECTION_TIMEOUT_SETTING .get (
337
- settingsResponse .getTransientSettings ()
354
+ settingsResponse .getPersistentSettings ()
338
355
);
339
356
boolean skipUnavailable = RemoteClusterService .REMOTE_CLUSTER_SKIP_UNAVAILABLE .getConcreteSettingForNamespace (clusterAlias )
340
- .get (settingsResponse .getTransientSettings ());
357
+ .get (settingsResponse .getPersistentSettings ());
341
358
342
359
RemoteInfoRequest request = new RemoteInfoRequest ();
343
360
RemoteInfoResponse response = execute (
0 commit comments