use of org.opensearch.common.settings.AbstractScopedSettings in project OpenSearch by opensearch-project.
the class ProxyConnectionStrategyTests method testModeSettingsCannotBeUsedWhenInDifferentMode.
public void testModeSettingsCannotBeUsedWhenInDifferentMode() {
List<Tuple<Setting.AffixSetting<?>, String>> restrictedSettings = Arrays.asList(new Tuple<>(ProxyConnectionStrategy.PROXY_ADDRESS, "192.168.0.1:8080"), new Tuple<>(ProxyConnectionStrategy.REMOTE_SOCKET_CONNECTIONS, "3"));
RemoteConnectionStrategy.ConnectionStrategy sniff = RemoteConnectionStrategy.ConnectionStrategy.SNIFF;
String clusterName = "cluster_name";
Settings settings = Settings.builder().put(RemoteConnectionStrategy.REMOTE_CONNECTION_MODE.getConcreteSettingForNamespace(clusterName).getKey(), sniff.name()).build();
Set<Setting<?>> clusterSettings = new HashSet<>();
clusterSettings.add(RemoteConnectionStrategy.REMOTE_CONNECTION_MODE);
clusterSettings.addAll(restrictedSettings.stream().map(Tuple::v1).collect(Collectors.toList()));
AbstractScopedSettings service = new ClusterSettings(Settings.EMPTY, clusterSettings);
// Should validate successfully
service.validate(settings, true);
for (Tuple<Setting.AffixSetting<?>, String> restrictedSetting : restrictedSettings) {
Setting<?> concreteSetting = restrictedSetting.v1().getConcreteSettingForNamespace(clusterName);
Settings invalid = Settings.builder().put(settings).put(concreteSetting.getKey(), restrictedSetting.v2()).build();
IllegalArgumentException iae = expectThrows(IllegalArgumentException.class, () -> service.validate(invalid, true));
String expected = "Setting \"" + concreteSetting.getKey() + "\" cannot be used with the configured " + "\"cluster.remote.cluster_name.mode\" [required=PROXY, configured=SNIFF]";
assertEquals(expected, iae.getMessage());
}
}
use of org.opensearch.common.settings.AbstractScopedSettings in project OpenSearch by opensearch-project.
the class SniffConnectionStrategyTests method testModeSettingsCannotBeUsedWhenInDifferentMode.
public void testModeSettingsCannotBeUsedWhenInDifferentMode() {
List<Tuple<Setting.AffixSetting<?>, String>> restrictedSettings = Arrays.asList(new Tuple<>(SniffConnectionStrategy.REMOTE_CLUSTER_SEEDS, "192.168.0.1:8080"), new Tuple<>(SniffConnectionStrategy.REMOTE_NODE_CONNECTIONS, "2"));
RemoteConnectionStrategy.ConnectionStrategy proxy = RemoteConnectionStrategy.ConnectionStrategy.PROXY;
String clusterName = "cluster_name";
Settings settings = Settings.builder().put(RemoteConnectionStrategy.REMOTE_CONNECTION_MODE.getConcreteSettingForNamespace(clusterName).getKey(), proxy.name()).build();
Set<Setting<?>> clusterSettings = new HashSet<>();
clusterSettings.add(RemoteConnectionStrategy.REMOTE_CONNECTION_MODE);
clusterSettings.addAll(restrictedSettings.stream().map(Tuple::v1).collect(Collectors.toList()));
AbstractScopedSettings service = new ClusterSettings(Settings.EMPTY, clusterSettings);
// Should validate successfully
service.validate(settings, true);
for (Tuple<Setting.AffixSetting<?>, String> restrictedSetting : restrictedSettings) {
Setting<?> concreteSetting = restrictedSetting.v1().getConcreteSettingForNamespace(clusterName);
Settings invalid = Settings.builder().put(settings).put(concreteSetting.getKey(), restrictedSetting.v2()).build();
IllegalArgumentException iae = expectThrows(IllegalArgumentException.class, () -> service.validate(invalid, true));
String expected = "Setting \"" + concreteSetting.getKey() + "\" cannot be used with the configured " + "\"cluster.remote.cluster_name.mode\" [required=SNIFF, configured=PROXY]";
assertEquals(expected, iae.getMessage());
}
}
Aggregations