From: Jacek Date: Mon, 14 Jun 2021 10:25:54 +0000 (+0200) Subject: SONAR-14792 Bump min upgrade version to current LTS X-Git-Tag: 9.0.0.45539~100 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=0d0918a8f5ff5e94f012ebf6dd345a12614ad888;p=sonarqube.git SONAR-14792 Bump min upgrade version to current LTS --- diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/DatabaseVersion.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/DatabaseVersion.java index 4949182e958..529b9a378b9 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/DatabaseVersion.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/DatabaseVersion.java @@ -30,7 +30,7 @@ public class DatabaseVersion { * versions must be previously upgraded to LTS version. * Note that the value can't be less than current LTS version. */ - public static final long MIN_UPGRADE_VERSION = 2_800; + public static final long MIN_UPGRADE_VERSION = 4_400; private final MigrationSteps migrationSteps; private final MigrationHistory migrationHistory; diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/DatabaseServerCompatibilityTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/DatabaseServerCompatibilityTest.java index c806766d108..acf32f945f8 100644 --- a/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/DatabaseServerCompatibilityTest.java +++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/DatabaseServerCompatibilityTest.java @@ -30,13 +30,12 @@ import org.sonar.api.utils.log.LoggerLevel; import org.sonar.server.platform.db.migration.version.DatabaseVersion; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; public class DatabaseServerCompatibilityTest { - @Rule - public ExpectedException thrown = ExpectedException.none(); @Rule public LogTester logTester = new LogTester(); @Rule @@ -45,24 +44,26 @@ public class DatabaseServerCompatibilityTest { @Test public void fail_if_requires_downgrade() { - thrown.expect(MessageException.class); - thrown.expectMessage("Database was upgraded to a more recent version of SonarQube. " - + "A backup must probably be restored or the DB settings are incorrect."); - DatabaseVersion version = mock(DatabaseVersion.class); when(version.getStatus()).thenReturn(DatabaseVersion.Status.REQUIRES_DOWNGRADE); - new DatabaseServerCompatibility(version, settings.asConfig()).start(); + var config = settings.asConfig(); + var compatibility = new DatabaseServerCompatibility(version, config); + assertThatThrownBy(compatibility::start) + .isInstanceOf(MessageException.class) + .hasMessage("Database was upgraded to a more recent version of SonarQube. " + + "A backup must probably be restored or the DB settings are incorrect."); } @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, settings.asConfig()).start(); + var config = settings.asConfig(); + var compatibility = new DatabaseServerCompatibility(version, config); + assertThatThrownBy(compatibility::start) + .isInstanceOf(MessageException.class) + .hasMessage("Current version is too old. Please upgrade to Long Term Support version firstly."); } @Test @@ -77,9 +78,9 @@ public class DatabaseServerCompatibilityTest { "The database must be manually upgraded. Please backup the database and browse /setup. " + "For more information: https://docs.sonarqube.org/latest/setup/upgrading", "################################################################################", - "The database must be manually upgraded. Please backup the database and browse /setup. " + "The database must be manually upgraded. Please backup the database and browse /setup. " + "For more information: https://docs.sonarqube.org/latest/setup/upgrading", - "################################################################################"); + "################################################################################"); } @Test