You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ek...@apache.org on 2015/05/27 16:20:50 UTC
[03/10] git commit: updated refs/heads/master to b155129
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b155129a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer56FP1WrapperTest.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer56FP1WrapperTest.java b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer56FP1WrapperTest.java
deleted file mode 100644
index 8333f3c..0000000
--- a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer56FP1WrapperTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.hypervisor.xenserver.resource.wrapper.citrix;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.powermock.modules.junit4.PowerMockRunner;
-
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.FenceCommand;
-import com.cloud.host.Host;
-import com.cloud.hypervisor.xenserver.resource.XenServer56FP1Resource;
-import com.cloud.vm.VMInstanceVO;
-import com.xensource.xenapi.Connection;
-
-@RunWith(PowerMockRunner.class)
-public class XenServer56FP1WrapperTest {
-
- @Mock
- private XenServer56FP1Resource xenServer56Resource;
-
- @Test
- public void testFenceCommand() {
- final VMInstanceVO vm = Mockito.mock(VMInstanceVO.class);
- final Host host = Mockito.mock(Host.class);
-
- final Connection conn = Mockito.mock(Connection.class);
-
- final FenceCommand fenceCommand = new FenceCommand(vm, host);
-
- final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
- assertNotNull(wrapper);
-
- when(xenServer56Resource.getConnection()).thenReturn(conn);
-
- final Answer answer = wrapper.execute(fenceCommand, xenServer56Resource);
-
- verify(xenServer56Resource, times(1)).getConnection();
- verify(xenServer56Resource, times(1)).checkHeartbeat(fenceCommand.getHostGuid());
-
- assertFalse(answer.getResult());
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b155129a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer56WrapperTest.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer56WrapperTest.java b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer56WrapperTest.java
deleted file mode 100644
index 57f4d82..0000000
--- a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer56WrapperTest.java
+++ /dev/null
@@ -1,177 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.hypervisor.xenserver.resource.wrapper.citrix;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.powermock.modules.junit4.PowerMockRunner;
-
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.CheckOnHostCommand;
-import com.cloud.agent.api.FenceCommand;
-import com.cloud.agent.api.NetworkUsageCommand;
-import com.cloud.agent.api.SetupCommand;
-import com.cloud.host.Host;
-import com.cloud.host.HostEnvironment;
-import com.cloud.hypervisor.xenserver.resource.XenServer56Resource;
-import com.cloud.hypervisor.xenserver.resource.XsHost;
-import com.cloud.utils.ExecutionResult;
-import com.cloud.vm.VMInstanceVO;
-import com.xensource.xenapi.Connection;
-
-@RunWith(PowerMockRunner.class)
-public class XenServer56WrapperTest {
-
- @Mock
- private XenServer56Resource xenServer56Resource;
-
- @Test
- public void testCheckOnHostCommand() {
- final com.cloud.host.Host host = Mockito.mock(com.cloud.host.Host.class);
- final CheckOnHostCommand onHostCommand = new CheckOnHostCommand(host);
-
- final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
- assertNotNull(wrapper);
-
- final Answer answer = wrapper.execute(onHostCommand, xenServer56Resource);
-
- assertTrue(answer.getResult());
- }
-
- @Test
- public void testFenceCommand() {
- final VMInstanceVO vm = Mockito.mock(VMInstanceVO.class);
- final Host host = Mockito.mock(Host.class);
-
- final Connection conn = Mockito.mock(Connection.class);
-
- final FenceCommand fenceCommand = new FenceCommand(vm, host);
-
- final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
- assertNotNull(wrapper);
-
- when(xenServer56Resource.getConnection()).thenReturn(conn);
-
- final Answer answer = wrapper.execute(fenceCommand, xenServer56Resource);
-
- verify(xenServer56Resource, times(1)).getConnection();
- verify(xenServer56Resource, times(1)).checkHeartbeat(fenceCommand.getHostGuid());
-
- assertFalse(answer.getResult());
- }
-
- @Test
- public void testNetworkUsageCommandSuccess() {
- final Connection conn = Mockito.mock(Connection.class);
-
- final NetworkUsageCommand networkCommand = new NetworkUsageCommand("192.168.10.10", "domRName", false, "192.168.10.1");
-
- final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
- assertNotNull(wrapper);
-
- when(xenServer56Resource.getConnection()).thenReturn(conn);
- when(xenServer56Resource.getNetworkStats(conn, networkCommand.getPrivateIP())).thenReturn(new long[]{1, 1});
-
- final Answer answer = wrapper.execute(networkCommand, xenServer56Resource);
-
- verify(xenServer56Resource, times(1)).getConnection();
-
- assertTrue(answer.getResult());
- }
-
- @Test
- public void testNetworkUsageCommandFailure() {
- final Connection conn = Mockito.mock(Connection.class);
-
- final NetworkUsageCommand networkCommand = new NetworkUsageCommand("192.168.10.10", "domRName", false, "192.168.10.1");
-
- final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
- assertNotNull(wrapper);
-
- when(xenServer56Resource.getConnection()).thenReturn(conn);
- when(xenServer56Resource.getNetworkStats(conn, networkCommand.getPrivateIP())).thenReturn(new long[0]);
-
- final Answer answer = wrapper.execute(networkCommand, xenServer56Resource);
-
- verify(xenServer56Resource, times(1)).getConnection();
-
- assertFalse(answer.getResult());
- }
-
- @Test
- public void testNetworkUsageCommandCreateVpc() {
- final ExecutionResult executionResult = Mockito.mock(ExecutionResult.class);
-
- final NetworkUsageCommand networkCommand = new NetworkUsageCommand("192.168.10.10", "domRName", true, "192.168.10.1", "10.1.1.1/24");
-
- final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
- assertNotNull(wrapper);
-
- final String args = " -l 192.168.10.1 -c -v 10.1.1.1/24";
- when(xenServer56Resource.executeInVR(networkCommand.getPrivateIP(), "vpc_netusage.sh", args)).thenReturn(executionResult);
- when(executionResult.isSuccess()).thenReturn(true);
-
- final Answer answer = wrapper.execute(networkCommand, xenServer56Resource);
-
- assertTrue(answer.getResult());
- }
-
- @Test
- public void testNetworkUsageCommandCreateVpcFailure() {
- final ExecutionResult executionResult = Mockito.mock(ExecutionResult.class);
-
- final NetworkUsageCommand networkCommand = new NetworkUsageCommand("192.168.10.10", "domRName", true, "192.168.10.1", "10.1.1.1/24");
-
- final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
- assertNotNull(wrapper);
-
- final String args = " -l 192.168.10.1 -c -v 10.1.1.1/24";
- when(xenServer56Resource.executeInVR(networkCommand.getPrivateIP(), "vpc_netusage.sh", args)).thenReturn(executionResult);
- when(executionResult.isSuccess()).thenReturn(false);
-
- final Answer answer = wrapper.execute(networkCommand, xenServer56Resource);
-
- assertFalse(answer.getResult());
- }
-
- @Test
- public void testSetupCommand() {
- final XsHost xsHost = Mockito.mock(XsHost.class);
- final HostEnvironment env = Mockito.mock(HostEnvironment.class);
-
- final SetupCommand setupCommand = new SetupCommand(env);
-
- final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
- assertNotNull(wrapper);
-
- when(xenServer56Resource.getHost()).thenReturn(xsHost);
-
- final Answer answer = wrapper.execute(setupCommand, xenServer56Resource);
- verify(xenServer56Resource, times(1)).getConnection();
-
- assertFalse(answer.getResult());
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b155129a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer610WrapperTest.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer610WrapperTest.java b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer610WrapperTest.java
deleted file mode 100644
index bf8099b..0000000
--- a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer610WrapperTest.java
+++ /dev/null
@@ -1,525 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.hypervisor.xenserver.resource.wrapper.citrix;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.xmlrpc.XmlRpcException;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.powermock.modules.junit4.PowerMockRunner;
-
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.CheckNetworkCommand;
-import com.cloud.agent.api.MigrateWithStorageCommand;
-import com.cloud.agent.api.MigrateWithStorageCompleteCommand;
-import com.cloud.agent.api.MigrateWithStorageReceiveCommand;
-import com.cloud.agent.api.MigrateWithStorageSendCommand;
-import com.cloud.agent.api.SetupCommand;
-import com.cloud.agent.api.storage.MigrateVolumeCommand;
-import com.cloud.agent.api.to.NicTO;
-import com.cloud.agent.api.to.StorageFilerTO;
-import com.cloud.agent.api.to.VirtualMachineTO;
-import com.cloud.agent.api.to.VolumeTO;
-import com.cloud.host.HostEnvironment;
-import com.cloud.hypervisor.xenserver.resource.XenServer610Resource;
-import com.cloud.hypervisor.xenserver.resource.XsHost;
-import com.cloud.hypervisor.xenserver.resource.XsLocalNetwork;
-import com.cloud.network.Networks.TrafficType;
-import com.cloud.network.PhysicalNetworkSetupInfo;
-import com.cloud.storage.StoragePool;
-import com.xensource.xenapi.Connection;
-import com.xensource.xenapi.Network;
-import com.xensource.xenapi.SR;
-import com.xensource.xenapi.Task;
-import com.xensource.xenapi.Types.BadServerResponse;
-import com.xensource.xenapi.Types.XenAPIException;
-import com.xensource.xenapi.VDI;
-import com.xensource.xenapi.VIF;
-
-@RunWith(PowerMockRunner.class)
-public class XenServer610WrapperTest {
-
- @Mock
- protected XenServer610Resource xenServer610Resource;
-
- @Test
- public void testCheckNetworkCommandFailure() {
- final XenServer610Resource xenServer610Resource = new XenServer610Resource();
-
- final PhysicalNetworkSetupInfo info = new PhysicalNetworkSetupInfo();
-
- final List<PhysicalNetworkSetupInfo> setupInfos = new ArrayList<PhysicalNetworkSetupInfo>();
- setupInfos.add(info);
-
- final CheckNetworkCommand checkNet = new CheckNetworkCommand(setupInfos);
-
- final Answer answer = xenServer610Resource.executeRequest(checkNet);
-
- assertTrue(answer.getResult());
- }
-
- @Test
- public void testSetupCommand() {
- final XenServer610Resource xenServer610Resource = new XenServer610Resource();
-
- final HostEnvironment env = Mockito.mock(HostEnvironment.class);
-
- final SetupCommand setupCommand = new SetupCommand(env);
-
- final Answer answer = xenServer610Resource.executeRequest(setupCommand);
-
- assertFalse(answer.getResult());
- }
-
- @Test
- public void testMigrateWithStorageCommand() {
- final String vmName = "small";
- final String uuid = "206b21a7-c6ec-40e2-b5e2-f861b9612f04";
- final String path = "/";
-
- final Connection conn = Mockito.mock(Connection.class);
- final VirtualMachineTO vmSpec = Mockito.mock(VirtualMachineTO.class);
-
- final VolumeTO vol1 = Mockito.mock(VolumeTO.class);
- final VolumeTO vol2 = Mockito.mock(VolumeTO.class);
- final StorageFilerTO storage1 = Mockito.mock(StorageFilerTO.class);
- final StorageFilerTO storage2 = Mockito.mock(StorageFilerTO.class);
-
- final Map<VolumeTO, StorageFilerTO> volumeToFiler = new HashMap<VolumeTO, StorageFilerTO>();
- volumeToFiler.put(vol1, storage1);
- volumeToFiler.put(vol2, storage2);
-
- final NicTO nicTO1 = Mockito.mock(NicTO.class);
- final NicTO nicTO2 = Mockito.mock(NicTO.class);
- final NicTO nicTO3 = Mockito.mock(NicTO.class);
- final NicTO [] nicTOs = {nicTO1, nicTO2, nicTO3};
-
- final XsLocalNetwork nativeNetworkForTraffic = Mockito.mock(XsLocalNetwork.class);
- final Network networkForSm = Mockito.mock(Network.class);
- final XsHost xsHost = Mockito.mock(XsHost.class);
-
- final SR sr1 = Mockito.mock(SR.class);
- final SR sr2 = Mockito.mock(SR.class);
-
- final VDI vdi1 = Mockito.mock(VDI.class);
- final VDI vdi2 = Mockito.mock(VDI.class);
-
- final MigrateWithStorageCommand migrateStorageCommand = new MigrateWithStorageCommand(vmSpec, volumeToFiler);
-
- final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
- assertNotNull(wrapper);
-
- when(xenServer610Resource.getConnection()).thenReturn(conn);
- when(vmSpec.getName()).thenReturn(vmName);
- when(vmSpec.getNics()).thenReturn(nicTOs);
-
- when(storage1.getUuid()).thenReturn(uuid);
- when(storage2.getUuid()).thenReturn(uuid);
-
- when(vol1.getPath()).thenReturn(path);
- when(vol2.getPath()).thenReturn(path);
-
- when(xenServer610Resource.getStorageRepository(conn, storage1.getUuid())).thenReturn(sr1);
- when(xenServer610Resource.getStorageRepository(conn, storage2.getUuid())).thenReturn(sr2);
-
- when(xenServer610Resource.getVDIbyUuid(conn, storage1.getPath())).thenReturn(vdi1);
- when(xenServer610Resource.getVDIbyUuid(conn, storage2.getPath())).thenReturn(vdi2);
-
- try {
- when(xenServer610Resource.getNativeNetworkForTraffic(conn, TrafficType.Storage, null)).thenReturn(nativeNetworkForTraffic);
- when(nativeNetworkForTraffic.getNetwork()).thenReturn(networkForSm);
-
- when(xenServer610Resource.getHost()).thenReturn(xsHost);
- when(xsHost.getUuid()).thenReturn(uuid);
- } catch (final XenAPIException e) {
- fail(e.getMessage());
- } catch (final XmlRpcException e) {
- fail(e.getMessage());
- }
-
- final Answer answer = wrapper.execute(migrateStorageCommand, xenServer610Resource);
-
- verify(xenServer610Resource, times(1)).getConnection();
-
- try {
- verify(xenServer610Resource, times(1)).prepareISO(conn, vmName);
- verify(xenServer610Resource, times(1)).getNetwork(conn, nicTO1);
- verify(xenServer610Resource, times(1)).getNetwork(conn, nicTO2);
- verify(xenServer610Resource, times(1)).getNetwork(conn, nicTO3);
-
- verify(xenServer610Resource, times(1)).getNativeNetworkForTraffic(conn, TrafficType.Storage, null);
- verify(nativeNetworkForTraffic, times(1)).getNetwork();
-
- verify(xenServer610Resource, times(1)).getHost();
- verify(xsHost, times(1)).getUuid();
- } catch (final XenAPIException e) {
- fail(e.getMessage());
- } catch (final XmlRpcException e) {
- fail(e.getMessage());
- }
-
- assertFalse(answer.getResult());
- }
-
- @Test
- public void testMigrateWithStorageReceiveCommand() {
- final String vmName = "small";
- final String uuid = "206b21a7-c6ec-40e2-b5e2-f861b9612f04";
-
- final Connection conn = Mockito.mock(Connection.class);
- final VirtualMachineTO vmSpec = Mockito.mock(VirtualMachineTO.class);
-
- final VolumeTO vol1 = Mockito.mock(VolumeTO.class);
- final VolumeTO vol2 = Mockito.mock(VolumeTO.class);
- final StorageFilerTO storage1 = Mockito.mock(StorageFilerTO.class);
- final StorageFilerTO storage2 = Mockito.mock(StorageFilerTO.class);
-
- final Map<VolumeTO, StorageFilerTO> volumeToFiler = new HashMap<VolumeTO, StorageFilerTO>();
- volumeToFiler.put(vol1, storage1);
- volumeToFiler.put(vol2, storage2);
-
- final NicTO nicTO1 = Mockito.mock(NicTO.class);
- final NicTO nicTO2 = Mockito.mock(NicTO.class);
- final NicTO nicTO3 = Mockito.mock(NicTO.class);
- final NicTO [] nicTOs = {nicTO1, nicTO2, nicTO3};
-
- final XsLocalNetwork nativeNetworkForTraffic = Mockito.mock(XsLocalNetwork.class);
- final Network network = Mockito.mock(Network.class);
- final XsHost xsHost = Mockito.mock(XsHost.class);
-
- final Network nw1 = Mockito.mock(Network.class);
- final Network nw2 = Mockito.mock(Network.class);
- final Network nw3 = Mockito.mock(Network.class);
-
- final SR sr1 = Mockito.mock(SR.class);
- final SR sr2 = Mockito.mock(SR.class);
-
- final MigrateWithStorageReceiveCommand migrateStorageCommand = new MigrateWithStorageReceiveCommand(vmSpec, volumeToFiler);
-
- final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
- assertNotNull(wrapper);
-
- when(xenServer610Resource.getConnection()).thenReturn(conn);
- when(vmSpec.getName()).thenReturn(vmName);
- when(vmSpec.getNics()).thenReturn(nicTOs);
-
- when(storage1.getUuid()).thenReturn(uuid);
- when(storage2.getUuid()).thenReturn(uuid);
-
- when(xenServer610Resource.getStorageRepository(conn, storage1.getUuid())).thenReturn(sr1);
- when(xenServer610Resource.getStorageRepository(conn, storage2.getUuid())).thenReturn(sr2);
-
- try {
-
- when(xenServer610Resource.getNetwork(conn, nicTO1)).thenReturn(nw1);
- when(xenServer610Resource.getNetwork(conn, nicTO2)).thenReturn(nw2);
- when(xenServer610Resource.getNetwork(conn, nicTO3)).thenReturn(nw3);
-
- when(xenServer610Resource.getNativeNetworkForTraffic(conn, TrafficType.Storage, null)).thenReturn(nativeNetworkForTraffic);
- when(nativeNetworkForTraffic.getNetwork()).thenReturn(network);
-
- when(xenServer610Resource.getHost()).thenReturn(xsHost);
- when(xsHost.getUuid()).thenReturn(uuid);
- } catch (final XenAPIException e) {
- fail(e.getMessage());
- } catch (final XmlRpcException e) {
- fail(e.getMessage());
- }
-
- final Answer answer = wrapper.execute(migrateStorageCommand, xenServer610Resource);
-
- verify(xenServer610Resource, times(1)).getConnection();
-
- try {
- verify(xenServer610Resource, times(1)).getNetwork(conn, nicTO1);
- verify(xenServer610Resource, times(1)).getNetwork(conn, nicTO2);
- verify(xenServer610Resource, times(1)).getNetwork(conn, nicTO3);
-
- verify(xenServer610Resource, times(1)).getNativeNetworkForTraffic(conn, TrafficType.Storage, null);
- verify(nativeNetworkForTraffic, times(1)).getNetwork();
-
- verify(xenServer610Resource, times(1)).getHost();
- verify(xsHost, times(1)).getUuid();
- } catch (final XenAPIException e) {
- fail(e.getMessage());
- } catch (final XmlRpcException e) {
- fail(e.getMessage());
- }
-
- assertFalse(answer.getResult());
- }
-
- @Test
- public void testMigrateWithStorageSendCommand() {
- final String vmName = "small";
- final String path = "/";
- final String mac = "3c:15:c2:c4:4f:18";
-
- final Connection conn = Mockito.mock(Connection.class);
- final VirtualMachineTO vmSpec = Mockito.mock(VirtualMachineTO.class);
-
- final VolumeTO volume1 = Mockito.mock(VolumeTO.class);
- final VolumeTO volume2 = Mockito.mock(VolumeTO.class);
-
- final SR sr1 = Mockito.mock(SR.class);
- final SR sr2 = Mockito.mock(SR.class);
-
- final VDI vdi1 = Mockito.mock(VDI.class);
- final VDI vdi2 = Mockito.mock(VDI.class);
-
- final NicTO nic1 = Mockito.mock(NicTO.class);
- final NicTO nic2 = Mockito.mock(NicTO.class);
-
- final Network network1 = Mockito.mock(Network.class);
- final Network network2 = Mockito.mock(Network.class);
-
- final Map<VolumeTO, Object> volumeToSr = new HashMap<VolumeTO, Object>();
- volumeToSr.put(volume1, sr1);
- volumeToSr.put(volume2, sr2);
-
- final Map<NicTO, Object> nicToNetwork = new HashMap<NicTO, Object>();
- nicToNetwork.put(nic1, network1);
- nicToNetwork.put(nic2, network2);
-
- final Map<String, String> token = new HashMap<String, String>();
-
- final VIF vif1 = Mockito.mock(VIF.class);
- final VIF vif2 = Mockito.mock(VIF.class);
-
- final MigrateWithStorageSendCommand migrateStorageCommand = new MigrateWithStorageSendCommand(vmSpec, volumeToSr, nicToNetwork, token);
-
- final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
- assertNotNull(wrapper);
-
- when(xenServer610Resource.getConnection()).thenReturn(conn);
- when(vmSpec.getName()).thenReturn(vmName);
-
- when(volume1.getPath()).thenReturn(path);
- when(volume2.getPath()).thenReturn(path);
-
- when(nic1.getMac()).thenReturn(mac);
- when(nic2.getMac()).thenReturn(mac);
-
- when(xenServer610Resource.getVDIbyUuid(conn, volume1.getPath())).thenReturn(vdi1);
- when(xenServer610Resource.getVDIbyUuid(conn, volume2.getPath())).thenReturn(vdi2);
-
- try {
- when(xenServer610Resource.getVifByMac(conn, null, nic1.getMac())).thenReturn(vif1);
- when(xenServer610Resource.getVifByMac(conn, null, nic2.getMac())).thenReturn(vif2);
- } catch (final XenAPIException e) {
- fail(e.getMessage());
- } catch (final XmlRpcException e) {
- fail(e.getMessage());
- }
-
- final Answer answer = wrapper.execute(migrateStorageCommand, xenServer610Resource);
-
- verify(xenServer610Resource, times(1)).getConnection();
-
- try {
- verify(xenServer610Resource, times(2)).getVDIbyUuid(conn, volume1.getPath());
- verify(xenServer610Resource, times(2)).getVifByMac(conn, null, nic1.getMac());
- } catch (final XenAPIException e) {
- fail(e.getMessage());
- } catch (final XmlRpcException e) {
- fail(e.getMessage());
- }
-
- assertFalse(answer.getResult());
- }
-
- @Test
- public void testMigrateWithStorageSendCommandSRException() {
- final String vmName = "small";
-
- final Connection conn = Mockito.mock(Connection.class);
- final VirtualMachineTO vmSpec = Mockito.mock(VirtualMachineTO.class);
-
- final VolumeTO volume1 = Mockito.mock(VolumeTO.class);
- final VolumeTO volume2 = Mockito.mock(VolumeTO.class);
-
- final Map<VolumeTO, Object> volumeToSr = new HashMap<VolumeTO, Object>();
- volumeToSr.put(volume1, new String("a"));
- volumeToSr.put(volume2, new String("b"));
-
- final Map<NicTO, Object> nicToNetwork = new HashMap<NicTO, Object>();
- final Map<String, String> token = new HashMap<String, String>();
-
- final MigrateWithStorageSendCommand migrateStorageCommand = new MigrateWithStorageSendCommand(vmSpec, volumeToSr, nicToNetwork, token);
-
- final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
- assertNotNull(wrapper);
-
- when(xenServer610Resource.getConnection()).thenReturn(conn);
- when(vmSpec.getName()).thenReturn(vmName);
-
- final Answer answer = wrapper.execute(migrateStorageCommand, xenServer610Resource);
-
- verify(xenServer610Resource, times(1)).getConnection();
-
- assertFalse(answer.getResult());
- }
-
- @Test
- public void testMigrateWithStorageSendCommandNetException() {
- final String vmName = "small";
- final String path = "/";
-
- final Connection conn = Mockito.mock(Connection.class);
- final VirtualMachineTO vmSpec = Mockito.mock(VirtualMachineTO.class);
-
- final VolumeTO volume1 = Mockito.mock(VolumeTO.class);
- final VolumeTO volume2 = Mockito.mock(VolumeTO.class);
-
- final SR sr1 = Mockito.mock(SR.class);
- final SR sr2 = Mockito.mock(SR.class);
-
- final VDI vdi1 = Mockito.mock(VDI.class);
- final VDI vdi2 = Mockito.mock(VDI.class);
-
- final NicTO nic1 = Mockito.mock(NicTO.class);
- final NicTO nic2 = Mockito.mock(NicTO.class);
-
- final Map<VolumeTO, Object> volumeToSr = new HashMap<VolumeTO, Object>();
- volumeToSr.put(volume1, sr1);
- volumeToSr.put(volume2, sr2);
-
- final Map<NicTO, Object> nicToNetwork = new HashMap<NicTO, Object>();
- nicToNetwork.put(nic1, new String("a"));
- nicToNetwork.put(nic2, new String("b"));
-
- final Map<String, String> token = new HashMap<String, String>();
-
- final MigrateWithStorageSendCommand migrateStorageCommand = new MigrateWithStorageSendCommand(vmSpec, volumeToSr, nicToNetwork, token);
-
- final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
- assertNotNull(wrapper);
-
- when(xenServer610Resource.getConnection()).thenReturn(conn);
- when(vmSpec.getName()).thenReturn(vmName);
-
- when(volume1.getPath()).thenReturn(path);
- when(volume2.getPath()).thenReturn(path);
-
- when(xenServer610Resource.getVDIbyUuid(conn, volume1.getPath())).thenReturn(vdi1);
- when(xenServer610Resource.getVDIbyUuid(conn, volume2.getPath())).thenReturn(vdi2);
-
- final Answer answer = wrapper.execute(migrateStorageCommand, xenServer610Resource);
-
- verify(xenServer610Resource, times(1)).getConnection();
-
- assertFalse(answer.getResult());
- }
-
- @Test
- public void testMigrateWithStorageCompleteCommand() {
- final String vmName = "small";
- final String uuid = "206b21a7-c6ec-40e2-b5e2-f861b9612f04";
-
- final Connection conn = Mockito.mock(Connection.class);
- final XsHost xsHost = Mockito.mock(XsHost.class);
-
- final VirtualMachineTO vm = Mockito.mock(VirtualMachineTO.class);
-
- final MigrateWithStorageCompleteCommand createStorageCommand = new MigrateWithStorageCompleteCommand(vm);
-
- final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
- assertNotNull(wrapper);
-
- when(xenServer610Resource.getConnection()).thenReturn(conn);
- when(vm.getName()).thenReturn(vmName);
- when(xenServer610Resource.getHost()).thenReturn(xsHost);
- when(xsHost.getUuid()).thenReturn(uuid);
-
- final Answer answer = wrapper.execute(createStorageCommand, xenServer610Resource);
-
- verify(xenServer610Resource, times(1)).getConnection();
-
- assertFalse(answer.getResult());
- }
-
- @Test
- public void testXenServer610MigrateVolumeCommandWrapper() {
- final String uuid = "206b21a7-c6ec-40e2-b5e2-f861b9612f04";
-
- final Connection conn = Mockito.mock(Connection.class);
- final SR destinationPool = Mockito.mock(SR.class);
- final VDI srcVolume = Mockito.mock(VDI.class);
- final Task task = Mockito.mock(Task.class);
-
- final long volumeId = 1l;
- final String volumePath = "206b21a7-c6ec-40e2-b5e2-f861b9612f04";
- final StoragePool pool = Mockito.mock(StoragePool.class);
- final int timeout = 120;
-
- final Map<String, String> other = new HashMap<String, String>();
- other.put("live", "true");
-
- final MigrateVolumeCommand createStorageCommand = new MigrateVolumeCommand(volumeId, volumePath, pool, timeout);
-
- final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
- assertNotNull(wrapper);
-
- when(xenServer610Resource.getConnection()).thenReturn(conn);
- when(pool.getUuid()).thenReturn(uuid);
- when(xenServer610Resource.getStorageRepository(conn, uuid)).thenReturn(destinationPool);
- when(xenServer610Resource.getVDIbyUuid(conn, volumePath)).thenReturn(srcVolume);
-
- try {
- when(srcVolume.poolMigrateAsync(conn, destinationPool, other)).thenReturn(task);
- } catch (final BadServerResponse e) {
- fail(e.getMessage());
- } catch (final XenAPIException e) {
- fail(e.getMessage());
- } catch (final XmlRpcException e) {
- fail(e.getMessage());
- }
-
- when(xenServer610Resource.getMigrateWait()).thenReturn(120);
-
- final Answer answer = wrapper.execute(createStorageCommand, xenServer610Resource);
-
- verify(xenServer610Resource, times(1)).getConnection();
-
- // try {
- // verify(xenServer610Resource, times(1)).waitForTask(conn, task, 1000, timeout);
- // verify(xenServer610Resource, times(1)).checkForSuccess(conn, task);
- // } catch (final XenAPIException e) {
- // fail(e.getMessage());
- // } catch (final XmlRpcException e) {
- // fail(e.getMessage());
- // } catch (final TimeoutException e) {
- // fail(e.getMessage());
- // }
-
- assertFalse(answer.getResult());
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b155129a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer620SP1WrapperTest.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer620SP1WrapperTest.java b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer620SP1WrapperTest.java
deleted file mode 100644
index 48d9717..0000000
--- a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer620SP1WrapperTest.java
+++ /dev/null
@@ -1,115 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.hypervisor.xenserver.resource.wrapper.citrix;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import java.util.HashMap;
-
-import org.apache.xmlrpc.XmlRpcException;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.powermock.modules.junit4.PowerMockRunner;
-
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.GetGPUStatsCommand;
-import com.cloud.agent.api.VgpuTypesInfo;
-import com.cloud.hypervisor.xenserver.resource.XenServer620SP1Resource;
-import com.cloud.utils.exception.CloudRuntimeException;
-import com.xensource.xenapi.Connection;
-import com.xensource.xenapi.Types.XenAPIException;
-
-@RunWith(PowerMockRunner.class)
-public class XenServer620SP1WrapperTest {
-
- @Mock
- private XenServer620SP1Resource xenServer620SP1Resource;
-
- @Test
- public void testGetGPUStatsCommand() {
- final String guuid = "246a5b75-05ed-4bbc-a171-2d1fe94a1b0e";
-
- final Connection conn = Mockito.mock(Connection.class);
-
- final GetGPUStatsCommand gpuStats = new GetGPUStatsCommand(guuid, "xen");
-
- final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
- assertNotNull(wrapper);
-
- when(xenServer620SP1Resource.getConnection()).thenReturn(conn);
- try {
- when(xenServer620SP1Resource.getGPUGroupDetails(conn)).thenReturn(new HashMap<String, HashMap<String, VgpuTypesInfo>>());
- } catch (final XenAPIException e) {
- fail(e.getMessage());
- } catch (final XmlRpcException e) {
- fail(e.getMessage());
- }
-
- final Answer answer = wrapper.execute(gpuStats, xenServer620SP1Resource);
- verify(xenServer620SP1Resource, times(1)).getConnection();
- try {
- verify(xenServer620SP1Resource, times(1)).getGPUGroupDetails(conn);
- } catch (final XenAPIException e) {
- fail(e.getMessage());
- } catch (final XmlRpcException e) {
- fail(e.getMessage());
- }
-
- assertTrue(answer.getResult());
- }
-
- @Test
- public void testGetGPUStatsCommandFailure() {
- final String guuid = "246a5b75-05ed-4bbc-a171-2d1fe94a1b0e";
-
- final Connection conn = Mockito.mock(Connection.class);
-
- final GetGPUStatsCommand gpuStats = new GetGPUStatsCommand(guuid, "xen");
-
- final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
- assertNotNull(wrapper);
-
- when(xenServer620SP1Resource.getConnection()).thenReturn(conn);
- try {
- when(xenServer620SP1Resource.getGPUGroupDetails(conn)).thenThrow(new CloudRuntimeException("Failed!"));
- } catch (final XenAPIException e) {
- fail(e.getMessage());
- } catch (final XmlRpcException e) {
- fail(e.getMessage());
- }
-
- final Answer answer = wrapper.execute(gpuStats, xenServer620SP1Resource);
- verify(xenServer620SP1Resource, times(1)).getConnection();
- try {
- verify(xenServer620SP1Resource, times(1)).getGPUGroupDetails(conn);
- } catch (final XenAPIException e) {
- fail(e.getMessage());
- } catch (final XmlRpcException e) {
- fail(e.getMessage());
- }
-
- assertFalse(answer.getResult());
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b155129a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer620WrapperTest.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer620WrapperTest.java b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer620WrapperTest.java
deleted file mode 100644
index 6043558..0000000
--- a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer620WrapperTest.java
+++ /dev/null
@@ -1,51 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.hypervisor.xenserver.resource.wrapper.citrix;
-
-import static org.junit.Assert.assertTrue;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.powermock.modules.junit4.PowerMockRunner;
-
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.CheckNetworkCommand;
-import com.cloud.hypervisor.xenserver.resource.XenServer620Resource;
-import com.cloud.network.PhysicalNetworkSetupInfo;
-
-@RunWith(PowerMockRunner.class)
-public class XenServer620WrapperTest {
-
- @Test
- public void testCheckNetworkCommandFailure() {
- final XenServer620Resource xenServer620Resource = new XenServer620Resource();
-
- final PhysicalNetworkSetupInfo info = new PhysicalNetworkSetupInfo();
-
- final List<PhysicalNetworkSetupInfo> setupInfos = new ArrayList<PhysicalNetworkSetupInfo>();
- setupInfos.add(info);
-
- final CheckNetworkCommand checkNet = new CheckNetworkCommand(setupInfos);
-
- final Answer answer = xenServer620Resource.executeRequest(checkNet);
-
- assertTrue(answer.getResult());
- }
-}
\ No newline at end of file