use of com.cloud.agent.api.to.VirtualMachineTO in project cloudstack by apache.
the class NotAValidCommand method testStartCommand.
@Test
public void testStartCommand() {
final VirtualMachineTO vm = Mockito.mock(VirtualMachineTO.class);
final com.cloud.host.Host host = Mockito.mock(com.cloud.host.Host.class);
final StartCommand startCommand = new StartCommand(vm, host, false);
final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
assertNotNull(wrapper);
final Answer answer = wrapper.execute(startCommand, citrixResourceBase);
verify(citrixResourceBase, times(1)).getConnection();
assertFalse(answer.getResult());
}
use of com.cloud.agent.api.to.VirtualMachineTO in project cloudstack by apache.
the class VmwareStorageMotionStrategyTest method testMigrateWithinClusterFailure.
@Test
public void testMigrateWithinClusterFailure() throws Exception {
Host srcHost = mock(Host.class);
Host destHost = mock(Host.class);
when(srcHost.getClusterId()).thenReturn(1L);
when(destHost.getClusterId()).thenReturn(1L);
Map<VolumeInfo, DataStore> volumeMap = new HashMap<VolumeInfo, DataStore>();
VirtualMachineTO to = mock(VirtualMachineTO.class);
when(to.getId()).thenReturn(6L);
VMInstanceVO instance = mock(VMInstanceVO.class);
when(instanceDao.findById(6L)).thenReturn(instance);
MockContext<CommandResult> context = new MockContext<CommandResult>(null, null, volumeMap);
AsyncCallbackDispatcher<VmwareStorageMotionStrategyTest, CopyCommandResult> caller = AsyncCallbackDispatcher.create(this);
caller.setCallback(caller.getTarget().mockCallBack(null, null)).setContext(context);
MigrateWithStorageAnswer migAnswerMock = mock(MigrateWithStorageAnswer.class);
when(migAnswerMock.getResult()).thenReturn(false);
when(agentMgr.send(anyLong(), isA(MigrateWithStorageCommand.class))).thenReturn(migAnswerMock);
strategy.copyAsync(volumeMap, to, srcHost, destHost, caller);
assertFalse("Migration within cluster didn't fail.", result.isSuccess());
}
use of com.cloud.agent.api.to.VirtualMachineTO in project cloudstack by apache.
the class VmwareStorageMotionStrategyTest method testMigrateWithinClusterSuccess.
@Test
public void testMigrateWithinClusterSuccess() throws Exception {
Host srcHost = mock(Host.class);
Host destHost = mock(Host.class);
when(srcHost.getClusterId()).thenReturn(1L);
when(destHost.getClusterId()).thenReturn(1L);
Map<VolumeInfo, DataStore> volumeMap = new HashMap<VolumeInfo, DataStore>();
VirtualMachineTO to = mock(VirtualMachineTO.class);
when(to.getId()).thenReturn(6L);
VMInstanceVO instance = mock(VMInstanceVO.class);
when(instanceDao.findById(6L)).thenReturn(instance);
MockContext<CommandResult> context = new MockContext<CommandResult>(null, null, volumeMap);
AsyncCallbackDispatcher<VmwareStorageMotionStrategyTest, CopyCommandResult> caller = AsyncCallbackDispatcher.create(this);
caller.setCallback(caller.getTarget().mockCallBack(null, null)).setContext(context);
MigrateWithStorageAnswer migAnswerMock = mock(MigrateWithStorageAnswer.class);
when(migAnswerMock.getResult()).thenReturn(true);
when(agentMgr.send(anyLong(), isA(MigrateWithStorageCommand.class))).thenReturn(migAnswerMock);
strategy.copyAsync(volumeMap, to, srcHost, destHost, caller);
assertTrue("Migration within cluster isn't successful.", result.isSuccess());
}
use of com.cloud.agent.api.to.VirtualMachineTO in project cloudstack by apache.
the class VmwareStorageMotionStrategyTest method testMigrateAcrossClusterSuccess.
@Test
public void testMigrateAcrossClusterSuccess() throws Exception {
Host srcHost = mock(Host.class);
Host destHost = mock(Host.class);
when(srcHost.getClusterId()).thenReturn(1L);
when(destHost.getClusterId()).thenReturn(2L);
Map<VolumeInfo, DataStore> volumeMap = new HashMap<VolumeInfo, DataStore>();
VirtualMachineTO to = mock(VirtualMachineTO.class);
when(to.getId()).thenReturn(6L);
VMInstanceVO instance = mock(VMInstanceVO.class);
when(instanceDao.findById(6L)).thenReturn(instance);
MockContext<CommandResult> context = new MockContext<CommandResult>(null, null, volumeMap);
AsyncCallbackDispatcher<VmwareStorageMotionStrategyTest, CopyCommandResult> caller = AsyncCallbackDispatcher.create(this);
caller.setCallback(caller.getTarget().mockCallBack(null, null)).setContext(context);
MigrateWithStorageAnswer migAnswerMock = mock(MigrateWithStorageAnswer.class);
when(migAnswerMock.getResult()).thenReturn(true);
when(agentMgr.send(anyLong(), isA(MigrateWithStorageCommand.class))).thenReturn(migAnswerMock);
strategy.copyAsync(volumeMap, to, srcHost, destHost, caller);
assertTrue("Migration across cluster isn't successful.", result.isSuccess());
}
use of com.cloud.agent.api.to.VirtualMachineTO in project cloudstack by apache.
the class VmwareStorageMotionStrategyTest method testMigrateAcrossClusterFailure.
@Test
public void testMigrateAcrossClusterFailure() throws Exception {
Host srcHost = mock(Host.class);
Host destHost = mock(Host.class);
when(srcHost.getClusterId()).thenReturn(1L);
when(destHost.getClusterId()).thenReturn(2L);
Map<VolumeInfo, DataStore> volumeMap = new HashMap<VolumeInfo, DataStore>();
VirtualMachineTO to = mock(VirtualMachineTO.class);
when(to.getId()).thenReturn(6L);
VMInstanceVO instance = mock(VMInstanceVO.class);
when(instanceDao.findById(6L)).thenReturn(instance);
MockContext<CommandResult> context = new MockContext<CommandResult>(null, null, volumeMap);
AsyncCallbackDispatcher<VmwareStorageMotionStrategyTest, CopyCommandResult> caller = AsyncCallbackDispatcher.create(this);
caller.setCallback(caller.getTarget().mockCallBack(null, null)).setContext(context);
MigrateWithStorageAnswer migAnswerMock = mock(MigrateWithStorageAnswer.class);
when(migAnswerMock.getResult()).thenReturn(false);
when(agentMgr.send(anyLong(), isA(MigrateWithStorageCommand.class))).thenReturn(migAnswerMock);
strategy.copyAsync(volumeMap, to, srcHost, destHost, caller);
assertFalse("Migration across cluster didn't fail.", result.isSuccess());
}
Aggregations