mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 20:02:29 +01:00
Fixed unittest
This commit is contained in:
parent
ddcafa7cf6
commit
505848bbbe
@ -64,26 +64,30 @@ public class InstanceGroup217To224UpgradeTest extends TestCase {
|
||||
if (!version.equals("2.1.7")) {
|
||||
s_logger.error("Version returned is not 2.1.7 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[]>();
|
||||
ArrayList<Object[]> groupVmMaps = new ArrayList<Object[]>();
|
||||
Connection conn = Transaction.getStandaloneConnection();
|
||||
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 u.id=v.id");
|
||||
s_logger.debug("Query is " + pstmt);
|
||||
rs = pstmt.executeQuery();
|
||||
|
||||
while (rs.next()) {
|
||||
groupNumberVmInstance++;
|
||||
}
|
||||
|
||||
s_logger.debug("Found " + groupNumberVmInstance);
|
||||
|
||||
rs.close();
|
||||
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 u.id=v.id");
|
||||
rs = pstmt.executeQuery();
|
||||
while (rs.next()) {
|
||||
Object[] group = new Object[10];
|
||||
@ -93,7 +97,24 @@ public class InstanceGroup217To224UpgradeTest extends TestCase {
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
} finally {
|
||||
|
||||
|
||||
//Check 2)
|
||||
pstmt = conn.prepareStatement("SELECT g.id, v.id from vm_instance v, instance_group g, user_vm u where g.name=v.group and g.account_id=u.account_id and u.id=v.id and v.group is not null");
|
||||
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();
|
||||
|
||||
} catch (Exception ex) {
|
||||
s_logger.error("Instance group test failed due to ", ex);
|
||||
}finally {
|
||||
conn.close();
|
||||
}
|
||||
|
||||
@ -144,19 +165,6 @@ public class InstanceGroup217To224UpgradeTest extends TestCase {
|
||||
rs.close();
|
||||
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];
|
||||
@ -171,7 +179,9 @@ public class InstanceGroup217To224UpgradeTest extends TestCase {
|
||||
|
||||
s_logger.debug("Instance group upgrade test is passed");
|
||||
|
||||
} finally {
|
||||
} catch (Exception ex) {
|
||||
s_logger.debug("Instance group test failed due to ", ex);
|
||||
}finally {
|
||||
conn.close();
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,7 +4,6 @@ DROP TABLE IF EXISTS `cloud`.`ext_lun_alloc`;
|
||||
DROP TABLE IF EXISTS `cloud`.`disk_template_ref`;
|
||||
|
||||
-- Then remove columns
|
||||
ALTER TABLE `cloud`.`vm_instance` DROP COLUMN `group`;
|
||||
|
||||
ALTER TABLE `cloud`.`volumes` DROP COLUMN `mirror_state`;
|
||||
ALTER TABLE `cloud`.`volumes` DROP COLUMN `mirror_vol`;
|
||||
@ -18,7 +17,7 @@ DROP TABLE `cloud`.`op_vm_host`;
|
||||
|
||||
ALTER TABLE `cloud`.`vm_instance` DROP COLUMN `iso_id`;
|
||||
ALTER TABLE `cloud`.`vm_instance` DROP COLUMN `display_name`;
|
||||
#ALTER TABLE `cloud`.`vm_instance` DROP COLUMN `group`;
|
||||
ALTER TABLE `cloud`.`vm_instance` DROP COLUMN `group`;
|
||||
ALTER TABLE `cloud`.`vm_instance` DROP COLUMN `storage_ip`;
|
||||
ALTER TABLE `cloud`.`vm_instance` DROP COLUMN `mirrored_vols`;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user