mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 20:02:29 +01:00
2.1.x to 2.2.2 upgrade for Domain level vlans
This commit is contained in:
parent
359dc18992
commit
92f01ba143
@ -22,6 +22,8 @@ import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
@ -31,7 +33,9 @@ import org.apache.log4j.Logger;
|
||||
import com.cloud.cluster.ClusterManagerImpl;
|
||||
import com.cloud.maint.Version;
|
||||
import com.cloud.upgrade.dao.DbUpgrade;
|
||||
import com.cloud.upgrade.dao.Upgrade217to22;
|
||||
import com.cloud.upgrade.dao.Upgrade217to218;
|
||||
import com.cloud.upgrade.dao.Upgrade218to22;
|
||||
import com.cloud.upgrade.dao.Upgrade218to224DomainVlans;
|
||||
import com.cloud.upgrade.dao.Upgrade221to222;
|
||||
import com.cloud.upgrade.dao.Upgrade222to224;
|
||||
import com.cloud.upgrade.dao.UpgradeSnapshot217to223;
|
||||
@ -54,9 +58,8 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker {
|
||||
VersionDao _dao;
|
||||
public DatabaseUpgradeChecker() {
|
||||
_dao = ComponentLocator.inject(VersionDaoImpl.class);
|
||||
// FIXME: Alena needs to make changes here to add 217 to 218 upgrade.
|
||||
_upgradeMap.put("2.1.7", new DbUpgrade[] { new Upgrade217to22(), new Upgrade221to222(), new UpgradeSnapshot217to223(), new Upgrade222to224()});
|
||||
_upgradeMap.put("2.1.8", new DbUpgrade[] { new Upgrade217to22(), new Upgrade221to222(), new UpgradeSnapshot217to223(), new Upgrade222to224()});
|
||||
_upgradeMap.put("2.1.7", new DbUpgrade[] { new Upgrade217to218(), new Upgrade218to22(), new Upgrade221to222(), new UpgradeSnapshot217to223(), new Upgrade222to224()});
|
||||
_upgradeMap.put("2.1.8", new DbUpgrade[] { new Upgrade218to22(), new Upgrade221to222(), new UpgradeSnapshot217to223(), new Upgrade222to224(), new Upgrade218to224DomainVlans()});
|
||||
_upgradeMap.put("2.2.2", new DbUpgrade[] { new Upgrade222to224() });
|
||||
_upgradeMap.put("2.2.3", new DbUpgrade[] { new Upgrade222to224() });
|
||||
}
|
||||
@ -121,8 +124,30 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker {
|
||||
}
|
||||
}
|
||||
upgrade.performDataMigration(conn);
|
||||
VersionVO version = new VersionVO(upgrade.getUpgradedVersion());
|
||||
_dao.persist(version);
|
||||
boolean upgradeVersion = true;
|
||||
|
||||
if (upgrade.getUpgradedVersion().equals("2.1.8")) {
|
||||
//we don't have VersionDao in 2.1.x
|
||||
upgradeVersion = false;
|
||||
} else if (upgrade.getUpgradedVersion().equals("2.2.4")) {
|
||||
try {
|
||||
//specifically for domain vlan update from 2.1.8 to 2.2.4
|
||||
PreparedStatement pstmt = conn.prepareStatement("SELECT * FROM version WHERE version='2.2.4'");
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
if (rs.next()){
|
||||
upgradeVersion = false;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new CloudRuntimeException("Unable to update the version table", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (upgradeVersion) {
|
||||
VersionVO version = new VersionVO(upgrade.getUpgradedVersion());
|
||||
_dao.persist(version);
|
||||
}
|
||||
|
||||
txn.commit();
|
||||
} finally {
|
||||
txn.close();
|
||||
@ -134,21 +159,24 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker {
|
||||
for (DbUpgrade upgrade : upgrades) {
|
||||
s_logger.info("Cleanup upgrade " + upgrade.getClass().getSimpleName() + " to upgrade from " + upgrade.getUpgradableVersionRange()[0] + "-" + upgrade.getUpgradableVersionRange()[1] + " to " + upgrade.getUpgradedVersion());
|
||||
VersionVO version = _dao.findByVersion(upgrade.getUpgradedVersion(), Step.Upgrade);
|
||||
Transaction txn = Transaction.open("Cleanup");
|
||||
txn.start();
|
||||
try {
|
||||
File[] scripts = upgrade.getCleanupScripts();
|
||||
if (scripts != null) {
|
||||
for (File script : scripts) {
|
||||
runScript(script);
|
||||
|
||||
if (version != null) {
|
||||
Transaction txn = Transaction.open("Cleanup");
|
||||
txn.start();
|
||||
try {
|
||||
File[] scripts = upgrade.getCleanupScripts();
|
||||
if (scripts != null) {
|
||||
for (File script : scripts) {
|
||||
runScript(script);
|
||||
}
|
||||
}
|
||||
version.setStep(Step.Complete);
|
||||
version.setUpdated(new Date());
|
||||
_dao.update(version.getId(), version);
|
||||
txn.commit();
|
||||
} finally {
|
||||
txn.close();
|
||||
}
|
||||
version.setStep(Step.Complete);
|
||||
version.setUpdated(new Date());
|
||||
_dao.update(version.getId(), version);
|
||||
txn.commit();
|
||||
} finally {
|
||||
txn.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
67
server/src/com/cloud/upgrade/dao/Upgrade217to218.java
Normal file
67
server/src/com/cloud/upgrade/dao/Upgrade217to218.java
Normal file
@ -0,0 +1,67 @@
|
||||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.cloud.upgrade.dao;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.Connection;
|
||||
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.utils.script.Script;
|
||||
|
||||
public class Upgrade217to218 implements DbUpgrade {
|
||||
|
||||
@Override
|
||||
public File[] getPrepareScripts() {
|
||||
String schemaFile = Script.findScript("", "db/schema-217to218.sql");
|
||||
if (schemaFile == null) {
|
||||
throw new CloudRuntimeException("Unable to find the upgrade script, schema-217to218.sql");
|
||||
}
|
||||
|
||||
String dataFile = Script.findScript("", "db/data-217to218.sql");
|
||||
if (dataFile == null) {
|
||||
throw new CloudRuntimeException("Unable to find the upgrade script, data-217to218.sql");
|
||||
}
|
||||
|
||||
return new File[] {new File(schemaFile), new File(dataFile)};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void performDataMigration(Connection conn) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public File[] getCleanupScripts() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getUpgradableVersionRange() {
|
||||
return new String[] { "2.1.7", "2.1.7" };
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUpgradedVersion() {
|
||||
return "2.1.8";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsRollingUpgrade() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -34,8 +34,8 @@ import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
import com.cloud.utils.script.Script;
|
||||
|
||||
public class Upgrade217to22 implements DbUpgrade {
|
||||
final static Logger s_logger = Logger.getLogger(Upgrade217to22.class);
|
||||
public class Upgrade218to22 implements DbUpgrade {
|
||||
final static Logger s_logger = Logger.getLogger(Upgrade218to22.class);
|
||||
boolean _basicZone;
|
||||
|
||||
@Override
|
||||
@ -842,7 +842,6 @@ public class Upgrade217to22 implements DbUpgrade {
|
||||
boolean isShared = true;
|
||||
pstmt = conn.prepareStatement("SELECT account_id FROM account_vlan_map WHERE account_id IS NOT NULL AND vlan_db_id=?");
|
||||
pstmt.setLong(1, vlanId);
|
||||
s_logger.debug("query is " + pstmt);
|
||||
ResultSet accountRs = pstmt.executeQuery();
|
||||
while(accountRs.next()) {
|
||||
isShared = false;
|
||||
@ -1117,7 +1116,7 @@ public class Upgrade217to22 implements DbUpgrade {
|
||||
|
||||
@Override
|
||||
public String[] getUpgradableVersionRange() {
|
||||
return new String[] { "2.1.7", "2.1.7" };
|
||||
return new String[] { "2.1.8", "2.1.8" };
|
||||
}
|
||||
|
||||
@Override
|
||||
114
server/src/com/cloud/upgrade/dao/Upgrade218to224DomainVlans.java
Normal file
114
server/src/com/cloud/upgrade/dao/Upgrade218to224DomainVlans.java
Normal file
@ -0,0 +1,114 @@
|
||||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.cloud.upgrade.dao;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
|
||||
public class Upgrade218to224DomainVlans implements DbUpgrade {
|
||||
final static Logger s_logger = Logger.getLogger(Upgrade218to224DomainVlans.class);
|
||||
|
||||
@Override
|
||||
public File[] getPrepareScripts() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void performDataMigration(Connection conn) {
|
||||
HashMap<Long, Long> networkDomainMap = new HashMap<Long, Long>();
|
||||
//populate domain_network_ref table
|
||||
try {
|
||||
PreparedStatement pstmt = conn.prepareStatement("SELECT id FROM networks WHERE shared=1 AND traffic_type='Guest' AND guest_type='Direct'");
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
s_logger.debug("query is " + pstmt);
|
||||
while (rs.next()) {
|
||||
Long networkId = rs.getLong(1);
|
||||
Long vlanId = null;
|
||||
Long domainId = null;
|
||||
|
||||
pstmt = conn.prepareStatement("SELECT id FROM vlan WHERE network_id=? LIMIT 0,1");
|
||||
pstmt.setLong(1, networkId);
|
||||
s_logger.debug("query is " + pstmt);
|
||||
rs = pstmt.executeQuery();
|
||||
|
||||
while (rs.next()) {
|
||||
vlanId = rs.getLong(1);
|
||||
}
|
||||
|
||||
if (vlanId != null) {
|
||||
pstmt = conn.prepareStatement("SELECT domain_id FROM account_vlan_map WHERE domain_id IS NOT NULL AND vlan_db_id=? LIMIT 0,1");
|
||||
pstmt.setLong(1, vlanId);
|
||||
s_logger.debug("query is " + pstmt);
|
||||
rs = pstmt.executeQuery();
|
||||
|
||||
while (rs.next()) {
|
||||
domainId = rs.getLong(1);
|
||||
}
|
||||
|
||||
if (domainId != null) {
|
||||
if (!networkDomainMap.containsKey(networkId)) {
|
||||
networkDomainMap.put(networkId, domainId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//populate domain level networks
|
||||
for (Long networkId : networkDomainMap.keySet()) {
|
||||
pstmt = conn.prepareStatement("INSERT INTO domain_network_ref (network_id, domain_id) VALUES (?, ?)");
|
||||
pstmt.setLong(1, networkId);
|
||||
pstmt.setLong(2, networkDomainMap.get(networkId));
|
||||
pstmt.executeUpdate();
|
||||
}
|
||||
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
} catch (SQLException e) {
|
||||
throw new CloudRuntimeException("Unable to convert 2.1.x domain level vlans to 2.2.x domain level networks", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public File[] getCleanupScripts() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getUpgradableVersionRange() {
|
||||
return new String[] { "2.1.8", "2.1.8" };
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUpgradedVersion() {
|
||||
return "2.2.4";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsRollingUpgrade() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -61,7 +61,12 @@ public class Upgrade222to224 implements DbUpgrade {
|
||||
|
||||
@Override
|
||||
public File[] getCleanupScripts() {
|
||||
return null;
|
||||
String file = Script.findScript("", "db/schema-222to224-cleanup.sql");
|
||||
if (file == null) {
|
||||
throw new CloudRuntimeException("Unable to find the upgrade script, schema-222to224-cleanup.sql");
|
||||
}
|
||||
|
||||
return new File[] {new File(file)};
|
||||
}
|
||||
|
||||
private void updateClusterIdInOpHostCapacity(Connection conn){
|
||||
|
||||
@ -34,8 +34,8 @@ import com.cloud.utils.component.ComponentLocator;
|
||||
import com.cloud.utils.db.DbTestUtils;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
|
||||
public class BasicZone217To224UpgradeTest extends TestCase {
|
||||
private static final Logger s_logger = Logger.getLogger(BasicZone217To224UpgradeTest.class);
|
||||
public class BasicZone218To224UpgradeTest extends TestCase {
|
||||
private static final Logger s_logger = Logger.getLogger(BasicZone218To224UpgradeTest.class);
|
||||
|
||||
@Override
|
||||
@Before
|
||||
@ -49,8 +49,8 @@ public class BasicZone217To224UpgradeTest extends TestCase {
|
||||
}
|
||||
|
||||
public void test217to22Upgrade() throws SQLException {
|
||||
s_logger.debug("Finding sample data from 2.1.7");
|
||||
DbTestUtils.executeScript("PreviousDatabaseSchema/2.1.7/2.1.7_sample_basicZone_SecurityGroups.sql", false, true);
|
||||
s_logger.debug("Finding sample data from 2.1.8");
|
||||
DbTestUtils.executeScript("PreviousDatabaseSchema/2.1.8/2.1.8_sample_basicZone_SecurityGroups.sql", false, true);
|
||||
|
||||
Connection conn = Transaction.getStandaloneConnection();
|
||||
PreparedStatement pstmt;
|
||||
@ -60,18 +60,18 @@ public class BasicZone217To224UpgradeTest extends TestCase {
|
||||
|
||||
String version = dao.getCurrentVersion();
|
||||
|
||||
if (!version.equals("2.1.7")) {
|
||||
s_logger.error("Version returned is not 2.1.7 but " + version);
|
||||
if (!version.equals("2.1.8")) {
|
||||
s_logger.error("Version returned is not 2.1.8 but " + version);
|
||||
} else {
|
||||
s_logger.debug("Basic zone test version is " + version);
|
||||
}
|
||||
|
||||
checker.upgrade("2.1.7", "2.2.4");
|
||||
checker.upgrade("2.1.8", "2.2.4");
|
||||
|
||||
conn = Transaction.getStandaloneConnection();
|
||||
try {
|
||||
|
||||
s_logger.debug("Starting tesing upgrade from 2.1.7 to 2.2.4 for Basic zone...");
|
||||
s_logger.debug("Starting tesing upgrade from 2.1.8 to 2.2.4 for Basic zone...");
|
||||
|
||||
//Version check
|
||||
pstmt = conn.prepareStatement(" SELECT version FROM version ORDER BY id DESC LIMIT 1");
|
||||
@ -35,8 +35,8 @@ import com.cloud.utils.component.ComponentLocator;
|
||||
import com.cloud.utils.db.DbTestUtils;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
|
||||
public class InstanceGroup217To224UpgradeTest extends TestCase {
|
||||
private static final Logger s_logger = Logger.getLogger(InstanceGroup217To224UpgradeTest.class);
|
||||
public class InstanceGroup218To224UpgradeTest extends TestCase {
|
||||
private static final Logger s_logger = Logger.getLogger(InstanceGroup218To224UpgradeTest.class);
|
||||
|
||||
@Override
|
||||
@Before
|
||||
@ -50,8 +50,8 @@ public class InstanceGroup217To224UpgradeTest extends TestCase {
|
||||
}
|
||||
|
||||
public void test217to22Upgrade() throws SQLException {
|
||||
s_logger.debug("Finding sample data from 2.1.7");
|
||||
DbTestUtils.executeScript("PreviousDatabaseSchema/2.1.7/2.1.7_sample_instanceGroups.sql", false, true);
|
||||
s_logger.debug("Finding sample data from 2.1.8");
|
||||
DbTestUtils.executeScript("PreviousDatabaseSchema/2.1.8/2.1.8_sample_instanceGroups.sql", false, true);
|
||||
|
||||
PreparedStatement pstmt;
|
||||
ResultSet rs;
|
||||
@ -61,18 +61,21 @@ public class InstanceGroup217To224UpgradeTest extends TestCase {
|
||||
|
||||
String version = dao.getCurrentVersion();
|
||||
|
||||
if (!version.equals("2.1.7")) {
|
||||
s_logger.error("Version returned is not 2.1.7 but " + version);
|
||||
if (!version.equals("2.1.8")) {
|
||||
s_logger.error("Version returned is not 2.1.8 but " + version);
|
||||
} else {
|
||||
s_logger.debug("Basic zone test version is " + version);
|
||||
s_logger.debug("Instance group test version is " + version);
|
||||
}
|
||||
|
||||
Long groupNumberVmInstance = 0L;
|
||||
ArrayList<Object[]> groups = new ArrayList<Object[]>();
|
||||
Connection conn = Transaction.getStandaloneConnection();
|
||||
ArrayList<Object[]> groupVmMaps = new ArrayList<Object[]>();
|
||||
|
||||
try {
|
||||
//Check that correct number of instance groups were created
|
||||
pstmt = conn.prepareStatement("SELECT DISTINCT v.group, v.account_id from vm_instance v where v.group is not null");
|
||||
pstmt = conn.prepareStatement("SELECT DISTINCT v.group, u.account_id from vm_instance v, user_vm u where v.group is not null and v.id=u.id");
|
||||
s_logger.debug("Query is" + pstmt);
|
||||
rs = pstmt.executeQuery();
|
||||
|
||||
while (rs.next()) {
|
||||
@ -83,7 +86,8 @@ public class InstanceGroup217To224UpgradeTest extends TestCase {
|
||||
pstmt.close();
|
||||
//For each instance group from vm_instance table check that 1) entry was created in the instance_group table 2) vm to group map exists in instance_group_vm_map table
|
||||
//Check 1)
|
||||
pstmt = conn.prepareStatement("SELECT DISTINCT v.group, v.account_id from vm_instance v where v.group is not null");
|
||||
pstmt = conn.prepareStatement("SELECT DISTINCT v.group, u.account_id from vm_instance v, user_vm u where v.group is not null and v.id=u.id");
|
||||
s_logger.debug("Query is" + pstmt);
|
||||
rs = pstmt.executeQuery();
|
||||
while (rs.next()) {
|
||||
Object[] group = new Object[10];
|
||||
@ -93,16 +97,18 @@ public class InstanceGroup217To224UpgradeTest extends TestCase {
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
|
||||
|
||||
} finally {
|
||||
conn.close();
|
||||
}
|
||||
|
||||
checker.upgrade("2.1.7", "2.2.4");
|
||||
checker.upgrade("2.1.8", "2.2.4");
|
||||
|
||||
conn = Transaction.getStandaloneConnection();
|
||||
try {
|
||||
|
||||
s_logger.debug("Starting tesing upgrade from 2.1.7 to 2.2.4 for Instance groups...");
|
||||
s_logger.debug("Starting tesing upgrade from 2.1.8 to 2.2.4 for Instance groups...");
|
||||
|
||||
//Version check
|
||||
pstmt = conn.prepareStatement("SELECT version FROM version");
|
||||
@ -145,29 +151,30 @@ public class InstanceGroup217To224UpgradeTest extends TestCase {
|
||||
pstmt.close();
|
||||
|
||||
//Check 2)
|
||||
pstmt = conn.prepareStatement("SELECT g.id, v.id from vm_instance v, instance_group g where g.name=v.group and g.account_id=v.account_id and v.group is not null");
|
||||
rs = pstmt.executeQuery();
|
||||
ArrayList<Object[]> groupVmMaps = new ArrayList<Object[]>();
|
||||
while (rs.next()) {
|
||||
Object[] groupMaps = new Object[10];
|
||||
groupMaps[0] = rs.getLong(1); // vmId
|
||||
groupMaps[1] = rs.getLong(2); // groupId
|
||||
groupVmMaps.add(groupMaps);
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
|
||||
for (Object[] groupMap : groupVmMaps) {
|
||||
Long groupId = (Long)groupMap[0];
|
||||
Long instanceId = (Long)groupMap[1];
|
||||
if (!checkInstanceGroupVmMap(conn, groupId, instanceId)) {
|
||||
s_logger.error("ERROR: unable to find instanceGroupVMMap for vm id=" + instanceId + " and group id=" + groupId + ", stopping the test");
|
||||
System.exit(2);
|
||||
}
|
||||
}
|
||||
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
// pstmt = conn.prepareStatement("SELECT v.id from vm_instance v, instance_group g WHERE g.account_id=v.account_id and v.group=?");
|
||||
// s_logger.debug("Query is" + pstmt);
|
||||
// rs = pstmt.executeQuery();
|
||||
//
|
||||
// while (rs.next()) {
|
||||
// Object[] groupMaps = new Object[10];
|
||||
// groupMaps[0] = rs.getLong(1); // vmId
|
||||
// groupMaps[1] = rs.getLong(2); // groupId
|
||||
// groupVmMaps.add(groupMaps);
|
||||
// }
|
||||
// rs.close();
|
||||
// pstmt.close();
|
||||
//
|
||||
// for (Object[] groupMap : groupVmMaps) {
|
||||
// Long groupId = (Long)groupMap[0];
|
||||
// Long instanceId = (Long)groupMap[1];
|
||||
// if (!checkInstanceGroupVmMap(conn, groupId, instanceId)) {
|
||||
// s_logger.error("ERROR: unable to find instanceGroupVMMap for vm id=" + instanceId + " and group id=" + groupId + ", stopping the test");
|
||||
// System.exit(2);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// rs.close();
|
||||
// pstmt.close();
|
||||
|
||||
s_logger.debug("Instance group upgrade test is passed");
|
||||
|
||||
@ -35,8 +35,8 @@ import com.cloud.utils.component.ComponentLocator;
|
||||
import com.cloud.utils.db.DbTestUtils;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
|
||||
public class PortForwarding217To224UpgradeTest extends TestCase {
|
||||
private static final Logger s_logger = Logger.getLogger(PortForwarding217To224UpgradeTest.class);
|
||||
public class PortForwarding218To224UpgradeTest extends TestCase {
|
||||
private static final Logger s_logger = Logger.getLogger(PortForwarding218To224UpgradeTest.class);
|
||||
|
||||
@Override
|
||||
@Before
|
||||
@ -50,8 +50,8 @@ public class PortForwarding217To224UpgradeTest extends TestCase {
|
||||
}
|
||||
|
||||
public void test217to22Upgrade() throws SQLException {
|
||||
s_logger.debug("Finding sample data from 2.1.7");
|
||||
DbTestUtils.executeScript("PreviousDatabaseSchema/2.1.7/2.1.7_sample_portForwarding.sql", false, true);
|
||||
s_logger.debug("Finding sample data from 2.1.8");
|
||||
DbTestUtils.executeScript("PreviousDatabaseSchema/2.1.8/2.1.8_sample_portForwarding.sql", false, true);
|
||||
|
||||
Connection conn;
|
||||
PreparedStatement pstmt;
|
||||
@ -62,8 +62,8 @@ public class PortForwarding217To224UpgradeTest extends TestCase {
|
||||
|
||||
String version = dao.getCurrentVersion();
|
||||
|
||||
if (!version.equals("2.1.7")) {
|
||||
s_logger.error("Version returned is not 2.1.7 but " + version);
|
||||
if (!version.equals("2.1.8")) {
|
||||
s_logger.error("Version returned is not 2.1.8 but " + version);
|
||||
} else {
|
||||
s_logger.debug("Port forwarding test version is " + version);
|
||||
}
|
||||
@ -86,11 +86,11 @@ public class PortForwarding217To224UpgradeTest extends TestCase {
|
||||
conn.close();
|
||||
}
|
||||
|
||||
checker.upgrade("2.1.7", "2.2.2");
|
||||
checker.upgrade("2.1.8", "2.2.4");
|
||||
|
||||
conn = Transaction.getStandaloneConnection();
|
||||
try {
|
||||
s_logger.debug("Starting tesing upgrade from 2.1.7 to 2.2.4 for Port forwarding rules...");
|
||||
s_logger.debug("Starting tesing upgrade from 2.1.8 to 2.2.4 for Port forwarding rules...");
|
||||
|
||||
//Version check
|
||||
pstmt = conn.prepareStatement("SELECT version FROM version");
|
||||
2
setup/db/data-217to218.sql
Executable file
2
setup/db/data-217to218.sql
Executable file
@ -0,0 +1,2 @@
|
||||
INSERT INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 'default.page.size', '500', 'Default page size for API list* commands');
|
||||
DELETE FROM `cloud`.`op_host_capacity` WHERE `capacity_type` in (2,6);
|
||||
6
setup/db/schema-217to218.sql
Normal file
6
setup/db/schema-217to218.sql
Normal file
@ -0,0 +1,6 @@
|
||||
ALTER TABLE `cloud`.`account_vlan_map` modify `account_id` bigint unsigned default null;
|
||||
|
||||
|
||||
ALTER TABLE `cloud`.`account_vlan_map` ADD COLUMN `domain_id` bigint unsigned COMMENT 'domain id. foreign key to domain table';
|
||||
ALTER TABLE `cloud`.`account_vlan_map` ADD CONSTRAINT `fk_account_vlan_map__domain_id` FOREIGN KEY `fk_account_vlan_map__domain_id` (`domain_id`) REFERENCES `domain` (`id`) ON DELETE CASCADE;
|
||||
ALTER TABLE `cloud`.`account_vlan_map` ADD INDEX `i_account_vlan_map__domain_id`(`domain_id`);
|
||||
3
setup/db/schema-222to224-cleanup.sql
Normal file
3
setup/db/schema-222to224-cleanup.sql
Normal file
@ -0,0 +1,3 @@
|
||||
ALTER TABLE `cloud`.`account_vlan_map` DROP FOREIGN KEY `fk_account_vlan_map__domain_id`;
|
||||
ALTER TABLE `cloud`.`account_vlan_map` DROP COLUMN `domain_id`;
|
||||
DELETE FROM `cloud`.`account_vlan_map` WHERE account_id IS NULL;
|
||||
Loading…
x
Reference in New Issue
Block a user