Search in sources :

Example 1 with DatabaseVersion

use of org.sonar.server.platform.db.migration.version.DatabaseVersion in project sonarqube by SonarSource.

the class DatabaseServerCompatibilityTest method log_warning_if_requires_upgrade.

@Test
public void log_warning_if_requires_upgrade() {
    DatabaseVersion version = mock(DatabaseVersion.class);
    when(version.getStatus()).thenReturn(DatabaseVersion.Status.REQUIRES_UPGRADE);
    when(version.getVersion()).thenReturn(Optional.of(DatabaseVersion.MIN_UPGRADE_VERSION));
    new DatabaseServerCompatibility(version).start();
    assertThat(logTester.logs()).hasSize(2);
    assertThat(logTester.logs(LoggerLevel.WARN)).contains("Database must be upgraded. Please backup database and browse /setup", "\n################################################################################\n" + "      Database must be upgraded. Please backup database and browse /setup\n" + "################################################################################");
}
Also used : DatabaseVersion(org.sonar.server.platform.db.migration.version.DatabaseVersion) Test(org.junit.Test)

Example 2 with DatabaseVersion

use of org.sonar.server.platform.db.migration.version.DatabaseVersion in project sonarqube by SonarSource.

the class DatabaseServerCompatibilityTest method do_nothing_if_up_to_date.

@Test
public void do_nothing_if_up_to_date() {
    DatabaseVersion version = mock(DatabaseVersion.class);
    when(version.getStatus()).thenReturn(DatabaseVersion.Status.UP_TO_DATE);
    new DatabaseServerCompatibility(version).start();
// no error
}
Also used : DatabaseVersion(org.sonar.server.platform.db.migration.version.DatabaseVersion) Test(org.junit.Test)

Example 3 with DatabaseVersion

use of org.sonar.server.platform.db.migration.version.DatabaseVersion in project sonarqube by SonarSource.

the class DatabaseServerCompatibilityTest method fail_if_requires_firstly_to_upgrade_to_lts.

@Test
public void fail_if_requires_firstly_to_upgrade_to_lts() {
    thrown.expect(MessageException.class);
    thrown.expectMessage("Current version is too old. Please upgrade to Long Term Support version firstly.");
    DatabaseVersion version = mock(DatabaseVersion.class);
    when(version.getStatus()).thenReturn(DatabaseVersion.Status.REQUIRES_UPGRADE);
    when(version.getVersion()).thenReturn(Optional.of(12L));
    new DatabaseServerCompatibility(version).start();
}
Also used : DatabaseVersion(org.sonar.server.platform.db.migration.version.DatabaseVersion) Test(org.junit.Test)

Example 4 with DatabaseVersion

use of org.sonar.server.platform.db.migration.version.DatabaseVersion in project sonarqube by SonarSource.

the class DatabaseServerCompatibilityTest method fail_if_requires_downgrade.

@Test
public void fail_if_requires_downgrade() {
    thrown.expect(MessageException.class);
    thrown.expectMessage("Database was upgraded to a more recent of SonarQube. Backup must probably be restored or db settings are incorrect.");
    DatabaseVersion version = mock(DatabaseVersion.class);
    when(version.getStatus()).thenReturn(DatabaseVersion.Status.REQUIRES_DOWNGRADE);
    new DatabaseServerCompatibility(version).start();
}
Also used : DatabaseVersion(org.sonar.server.platform.db.migration.version.DatabaseVersion) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)4 DatabaseVersion (org.sonar.server.platform.db.migration.version.DatabaseVersion)4