Search in sources :

Example 1 with GetStorageStatsCommand

use of com.cloud.legacymodel.communication.command.GetStorageStatsCommand in project cosmic by MissionCriticalCloud.

the class LibvirtComputingResourceTest method testGetStorageStatsCommand.

@Test
public void testGetStorageStatsCommand() {
    final DataStoreTO store = Mockito.mock(DataStoreTO.class);
    final GetStorageStatsCommand command = new GetStorageStatsCommand(store);
    final KvmStoragePoolManager storagePoolMgr = Mockito.mock(KvmStoragePoolManager.class);
    final KvmStoragePool secondaryPool = Mockito.mock(KvmStoragePool.class);
    when(this.libvirtComputingResource.getStoragePoolMgr()).thenReturn(storagePoolMgr);
    when(storagePoolMgr.getStoragePool(command.getPooltype(), command.getStorageId(), true)).thenReturn(secondaryPool);
    final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
    assertNotNull(wrapper);
    final Answer answer = wrapper.execute(command, this.libvirtComputingResource);
    assertTrue(answer.getResult());
    verify(this.libvirtComputingResource, times(1)).getStoragePoolMgr();
    verify(storagePoolMgr, times(1)).getStoragePool(command.getPooltype(), command.getStorageId(), true);
}
Also used : Answer(com.cloud.legacymodel.communication.answer.Answer) CheckRouterAnswer(com.cloud.legacymodel.communication.answer.CheckRouterAnswer) AttachAnswer(com.cloud.legacymodel.communication.answer.AttachAnswer) DataStoreTO(com.cloud.legacymodel.to.DataStoreTO) LibvirtRequestWrapper(com.cloud.agent.resource.kvm.wrapper.LibvirtRequestWrapper) KvmStoragePool(com.cloud.agent.resource.kvm.storage.KvmStoragePool) KvmStoragePoolManager(com.cloud.agent.resource.kvm.storage.KvmStoragePoolManager) GetStorageStatsCommand(com.cloud.legacymodel.communication.command.GetStorageStatsCommand) Test(org.junit.Test)

Example 2 with GetStorageStatsCommand

use of com.cloud.legacymodel.communication.command.GetStorageStatsCommand in project cosmic by MissionCriticalCloud.

the class LibvirtComputingResourceTest method testGetStorageStatsCommandException.

@Test
public void testGetStorageStatsCommandException() {
    final DataStoreTO store = Mockito.mock(DataStoreTO.class);
    final GetStorageStatsCommand command = new GetStorageStatsCommand(store);
    when(this.libvirtComputingResource.getStoragePoolMgr()).thenThrow(CloudRuntimeException.class);
    final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
    assertNotNull(wrapper);
    final Answer answer = wrapper.execute(command, this.libvirtComputingResource);
    assertFalse(answer.getResult());
    verify(this.libvirtComputingResource, times(1)).getStoragePoolMgr();
}
Also used : Answer(com.cloud.legacymodel.communication.answer.Answer) CheckRouterAnswer(com.cloud.legacymodel.communication.answer.CheckRouterAnswer) AttachAnswer(com.cloud.legacymodel.communication.answer.AttachAnswer) DataStoreTO(com.cloud.legacymodel.to.DataStoreTO) LibvirtRequestWrapper(com.cloud.agent.resource.kvm.wrapper.LibvirtRequestWrapper) GetStorageStatsCommand(com.cloud.legacymodel.communication.command.GetStorageStatsCommand) Test(org.junit.Test)

Example 3 with GetStorageStatsCommand

use of com.cloud.legacymodel.communication.command.GetStorageStatsCommand in project cosmic by MissionCriticalCloud.

the class NotAValidCommand method testGetStorageStatsCommand.

@Test
public void testGetStorageStatsCommand() {
    final XsHost xsHost = Mockito.mock(XsHost.class);
    final DataStoreTO store = Mockito.mock(DataStoreTO.class);
    final GetStorageStatsCommand storageStatsCommand = new GetStorageStatsCommand(store);
    final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
    assertNotNull(wrapper);
    when(this.citrixResourceBase.getHost()).thenReturn(xsHost);
    final Answer answer = wrapper.execute(storageStatsCommand, this.citrixResourceBase);
    verify(this.citrixResourceBase, times(1)).getConnection();
    assertFalse(answer.getResult());
}
Also used : RebootAnswer(com.cloud.legacymodel.communication.answer.RebootAnswer) Answer(com.cloud.legacymodel.communication.answer.Answer) CreateAnswer(com.cloud.legacymodel.communication.answer.CreateAnswer) AttachAnswer(com.cloud.legacymodel.communication.answer.AttachAnswer) XsHost(com.cloud.hypervisor.xenserver.resource.XsHost) DataStoreTO(com.cloud.legacymodel.to.DataStoreTO) GetStorageStatsCommand(com.cloud.legacymodel.communication.command.GetStorageStatsCommand) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

Answer (com.cloud.legacymodel.communication.answer.Answer)3 AttachAnswer (com.cloud.legacymodel.communication.answer.AttachAnswer)3 GetStorageStatsCommand (com.cloud.legacymodel.communication.command.GetStorageStatsCommand)3 DataStoreTO (com.cloud.legacymodel.to.DataStoreTO)3 Test (org.junit.Test)3 LibvirtRequestWrapper (com.cloud.agent.resource.kvm.wrapper.LibvirtRequestWrapper)2 CheckRouterAnswer (com.cloud.legacymodel.communication.answer.CheckRouterAnswer)2 KvmStoragePool (com.cloud.agent.resource.kvm.storage.KvmStoragePool)1 KvmStoragePoolManager (com.cloud.agent.resource.kvm.storage.KvmStoragePoolManager)1 XsHost (com.cloud.hypervisor.xenserver.resource.XsHost)1 CreateAnswer (com.cloud.legacymodel.communication.answer.CreateAnswer)1 RebootAnswer (com.cloud.legacymodel.communication.answer.RebootAnswer)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1