Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,15 @@ private boolean canBypassSecondaryStorage(DataObject srcData, DataObject destDat
return true;
}

if (Hypervisor.HypervisorType.XenServer.equals(((VolumeInfo) srcData).getHypervisorType())) {
return false;
}
Comment thread
weizhouapache marked this conversation as resolved.

if (destData instanceof VolumeInfo) {
if (Hypervisor.HypervisorType.XenServer.equals(((VolumeInfo) destData).getHypervisorType())) {
return false;
}
Comment on lines +559 to +566

Scope srcDataStoreScope = srcData.getDataStore().getScope();
Scope destDataStoreScope = destData.getDataStore().getScope();
logger.info("srcDataStoreScope: {}, srcData pool type: {}; destDataStoreScope: {}, destData pool type: {}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ public void testCanBypassSecondaryStorageForDirectDownload() throws NoSuchMethod
@Test
public void testCanBypassSecondaryStorageForUnsupportedDataObject() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
VolumeObject srcVolumeInfo = Mockito.spy(new VolumeObject());
Mockito.doReturn(HypervisorType.KVM).when(srcVolumeInfo).getHypervisorType();

TemplateObject destTemplateInfo = Mockito.spy(new TemplateObject());

Expand All @@ -156,12 +157,14 @@ public void testCanBypassSecondaryStorageForUnsupportedDataObject() throws NoSuc
@Test
public void testCanBypassSecondaryStorageForUnsupportedSrcPoolType() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
VolumeObject srcVolumeInfo = Mockito.spy(new VolumeObject());
Mockito.doReturn(HypervisorType.KVM).when(srcVolumeInfo).getHypervisorType();
DataStore srcDataStore = Mockito.mock(DataStore.class);
Mockito.doReturn(new ZoneScope(1L)).when(srcDataStore).getScope();
Mockito.doReturn(srcDataStore).when(srcVolumeInfo).getDataStore();
Mockito.doReturn(Storage.StoragePoolType.PowerFlex).when(srcVolumeInfo).getStoragePoolType();

VolumeObject destVolumeInfo = Mockito.spy(new VolumeObject());
Mockito.doReturn(HypervisorType.KVM).when(destVolumeInfo).getHypervisorType();
DataStore destDataStore = Mockito.mock(DataStore.class);
Mockito.doReturn(new ZoneScope(1L)).when(destDataStore).getScope();
Mockito.doReturn(destDataStore).when(destVolumeInfo).getDataStore();
Expand All @@ -177,12 +180,14 @@ public void testCanBypassSecondaryStorageForUnsupportedSrcPoolType() throws NoSu
@Test
public void testCanBypassSecondaryStorageForUnsupportedDestPoolType() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
VolumeObject srcVolumeInfo = Mockito.spy(new VolumeObject());
Mockito.doReturn(HypervisorType.KVM).when(srcVolumeInfo).getHypervisorType();
DataStore srcDataStore = Mockito.mock(DataStore.class);
Mockito.doReturn(new ZoneScope(1L)).when(srcDataStore).getScope();
Mockito.doReturn(srcDataStore).when(srcVolumeInfo).getDataStore();
Mockito.doReturn(Storage.StoragePoolType.NetworkFilesystem).when(srcVolumeInfo).getStoragePoolType();

VolumeObject destVolumeInfo = Mockito.spy(new VolumeObject());
Mockito.doReturn(HypervisorType.KVM).when(destVolumeInfo).getHypervisorType();
DataStore destDataStore = Mockito.mock(DataStore.class);
Mockito.doReturn(new ZoneScope(1L)).when(destDataStore).getScope();
Mockito.doReturn(destDataStore).when(destVolumeInfo).getDataStore();
Expand All @@ -198,12 +203,14 @@ public void testCanBypassSecondaryStorageForUnsupportedDestPoolType() throws NoS
@Test
public void testCanBypassSecondaryStorageWithZoneWideNFSPoolsInSameZone() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
VolumeObject srcVolumeInfo = Mockito.spy(new VolumeObject());
Mockito.doReturn(HypervisorType.KVM).when(srcVolumeInfo).getHypervisorType();
DataStore srcDataStore = Mockito.mock(DataStore.class);
Mockito.doReturn(new ZoneScope(1L)).when(srcDataStore).getScope();
Mockito.doReturn(srcDataStore).when(srcVolumeInfo).getDataStore();
Mockito.doReturn(Storage.StoragePoolType.NetworkFilesystem).when(srcVolumeInfo).getStoragePoolType();

VolumeObject destVolumeInfo = Mockito.spy(new VolumeObject());
Mockito.doReturn(HypervisorType.KVM).when(destVolumeInfo).getHypervisorType();
DataStore destDataStore = Mockito.mock(DataStore.class);
Mockito.doReturn(new ZoneScope(1L)).when(destDataStore).getScope();
Mockito.doReturn(destDataStore).when(destVolumeInfo).getDataStore();
Expand All @@ -219,12 +226,14 @@ public void testCanBypassSecondaryStorageWithZoneWideNFSPoolsInSameZone() throws
@Test
public void testCanBypassSecondaryStorageWithClusterWideNFSPoolsInSameCluster() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
VolumeObject srcVolumeInfo = Mockito.spy(new VolumeObject());
Mockito.doReturn(HypervisorType.KVM).when(srcVolumeInfo).getHypervisorType();
DataStore srcDataStore = Mockito.mock(DataStore.class);
Mockito.doReturn(new ClusterScope(5L, 2L, 1L)).when(srcDataStore).getScope();
Mockito.doReturn(srcDataStore).when(srcVolumeInfo).getDataStore();
Mockito.doReturn(Storage.StoragePoolType.NetworkFilesystem).when(srcVolumeInfo).getStoragePoolType();

VolumeObject destVolumeInfo = Mockito.spy(new VolumeObject());
Mockito.doReturn(HypervisorType.KVM).when(destVolumeInfo).getHypervisorType();
DataStore destDataStore = Mockito.mock(DataStore.class);
Mockito.doReturn(new ClusterScope(5L, 2L, 1L)).when(destDataStore).getScope();
Mockito.doReturn(destDataStore).when(destVolumeInfo).getDataStore();
Expand All @@ -240,12 +249,14 @@ public void testCanBypassSecondaryStorageWithClusterWideNFSPoolsInSameCluster()
@Test
public void testCanBypassSecondaryStorageWithLocalAndClusterWideNFSPoolsInSameCluster() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
VolumeObject srcVolumeInfo = Mockito.spy(new VolumeObject());
Mockito.doReturn(HypervisorType.KVM).when(srcVolumeInfo).getHypervisorType();
DataStore srcDataStore = Mockito.mock(DataStore.class);
Mockito.doReturn(new HostScope(1L, 1L, 1L)).when(srcDataStore).getScope();
Mockito.doReturn(srcDataStore).when(srcVolumeInfo).getDataStore();
Mockito.doReturn(Storage.StoragePoolType.Filesystem).when(srcVolumeInfo).getStoragePoolType();

VolumeObject destVolumeInfo = Mockito.spy(new VolumeObject());
Mockito.doReturn(HypervisorType.KVM).when(destVolumeInfo).getHypervisorType();
DataStore destDataStore = Mockito.mock(DataStore.class);
Mockito.doReturn(new ClusterScope(1L, 1L, 1L)).when(destDataStore).getScope();
Mockito.doReturn(destDataStore).when(destVolumeInfo).getDataStore();
Expand All @@ -264,12 +275,14 @@ public void testCanBypassSecondaryStorageWithLocalAndClusterWideNFSPoolsInSameCl
@Test
public void testCanBypassSecondaryStorageWithLocalAndZoneWideNFSPoolsInSameZone() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
VolumeObject srcVolumeInfo = Mockito.spy(new VolumeObject());
Mockito.doReturn(HypervisorType.KVM).when(srcVolumeInfo).getHypervisorType();
DataStore srcDataStore = Mockito.mock(DataStore.class);
Mockito.doReturn(new HostScope(1L, 1L, 1L)).when(srcDataStore).getScope();
Mockito.doReturn(srcDataStore).when(srcVolumeInfo).getDataStore();
Mockito.doReturn(Storage.StoragePoolType.Filesystem).when(srcVolumeInfo).getStoragePoolType();

VolumeObject destVolumeInfo = Mockito.spy(new VolumeObject());
Mockito.doReturn(HypervisorType.KVM).when(destVolumeInfo).getHypervisorType();
DataStore destDataStore = Mockito.mock(DataStore.class);
Mockito.doReturn(new ZoneScope(1L)).when(destDataStore).getScope();
Mockito.doReturn(destDataStore).when(destVolumeInfo).getDataStore();
Expand All @@ -288,12 +301,14 @@ public void testCanBypassSecondaryStorageWithLocalAndZoneWideNFSPoolsInSameZone(
@Test
public void testCanBypassSecondaryStorageWithClusterWideNFSAndZoneWideNFSPoolsInSameZone() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
VolumeObject srcVolumeInfo = Mockito.spy(new VolumeObject());
Mockito.doReturn(HypervisorType.KVM).when(srcVolumeInfo).getHypervisorType();
DataStore srcDataStore = Mockito.mock(DataStore.class);
Mockito.doReturn(new ClusterScope(5L, 2L, 1L)).when(srcDataStore).getScope();
Mockito.doReturn(srcDataStore).when(srcVolumeInfo).getDataStore();
Mockito.doReturn(Storage.StoragePoolType.NetworkFilesystem).when(srcVolumeInfo).getStoragePoolType();

VolumeObject destVolumeInfo = Mockito.spy(new VolumeObject());
Mockito.doReturn(HypervisorType.KVM).when(destVolumeInfo).getHypervisorType();
DataStore destDataStore = Mockito.mock(DataStore.class);
Mockito.doReturn(new ZoneScope(1L)).when(destDataStore).getScope();
Mockito.doReturn(destDataStore).when(destVolumeInfo).getDataStore();
Expand Down
15 changes: 11 additions & 4 deletions test/integration/smoke/test_cluster_drs.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,22 +128,29 @@ def migrateSvms(cls, cluster):
responseS = cls.apiclient.listSystemVms(cmds)
if isinstance(responseS, Iterable):
for svm in responseS:
if svm.hostid != cls.hosts[0].id:
if svm.hostid != cls.hosts[0].id and svm.state == 'Running':
systemVmIds.append(svm.id)
cmdv = listRouters.listRoutersCmd()
responseR = cls.apiclient.listRouters(cmdv)
if isinstance(responseR, Iterable):
for svm in responseR:
if svm.hostid != cls.hosts[0].id:
if svm.hostid != cls.hosts[0].id and svm.state == 'Running':
systemVmIds.append(svm.id)
numToMigrate = len(systemVmIds)
cls.logger.debug(f'system vms and routers to migrate -- {numToMigrate}')
cmdM = migrateSystemVm.migrateSystemVmCmd()
cmdM.hostId=cls.hosts[0].id
for id in systemVmIds:
cmdM.virtualmachineid=id
responseM = cls.apiclient.migrateSystemVm(cmdM)
cls.logger.debug(f'migrated {responseM}')
try:
responseM = cls.apiclient.migrateSystemVm(cmdM)
cls.logger.debug(f'migrated {responseM}')
except Exception as e:
# A system vm/router may have moved out of Running state (e.g. redundant
# router failover, or an in-progress restart from a previous test's cleanup)
# between the listSystemVms/listRouters call above and this migration attempt.
# Don't fail the whole test class setup for one such VM.
cls.logger.debug(f'Skipping migration of {id}, it may no longer be in Running state: {e}')


@classmethod
Expand Down
36 changes: 36 additions & 0 deletions test/integration/smoke/test_deploy_vms_in_parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
""" P1 for Deploy VM from ISO
"""
# Import Local Modules
import time

from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase
from marvin.lib.base import (Account,
Expand Down Expand Up @@ -123,6 +125,40 @@ def update_resource_limit(self, max=1):
)

def tearDown(self):
# Deleting the account only soft-deletes it; the account row (and
# its "needs cleanup" state) is purged asynchronously by the
# account.cleanup.interval background task. Deleting the domain
# right after the account can therefore race with that task and
# fail with "Can't delete the domain yet because it has N
# accounts to cleanup". Delete the account first, then retry the
# domain deletion for a bit to ride out that race.
try:
self.cleanup_resources(self.apiclient, [self.account])
except Exception as e:
self.debug("Warning: Exception during account cleanup : %s" % e)

retries_left = 15
while True:
try:
self.domain.delete(self.apiclient)
break
except Exception as e:
retries_left -= 1
if "accounts to cleanup" not in str(e):
raise Exception("Warning: Exception during cleanup : %s" % e)
Comment on lines +145 to +148
if retries_left <= 0:
# The account cleanup task can get permanently stuck detaching
# the account's data volume from an already-expunged VM (a
# known server-side race between VM expunge and account
# cleanup, unrelated to what this test verifies). Don't fail
# the test on that; just leave the domain/account behind for
# cleanup to retry indefinitely, and log it for visibility.
self.debug("Warning: giving up on domain cleanup, leaving it "
"behind for a later cleanup attempt: %s" % e)
break
time.sleep(5)

self.cleanup = []
super(TestDeployVMsInParallel, self).tearDown()

@attr(
Expand Down
1 change: 1 addition & 0 deletions test/integration/smoke/test_events_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ def test_01_events_resource(self):
diskofferingid=self.disk_offering.id
)
self.cleanup.append(volume)
time.sleep(10)
virtual_machine.attach_volume(
self.apiclient,
volume
Expand Down
Loading
Loading