]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-14792 Bump min upgrade version to current LTS
authorJacek <jacek.poreda@sonarsource.com>
Mon, 14 Jun 2021 10:25:54 +0000 (12:25 +0200)
committersonartech <sonartech@sonarsource.com>
Wed, 16 Jun 2021 20:03:04 +0000 (20:03 +0000)
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/DatabaseVersion.java
server/sonar-webserver-core/src/test/java/org/sonar/server/platform/DatabaseServerCompatibilityTest.java

index 4949182e9585086d8274b1af078a75084098cbd3..529b9a378b94cae757cf178392a9dac851aacef3 100644 (file)
@@ -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;
index c806766d108f915fb121d9920fb5434b4cf0b071..acf32f945f8d8eddf05c98baf1279feaaefb7e60 100644 (file)
@@ -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