use of org.sonar.process.ProcessProperties in project sonarqube by SonarSource.
the class CommandFactoryImplTest method newFactory.
private CommandFactoryImpl newFactory(Properties userProps, System2 system2) {
Properties p = new Properties();
p.setProperty("sonar.path.home", homeDir.getAbsolutePath());
p.setProperty("sonar.path.temp", tempDir.getAbsolutePath());
p.setProperty("sonar.path.logs", logsDir.getAbsolutePath());
p.putAll(userProps);
Props props = new Props(p);
ServiceLoaderWrapper serviceLoaderWrapper = mock(ServiceLoaderWrapper.class);
when(serviceLoaderWrapper.load()).thenReturn(ImmutableSet.of());
new ProcessProperties(serviceLoaderWrapper).completeDefaults(props);
return new CommandFactoryImpl(props, tempDir, system2);
}
use of org.sonar.process.ProcessProperties in project sonarqube by SonarSource.
the class AppSettingsLoaderImpl method load.
@Override
public AppSettings load() {
Properties p = loadPropertiesFile(homeDir);
Set<String> keysOverridableFromEnv = stream(ProcessProperties.Property.values()).map(ProcessProperties.Property::getKey).collect(Collectors.toSet());
keysOverridableFromEnv.addAll(p.stringPropertyNames());
// 1st pass to load static properties
Props staticProps = reloadProperties(keysOverridableFromEnv, p);
keysOverridableFromEnv.addAll(getDynamicPropertiesKeys(staticProps));
// 2nd pass to load dynamic properties like `ldap.*.url` or `ldap.*.baseDn` which keys depend on values of static
// properties loaded in 1st step
Props props = reloadProperties(keysOverridableFromEnv, p);
new ProcessProperties(serviceLoaderWrapper).completeDefaults(props);
stream(consumers).forEach(c -> c.accept(props));
return new AppSettingsImpl(props);
}
use of org.sonar.process.ProcessProperties in project sonarqube by SonarSource.
the class SearchServerTest method start_stop_server.
@Test
public void start_stop_server() throws Exception {
Props props = new Props(new Properties());
// the following properties have always default values (see ProcessProperties)
InetAddress host = InetAddress.getLoopbackAddress();
props.set(ProcessProperties.SEARCH_HOST, host.getHostAddress());
props.set(ProcessProperties.SEARCH_PORT, String.valueOf(port));
props.set(ProcessProperties.CLUSTER_NAME, A_CLUSTER_NAME);
props.set(EsSettings.CLUSTER_SEARCH_NODE_NAME, A_NODE_NAME);
props.set(ProcessProperties.PATH_HOME, temp.newFolder().getAbsolutePath());
props.set(ProcessEntryPoint.PROPERTY_SHARED_PATH, temp.newFolder().getAbsolutePath());
underTest = new SearchServer(props);
underTest.start();
assertThat(underTest.getStatus()).isEqualTo(Monitored.Status.OPERATIONAL);
Settings settings = Settings.builder().put("cluster.name", A_CLUSTER_NAME).build();
client = TransportClient.builder().settings(settings).build().addTransportAddress(new InetSocketTransportAddress(host, port));
assertThat(client.admin().cluster().prepareClusterStats().get().getStatus()).isEqualTo(ClusterHealthStatus.GREEN);
underTest.stop();
underTest.awaitStop();
underTest = null;
try {
client.admin().cluster().prepareClusterStats().get();
fail();
} catch (NoNodeAvailableException exception) {
// ok
}
}
use of org.sonar.process.ProcessProperties in project sonarqube by SonarSource.
the class EsSettingsTest method minProps.
private Props minProps(boolean cluster, @Nullable String host, @Nullable String port) throws IOException {
File homeDir = temp.newFolder();
Props props = new Props(new Properties());
ServiceLoaderWrapper serviceLoaderWrapper = mock(ServiceLoaderWrapper.class);
when(serviceLoaderWrapper.load()).thenReturn(ImmutableSet.of());
new ProcessProperties(serviceLoaderWrapper).completeDefaults(props);
props.set(PATH_HOME.getKey(), homeDir.getAbsolutePath());
props.set(Property.CLUSTER_ENABLED.getKey(), Boolean.toString(cluster));
if (cluster) {
ofNullable(host).ifPresent(h -> props.set(CLUSTER_NODE_ES_HOST.getKey(), h));
ofNullable(port).ifPresent(p -> props.set(CLUSTER_NODE_ES_PORT.getKey(), p));
ofNullable(host).ifPresent(h -> props.set(CLUSTER_NODE_SEARCH_HOST.getKey(), h));
ofNullable(port).ifPresent(p -> props.set(CLUSTER_NODE_SEARCH_PORT.getKey(), p));
ofNullable(port).ifPresent(h -> props.set(CLUSTER_ES_HOSTS.getKey(), h));
} else {
ofNullable(host).ifPresent(h -> props.set(SEARCH_HOST.getKey(), h));
ofNullable(port).ifPresent(p -> props.set(SEARCH_PORT.getKey(), p));
}
return props;
}
Aggregations