You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ed...@apache.org on 2013/08/20 00:26:39 UTC
[2/7] git commit: updated refs/heads/master to 4fd09cb
CLOUDSTACK-4325: add more test cases for zone wide storage pool allocator
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/77e7ccbb
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/77e7ccbb
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/77e7ccbb
Branch: refs/heads/master
Commit: 77e7ccbbe1797a1aef6d4b0a219d4c9d2056a5e6
Parents: a7f3e1e
Author: Edison Su <ed...@citrix.com>
Authored: Sat Aug 17 12:37:35 2013 -0700
Committer: Edison Su <su...@gmail.com>
Committed: Mon Aug 19 15:25:04 2013 -0700
----------------------------------------------------------------------
.../storage/allocator/StorageAllocatorTest.java | 66 +++++++++++++++++++-
.../test/resources/storageContext.xml | 3 -
.../resource/SimulatorStorageProcessor.java | 12 +++-
3 files changed, 74 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/77e7ccbb/engine/storage/integration-test/test/org/apache/cloudstack/storage/allocator/StorageAllocatorTest.java
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/allocator/StorageAllocatorTest.java b/engine/storage/integration-test/test/org/apache/cloudstack/storage/allocator/StorageAllocatorTest.java
index 90696ca..2fc701a 100644
--- a/engine/storage/integration-test/test/org/apache/cloudstack/storage/allocator/StorageAllocatorTest.java
+++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/allocator/StorageAllocatorTest.java
@@ -22,6 +22,12 @@ import java.util.UUID;
import javax.inject.Inject;
+import com.cloud.configuration.Config;
+import com.cloud.configuration.ConfigurationVO;
+import com.cloud.configuration.dao.ConfigurationDao;
+import com.cloud.user.Account;
+import com.cloud.utils.db.DB;
+import com.cloud.vm.VMInstanceVO;
import junit.framework.Assert;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider;
@@ -87,6 +93,8 @@ public class StorageAllocatorTest {
StoragePoolDetailsDao poolDetailsDao;
@Inject
DataStoreProviderManager providerMgr;
+ @Inject
+ ConfigurationDao configDao;
Long dcId = 1l;
Long podId = 1l;
Long clusterId = 1l;
@@ -98,7 +106,13 @@ public class StorageAllocatorTest {
StoragePoolVO storage = null;
@Before
+ @DB
public void setup() throws Exception {
+ ConfigurationVO cfg = configDao.findByName(Config.VmAllocationAlgorithm.key());
+ if (cfg == null) {
+ ConfigurationVO configVO = new ConfigurationVO("test", "DEFAULT", "test", Config.VmAllocationAlgorithm.key(), "userdispersing", null);
+ configDao.persist(configVO);
+ }
ComponentContext.initComponentsLifeCycle();
}
@@ -120,7 +134,7 @@ public class StorageAllocatorTest {
cluster = clusterDao.persist(cluster);
clusterId = cluster.getId();
- DataStoreProvider provider = providerMgr.getDataStoreProvider("cloudstack primary data store provider");
+ DataStoreProvider provider = providerMgr.getDataStoreProvider(DataStoreProvider.DEFAULT_PRIMARY);
storage = new StoragePoolVO();
storage.setDataCenterId(dcId);
storage.setPodId(podId);
@@ -163,7 +177,7 @@ public class StorageAllocatorTest {
try {
createDb();
- DataStoreProvider provider = providerMgr.getDataStoreProvider("cloudstack primary data store provider");
+ DataStoreProvider provider = providerMgr.getDataStoreProvider(DataStoreProvider.DEFAULT_PRIMARY);
storage = new StoragePoolVO();
storage.setDataCenterId(dcId);
storage.setPodId(podId);
@@ -312,7 +326,10 @@ public class StorageAllocatorTest {
createDb();
StoragePoolVO pool = storagePoolDao.findById(storagePoolId);
+ pool.setHypervisor(HypervisorType.KVM);
pool.setScope(ScopeType.ZONE);
+ pool.setClusterId(null);
+ pool.setPodId(null);
storagePoolDao.update(pool.getId(), pool);
DiskProfile profile = new DiskProfile(volume, diskOffering, HypervisorType.KVM);
@@ -321,6 +338,8 @@ public class StorageAllocatorTest {
Mockito.when(
storageMgr.storagePoolHasEnoughSpace(Matchers.anyListOf(Volume.class),
Matchers.any(StoragePool.class))).thenReturn(true);
+ Mockito.when(storageMgr.storagePoolHasEnoughIops(Matchers.anyListOf(Volume.class),
+ Matchers.any(StoragePool.class))).thenReturn(true);
DeploymentPlan plan = new DataCenterDeployment(dcId, podId, clusterId, null, null, null);
int foundAcct = 0;
for (StoragePoolAllocator allocator : allocators) {
@@ -341,6 +360,49 @@ public class StorageAllocatorTest {
}
@Test
+ public void testCLOUDSTACK3481() {
+ try {
+ createDb();
+
+ StoragePoolVO pool = storagePoolDao.findById(storagePoolId);
+ pool.setHypervisor(HypervisorType.KVM);
+ pool.setScope(ScopeType.ZONE);
+ pool.setClusterId(null);
+ pool.setPodId(null);
+ storagePoolDao.update(pool.getId(), pool);
+
+
+ DiskProfile profile = new DiskProfile(volume, diskOffering, HypervisorType.KVM);
+ VirtualMachineProfile vmProfile = Mockito.mock(VirtualMachineProfile.class);
+ Account account = Mockito.mock(Account.class);
+ Mockito.when(account.getAccountId()).thenReturn(1L);
+ Mockito.when(vmProfile.getHypervisorType()).thenReturn(HypervisorType.KVM);
+ Mockito.when(vmProfile.getOwner()).thenReturn(account);
+ Mockito.when(
+ storageMgr.storagePoolHasEnoughSpace(Matchers.anyListOf(Volume.class),
+ Matchers.any(StoragePool.class))).thenReturn(true);
+ Mockito.when(storageMgr.storagePoolHasEnoughIops(Matchers.anyListOf(Volume.class),
+ Matchers.any(StoragePool.class))).thenReturn(true);
+ DeploymentPlan plan = new DataCenterDeployment(dcId, podId, clusterId, null, null, null);
+ int foundAcct = 0;
+ for (StoragePoolAllocator allocator : allocators) {
+ List<StoragePool> pools = allocator.allocateToPool(profile, vmProfile, plan, new ExcludeList(), 1);
+ if (!pools.isEmpty()) {
+ Assert.assertEquals(pools.get(0).getId(), storage.getId());
+ foundAcct++;
+ }
+ }
+
+ if (foundAcct > 1 || foundAcct == 0) {
+ Assert.fail();
+ }
+ } catch (Exception e) {
+ cleanDb();
+ Assert.fail();
+ }
+ }
+
+ @Test
public void testPoolStateIsNotUp() {
try {
createDb();
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/77e7ccbb/engine/storage/integration-test/test/resources/storageContext.xml
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/test/resources/storageContext.xml b/engine/storage/integration-test/test/resources/storageContext.xml
index f9c891a..664f1e3 100644
--- a/engine/storage/integration-test/test/resources/storageContext.xml
+++ b/engine/storage/integration-test/test/resources/storageContext.xml
@@ -47,7 +47,6 @@
<bean id="LocalStoragePoolAllocator" class="org.apache.cloudstack.storage.allocator.LocalStoragePoolAllocator"/>
<bean id="clusterScopeStoragePoolAllocator" class="org.apache.cloudstack.storage.allocator.ClusterScopeStoragePoolAllocator" />
<bean id="zoneWideStoragePoolAllocator" class="org.apache.cloudstack.storage.allocator.ZoneWideStoragePoolAllocator" />
- <bean id="garbageCollectingStoragePoolAllocator" class="org.apache.cloudstack.storage.allocator.GarbageCollectingStoragePoolAllocator"/>
<bean id="dataStoreProviderManagerImpl" class="org.apache.cloudstack.storage.datastore.provider.DataStoreProviderManagerImpl" />
<bean id="ancientDataMotionStrategy" class="org.apache.cloudstack.storage.motion.AncientDataMotionStrategy" />
<bean id="storageCacheManagerImpl" class="org.apache.cloudstack.storage.cache.manager.StorageCacheManagerImpl" />
@@ -62,7 +61,6 @@
<bean id="iSCSI" class="org.apache.cloudstack.storage.datastore.type.ISCSI" />
<bean id="ISO" class="org.apache.cloudstack.storage.image.format.ISO" />
<bean id="templateDataFactoryImpl" class="org.apache.cloudstack.storage.image.TemplateDataFactoryImpl" />
- <bean id="imageDataManagerImpl" class="org.apache.cloudstack.storage.image.manager.ImageDataManagerImpl" />
<bean id="imageStoreHelper" class="org.apache.cloudstack.storage.image.datastore.ImageStoreHelper" />
<bean id="imageFormatHelper" class="org.apache.cloudstack.storage.image.format.ImageFormatHelper" />
<bean id="templateServiceImpl" class="org.apache.cloudstack.storage.image.TemplateServiceImpl" />
@@ -82,7 +80,6 @@
<bean id="cloudStackImageStoreProviderImpl" class="org.apache.cloudstack.storage.datastore.provider.CloudStackImageStoreProviderImpl" />
<bean id="s3ImageStoreProviderImpl" class="org.apache.cloudstack.storage.datastore.provider.S3ImageStoreProviderImpl" />
<bean id="swiftImageStoreProviderImpl" class="org.apache.cloudstack.storage.datastore.provider.SwiftImageStoreProviderImpl" />
- <bean id="simulatorImageStoreProviderImpl" class="org.apache.cloudstack.storage.datastore.provider.SimulatorImageStoreProviderImpl" />
<bean id="BAREMETAL" class="org.apache.cloudstack.storage.image.format.BAREMETAL" />
<bean id="storagePoolAutomationImpl" class="com.cloud.storage.StoragePoolAutomationImpl" />
<bean id="AccountGuestVlanMapDaoImpl" class="com.cloud.network.dao.AccountGuestVlanMapDaoImpl" />
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/77e7ccbb/plugins/hypervisors/simulator/src/com/cloud/resource/SimulatorStorageProcessor.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/resource/SimulatorStorageProcessor.java b/plugins/hypervisors/simulator/src/com/cloud/resource/SimulatorStorageProcessor.java
index 12c2733..c7768aa 100644
--- a/plugins/hypervisors/simulator/src/com/cloud/resource/SimulatorStorageProcessor.java
+++ b/plugins/hypervisors/simulator/src/com/cloud/resource/SimulatorStorageProcessor.java
@@ -72,12 +72,20 @@ public class SimulatorStorageProcessor implements StorageProcessor {
@Override
public Answer copyVolumeFromImageCacheToPrimary(CopyCommand cmd) {
- return null;
+ VolumeObjectTO volume = new VolumeObjectTO();
+ volume.setPath(UUID.randomUUID().toString());
+ volume.setSize(100);
+ volume.setFormat(Storage.ImageFormat.RAW);
+ return new CopyCmdAnswer(volume);
}
@Override
public Answer copyVolumeFromPrimaryToSecondary(CopyCommand cmd) {
- return null;
+ VolumeObjectTO volume = new VolumeObjectTO();
+ volume.setPath(UUID.randomUUID().toString());
+ volume.setSize(100);
+ volume.setFormat(Storage.ImageFormat.RAW);
+ return new CopyCmdAnswer(volume);
}
@Override