use of org.sonar.application.config.TestAppSettings in project sonarqube by SonarSource.
the class AppStateClusterImplTest method simulate_network_cluster.
@Test
public void simulate_network_cluster() throws InterruptedException {
TestAppSettings settings = newClusterSettings();
settings.set(ProcessProperties.CLUSTER_NETWORK_INTERFACES, InetAddress.getLoopbackAddress().getHostAddress());
AppStateListener listener = mock(AppStateListener.class);
try (AppStateClusterImpl appStateCluster = new AppStateClusterImpl(settings)) {
appStateCluster.addListener(listener);
HazelcastInstance hzInstance = createHazelcastClient(appStateCluster);
String uuid = UUID.randomUUID().toString();
ReplicatedMap<ClusterProcess, Boolean> replicatedMap = hzInstance.getReplicatedMap(OPERATIONAL_PROCESSES);
// process is not up yet --> no events are sent to listeners
replicatedMap.put(new ClusterProcess(uuid, ProcessId.ELASTICSEARCH), Boolean.FALSE);
// process is up yet --> notify listeners
replicatedMap.replace(new ClusterProcess(uuid, ProcessId.ELASTICSEARCH), Boolean.TRUE);
// should be called only once
verify(listener, timeout(20_000)).onAppStateOperational(ProcessId.ELASTICSEARCH);
verifyNoMoreInteractions(listener);
hzInstance.shutdown();
}
}
use of org.sonar.application.config.TestAppSettings in project sonarqube by SonarSource.
the class AppStateClusterImplTest method registerSonarQubeVersion_publishes_version_on_first_call.
@Test
public void registerSonarQubeVersion_publishes_version_on_first_call() {
TestAppSettings settings = newClusterSettings();
try (AppStateClusterImpl appStateCluster = new AppStateClusterImpl(settings)) {
appStateCluster.registerSonarQubeVersion("6.4.1.5");
HazelcastInstance hzInstance = createHazelcastClient(appStateCluster);
assertThat(hzInstance.getAtomicReference(SONARQUBE_VERSION).get()).isNotNull().isInstanceOf(String.class).isEqualTo("6.4.1.5");
}
}
use of org.sonar.application.config.TestAppSettings in project sonarqube by SonarSource.
the class AppReloaderImplTest method reload_configuration_then_reset_all.
@Test
public void reload_configuration_then_reset_all() throws IOException {
AppSettings settings = new TestAppSettings().set("foo", "bar");
AppSettings newSettings = new TestAppSettings().set("foo", "newBar").set("newProp", "newVal");
when(settingsLoader.load()).thenReturn(newSettings);
underTest.reload(settings);
assertThat(settings.getProps().rawProperties()).contains(entry("foo", "newBar")).contains(entry("newProp", "newVal"));
verify(logging).configure();
verify(state).reset();
verify(fs).reset();
}
use of org.sonar.application.config.TestAppSettings in project sonarqube by SonarSource.
the class AppReloaderImplTest method verifyFailureIfPropertyValueChanged.
private void verifyFailureIfPropertyValueChanged(String propertyKey) throws IOException {
AppSettings settings = new TestAppSettings().set(propertyKey, "val1");
AppSettings newSettings = new TestAppSettings().set(propertyKey, "val2");
when(settingsLoader.load()).thenReturn(newSettings);
expectedException.expect(MessageException.class);
expectedException.expectMessage("Property [" + propertyKey + "] cannot be changed on restart: [val1] => [val2]");
underTest.reload(settings);
verifyZeroInteractions(logging);
verifyZeroInteractions(state);
verifyZeroInteractions(fs);
}
use of org.sonar.application.config.TestAppSettings in project sonarqube by SonarSource.
the class AppReloaderImplTest method throw_ISE_if_cluster_is_enabled.
@Test
public void throw_ISE_if_cluster_is_enabled() throws IOException {
AppSettings settings = new TestAppSettings().set(ProcessProperties.CLUSTER_ENABLED, "true");
expectedException.expect(IllegalStateException.class);
expectedException.expectMessage("Restart is not possible with cluster mode");
underTest.reload(settings);
verifyZeroInteractions(logging);
verifyZeroInteractions(state);
verifyZeroInteractions(fs);
}
Aggregations