Add unit test back for async-job after job project structure re-org
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/3327371f Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/3327371f Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/3327371f Branch: refs/heads/vmsync Commit: 3327371f97b7137f6e837c080e4ec5cc54afa525 Parents: 70728a7 Author: Kelven Yang <[email protected]> Authored: Tue Jun 4 17:16:12 2013 -0700 Committer: Kelven Yang <[email protected]> Committed: Tue Jun 4 17:16:12 2013 -0700 ---------------------------------------------------------------------- server/pom.xml | 2 + .../com/cloud/async/AsyncJobTestConfiguration.java | 23 +- .../cloud/async/MockVirtualMachineManagerImpl.java | 198 ++++++-------- .../cloud/async/SyncQueueTestConfiguration.java | 14 +- .../test/com/cloud/async/TestAsyncJobManager.java | 21 +- .../test/com/cloud/async/TestSyncQueueManager.java | 3 + server/test/resources/AsyncJobTestContext.xml | 7 +- 7 files changed, 126 insertions(+), 142 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3327371f/server/pom.xml ---------------------------------------------------------------------- diff --git a/server/pom.xml b/server/pom.xml index 758a1de..dfbf07d 100644 --- a/server/pom.xml +++ b/server/pom.xml @@ -125,7 +125,9 @@ <configuration> <testExcludes> <exclude>**/com/cloud/upgrade/*.java</exclude> +<!-- <exclude>**/com/cloud/async/*.java</exclude> +--> </testExcludes> </configuration> <goals> http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3327371f/server/test/com/cloud/async/AsyncJobTestConfiguration.java ---------------------------------------------------------------------- diff --git a/server/test/com/cloud/async/AsyncJobTestConfiguration.java b/server/test/com/cloud/async/AsyncJobTestConfiguration.java index 03dff84..7195a75 100644 --- a/server/test/com/cloud/async/AsyncJobTestConfiguration.java +++ b/server/test/com/cloud/async/AsyncJobTestConfiguration.java @@ -14,23 +14,26 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. + package com.cloud.async; +import org.apache.cloudstack.framework.jobs.dao.AsyncJobDao; +import org.apache.cloudstack.framework.jobs.dao.AsyncJobDaoImpl; +import org.apache.cloudstack.framework.jobs.dao.AsyncJobJoinMapDao; +import org.apache.cloudstack.framework.jobs.dao.AsyncJobJoinMapDaoImpl; +import org.apache.cloudstack.framework.jobs.dao.AsyncJobJournalDao; +import org.apache.cloudstack.framework.jobs.dao.AsyncJobJournalDaoImpl; +import org.apache.cloudstack.framework.jobs.dao.SyncQueueDao; +import org.apache.cloudstack.framework.jobs.dao.SyncQueueDaoImpl; +import org.apache.cloudstack.framework.jobs.dao.SyncQueueItemDao; +import org.apache.cloudstack.framework.jobs.dao.SyncQueueItemDaoImpl; +import org.apache.cloudstack.framework.jobs.impl.SyncQueueManager; +import org.apache.cloudstack.framework.jobs.impl.SyncQueueManagerImpl; import org.mockito.Mockito; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import com.cloud.api.ApiDispatcher; -import com.cloud.async.dao.AsyncJobDao; -import com.cloud.async.dao.AsyncJobDaoImpl; -import com.cloud.async.dao.AsyncJobJoinMapDao; -import com.cloud.async.dao.AsyncJobJoinMapDaoImpl; -import com.cloud.async.dao.AsyncJobJournalDao; -import com.cloud.async.dao.AsyncJobJournalDaoImpl; -import com.cloud.async.dao.SyncQueueDao; -import com.cloud.async.dao.SyncQueueDaoImpl; -import com.cloud.async.dao.SyncQueueItemDao; -import com.cloud.async.dao.SyncQueueItemDaoImpl; import com.cloud.cluster.ClusterManager; import com.cloud.configuration.ConfigurationManager; import com.cloud.configuration.dao.ConfigurationDao; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3327371f/server/test/com/cloud/async/MockVirtualMachineManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/test/com/cloud/async/MockVirtualMachineManagerImpl.java b/server/test/com/cloud/async/MockVirtualMachineManagerImpl.java index e42893b..1408afd 100644 --- a/server/test/com/cloud/async/MockVirtualMachineManagerImpl.java +++ b/server/test/com/cloud/async/MockVirtualMachineManagerImpl.java @@ -23,6 +23,8 @@ import java.util.Map; import javax.naming.ConfigurationException; +import org.apache.cloudstack.storage.datastore.db.StoragePoolVO; + import com.cloud.agent.api.to.NicTO; import com.cloud.agent.api.to.VirtualMachineTO; import com.cloud.deploy.DeployDestination; @@ -43,6 +45,7 @@ import com.cloud.service.ServiceOfferingVO; import com.cloud.storage.DiskOfferingVO; import com.cloud.storage.StoragePool; import com.cloud.storage.VMTemplateVO; +import com.cloud.storage.VolumeVO; import com.cloud.user.Account; import com.cloud.user.User; import com.cloud.utils.Pair; @@ -117,83 +120,69 @@ public class MockVirtualMachineManagerImpl implements VirtualMachineManager { } @Override - public <T extends VMInstanceVO> T allocate(T vm, VMTemplateVO template, + public boolean allocate(String vmInstanceName, VMTemplateVO template, ServiceOfferingVO serviceOffering, Pair<? extends DiskOfferingVO, Long> rootDiskOffering, List<Pair<DiskOfferingVO, Long>> dataDiskOfferings, List<Pair<NetworkVO, NicProfile>> networks, Map<Param, Object> params, DeploymentPlan plan, - HypervisorType hyperType, Account owner) - throws InsufficientCapacityException { - // TODO Auto-generated method stub - return null; - } - - @Override - public <T extends VMInstanceVO> T allocate(T vm, VMTemplateVO template, - ServiceOfferingVO serviceOffering, Long rootSize, - Pair<DiskOfferingVO, Long> dataDiskOffering, - List<Pair<NetworkVO, NicProfile>> networks, DeploymentPlan plan, - HypervisorType hyperType, Account owner) - throws InsufficientCapacityException { + HypervisorType hyperType, Account owner) { // TODO Auto-generated method stub - return null; + return false; } @Override - public <T extends VMInstanceVO> T allocate(T vm, VMTemplateVO template, + public boolean allocate(String vmInstanceName, VMTemplateVO template, ServiceOfferingVO serviceOffering, List<Pair<NetworkVO, NicProfile>> networkProfiles, - DeploymentPlan plan, HypervisorType hyperType, Account owner) - throws InsufficientCapacityException { + DeploymentPlan plan, HypervisorType hyperType, Account owner) { // TODO Auto-generated method stub - return null; + return false; } @Override - public <T extends VMInstanceVO> T start(T vm, Map<Param, Object> params, - User caller, Account account) throws InsufficientCapacityException, - ResourceUnavailableException { + public void start(String vmUuid, Map<Param, Object> params, + @Deprecated User caller, @Deprecated Account account) { // TODO Auto-generated method stub - return null; + } @Override - public <T extends VMInstanceVO> T start(T vm, Map<Param, Object> params, - User caller, Account account, DeploymentPlan planToDeploy) - throws InsufficientCapacityException, ResourceUnavailableException { + public void start(String vmUuid, Map<Param, Object> params, + @Deprecated User caller, @Deprecated Account account, + DeploymentPlan planToDeploy) { // TODO Auto-generated method stub - return null; + } @Override - public <T extends VMInstanceVO> boolean stop(T vm, User caller, - Account account) throws ResourceUnavailableException { + public void stop(String vmUuid, @Deprecated User caller, + @Deprecated Account account) { // TODO Auto-generated method stub - return false; + } @Override - public <T extends VMInstanceVO> boolean expunge(T vm, User caller, - Account account) throws ResourceUnavailableException { + public void expunge(String vmUuid, @Deprecated User caller, + @Deprecated Account account) { // TODO Auto-generated method stub - return false; + } @Override - public <T extends VMInstanceVO> void registerGuru(Type type, - VirtualMachineGuru<T> guru) { + public void registerGuru(Type type, VirtualMachineGuru guru) { // TODO Auto-generated method stub } - public <T extends VMInstanceVO> VirtualMachineGuru<T> getVmGuru(T vm) { + @Override + public Collection<VirtualMachineGuru> getRegisteredGurus() { // TODO Auto-generated method stub - return null; - } + return null; + } @Override - public Collection<VirtualMachineGuru<? extends VMInstanceVO>> getRegisteredGurus() { + public VirtualMachineGuru getVmGuru(VirtualMachine vm) { // TODO Auto-generated method stub return null; } @@ -206,50 +195,44 @@ public class MockVirtualMachineManagerImpl implements VirtualMachineManager { } @Override - public <T extends VMInstanceVO> T advanceStart(T vm, - Map<Param, Object> params, User caller, Account account) + public void advanceStart(String vmUuid, Map<Param, Object> params, + @Deprecated User caller, @Deprecated Account account) throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException, OperationTimedoutException { // TODO Auto-generated method stub - return null; + } @Override - public <T extends VMInstanceVO> T advanceStart(T vm, - Map<Param, Object> params, User caller, Account account, + public void advanceStart(String vmUuid, Map<Param, Object> params, + @Deprecated User caller, @Deprecated Account account, DeploymentPlan planToDeploy) throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException, OperationTimedoutException { // TODO Auto-generated method stub - return null; + } @Override - public <T extends VMInstanceVO> boolean advanceStop(T vm, boolean forced, - User caller, Account account) throws ResourceUnavailableException, - OperationTimedoutException, ConcurrentOperationException { + public void advanceStop(String vmUuid, boolean cleanup, + @Deprecated User caller, @Deprecated Account account) + throws ResourceUnavailableException, OperationTimedoutException, + ConcurrentOperationException { // TODO Auto-generated method stub - return false; + } @Override - public <T extends VMInstanceVO> boolean advanceExpunge(T vm, User caller, - Account account) throws ResourceUnavailableException, + public void advanceExpunge(String vmUuid, @Deprecated User caller, + @Deprecated Account account) throws ResourceUnavailableException, OperationTimedoutException, ConcurrentOperationException { // TODO Auto-generated method stub - return false; - } - - @Override - public <T extends VMInstanceVO> boolean remove(T vm, User caller, - Account account) { - // TODO Auto-generated method stub - return false; + } @Override - public <T extends VMInstanceVO> boolean destroy(T vm, User caller, - Account account) throws AgentUnavailableException, + public boolean destroy(String vmUuid, @Deprecated User caller, + @Deprecated Account account) throws ResourceUnavailableException, OperationTimedoutException, ConcurrentOperationException { // TODO Auto-generated method stub return false; @@ -264,7 +247,7 @@ public class MockVirtualMachineManagerImpl implements VirtualMachineManager { } @Override - public <T extends VMInstanceVO> T migrate(T vm, long srcHostId, + public VirtualMachine migrate(String vmUuid, long srcHostId, DeployDestination dest) throws ResourceUnavailableException, ConcurrentOperationException, ManagementServerException, VirtualMachineMigrationException { @@ -273,43 +256,30 @@ public class MockVirtualMachineManagerImpl implements VirtualMachineManager { } @Override - public <T extends VMInstanceVO> T reboot(T vm, Map<Param, Object> params, - User caller, Account account) throws InsufficientCapacityException, - ResourceUnavailableException { - // TODO Auto-generated method stub - return null; - } - - @Override - public <T extends VMInstanceVO> T advanceReboot(T vm, - Map<Param, Object> params, User caller, Account account) - throws InsufficientCapacityException, ResourceUnavailableException, - ConcurrentOperationException, OperationTimedoutException { - // TODO Auto-generated method stub - return null; - } - - @Override - public VMInstanceVO findByIdAndType(Type type, long vmId) { + public VirtualMachine migrateWithStorage(String vmUuid, long srcId, + long destId, Map<VolumeVO, StoragePoolVO> volumeToPool) + throws ResourceUnavailableException, ConcurrentOperationException, + ManagementServerException, VirtualMachineMigrationException { // TODO Auto-generated method stub return null; } @Override - public boolean isVirtualMachineUpgradable(VirtualMachine vm, - ServiceOffering offering) { + public void reboot(String vmUuid, User caller, Account account) { // TODO Auto-generated method stub - return false; + } @Override - public VMInstanceVO findById(long vmId) { + public void advanceReboot(String vmUuid, User caller, Account account) + throws InsufficientCapacityException, ResourceUnavailableException, + ConcurrentOperationException, OperationTimedoutException { // TODO Auto-generated method stub - return null; + } @Override - public <T extends VMInstanceVO> T storageMigration(T vm, + public VirtualMachine storageMigration(String vmUuid, StoragePool storagePoolId) { // TODO Auto-generated method stub return null; @@ -352,55 +322,57 @@ public class MockVirtualMachineManagerImpl implements VirtualMachineManager { } @Override - public NicTO toNicTO(NicProfile nic, HypervisorType hypervisorType) { + public VirtualMachineTO toVmTO(VirtualMachineProfile profile) { // TODO Auto-generated method stub return null; } @Override - public VirtualMachineTO toVmTO( - VirtualMachineProfile profile) { - // TODO Auto-generated method stub - return null; - } - - @Override - public VMInstanceVO reConfigureVm(VMInstanceVO vm, + public boolean reConfigureVm(VirtualMachine vm, ServiceOffering newServiceOffering, boolean sameHost) throws ResourceUnavailableException, ConcurrentOperationException { // TODO Auto-generated method stub - return null; + return false; } @Override - public VMInstanceVO findHostAndMigrate(Type vmType, VMInstanceVO vm, - Long newSvcOfferingId) throws InsufficientCapacityException, - ConcurrentOperationException, ResourceUnavailableException, - VirtualMachineMigrationException, ManagementServerException { + public boolean findHostAndMigrate(String vmUuid, Long newSvcOfferingId) + throws InsufficientCapacityException, ConcurrentOperationException, + ResourceUnavailableException, VirtualMachineMigrationException, + ManagementServerException { // TODO Auto-generated method stub - return null; + return false; } @Override - public <T extends VMInstanceVO> T migrateForScale(T vm, long srcHostId, + public boolean migrateForScale(String vmUuid, long srcHostId, DeployDestination dest, Long newSvcOfferingId) throws ResourceUnavailableException, ConcurrentOperationException, ManagementServerException, VirtualMachineMigrationException { // TODO Auto-generated method stub + return false; + } + + @Override + public VirtualMachine processVmStartWork(String vmUuid, + Map<Param, Object> params, User caller, Account account, + DeploymentPlan planToDeploy) throws InsufficientCapacityException, + ConcurrentOperationException, ResourceUnavailableException { + // TODO Auto-generated method stub return null; } - + @Override - public <T extends VMInstanceVO> T processVmStartWork(T vm, Map<VirtualMachineProfile.Param, Object> params, User caller, Account account, DeploymentPlan planToDeploy) - throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException { - - return vm; - } - + public boolean processVmStopWork(String vmUuid, boolean forced, User user, + Account account) throws AgentUnavailableException, + OperationTimedoutException, ConcurrentOperationException { + // TODO Auto-generated method stub + return false; + } + @Override - public <T extends VMInstanceVO> boolean processVmStopWork(T vm, boolean forced, User user, Account account) - throws AgentUnavailableException, OperationTimedoutException, ConcurrentOperationException { - - return true; + public NicTO toNicTO(NicProfile nic, HypervisorType hypervisorType) { + // TODO Auto-generated method stub + return null; } } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3327371f/server/test/com/cloud/async/SyncQueueTestConfiguration.java ---------------------------------------------------------------------- diff --git a/server/test/com/cloud/async/SyncQueueTestConfiguration.java b/server/test/com/cloud/async/SyncQueueTestConfiguration.java index 424a3d6..e7826a7 100644 --- a/server/test/com/cloud/async/SyncQueueTestConfiguration.java +++ b/server/test/com/cloud/async/SyncQueueTestConfiguration.java @@ -16,16 +16,18 @@ // under the License. package com.cloud.async; +import org.apache.cloudstack.framework.jobs.dao.AsyncJobJoinMapDao; +import org.apache.cloudstack.framework.jobs.dao.AsyncJobJoinMapDaoImpl; +import org.apache.cloudstack.framework.jobs.dao.SyncQueueDao; +import org.apache.cloudstack.framework.jobs.dao.SyncQueueDaoImpl; +import org.apache.cloudstack.framework.jobs.dao.SyncQueueItemDao; +import org.apache.cloudstack.framework.jobs.dao.SyncQueueItemDaoImpl; +import org.apache.cloudstack.framework.jobs.impl.SyncQueueManager; +import org.apache.cloudstack.framework.jobs.impl.SyncQueueManagerImpl; import org.mockito.Mockito; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import com.cloud.async.dao.AsyncJobJoinMapDao; -import com.cloud.async.dao.AsyncJobJoinMapDaoImpl; -import com.cloud.async.dao.SyncQueueDao; -import com.cloud.async.dao.SyncQueueDaoImpl; -import com.cloud.async.dao.SyncQueueItemDao; -import com.cloud.async.dao.SyncQueueItemDaoImpl; import com.cloud.configuration.ConfigurationManager; import com.cloud.configuration.dao.ConfigurationDao; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3327371f/server/test/com/cloud/async/TestAsyncJobManager.java ---------------------------------------------------------------------- diff --git a/server/test/com/cloud/async/TestAsyncJobManager.java b/server/test/com/cloud/async/TestAsyncJobManager.java index 93b7972..6202e0d 100644 --- a/server/test/com/cloud/async/TestAsyncJobManager.java +++ b/server/test/com/cloud/async/TestAsyncJobManager.java @@ -24,6 +24,18 @@ import java.util.List; import javax.inject.Inject; import junit.framework.TestCase; +import org.apache.cloudstack.framework.jobs.AsyncJob; +import org.apache.cloudstack.framework.jobs.AsyncJobConstants; +import org.apache.cloudstack.framework.jobs.AsyncJobManager; +import org.apache.cloudstack.framework.jobs.dao.AsyncJobJoinMapDao; +import org.apache.cloudstack.framework.jobs.dao.AsyncJobJournalDao; +import org.apache.cloudstack.framework.jobs.dao.SyncQueueDao; +import org.apache.cloudstack.framework.jobs.dao.SyncQueueItemDao; +import org.apache.cloudstack.framework.jobs.impl.AsyncJobJoinMapVO; +import org.apache.cloudstack.framework.jobs.impl.AsyncJobJournalVO; +import org.apache.cloudstack.framework.jobs.impl.AsyncJobMonitor; +import org.apache.cloudstack.framework.jobs.impl.SyncQueueItemVO; +import org.apache.cloudstack.framework.jobs.impl.SyncQueueVO; import org.apache.cloudstack.framework.messagebus.MessageBus; import org.apache.cloudstack.framework.messagebus.PublishScope; import org.apache.cloudstack.messagebus.TopicConstants; @@ -36,13 +48,6 @@ import org.mockito.Mockito; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import com.cloud.async.AsyncJobJournalVO; -import com.cloud.async.AsyncJobManager; -import com.cloud.async.AsyncJobMonitor; -import com.cloud.async.dao.AsyncJobJoinMapDao; -import com.cloud.async.dao.AsyncJobJournalDao; -import com.cloud.async.dao.SyncQueueDao; -import com.cloud.async.dao.SyncQueueItemDao; import com.cloud.cluster.ClusterManager; import com.cloud.user.AccountManager; import com.cloud.user.AccountVO; @@ -212,7 +217,7 @@ public class TestAsyncJobManager extends TestCase { }); thread.start(); - jobMonitor.registerActiveTask(1, 1, false); + jobMonitor.registerActiveTask(1); asyncMgr.waitAndCheck(new String[] {"VM"}, 5000L, 10000L, new Predicate() { public boolean checkCondition() { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3327371f/server/test/com/cloud/async/TestSyncQueueManager.java ---------------------------------------------------------------------- diff --git a/server/test/com/cloud/async/TestSyncQueueManager.java b/server/test/com/cloud/async/TestSyncQueueManager.java index 4c55427..f6af7b3 100644 --- a/server/test/com/cloud/async/TestSyncQueueManager.java +++ b/server/test/com/cloud/async/TestSyncQueueManager.java @@ -22,6 +22,9 @@ import javax.inject.Inject; import junit.framework.TestCase; +import org.apache.cloudstack.framework.jobs.impl.SyncQueueItemVO; +import org.apache.cloudstack.framework.jobs.impl.SyncQueueManager; +import org.apache.cloudstack.framework.jobs.impl.SyncQueueVO; import org.apache.log4j.Logger; import org.junit.After; import org.junit.Assert; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3327371f/server/test/resources/AsyncJobTestContext.xml ---------------------------------------------------------------------- diff --git a/server/test/resources/AsyncJobTestContext.xml b/server/test/resources/AsyncJobTestContext.xml index 3674f15..fc8085e 100644 --- a/server/test/resources/AsyncJobTestContext.xml +++ b/server/test/resources/AsyncJobTestContext.xml @@ -27,29 +27,26 @@ <bean id="componentContext" class="com.cloud.utils.component.ComponentContext" /> <bean id="transactionContextBuilder" class="com.cloud.utils.db.TransactionContextBuilder" /> - <bean id="actionEventInterceptor" class="com.cloud.event.ActionEventInterceptor" /> <bean id="instantiatePostProcessor" class="com.cloud.utils.component.ComponentInstantiationPostProcessor"> <property name="Interceptors"> <list> <ref bean="transactionContextBuilder" /> - <ref bean="actionEventInterceptor" /> </list> </property> </bean> <bean id="asyncJobManagerImpl" class="com.cloud.async.AsyncJobManagerImpl"> - <property name="defaultDispatcher" value="ApiAsyncJobDispatcher" /> </bean> <bean id="ApiAsyncJobDispatcher" class="com.cloud.api.ApiAsyncJobDispatcher"> <property name="name" value="ApiAsyncJobDispatcher" /> </bean> - <bean id="asyncJobMonitor" class="com.cloud.async.AsyncJobMonitor"> + <bean id="asyncJobMonitor" class="org.apache.cloudstack.framework.jobs.impl.AsyncJobMonitor"> <property name="inactivityWarningThresholdMs" value="5" /> <property name="InactivityCheckIntervalMs" value="1" /> </bean> <bean id="messageBus" class = "org.apache.cloudstack.framework.messagebus.MessageBusBase" /> - <bean class="com.cloud.async.AsyncJobTestConfiguration" /> + <bean id="AsyncJobTestConfiguration" class="com.cloud.async.AsyncJobTestConfiguration" /> </beans>
