You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by GitBox <gi...@apache.org> on 2022/12/16 08:39:40 UTC

[GitHub] [cloudstack] DaanHoogland commented on a diff in pull request #6858: allow a new upgrade version without DB changes to be inserted

DaanHoogland commented on code in PR #6858:
URL: https://github.com/apache/cloudstack/pull/6858#discussion_r1050492358


##########
engine/schema/src/test/java/com/cloud/upgrade/DatabaseVersionHierarchyTest.java:
##########
@@ -0,0 +1,117 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.upgrade;
+
+import com.cloud.upgrade.dao.DbUpgrade;
+import com.cloud.upgrade.dao.Upgrade41110to41120;
+import com.cloud.upgrade.dao.Upgrade41120to41130;
+import com.cloud.upgrade.dao.Upgrade41120to41200;
+import com.cloud.upgrade.dao.Upgrade41500to41510;
+import com.cloud.upgrade.dao.Upgrade41510to41520;
+import com.cloud.upgrade.dao.Upgrade41520to41600;
+import com.cloud.upgrade.dao.Upgrade41710to41800;

Review Comment:
   ```suggestion
   import com.cloud.upgrade.dao.Upgrade41720to41800;
   ```



##########
engine/schema/src/test/java/com/cloud/upgrade/DatabaseVersionHierarchyTest.java:
##########
@@ -0,0 +1,117 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.upgrade;
+
+import com.cloud.upgrade.dao.DbUpgrade;
+import com.cloud.upgrade.dao.Upgrade41110to41120;
+import com.cloud.upgrade.dao.Upgrade41120to41130;
+import com.cloud.upgrade.dao.Upgrade41120to41200;
+import com.cloud.upgrade.dao.Upgrade41500to41510;
+import com.cloud.upgrade.dao.Upgrade41510to41520;
+import com.cloud.upgrade.dao.Upgrade41520to41600;
+import com.cloud.upgrade.dao.Upgrade41710to41800;
+import com.cloud.upgrade.dao.Upgrade481to490;
+import org.apache.cloudstack.utils.CloudStackVersion;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import java.io.InputStream;
+import java.sql.Connection;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+class DatabaseVersionHierarchyTest {
+
+    private static DatabaseVersionHierarchy hierarchy;
+
+    static class DummyUpgrade implements DbUpgrade {
+        @Override
+        public String[] getUpgradableVersionRange() {
+            return new String[0];
+        }
+
+        @Override
+        public String getUpgradedVersion() {
+            return null;
+        }
+
+        @Override
+        public boolean supportsRollingUpgrade() {
+            return false;
+        }
+
+        @Override
+        public InputStream[] getPrepareScripts() {
+            return new InputStream[0];
+        }
+
+        @Override
+        public void performDataMigration(Connection conn) {
+
+        }
+
+        @Override
+        public InputStream[] getCleanupScripts() {
+            return new InputStream[0];
+        }
+
+    }
+
+    @BeforeAll
+    static void init() {
+        DatabaseVersionHierarchy.DatabaseVersionHierarchyBuilder builder = DatabaseVersionHierarchy.builder()
+                .next("0.0.5", new DummyUpgrade())
+                .next("1.0.0.0", new DummyUpgrade())
+                .next("1.0.1"   , new DummyUpgrade())
+                .next("1.2.0"   , new DummyUpgrade())
+                .next("2.0.0"   , new DummyUpgrade())
+                .next("2.3.2"   , new DummyUpgrade())
+                .next("3.4.5.6"   , new DummyUpgrade())
+                .next("4.8.2.0" , new Upgrade481to490())
+                .next("4.9.10.11"   , new DummyUpgrade())
+                .next("4.11.1.0", new Upgrade41110to41120())
+                .next("4.11.2.0", new Upgrade41120to41130())
+                .next("4.11.3.0", new Upgrade41120to41200())
+                .next("4.15.0.0", new Upgrade41500to41510())
+                .next("4.15.1.0", new Upgrade41510to41520())
+                .next("4.15.2.0", new Upgrade41520to41600())
+                .next("4.15.4", new DummyUpgrade())
+                .next("4.17.1.0", new Upgrade41710to41800());

Review Comment:
   ```suggestion
                   .next("4.17.2.0", new Upgrade41710to41800());
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org