cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edi...@apache.org
Subject [03/24] git commit: updated refs/heads/master to 81ff479
Date Thu, 26 Sep 2013 01:01:07 GMT
add test

Conflicts:

	engine/storage/integration-test/test/org/apache/cloudstack/storage/test/FakeDriverTestConfiguration.java


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/7b6aebc1
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/7b6aebc1
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/7b6aebc1

Branch: refs/heads/master
Commit: 7b6aebc1029088a65710f38f730bcd3b92fb1ad3
Parents: 5e94e16
Author: Edison Su <sudison@gmail.com>
Authored: Wed Sep 25 15:58:46 2013 -0700
Committer: Edison Su <sudison@gmail.com>
Committed: Wed Sep 25 15:58:46 2013 -0700

----------------------------------------------------------------------
 .../storage/test/ChildTestConfiguration.java    |  6 ---
 .../test/FakeDriverTestConfiguration.java       |  3 ++
 .../storage/test/MockStorageMotionStrategy.java | 24 +++++++++++-
 .../storage/test/SnapshotTestWithFakeData.java  | 39 +++++++++++++++++++-
 .../test/resource/fakeDriverTestContext.xml     |  3 +-
 .../storage/snapshot/SnapshotManagerImpl.java   |  4 --
 6 files changed, 66 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7b6aebc1/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/ChildTestConfiguration.java
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/ChildTestConfiguration.java
b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/ChildTestConfiguration.java
index 0f97f31..2724118 100644
--- a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/ChildTestConfiguration.java
+++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/ChildTestConfiguration.java
@@ -186,12 +186,6 @@ public class ChildTestConfiguration extends TestConfiguration {
         return Mockito.mock(VirtualMachineManager.class);
     }
 
-
-    @Bean
-    public SnapshotManager snapshotMgr() {
-        return Mockito.mock(SnapshotManager.class);
-    }
-
     @Bean
     public ResourceManager resourceMgr() {
         return Mockito.mock(ResourceManager.class);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7b6aebc1/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/FakeDriverTestConfiguration.java
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/FakeDriverTestConfiguration.java
b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/FakeDriverTestConfiguration.java
index 75eda90..943b73c 100644
--- a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/FakeDriverTestConfiguration.java
+++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/FakeDriverTestConfiguration.java
@@ -18,10 +18,12 @@
  */
 package org.apache.cloudstack.storage.test;
 
+
 import com.cloud.storage.snapshot.SnapshotScheduler;
 import com.cloud.storage.snapshot.SnapshotSchedulerImpl;
 import com.cloud.user.DomainManager;
 import com.cloud.utils.component.ComponentContext;
+
 import org.apache.cloudstack.engine.subsystem.api.storage.DataMotionStrategy;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider;
 import org.apache.cloudstack.engine.subsystem.api.storage.EndPointSelector;
@@ -48,6 +50,7 @@ public class FakeDriverTestConfiguration extends ChildTestConfiguration{
         return strategy;
     }
 
+
     @Bean
     public SnapshotScheduler SnapshotScheduler() {
         return Mockito.mock(SnapshotScheduler.class);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7b6aebc1/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/MockStorageMotionStrategy.java
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/MockStorageMotionStrategy.java
b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/MockStorageMotionStrategy.java
index 52ccf41..2a83689 100644
--- a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/MockStorageMotionStrategy.java
+++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/MockStorageMotionStrategy.java
@@ -19,7 +19,11 @@
 package org.apache.cloudstack.storage.test;
 
 import java.util.Map;
+import java.util.UUID;
 
+import com.cloud.agent.api.to.DataObjectType;
+import com.cloud.agent.api.to.DataTO;
+import com.cloud.storage.Storage;
 import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataMotionStrategy;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
@@ -29,6 +33,9 @@ import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
 
 import com.cloud.agent.api.to.VirtualMachineTO;
 import com.cloud.host.Host;
+import org.apache.cloudstack.storage.command.CopyCmdAnswer;
+import org.apache.cloudstack.storage.to.SnapshotObjectTO;
+import org.apache.cloudstack.storage.to.TemplateObjectTO;
 
 public class MockStorageMotionStrategy implements DataMotionStrategy {
 
@@ -45,7 +52,22 @@ public class MockStorageMotionStrategy implements DataMotionStrategy {
 
     @Override
     public Void copyAsync(DataObject srcData, DataObject destData, AsyncCompletionCallback<CopyCommandResult>
callback) {
-        CopyCommandResult result = new CopyCommandResult("something", null);
+        CopyCmdAnswer answer = null;
+        DataTO data = null;
+        if (destData.getType() == DataObjectType.SNAPSHOT) {
+            SnapshotObjectTO newSnapshot = new SnapshotObjectTO();
+            newSnapshot.setPath(UUID.randomUUID().toString());
+            data = newSnapshot;
+        } else if (destData.getType() == DataObjectType.TEMPLATE) {
+            TemplateObjectTO newTemplate = new TemplateObjectTO();
+            newTemplate.setPath(UUID.randomUUID().toString());
+            newTemplate.setFormat(Storage.ImageFormat.QCOW2);
+            newTemplate.setSize(10L);
+            newTemplate.setPhysicalSize(10L);
+            data = newTemplate;
+        }
+        answer = new CopyCmdAnswer(data);
+        CopyCommandResult result = new CopyCommandResult("something", answer);
         callback.complete(result);
         return null;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7b6aebc1/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/SnapshotTestWithFakeData.java
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/SnapshotTestWithFakeData.java
b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/SnapshotTestWithFakeData.java
index c98f705..d546505 100644
--- a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/SnapshotTestWithFakeData.java
+++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/SnapshotTestWithFakeData.java
@@ -29,6 +29,7 @@ import com.cloud.storage.VolumeVO;
 import com.cloud.storage.dao.SnapshotDao;
 import com.cloud.storage.dao.VolumeDao;
 import com.cloud.utils.component.ComponentContext;
+import com.cloud.utils.db.DB;
 import junit.framework.Assert;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
@@ -61,10 +62,17 @@ import java.net.URISyntaxException;
 import java.util.HashSet;
 import java.util.Set;
 import java.util.UUID;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Executor;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
 
 @RunWith(SpringJUnit4ClassRunner.class)
 @ContextConfiguration(locations = { "classpath:/fakeDriverTestContext.xml" })
-public class SnapshotTestWithFakeData {
+public class SnapshotTestWithFakeData  {
     @Inject
     SnapshotService snapshotService;
     @Inject
@@ -85,6 +93,7 @@ public class SnapshotTestWithFakeData {
     VolumeService volumeService;
     @Inject
     VolumeDataFactory volumeDataFactory;
+    VolumeInfo vol = null;
     FakePrimaryDataStoreDriver driver = new FakePrimaryDataStoreDriver();
 
     @Before
@@ -191,4 +200,32 @@ public class SnapshotTestWithFakeData {
         Assert.assertTrue(result == null);
     }
 
+    @Test
+    public void testConcurrentSnapshot() throws URISyntaxException, InterruptedException,
ExecutionException {
+        DataStore store = createDataStore();
+        FakePrimaryDataStoreDriver dataStoreDriver = (FakePrimaryDataStoreDriver)store.getDriver();
+        dataStoreDriver.makeTakeSnapshotSucceed(true);
+        final VolumeInfo volumeInfo = createVolume(1L, store);
+        Assert.assertTrue(volumeInfo.getState() == Volume.State.Ready);
+        vol = volumeInfo;
+        ExecutorService pool = Executors.newFixedThreadPool(2);
+        boolean result = false;
+        Future<Boolean> future = null;
+        for(int i = 0; i < 1; i++) {
+           future =  pool.submit(new Callable<Boolean>() {
+                @Override
+                public Boolean call() throws Exception {
+                    boolean r = false;
+                    try {
+                        SnapshotInfo newSnapshot = volumeService.takeSnapshot(vol);
+                        Assert.assertTrue(newSnapshot != null);
+                    } catch (Exception e) {
+                        r = false;
+                    }
+                    return true;
+                }
+            });
+        }
+        future.get();
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7b6aebc1/engine/storage/integration-test/test/resource/fakeDriverTestContext.xml
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/test/resource/fakeDriverTestContext.xml b/engine/storage/integration-test/test/resource/fakeDriverTestContext.xml
index 3abcf08..98209de 100644
--- a/engine/storage/integration-test/test/resource/fakeDriverTestContext.xml
+++ b/engine/storage/integration-test/test/resource/fakeDriverTestContext.xml
@@ -48,7 +48,6 @@
     <bean id="clusterScopeStoragePoolAllocator" class="org.apache.cloudstack.storage.allocator.ClusterScopeStoragePoolAllocator"
/>
     <bean id="zoneWideStoragePoolAllocator" class="org.apache.cloudstack.storage.allocator.ZoneWideStoragePoolAllocator"
/>
     <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"
 />
     <bean id="storageCacheRandomAllocator" class="org.apache.cloudstack.storage.cache.allocator.StorageCacheRandomAllocator"
/>
     <bean id="xenserverSnapshotStrategy" class="org.apache.cloudstack.storage.snapshot.XenserverSnapshotStrategy"
/>
@@ -84,4 +83,6 @@
     <bean id="AccountGuestVlanMapDaoImpl" class="com.cloud.network.dao.AccountGuestVlanMapDaoImpl"
/>
     <bean id="StorageCacheReplacementAlgorithm" class="org.apache.cloudstack.storage.cache.manager.StorageCacheReplacementAlgorithmLRU"
/>
     <bean id="ServiceOfferingDetailsDao" class="com.cloud.service.dao.ServiceOfferingDetailsDaoImpl"
/>
+    <bean id='SnapshotManagerImpl' class='com.cloud.storage.snapshot.SnapshotManagerImpl'/>
+    <bean id='SnapshotPolicyDao' class='com.cloud.storage.dao.SnapshotPolicyDaoImpl'/>
 </beans>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7b6aebc1/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
index a884b95..6574b7f 100755
--- a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
+++ b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
@@ -140,8 +140,6 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
     @Inject
     protected VMTemplateDao _templateDao;
     @Inject
-    protected HostDao _hostDao;
-    @Inject
     protected UserVmDao _vmDao;
     @Inject
     protected VolumeDao _volsDao;
@@ -158,8 +156,6 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
     @Inject
     protected PrimaryDataStoreDao _storagePoolDao;
     @Inject
-    protected EventDao _eventDao;
-    @Inject
     protected SnapshotPolicyDao _snapshotPolicyDao = null;
     @Inject
     protected SnapshotScheduleDao _snapshotScheduleDao;


Mime
View raw message