Search in sources :

Example 6 with TestAppSettings

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);
    }
}
Also used : TestAppSettings(org.sonar.application.config.TestAppSettings) Test(org.junit.Test)

Example 7 with TestAppSettings

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);
}
Also used : TestAppSettings(org.sonar.application.config.TestAppSettings) Test(org.junit.Test)

Example 8 with TestAppSettings

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");
    }
}
Also used : TestAppSettings(org.sonar.application.config.TestAppSettings) Test(org.junit.Test)

Example 9 with TestAppSettings

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;
}
Also used : TestAppSettings(org.sonar.application.config.TestAppSettings)

Aggregations

TestAppSettings (org.sonar.application.config.TestAppSettings)9 Test (org.junit.Test)7 AppSettings (org.sonar.application.config.AppSettings)3 HazelcastInstance (com.hazelcast.core.HazelcastInstance)2 AppStateListener (org.sonar.application.AppStateListener)1