Search in sources :

Example 41 with NetworkUsageCommand

use of com.cloud.agent.api.NetworkUsageCommand in project cloudstack by apache.

the class LibvirtComputingResourceTest method testNetworkUsageCommandNonVpc.

@Test
public void testNetworkUsageCommandNonVpc() {
    final String privateIP = "127.0.0.1";
    final String domRName = "domR";
    final boolean forVpc = false;
    final String gatewayIP = "127.0.0.1";
    final NetworkUsageCommand command = new NetworkUsageCommand(privateIP, domRName, forVpc, gatewayIP);
    libvirtComputingResource.getNetworkStats(command.getPrivateIP());
    when(libvirtComputingResource.getNetworkStats(command.getPrivateIP())).thenReturn(new long[] { 10l, 10l });
    final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
    assertNotNull(wrapper);
    final Answer answer = wrapper.execute(command, libvirtComputingResource);
    assertTrue(answer.getResult());
    // Being called twice, although I did not find the second place yet.
    verify(libvirtComputingResource, times(2)).getNetworkStats(command.getPrivateIP());
}
Also used : UnsupportedAnswer(com.cloud.agent.api.UnsupportedAnswer) AttachAnswer(org.apache.cloudstack.storage.command.AttachAnswer) Answer(com.cloud.agent.api.Answer) CheckRouterAnswer(com.cloud.agent.api.CheckRouterAnswer) LibvirtRequestWrapper(com.cloud.hypervisor.kvm.resource.wrapper.LibvirtRequestWrapper) NetworkUsageCommand(com.cloud.agent.api.NetworkUsageCommand) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

NetworkUsageCommand (com.cloud.agent.api.NetworkUsageCommand)41 Answer (com.cloud.agent.api.Answer)33 Test (org.junit.Test)28 CheckRouterAnswer (com.cloud.agent.api.CheckRouterAnswer)13 LibvirtRequestWrapper (com.cloud.hypervisor.kvm.resource.wrapper.LibvirtRequestWrapper)12 Connection (com.xensource.xenapi.Connection)10 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)9 ConfigurationException (javax.naming.ConfigurationException)7 PlugNicCommand (com.cloud.agent.api.PlugNicCommand)5 UnsupportedAnswer (com.cloud.agent.api.UnsupportedAnswer)5 NetworkUsageAnswer (com.cloud.agent.api.NetworkUsageAnswer)4 PingTestCommand (com.cloud.agent.api.PingTestCommand)4 StartCommand (com.cloud.agent.api.StartCommand)4 CheckSshCommand (com.cloud.agent.api.check.CheckSshCommand)4 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)4 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)4 Network (com.cloud.network.Network)4 AttachAnswer (com.cloud.storage.command.AttachAnswer)4 UserStatisticsVO (com.cloud.user.UserStatisticsVO)4 HashMap (java.util.HashMap)4