use of com.cloud.agent.api.storage.DestroyCommand in project cloudstack by apache.
the class HypervDirectConnectResourceTest method testDestroyCommand.
@Test
public final void testDestroyCommand() {
// TODO: how does the command vary when we are only deleting a vm versus
// deleting a volume?
// String sample2 = "{\"volume\":" + getSampleVolumeObjectTO() + "}";
String sample2 = "{\"volume\":{\"name\":\"" + s_testSampleVolumeWorkingUUIDNoExt + "\",\"storagePoolType\":\"Filesystem\"," + "\"mountPoint\":" + s_testLocalStorePathJSON + ",\"path\":" + s_testSampleVolumeTempURIJSON + ",\"storagePoolUuid\":\"" + s_testLocalStoreUUID + "\"," + "\"type\":\"ROOT\",\"id\":9,\"size\":0}}";
DestroyCommand cmd = s_gson.fromJson(sample2, DestroyCommand.class);
Answer ans = s_hypervresource.executeRequest(cmd);
Assert.assertTrue(ans.getDetails(), ans.getResult());
}
use of com.cloud.agent.api.storage.DestroyCommand in project cloudstack by apache.
the class LibvirtComputingResourceTest method testDestroyCommand.
@Test
public void testDestroyCommand() {
final StoragePool pool = Mockito.mock(StoragePool.class);
final Volume volume = Mockito.mock(Volume.class);
final String vmName = "Test";
final DestroyCommand command = new DestroyCommand(pool, volume, vmName);
final KVMStoragePoolManager poolManager = Mockito.mock(KVMStoragePoolManager.class);
final KVMStoragePool primary = Mockito.mock(KVMStoragePool.class);
final VolumeTO vol = command.getVolume();
when(libvirtComputingResource.getStoragePoolMgr()).thenReturn(poolManager);
when(poolManager.getStoragePool(vol.getPoolType(), vol.getPoolUuid())).thenReturn(primary);
final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
assertNotNull(wrapper);
final Answer answer = wrapper.execute(command, libvirtComputingResource);
assertTrue(answer.getResult());
verify(libvirtComputingResource, times(1)).getStoragePoolMgr();
verify(poolManager, times(1)).getStoragePool(vol.getPoolType(), vol.getPoolUuid());
}
Aggregations