use of org.sonar.application.config.TestAppSettings in project sonarqube by SonarSource.
the class AppStateClusterImplTest method tryToLockWebLeader_returns_true_only_for_the_first_call.
@Test
public void tryToLockWebLeader_returns_true_only_for_the_first_call() throws Exception {
TestAppSettings settings = newClusterSettings();
try (AppStateClusterImpl underTest = new AppStateClusterImpl(settings)) {
assertThat(underTest.tryToLockWebLeader()).isEqualTo(true);
assertThat(underTest.tryToLockWebLeader()).isEqualTo(false);
}
}
use of org.sonar.application.config.TestAppSettings in project sonarqube by SonarSource.
the class AppStateClusterImplTest method instantiation_throws_ISE_if_cluster_mode_is_disabled.
@Test
public void instantiation_throws_ISE_if_cluster_mode_is_disabled() throws Exception {
TestAppSettings settings = new TestAppSettings();
settings.set(ProcessProperties.CLUSTER_ENABLED, "false");
expectedException.expect(IllegalStateException.class);
expectedException.expectMessage("Cluster is not enabled on this instance");
new AppStateClusterImpl(settings);
}
use of org.sonar.application.config.TestAppSettings in project sonarqube by SonarSource.
the class AppStateClusterImplTest method registerSonarQubeVersion_throws_ISE_if_initial_version_is_different.
@Test
public void registerSonarQubeVersion_throws_ISE_if_initial_version_is_different() throws Exception {
// Now launch an instance that try to be part of the hzInstance cluster
TestAppSettings settings = new TestAppSettings();
settings.set(ProcessProperties.CLUSTER_ENABLED, "true");
settings.set(ProcessProperties.CLUSTER_NAME, "sonarqube");
try (AppStateClusterImpl appStateCluster = new AppStateClusterImpl(settings)) {
// Register first version
appStateCluster.registerSonarQubeVersion("1.0.0");
expectedException.expect(IllegalStateException.class);
expectedException.expectMessage("The local version 2.0.0 is not the same as the cluster 1.0.0");
// Registering a second different version must trigger an exception
appStateCluster.registerSonarQubeVersion("2.0.0");
}
}
use of org.sonar.application.config.TestAppSettings in project sonarqube by SonarSource.
the class AppStateClusterImplTest method newClusterSettings.
private static TestAppSettings newClusterSettings() {
TestAppSettings settings = new TestAppSettings();
settings.set(ProcessProperties.CLUSTER_ENABLED, "true");
settings.set(ProcessProperties.CLUSTER_NAME, "sonarqube");
return settings;
}
Aggregations