You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bh...@apache.org on 2015/03/12 07:04:58 UTC
[06/12] git commit: updated refs/heads/master to c27c694
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c27c6943/plugins/hypervisors/ovm3/src/test/java/com/cloud/hypervisor/ovm3/objects/CommonTest.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/ovm3/src/test/java/com/cloud/hypervisor/ovm3/objects/CommonTest.java b/plugins/hypervisors/ovm3/src/test/java/com/cloud/hypervisor/ovm3/objects/CommonTest.java
new file mode 100644
index 0000000..23df823
--- /dev/null
+++ b/plugins/hypervisors/ovm3/src/test/java/com/cloud/hypervisor/ovm3/objects/CommonTest.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * 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.ovm3.objects;
+
+import org.junit.Test;
+
+public class CommonTest {
+ ConnectionTest con = new ConnectionTest();
+ Common cOm = new Common(con);
+ XmlTestResultTest results = new XmlTestResultTest();
+ String echo = "put";
+ String remoteUrl = "http://oracle:password@ovm-2:8899";
+
+ @Test
+ public void testGetApiVersion() throws Ovm3ResourceException {
+ con.setResult(results
+ .simpleResponseWrap("<array><data>\n<value><int>3</int></value>\n</data></array>"));
+ results.basicIntTest(cOm.getApiVersion(), 3);
+ }
+
+ @Test
+ public void testSleep() throws Ovm3ResourceException {
+ con.setResult(results.getNil());
+ results.basicBooleanTest(cOm.sleep(1));
+ }
+
+ @Test
+ public void testDispatch() throws Ovm3ResourceException {
+ con.setResult(results.getString(echo));
+ results.basicStringTest(cOm.dispatch(remoteUrl, "echo", echo), echo);
+ }
+
+ @Test
+ public void testEcho() throws Ovm3ResourceException {
+ con.setResult(results.getString(echo));
+ results.basicStringTest(cOm.echo(echo), echo);
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c27c6943/plugins/hypervisors/ovm3/src/test/java/com/cloud/hypervisor/ovm3/objects/ConnectionTest.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/ovm3/src/test/java/com/cloud/hypervisor/ovm3/objects/ConnectionTest.java b/plugins/hypervisors/ovm3/src/test/java/com/cloud/hypervisor/ovm3/objects/ConnectionTest.java
new file mode 100644
index 0000000..5faaea8
--- /dev/null
+++ b/plugins/hypervisors/ovm3/src/test/java/com/cloud/hypervisor/ovm3/objects/ConnectionTest.java
@@ -0,0 +1,164 @@
+/*******************************************************************************
+ * 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.ovm3.objects;
+
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+import org.apache.xmlrpc.XmlRpcException;
+import org.apache.xmlrpc.client.XmlRpcClient;
+import org.apache.xmlrpc.common.XmlRpcHttpRequestConfigImpl;
+import org.apache.xmlrpc.common.XmlRpcStreamConfig;
+import org.apache.xmlrpc.common.XmlRpcStreamRequestConfig;
+import org.apache.xmlrpc.parser.XmlRpcResponseParser;
+import org.apache.xmlrpc.util.SAXParsers;
+import org.junit.Test;
+import org.xml.sax.InputSource;
+import org.xml.sax.XMLReader;
+
+/*
+ * This is a stub for XML parsing into result sets, it also contains test for
+ * Connection
+ */
+public class ConnectionTest extends Connection {
+ private final Logger LOGGER = Logger.getLogger(ConnectionTest.class);
+ XmlTestResultTest results = new XmlTestResultTest();
+ String result;
+ List<String> multiRes = new ArrayList<String>();
+ String hostIp;
+ private Map<String, String> methodResponse = new HashMap<String, String>();
+
+ public ConnectionTest() {
+ }
+
+ @Override
+ public Object callTimeoutInSec(String method, List<?> params, int timeout,
+ boolean debug) throws XmlRpcException {
+ XmlRpcStreamConfig config = new XmlRpcHttpRequestConfigImpl();
+ XmlRpcClient client = new XmlRpcClient();
+ client.setTypeFactory(new RpcTypeFactory(client));
+ XmlRpcResponseParser parser = new XmlRpcResponseParser(
+ (XmlRpcStreamRequestConfig) config, client.getTypeFactory());
+ XMLReader xr = SAXParsers.newXMLReader();
+ xr.setContentHandler(parser);
+ try {
+ String result = null;
+ if (getMethodResponse(method) != null) {
+ result = getMethodResponse(method);
+ LOGGER.debug("methodresponse call: " + method + " - " + params);
+ LOGGER.trace("methodresponse reply: " + result);
+ }
+ if (result == null && multiRes.size() >= 0) {
+ result = getResult();
+ LOGGER.debug("getresult call: " + method + " - " + params);
+ LOGGER.trace("getresult reply: " + result);
+ }
+ xr.parse(new InputSource(new StringReader(result)));
+ } catch (Exception e) {
+ throw new XmlRpcException("Exception: " + e.getMessage(), e);
+ }
+ if (parser.getErrorCode() != 0) {
+ throw new XmlRpcException("Fault received[" + parser.getErrorCode()
+ + "]: " + parser.getErrorMessage());
+ }
+ return parser.getResult();
+ }
+
+ public void setMethodResponse(String method, String response) {
+ methodResponse.put(method, response);
+ }
+
+ public String getMethodResponse(String method) {
+ if (methodResponse.containsKey(method)) {
+ return methodResponse.get(method);
+ }
+ return null;
+ }
+
+ public void removeMethodResponse(String method) {
+ if (methodResponse.containsKey(method)) {
+ methodResponse.remove(method);
+ }
+ }
+
+ public void setResult(String res) {
+ multiRes = new ArrayList<String>();
+ multiRes.add(0, res);
+ }
+
+ public void setResult(List<String> l) {
+ multiRes = new ArrayList<String>();
+ multiRes.addAll(l);
+ }
+
+ public void setNull() {
+ multiRes = new ArrayList<String>();
+ multiRes.add(0, null);
+ }
+
+ /* result chainsing */
+ public void addResult(String e) {
+ multiRes.add(e);
+ }
+
+ public void addNull() {
+ multiRes.add(null);
+ }
+
+ public String getResult() {
+ return popResult();
+ }
+
+ public String popResult() {
+ String res = multiRes.get(0);
+ if (multiRes.size() > 1)
+ multiRes.remove(0);
+ return res;
+ }
+
+ public List<String> resultList() {
+ return multiRes;
+ }
+
+ @Test
+ public void testConnection() {
+ String host = "ovm-1";
+ String user = "admin";
+ String pass = "password";
+ Integer port = 8899;
+ List<?> emptyParams = new ArrayList<Object>();
+ Connection con = new Connection(host, port, user, pass);
+ results.basicStringTest(con.getIp(), host);
+ results.basicStringTest(con.getUserName(), user);
+ results.basicStringTest(con.getPassword(), pass);
+ results.basicIntTest(con.getPort(), port);
+ try {
+ con.callTimeoutInSec("ping", emptyParams, 1);
+ // con.call("ping", emptyParams, 1, false);
+ } catch (XmlRpcException e) {
+ // TODO Auto-generated catch block
+ System.out.println("Exception: " + e);
+ }
+ new Connection(host, user, pass);
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c27c6943/plugins/hypervisors/ovm3/src/test/java/com/cloud/hypervisor/ovm3/objects/LinuxTest.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/ovm3/src/test/java/com/cloud/hypervisor/ovm3/objects/LinuxTest.java b/plugins/hypervisors/ovm3/src/test/java/com/cloud/hypervisor/ovm3/objects/LinuxTest.java
new file mode 100644
index 0000000..4c41960
--- /dev/null
+++ b/plugins/hypervisors/ovm3/src/test/java/com/cloud/hypervisor/ovm3/objects/LinuxTest.java
@@ -0,0 +1,643 @@
+/*******************************************************************************
+ * 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.ovm3.objects;
+
+import org.junit.Test;
+
+public class LinuxTest {
+ public LinuxTest() {
+ }
+ ConnectionTest con = new ConnectionTest();
+ Linux lin = new Linux(con);
+ XmlTestResultTest results = new XmlTestResultTest();
+
+ private final String DISCOVERSERVER = "<?xml version=\"1.0\" ?>"
+ + "<Discover_Server_Result>"
+ + "<Server>"
+ + "<Unique_Id>1d:d5:e8:91:d9:d0:ed:bd:81:c2:a6:9a:b3:d1:b7:ea</Unique_Id>"
+ + "<Boot_Time>1413834408</Boot_Time>"
+ + "<Date_Time>"
+ + "<Time_Zone>Europe/Amsterdam</Time_Zone>"
+ + "<UTC>True</UTC>"
+ + "</Date_Time>"
+ + "<NTP>"
+ + "<Local_Time_Source>True</Local_Time_Source>"
+ + "<Is_NTP_Running>True</Is_NTP_Running>"
+ + "</NTP>"
+ + "<Agent_Version>3.2.1-183</Agent_Version>"
+ + "<RPM_Version>3.2.1-183</RPM_Version>"
+ + "<OVM_Version>3.2.1-517</OVM_Version>"
+ + "<CPU_Type>x86_64</CPU_Type>"
+ + "<OS_Type>Linux</OS_Type>"
+ + "<OS_Name>Oracle VM Server</OS_Name>"
+ + "<OS_Major_Version>5</OS_Major_Version>"
+ + "<OS_Minor_Version>7</OS_Minor_Version>"
+ + "<Hypervisor_Type>xen</Hypervisor_Type>"
+ + "<Hypervisor_Name>Xen</Hypervisor_Name>"
+ + "<Host_Kernel_Release>2.6.39-300.22.2.el5uek</Host_Kernel_Release>"
+ + "<Host_Kernel_Version>#1 SMP Fri Jan 4 12:40:29 PST 2013</Host_Kernel_Version>"
+ + "<VMM>"
+ + "<Version>"
+ + "<Major>4</Major>"
+ + "<Minor>1</Minor>"
+ + "<Extra>.3OVM</Extra>"
+ + "</Version>"
+ + "<Compile_Information>"
+ + "<Compiler>gcc version 4.1.2 20080704 (Red Hat 4.1.2-48)</Compiler>"
+ + "<By>mockbuild</By>"
+ + "<Domain>us.oracle.com</Domain>"
+ + "<Date>Wed Dec 5 09:11:29 PST 2012</Date>"
+ + "</Compile_Information>"
+ + "<Capabilities>xen-3.0-x86_64 xen-3.0-x86_32p</Capabilities>"
+ + "</VMM>"
+ + "<Pool_Unique_Id>f12842eb-f5ed-3fe7-8da1-eb0e17f5ede8</Pool_Unique_Id>"
+ + "<Manager_Unique_Id>d1a749d4295041fb99854f52ea4dea97</Manager_Unique_Id>"
+ + "<Hostname>ovm-1</Hostname>"
+ + "<Registered_IP>192.168.1.64</Registered_IP>"
+ + "<Node_Number>1</Node_Number>"
+ + "<Server_Roles>xen,utility</Server_Roles>"
+ + "<Is_Current_Master>true</Is_Current_Master>"
+ + "<Master_Virtual_Ip>192.168.1.230</Master_Virtual_Ip>"
+ + "<Manager_Core_API_Version>3.2.1.516</Manager_Core_API_Version>"
+ + "<Membership_State>Pooled</Membership_State>"
+ + "<Cluster_State>Offline</Cluster_State>"
+ + "<Statistic>"
+ + "<Interval>20</Interval>"
+ + "</Statistic>"
+ + "<Exports/>"
+ + "<Capabilities>"
+ + "<ISCSI>True</ISCSI>"
+ + "<BOND_MODE_LINK_AGGREGATION>True</BOND_MODE_LINK_AGGREGATION>"
+ + "<POWER_ON_WOL>True</POWER_ON_WOL>"
+ + "<ALL_VM_CPU_OVERSUBSCRIBE>True</ALL_VM_CPU_OVERSUBSCRIBE>"
+ + "<HVM_MAX_VNICS>8</HVM_MAX_VNICS>"
+ + "<FIBRE_CHANNEL>True</FIBRE_CHANNEL>"
+ + "<MAX_CONCURRENT_MIGRATION_OUT>1</MAX_CONCURRENT_MIGRATION_OUT>"
+ + "<LOCAL_STORAGE_ELEMENT>True</LOCAL_STORAGE_ELEMENT>"
+ + "<CLUSTERS>True</CLUSTERS>"
+ + "<CONCURRENT_MIGRATION>False</CONCURRENT_MIGRATION>"
+ + "<VM_MEMORY_ALIGNMENT>1048576</VM_MEMORY_ALIGNMENT>"
+ + "<MIGRATION_SETUP>False</MIGRATION_SETUP>"
+ + "<PER_VM_CPU_OVERSUBSCRIBE>True</PER_VM_CPU_OVERSUBSCRIBE>"
+ + "<BOND_MODE_ACTIVE_BACKUP>True</BOND_MODE_ACTIVE_BACKUP>"
+ + "<NFS>True</NFS>"
+ + "<VM_VNC_CONSOLE>True</VM_VNC_CONSOLE>"
+ + "<MTU_CONFIGURATION>True</MTU_CONFIGURATION>"
+ + "<HIGH_AVAILABILITY>True</HIGH_AVAILABILITY>"
+ + "<MAX_CONCURRENT_MIGRATION_IN>1</MAX_CONCURRENT_MIGRATION_IN>"
+ + "<VM_SERIAL_CONSOLE>True</VM_SERIAL_CONSOLE>"
+ + "<BOND_MODE_ADAPTIVE_LOAD_BALANCING>True</BOND_MODE_ADAPTIVE_LOAD_BALANCING>"
+ + "<VM_SUSPEND>True</VM_SUSPEND>"
+ + "<YUM_PACKAGE_MANAGEMENT>True</YUM_PACKAGE_MANAGEMENT>"
+ + "</Capabilities>" + "</Server>"
+ + "</Discover_Server_Result>";
+
+ public String getDiscoverserver() {
+ return DISCOVERSERVER;
+ }
+
+ public String getDiscoverHw() {
+ return DISCOVERHW;
+ }
+
+ public String getDiscoverFs() {
+ return DISCOVERFS;
+ }
+
+ private final String DISCOVERHW = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ + "<Discover_Hardware_Result>"
+ + "<NodeInformation>"
+ + "<VMM>"
+ + "<PhysicalInfo>"
+ + "<ThreadsPerCore>1</ThreadsPerCore>"
+ + "<CoresPerSocket>1</CoresPerSocket>"
+ + "<SocketsPerNode>2</SocketsPerNode>"
+ + "<Nodes>1</Nodes>"
+ + "<CPUKHz>3392400</CPUKHz>"
+ + "<TotalPages>1048476</TotalPages>"
+ + "<FreePages>863459</FreePages>"
+ + "<HW_Caps>"
+ + "<Item_0>0x0f8bf3ff</Item_0>"
+ + "<Item_1>0x28100800</Item_1>"
+ + "<Item_2>0x00000000</Item_2>"
+ + "<Item_3>0x00000040</Item_3>"
+ + "<Item_4>0xb19a2223</Item_4>"
+ + "<Item_5>0x00000000</Item_5>"
+ + "<Item_6>0x00000001</Item_6>"
+ + "<Item_7>0x00000281</Item_7>"
+ + "</HW_Caps>"
+ + "</PhysicalInfo>"
+ + "</VMM>"
+ + "<CPUInfo>"
+ + "<Proc_Info>"
+ + "<CPU ID=\"0\">"
+ + "<vendor_id>GenuineIntel</vendor_id>"
+ + "<cpu_family>6</cpu_family>"
+ + "<model>2</model>"
+ + "<model_name>Intel Core i7 9xx (Nehalem Class Core i7)</model_name>"
+ + "<stepping>3</stepping>"
+ + "<cache_size>4096 KB</cache_size>"
+ + "<flags>fpu de tsc msr pae mce cx8 apic mca cmov clflush mmx fxsr sse sse2 ss syscall nx lm rep_good nopl pni pclmulqdq ssse3 cx16 sse4_1 sse4_2 popcnt f16c hypervisor lahf_lm fsgsbase erms</flags>"
+ + "</CPU>"
+ + "<CPU ID=\"1\">"
+ + "<vendor_id>GenuineIntel</vendor_id>"
+ + "<cpu_family>6</cpu_family>"
+ + "<model>2</model>"
+ + "<model_name>Intel Core i7 9xx (Nehalem Class Core i7)</model_name>"
+ + "<stepping>3</stepping>"
+ + "<cache_size>4096 KB</cache_size>"
+ + "<flags>fpu de tsc msr pae mce cx8 apic mca cmov clflush mmx fxsr sse sse2 ss syscall nx lm rep_good nopl pni pclmulqdq ssse3 cx16 sse4_1 sse4_2 popcnt f16c hypervisor lahf_lm fsgsbase erms</flags>"
+ + "</CPU>"
+ + "</Proc_Info>"
+ + "</CPUInfo>"
+ + "<IO>"
+ + "<SCSI>"
+ + "<SCSI_Host Num=\"0\">"
+ + "<Active_Mode>Initiator</Active_Mode>"
+ + "<Ahci_Host_Cap2>0</Ahci_Host_Cap2>"
+ + "<Ahci_Host_Caps>40141f05</Ahci_Host_Caps>"
+ + "<Ahci_Host_Version>10000</Ahci_Host_Version>"
+ + "<Ahci_Port_Cmd>1000c017</Ahci_Port_Cmd>"
+ + "<Can_Queue>31</Can_Queue>"
+ + "<Cmd_Per_Lun>1</Cmd_Per_Lun>"
+ + "<Em_Message_Supported></Em_Message_Supported>"
+ + "<Em_Message_Type>0</Em_Message_Type>"
+ + "<Host_Busy>0</Host_Busy>"
+ + "<Link_Power_Management_Policy>max_performance</Link_Power_Management_Policy>"
+ + "<Proc_Name>ahci</Proc_Name>"
+ + "<Prot_Capabilities>0</Prot_Capabilities>"
+ + "<Prot_Guard_Type>0</Prot_Guard_Type>"
+ + "<Sg_Prot_Tablesize>0</Sg_Prot_Tablesize>"
+ + "<Sg_Tablesize>168</Sg_Tablesize>"
+ + "<State>running</State>"
+ + "<Supported_Mode>Initiator</Supported_Mode>"
+ + "<Uevent></Uevent>"
+ + "<Unique_Id>1</Unique_Id>"
+ + "<SysFSDev>"
+ + "<Broken_Parity_Status>0</Broken_Parity_Status>"
+ + "<Class>0x010601</Class>"
+ + "<Consistent_Dma_Mask_Bits>32</Consistent_Dma_Mask_Bits>"
+ + "<Device>0x2922</Device>"
+ + "<Dma_Mask_Bits>32</Dma_Mask_Bits>"
+ + "<Enable>1</Enable>"
+ + "<Irq>58</Irq>"
+ + "<Local_Cpulist>0-1</Local_Cpulist>"
+ + "<Msi_Bus></Msi_Bus>"
+ + "<Msi_Irqs>58</Msi_Irqs>"
+ + "<Numa_Node>-1</Numa_Node>"
+ + "<Subsystem_Device>0x1100</Subsystem_Device>"
+ + "<Subsystem_Vendor>0x1af4</Subsystem_Vendor>"
+ + "<Uevent>DRIVER=ahci PCI_CLASS=10601 PCI_ID=8086:2922 PCI_SUBSYS_ID=1AF4:1100 PCI_SLOT_NAME=0000:00:05.0 MODALIAS=pci:v00008086d00002922sv00001AF4sd00001100bc01sc06i01</Uevent>"
+ + "<Vendor>0x8086</Vendor>"
+ + "</SysFSDev>"
+ + "</SCSI_Host>"
+ + "<SCSI_Host Num=\"1\">"
+ + "<Active_Mode>Initiator</Active_Mode>"
+ + "<Ahci_Host_Cap2>0</Ahci_Host_Cap2>"
+ + "<Ahci_Host_Caps>40141f05</Ahci_Host_Caps>"
+ + "<Ahci_Host_Version>10000</Ahci_Host_Version>"
+ + "<Ahci_Port_Cmd>10004016</Ahci_Port_Cmd>"
+ + "<Can_Queue>31</Can_Queue>"
+ + "<Cmd_Per_Lun>1</Cmd_Per_Lun>"
+ + "<Em_Message_Supported></Em_Message_Supported>"
+ + "<Em_Message_Type>0</Em_Message_Type>"
+ + "<Host_Busy>0</Host_Busy>"
+ + "<Link_Power_Management_Policy>max_performance</Link_Power_Management_Policy>"
+ + "<Proc_Name>ahci</Proc_Name>"
+ + "<Prot_Capabilities>0</Prot_Capabilities>"
+ + "<Prot_Guard_Type>0</Prot_Guard_Type>"
+ + "<Sg_Prot_Tablesize>0</Sg_Prot_Tablesize>"
+ + "<Sg_Tablesize>168</Sg_Tablesize>"
+ + "<State>running</State>"
+ + "<Supported_Mode>Initiator</Supported_Mode>"
+ + "<Uevent></Uevent>"
+ + "<Unique_Id>2</Unique_Id>"
+ + "<SysFSDev>"
+ + "<Broken_Parity_Status>0</Broken_Parity_Status>"
+ + "<Class>0x010601</Class>"
+ + "<Consistent_Dma_Mask_Bits>32</Consistent_Dma_Mask_Bits>"
+ + "<Device>0x2922</Device>"
+ + "<Dma_Mask_Bits>32</Dma_Mask_Bits>"
+ + "<Enable>1</Enable>"
+ + "<Irq>58</Irq>"
+ + "<Local_Cpulist>0-1</Local_Cpulist>"
+ + "<Msi_Bus></Msi_Bus>"
+ + "<Msi_Irqs>58</Msi_Irqs>"
+ + "<Numa_Node>-1</Numa_Node>"
+ + "<Subsystem_Device>0x1100</Subsystem_Device>"
+ + "<Subsystem_Vendor>0x1af4</Subsystem_Vendor>"
+ + "<Uevent>DRIVER=ahci PCI_CLASS=10601 PCI_ID=8086:2922 PCI_SUBSYS_ID=1AF4:1100 PCI_SLOT_NAME=0000:00:05.0 MODALIAS=pci:v00008086d00002922sv00001AF4sd00001100bc01sc06i01</Uevent>"
+ + "<Vendor>0x8086</Vendor>"
+ + "</SysFSDev>"
+ + "</SCSI_Host>"
+ + "<SCSI_Host Num=\"2\">"
+ + "<Active_Mode>Initiator</Active_Mode>"
+ + "<Ahci_Host_Cap2>0</Ahci_Host_Cap2>"
+ + "<Ahci_Host_Caps>40141f05</Ahci_Host_Caps>"
+ + "<Ahci_Host_Version>10000</Ahci_Host_Version>"
+ + "<Ahci_Port_Cmd>10004016</Ahci_Port_Cmd>"
+ + "<Can_Queue>31</Can_Queue>"
+ + "<Cmd_Per_Lun>1</Cmd_Per_Lun>"
+ + "<Em_Message_Supported></Em_Message_Supported>"
+ + "<Em_Message_Type>0</Em_Message_Type>"
+ + "<Host_Busy>0</Host_Busy>"
+ + "<Link_Power_Management_Policy>max_performance</Link_Power_Management_Policy>"
+ + "<Proc_Name>ahci</Proc_Name>"
+ + "<Prot_Capabilities>0</Prot_Capabilities>"
+ + "<Prot_Guard_Type>0</Prot_Guard_Type>"
+ + "<Sg_Prot_Tablesize>0</Sg_Prot_Tablesize>"
+ + "<Sg_Tablesize>168</Sg_Tablesize>"
+ + "<State>running</State>"
+ + "<Supported_Mode>Initiator</Supported_Mode>"
+ + "<Uevent></Uevent>"
+ + "<Unique_Id>3</Unique_Id>"
+ + "<SysFSDev>"
+ + "<Broken_Parity_Status>0</Broken_Parity_Status>"
+ + "<Class>0x010601</Class>"
+ + "<Consistent_Dma_Mask_Bits>32</Consistent_Dma_Mask_Bits>"
+ + "<Device>0x2922</Device>"
+ + "<Dma_Mask_Bits>32</Dma_Mask_Bits>"
+ + "<Enable>1</Enable>"
+ + "<Irq>58</Irq>"
+ + "<Local_Cpulist>0-1</Local_Cpulist>"
+ + "<Msi_Bus></Msi_Bus>"
+ + "<Msi_Irqs>58</Msi_Irqs>"
+ + "<Numa_Node>-1</Numa_Node>"
+ + "<Subsystem_Device>0x1100</Subsystem_Device>"
+ + "<Subsystem_Vendor>0x1af4</Subsystem_Vendor>"
+ + "<Uevent>DRIVER=ahci PCI_CLASS=10601 PCI_ID=8086:2922 PCI_SUBSYS_ID=1AF4:1100 PCI_SLOT_NAME=0000:00:05.0 MODALIAS=pci:v00008086d00002922sv00001AF4sd00001100bc01sc06i01</Uevent>"
+ + "<Vendor>0x8086</Vendor>"
+ + "</SysFSDev>"
+ + "</SCSI_Host>"
+ + "<SCSI_Host Num=\"3\">"
+ + "<Active_Mode>Initiator</Active_Mode>"
+ + "<Ahci_Host_Cap2>0</Ahci_Host_Cap2>"
+ + "<Ahci_Host_Caps>40141f05</Ahci_Host_Caps>"
+ + "<Ahci_Host_Version>10000</Ahci_Host_Version>"
+ + "<Ahci_Port_Cmd>10004016</Ahci_Port_Cmd>"
+ + "<Can_Queue>31</Can_Queue>"
+ + "<Cmd_Per_Lun>1</Cmd_Per_Lun>"
+ + "<Em_Message_Supported></Em_Message_Supported>"
+ + "<Em_Message_Type>0</Em_Message_Type>"
+ + "<Host_Busy>0</Host_Busy>"
+ + "<Link_Power_Management_Policy>max_performance</Link_Power_Management_Policy>"
+ + "<Proc_Name>ahci</Proc_Name>"
+ + "<Prot_Capabilities>0</Prot_Capabilities>"
+ + "<Prot_Guard_Type>0</Prot_Guard_Type>"
+ + "<Sg_Prot_Tablesize>0</Sg_Prot_Tablesize>"
+ + "<Sg_Tablesize>168</Sg_Tablesize>"
+ + "<State>running</State>"
+ + "<Supported_Mode>Initiator</Supported_Mode>"
+ + "<Uevent></Uevent>"
+ + "<Unique_Id>4</Unique_Id>"
+ + "<SysFSDev>"
+ + "<Broken_Parity_Status>0</Broken_Parity_Status>"
+ + "<Class>0x010601</Class>"
+ + "<Consistent_Dma_Mask_Bits>32</Consistent_Dma_Mask_Bits>"
+ + "<Device>0x2922</Device>"
+ + "<Dma_Mask_Bits>32</Dma_Mask_Bits>"
+ + "<Enable>1</Enable>"
+ + "<Irq>58</Irq>"
+ + "<Local_Cpulist>0-1</Local_Cpulist>"
+ + "<Msi_Bus></Msi_Bus>"
+ + "<Msi_Irqs>58</Msi_Irqs>"
+ + "<Numa_Node>-1</Numa_Node>"
+ + "<Subsystem_Device>0x1100</Subsystem_Device>"
+ + "<Subsystem_Vendor>0x1af4</Subsystem_Vendor>"
+ + "<Uevent>DRIVER=ahci PCI_CLASS=10601 PCI_ID=8086:2922 PCI_SUBSYS_ID=1AF4:1100 PCI_SLOT_NAME=0000:00:05.0 MODALIAS=pci:v00008086d00002922sv00001AF4sd00001100bc01sc06i01</Uevent>"
+ + "<Vendor>0x8086</Vendor>"
+ + "</SysFSDev>"
+ + "</SCSI_Host>"
+ + "<SCSI_Host Num=\"4\">"
+ + "<Active_Mode>Initiator</Active_Mode>"
+ + "<Ahci_Host_Cap2>0</Ahci_Host_Cap2>"
+ + "<Ahci_Host_Caps>40141f05</Ahci_Host_Caps>"
+ + "<Ahci_Host_Version>10000</Ahci_Host_Version>"
+ + "<Ahci_Port_Cmd>10004016</Ahci_Port_Cmd>"
+ + "<Can_Queue>31</Can_Queue>"
+ + "<Cmd_Per_Lun>1</Cmd_Per_Lun>"
+ + "<Em_Message_Supported></Em_Message_Supported>"
+ + "<Em_Message_Type>0</Em_Message_Type>"
+ + "<Host_Busy>0</Host_Busy>"
+ + "<Link_Power_Management_Policy>max_performance</Link_Power_Management_Policy>"
+ + "<Proc_Name>ahci</Proc_Name>"
+ + "<Prot_Capabilities>0</Prot_Capabilities>"
+ + "<Prot_Guard_Type>0</Prot_Guard_Type>"
+ + "<Sg_Prot_Tablesize>0</Sg_Prot_Tablesize>"
+ + "<Sg_Tablesize>168</Sg_Tablesize>"
+ + "<State>running</State>"
+ + "<Supported_Mode>Initiator</Supported_Mode>"
+ + "<Uevent></Uevent>"
+ + "<Unique_Id>5</Unique_Id>"
+ + "<SysFSDev>"
+ + "<Broken_Parity_Status>0</Broken_Parity_Status>"
+ + "<Class>0x010601</Class>"
+ + "<Consistent_Dma_Mask_Bits>32</Consistent_Dma_Mask_Bits>"
+ + "<Device>0x2922</Device>"
+ + "<Dma_Mask_Bits>32</Dma_Mask_Bits>"
+ + "<Enable>1</Enable>"
+ + "<Irq>58</Irq>"
+ + "<Local_Cpulist>0-1</Local_Cpulist>"
+ + "<Msi_Bus></Msi_Bus>"
+ + "<Msi_Irqs>58</Msi_Irqs>"
+ + "<Numa_Node>-1</Numa_Node>"
+ + "<Subsystem_Device>0x1100</Subsystem_Device>"
+ + "<Subsystem_Vendor>0x1af4</Subsystem_Vendor>"
+ + "<Uevent>DRIVER=ahci PCI_CLASS=10601 PCI_ID=8086:2922 PCI_SUBSYS_ID=1AF4:1100 PCI_SLOT_NAME=0000:00:05.0 MODALIAS=pci:v00008086d00002922sv00001AF4sd00001100bc01sc06i01</Uevent>"
+ + "<Vendor>0x8086</Vendor>"
+ + "</SysFSDev>"
+ + "</SCSI_Host>"
+ + "<SCSI_Host Num=\"5\">"
+ + "<Active_Mode>Initiator</Active_Mode>"
+ + "<Ahci_Host_Cap2>0</Ahci_Host_Cap2>"
+ + "<Ahci_Host_Caps>40141f05</Ahci_Host_Caps>"
+ + "<Ahci_Host_Version>10000</Ahci_Host_Version>"
+ + "<Ahci_Port_Cmd>10004016</Ahci_Port_Cmd>"
+ + "<Can_Queue>31</Can_Queue>"
+ + "<Cmd_Per_Lun>1</Cmd_Per_Lun>"
+ + "<Em_Message_Supported></Em_Message_Supported>"
+ + "<Em_Message_Type>0</Em_Message_Type>"
+ + "<Host_Busy>0</Host_Busy>"
+ + "<Link_Power_Management_Policy>max_performance</Link_Power_Management_Policy>"
+ + "<Proc_Name>ahci</Proc_Name>"
+ + "<Prot_Capabilities>0</Prot_Capabilities>"
+ + "<Prot_Guard_Type>0</Prot_Guard_Type>"
+ + "<Sg_Prot_Tablesize>0</Sg_Prot_Tablesize>"
+ + "<Sg_Tablesize>168</Sg_Tablesize>"
+ + "<State>running</State>"
+ + "<Supported_Mode>Initiator</Supported_Mode>"
+ + "<Uevent></Uevent>"
+ + "<Unique_Id>6</Unique_Id>"
+ + "<SysFSDev>"
+ + "<Broken_Parity_Status>0</Broken_Parity_Status>"
+ + "<Class>0x010601</Class>"
+ + "<Consistent_Dma_Mask_Bits>32</Consistent_Dma_Mask_Bits>"
+ + "<Device>0x2922</Device>"
+ + "<Dma_Mask_Bits>32</Dma_Mask_Bits>"
+ + "<Enable>1</Enable>"
+ + "<Irq>58</Irq>"
+ + "<Local_Cpulist>0-1</Local_Cpulist>"
+ + "<Msi_Bus></Msi_Bus>"
+ + "<Msi_Irqs>58</Msi_Irqs>"
+ + "<Numa_Node>-1</Numa_Node>"
+ + "<Subsystem_Device>0x1100</Subsystem_Device>"
+ + "<Subsystem_Vendor>0x1af4</Subsystem_Vendor>"
+ + "<Uevent>DRIVER=ahci PCI_CLASS=10601 PCI_ID=8086:2922 PCI_SUBSYS_ID=1AF4:1100 PCI_SLOT_NAME=0000:00:05.0 MODALIAS=pci:v00008086d00002922sv00001AF4sd00001100bc01sc06i01</Uevent>"
+ + "<Vendor>0x8086</Vendor>"
+ + "</SysFSDev>"
+ + "</SCSI_Host>"
+ + "<SCSI_Host Num=\"6\">"
+ + "<Active_Mode>Initiator</Active_Mode>"
+ + "<Can_Queue>1</Can_Queue>"
+ + "<Cmd_Per_Lun>1</Cmd_Per_Lun>"
+ + "<Host_Busy>0</Host_Busy>"
+ + "<Proc_Name>ata_piix</Proc_Name>"
+ + "<Prot_Capabilities>0</Prot_Capabilities>"
+ + "<Prot_Guard_Type>0</Prot_Guard_Type>"
+ + "<Sg_Prot_Tablesize>0</Sg_Prot_Tablesize>"
+ + "<Sg_Tablesize>128</Sg_Tablesize>"
+ + "<State>running</State>"
+ + "<Supported_Mode>Initiator</Supported_Mode>"
+ + "<Uevent></Uevent>"
+ + "<Unique_Id>7</Unique_Id>"
+ + "<SysFSDev>"
+ + "<Broken_Parity_Status>0</Broken_Parity_Status>"
+ + "<Class>0x010180</Class>"
+ + "<Consistent_Dma_Mask_Bits>32</Consistent_Dma_Mask_Bits>"
+ + "<Device>0x7010</Device>"
+ + "<Dma_Mask_Bits>32</Dma_Mask_Bits>"
+ + "<Enable>1</Enable>"
+ + "<Irq>0</Irq>"
+ + "<Local_Cpulist>0-1</Local_Cpulist>"
+ + "<Msi_Bus></Msi_Bus>"
+ + "<Msi_Irqs></Msi_Irqs>"
+ + "<Numa_Node>-1</Numa_Node>"
+ + "<Subsystem_Device>0x1100</Subsystem_Device>"
+ + "<Subsystem_Vendor>0x1af4</Subsystem_Vendor>"
+ + "<Uevent>DRIVER=ata_piix PCI_CLASS=10180 PCI_ID=8086:7010 PCI_SUBSYS_ID=1AF4:1100 PCI_SLOT_NAME=0000:00:01.1 MODALIAS=pci:v00008086d00007010sv00001AF4sd00001100bc01sc01i80</Uevent>"
+ + "<Vendor>0x8086</Vendor>"
+ + "</SysFSDev>"
+ + "</SCSI_Host>"
+ + "<SCSI_Host Num=\"7\">"
+ + "<Active_Mode>Initiator</Active_Mode>"
+ + "<Can_Queue>1</Can_Queue>"
+ + "<Cmd_Per_Lun>1</Cmd_Per_Lun>"
+ + "<Host_Busy>0</Host_Busy>"
+ + "<Proc_Name>ata_piix</Proc_Name>"
+ + "<Prot_Capabilities>0</Prot_Capabilities>"
+ + "<Prot_Guard_Type>0</Prot_Guard_Type>"
+ + "<Sg_Prot_Tablesize>0</Sg_Prot_Tablesize>"
+ + "<Sg_Tablesize>128</Sg_Tablesize>"
+ + "<State>running</State>"
+ + "<Supported_Mode>Initiator</Supported_Mode>"
+ + "<Uevent></Uevent>"
+ + "<Unique_Id>8</Unique_Id>"
+ + "<SysFSDev>"
+ + "<Broken_Parity_Status>0</Broken_Parity_Status>"
+ + "<Class>0x010180</Class>"
+ + "<Consistent_Dma_Mask_Bits>32</Consistent_Dma_Mask_Bits>"
+ + "<Device>0x7010</Device>"
+ + "<Dma_Mask_Bits>32</Dma_Mask_Bits>"
+ + "<Enable>1</Enable>"
+ + "<Irq>0</Irq>"
+ + "<Local_Cpulist>0-1</Local_Cpulist>"
+ + "<Msi_Bus></Msi_Bus>"
+ + "<Msi_Irqs></Msi_Irqs>"
+ + "<Numa_Node>-1</Numa_Node>"
+ + "<Subsystem_Device>0x1100</Subsystem_Device>"
+ + "<Subsystem_Vendor>0x1af4</Subsystem_Vendor>"
+ + "<Uevent>DRIVER=ata_piix PCI_CLASS=10180 PCI_ID=8086:7010 PCI_SUBSYS_ID=1AF4:1100 PCI_SLOT_NAME=0000:00:01.1 MODALIAS=pci:v00008086d00007010sv00001AF4sd00001100bc01sc01i80</Uevent>"
+ + "<Vendor>0x8086</Vendor>"
+ + "</SysFSDev>"
+ + "</SCSI_Host>"
+ + "<ISCSI_Node>"
+ + "<Initiatorname>iqn.1988-12.com.oracle:3b3f5e2f59cb</Initiatorname>"
+ + "</ISCSI_Node>"
+ + "</SCSI>"
+ + "<IDE>"
+ + "</IDE>"
+ + "</IO>"
+ + "<DMTF>"
+ + "<SMBIOS Version=\"2.4.0\">"
+ + "<MaxSize>48</MaxSize>"
+ + "</SMBIOS>"
+ + "<DMI Version=\"2.4\">"
+ + "<TableLength>346</TableLength>"
+ + "<Items>13</Items>"
+ + "<Buffer>"
+ + "ABgAAAECAOgDAAgAAAAAAAAAAAQBAP//Qm9jaHMAQm9jaHMAMDEvMDEvMjAxMQAAARsAAQEC"
+ + "AAAd1eiR2dDtvYHCppqz0bfqBgAAQm9jaHMAQm9jaHMAAAMUAAMBAQAAAAMDAwIAAAAAAAAA"
+ + "Qm9jaHMAAAQgAQQBAwECIwYAAP/7iw8AAAAA0AfQB0EB////////Q1BVIDEAQm9jaHMAAAQg"
+ + "AgQBAwECIwYAAP/7iw8AAAAA0AfQB0EB////////Q1BVIDIAQm9jaHMAABAPABABAwYAAEAA"
+ + "/v8BAAAAERUAEQAQAwBAAEAAABAJAAEABwAARElNTSAwAAATDwATAAAAAP//NwAAEAEAABMP"
+ + "ARMAAEAA//9HAAAQAQAAFBMAFAAAAAD//zcAABEAEwEAAAAAFBMBFAAAQAD//0cAABEBEwEA"
+ + "AAAAIAsAIAAAAAAAAAAAAH8EAH8AAA=="
+ + "</Buffer>"
+ + "</DMI>"
+ + "<BIOS Type=\"0\" Item=\"0\" Handle=\"0x0\">"
+ + "<Vendor>Bochs</Vendor>"
+ + "<Version>Bochs</Version>"
+ + "<ReleaseDate>01/01/2011</ReleaseDate>"
+ + "</BIOS>"
+ + "<System Type=\"1\" Item=\"1\" Handle=\"0x100\">"
+ + "<UUID>1d:d5:e8:91:d9:d0:ed:bd:81:c2:a6:9a:b3:d1:b7:ea</UUID>"
+ + "<Manufacturer>Bochs</Manufacturer>"
+ + "<ProductName>Bochs</ProductName>"
+ + "</System>"
+ + "<Chassis Type=\"3\" Item=\"2\" Handle=\"0x300\">"
+ + "<Height>0U</Height>"
+ + "<Manufacturer>Bochs</Manufacturer>"
+ + "</Chassis>"
+ + "</DMTF>"
+ + "</NodeInformation>"
+ + "</Discover_Hardware_Result>";
+ private final String FSTYPE = "nfs";
+ private final String REMOTEHOST = "cs-mgmt";
+ private final String REMOTEDIR = "/volumes/cs-data/primary/ovm";
+ public String getFsType() {
+ return FSTYPE;
+ }
+
+ public String getRemoteHost() {
+ return REMOTEHOST;
+ }
+
+ public String getRemoteDir() {
+ return REMOTEDIR;
+ }
+
+ public String getRemote() {
+ return REMOTE;
+ }
+
+ public String getRepoId() {
+ return REPOID;
+ }
+
+ public String getRepoMnt() {
+ return REPOMNT;
+ }
+ public String getVirtualDisksDir() {
+ return REPOMNT + "/VirtualDisks";
+ }
+ public String getTemplatesDir() {
+ return REPOMNT + "/Templates";
+ }
+ public String getIsoDir() {
+ return REPOMNT + "/ISOs";
+ }
+ private final String REMOTE = REMOTEHOST + ":" + REMOTEDIR;
+ private final String REPOID = "f12842eb-f5ed-3fe7-8da1-eb0e17f5ede8";
+ private final String DDREPOID = lin.deDash(REPOID);
+ private final String REPOMNT = "/OVS/Repositories/" + DDREPOID;
+ private final String VMMNT = "/nfsmnt/" + REPOID;
+ private final String DISCOVERFS = "<?xml version=\"1.0\" ?>"
+ + "<Discover_Mounted_File_Systems_Result>"
+ + "<Filesystem Type=\""
+ + FSTYPE
+ + "\">"
+ + "<Mount Dir=\""
+ + REPOMNT
+ + "\">"
+ + "<Device>"
+ + REMOTE
+ + "</Device>"
+ + "<Mount_Options>rw,relatime,vers=3,rsize=524288,wsize=524288,namlen=255,hard,proto=tcp,port=65535,timeo=600,retrans=2,sec=sys,local_lock=none,addr=192.168.1.61</Mount_Options>"
+ + "</Mount>"
+ + "<Mount Dir=\""
+ + VMMNT
+ + "\">"
+ + "<Device>"
+ + REMOTE
+ + "/VirtualMachines</Device>"
+ + "<Mount_Options>rw,relatime,vers=3,rsize=524288,wsize=524288,namlen=255,hard,proto=tcp,port=65535,timeo=600,retrans=2,sec=sys,local_lock=none,addr=192.168.1.61</Mount_Options>"
+ + "</Mount>" + "</Filesystem>"
+ + "</Discover_Mounted_File_Systems_Result>";
+ private final String LASTBOOT = "<struct>" + "<member>"
+ + "<name>last_boot_time</name>"
+ + "<value><i8>1413834408</i8></value>" + "</member>" + "<member>"
+ + "<name>local_time</name>" + "<value><i8>1414082517</i8></value>"
+ + "</member>" + "</struct>";
+ private final String TIMEZONE = "<array><data>"
+ + "<value><string>Europe/Amsterdam</string></value>"
+ + "<value><boolean>1</boolean></value>" + "</data></array>";
+
+ @Test
+ public void testDiscoverServer() throws Ovm3ResourceException {
+ con.setResult(results.simpleResponseWrapWrapper(DISCOVERSERVER));
+ results.basicStringTest(lin.getMembershipState(), "Pooled");
+ lin.discoverServer();
+ results.basicStringTest(lin.getCapabilities(),
+ "xen-3.0-x86_64 xen-3.0-x86_32p");
+ results.basicStringTest(lin.getOvmVersion(), "3.2.1-517");
+ results.basicStringTest(lin.getHypervisorVersion(), "4.1.3OVM");
+ results.basicStringTest(lin.get("MAX_CONCURRENT_MIGRATION_IN"), "1");
+ }
+
+ @Test
+ public void testGetTimeZone() throws Ovm3ResourceException {
+ con.setResult(results.simpleResponseWrapWrapper(TIMEZONE));
+ results.basicBooleanTest(lin.getTimeZone());
+ }
+
+ @Test
+ public void testLastBootTime() throws Ovm3ResourceException {
+ con.setResult(results.simpleResponseWrapWrapper(LASTBOOT));
+ results.basicIntTest(lin.getLastBootTime(), 1413834408);
+ }
+
+ @Test
+ public void testDiscoverHardware() throws Ovm3ResourceException {
+ con.setResult(results.simpleResponseWrapWrapper(DISCOVERHW));
+ lin.discoverHardware();
+ results.basicDoubleTest(lin.getMemory(),
+ Double.valueOf("1048476") * 4096);
+ results.basicDoubleTest(lin.getFreeMemory(),
+ Double.valueOf("863459") * 4096);
+ results.basicStringTest(lin.get("UUID"),
+ "1d:d5:e8:91:d9:d0:ed:bd:81:c2:a6:9a:b3:d1:b7:ea");
+ }
+
+ @Test
+ public void testDiscoverMountedFileSystems() throws Ovm3ResourceException {
+ con.setResult(results.simpleResponseWrapWrapper(DISCOVERFS));
+ lin.discoverMountedFs(FSTYPE);
+ results.basicBooleanTest(
+ results.basicListHasString(lin.getFileSystemList(), REPOMNT),
+ true);
+ results.basicBooleanTest(
+ results.basicListHasString(lin.getFileSystemList(), VMMNT),
+ true);
+ results.basicBooleanTest(
+ results.basicListHasString(lin.getFileSystemList(), REMOTE),
+ false);
+ results.basicStringTest(lin.getFileSystem(VMMNT, FSTYPE)
+ .getMountPoint(), VMMNT);
+ results.basicStringTest(lin.getFileSystem(VMMNT, FSTYPE).getHost(),
+ REMOTEHOST);
+ results.basicStringTest(lin.getFileSystem(VMMNT, FSTYPE).getUuid(),
+ REPOID);
+ results.basicStringTest(lin.getFileSystem(REPOMNT, FSTYPE).getUuid(),
+ DDREPOID);
+ results.basicStringTest(lin.getFileSystem(REPOMNT, FSTYPE)
+ .getRemoteDir(), REMOTEDIR);
+ results.basicBooleanTest(lin.getFileSystem(VMMNT, FSTYPE).getDetails()
+ .containsKey("Uuid"), true);
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c27c6943/plugins/hypervisors/ovm3/src/test/java/com/cloud/hypervisor/ovm3/objects/NetworkTest.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/ovm3/src/test/java/com/cloud/hypervisor/ovm3/objects/NetworkTest.java b/plugins/hypervisors/ovm3/src/test/java/com/cloud/hypervisor/ovm3/objects/NetworkTest.java
new file mode 100644
index 0000000..c45fd40
--- /dev/null
+++ b/plugins/hypervisors/ovm3/src/test/java/com/cloud/hypervisor/ovm3/objects/NetworkTest.java
@@ -0,0 +1,346 @@
+/*******************************************************************************
+ * 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.ovm3.objects;
+
+import org.junit.Test;
+
+public class NetworkTest {
+ ConnectionTest con = new ConnectionTest();
+ Network net = new Network(con);
+ XmlTestResultTest results = new XmlTestResultTest();
+
+ private String IP = "192.168.1.64";
+ private String BR = "192.168.1.255";
+ private String MAC = "52:54:00:24:47:70";
+ private String INT = "xenbr0";
+ private String PHY = "bond0";
+ private String VLANBR = "bond0";
+ public String getBroadcast() {
+ return BR;
+ }
+
+ public String getMac() {
+ return MAC;
+ }
+
+ public String getInterface() {
+ return INT;
+ }
+
+ public String getPhysical() {
+ return PHY;
+ }
+
+ public String getVlanBridge() {
+ return VLANBR;
+ }
+
+ public String getVlanInterface() {
+ return VLANINT;
+ }
+
+ public Integer getVlan() {
+ return VLAN;
+ }
+
+ public String getControl() {
+ return CONTROL;
+ }
+
+ private String VLANINT = "xenbr0";
+ private Integer VLAN = 200;
+ private String CONTROL = "control0";
+ private String CONTROLMAC = "B2:D1:75:69:8C:58";
+ private String EMPTY = results.escapeOrNot("<?xml version=\"1.0\" ?>"
+ + "<Discover_Network_Result>" + "</Discover_Network_Result>");
+ private String DISCOVERNETWORK = results
+ .escapeOrNot("<?xml version=\"1.0\" ?>"
+ + "<Discover_Network_Result>" + " <Network>"
+ + " <Active>" + " <Network>"
+ + " <Device Name=\""
+ + PHY
+ + "\">"
+ + " <MAC>52:54:00:24:47:70</MAC>"
+ + " <Flags>(0x1043) IFF_UP IFF_BROADCAST IFF_RUNNING IFF_MULTICAST</Flags>"
+ + " <MII>"
+ + " <Autonegotiate>"
+ + " <State>Incomplete</State>"
+ + " <Speed>100baseT-FD</Speed>"
+ + " </Autonegotiate>"
+ + " <Link>ok</Link>"
+ + " <Product>"
+ + " <Vendor>00:00:00</Vendor>"
+ + " <Model>0</Model>"
+ + " <Revision>0</Revision>"
+ + " </Product>"
+ + " <Status>autonegotiation complete </Status>"
+ + " <Capabilities>100baseT-FD 100baseT-HD 10baseT-FD 10baseT-HD</Capabilities>"
+ + " <Advertising>100baseT-FD 100baseT-HD 10baseT-FD 10baseT-HD</Advertising>"
+ + " <LinkPartner>100baseT-FD 100baseT-HD 10baseT-FD 10baseT-HD</LinkPartner>"
+ + " </MII>"
+ + " <WOL>"
+ + " <WakeOnLan>disabled</WakeOnLan>"
+ + " </WOL>"
+ + " <SysFS>"
+ + " <uevent>INTERFACE="
+ + PHY
+ + "IFINDEX=2</uevent>"
+ + " <addr_assign_type>0</addr_assign_type>"
+ + " <addr_len>6</addr_len>"
+ + " <dev_id>0x0</dev_id>"
+ + " <ifalias/>"
+ + " <iflink>2</iflink>"
+ + " <ifindex>2</ifindex>"
+ + " <features>0x200041a0</features>"
+ + " <type>1</type>"
+ + " <link_mode>0</link_mode>"
+ + " <carrier>1</carrier>"
+ + " <speed>100</speed>"
+ + " <duplex>full</duplex>"
+ + " <dormant>0</dormant>"
+ + " <operstate>up</operstate>"
+ + " <mtu>1500</mtu>"
+ + " <flags>0x1103</flags>"
+ + " <tx_queue_len>1000</tx_queue_len>"
+ + " <netdev_group>0</netdev_group>"
+ + " <SysFSDev>"
+ + " <vendor>0x10ec</vendor>"
+ + " <device>0x8139</device>"
+ + " <subsystem_vendor>0x1af4</subsystem_vendor>"
+ + " <subsystem_device>0x1100</subsystem_device>"
+ + " <class>0x020000</class>"
+ + " </SysFSDev>"
+ + " </SysFS>"
+ + " <BootProto>none</BootProto>"
+ + " <MetaData>ethernet:c0a80100{192.168.1.0}:MANAGEMENT,CLUSTER_HEARTBEAT,LIVE_MIGRATE,VIRTUAL_MACHINE,STORAGE</MetaData>"
+ + " </Device>"
+ + " <Device Name=\"eth1\">"
+ + " <MAC>52:54:00:26:7F:A0</MAC>"
+ + " <Flags>(0x1843) IFF_UP IFF_BROADCAST IFF_RUNNING IFF_SLAVE IFF_MULTICAST</Flags>"
+ + " <MII>"
+ + " <Autonegotiate>"
+ + " <State>Incomplete</State>"
+ + " <Speed>100baseT-FD</Speed>"
+ + " </Autonegotiate>"
+ + " <Link>ok</Link>"
+ + " <Product>"
+ + " <Vendor>00:00:00</Vendor>"
+ + " <Model>0</Model>"
+ + " <Revision>0</Revision>"
+ + " </Product>"
+ + " <Status>autonegotiation complete </Status>"
+ + " <Capabilities>100baseT-FD 100baseT-HD 10baseT-FD 10baseT-HD</Capabilities>"
+ + " <Advertising>100baseT-FD 100baseT-HD 10baseT-FD 10baseT-HD</Advertising>"
+ + " <LinkPartner>100baseT-FD 100baseT-HD 10baseT-FD 10baseT-HD</LinkPartner>"
+ + " </MII>"
+ + " <WOL>"
+ + " <WakeOnLan>disabled</WakeOnLan>"
+ + " </WOL>"
+ + " <SysFS>"
+ + " <uevent>INTERFACE=eth1"
+ + "IFINDEX=3</uevent>"
+ + " <addr_assign_type>0</addr_assign_type>"
+ + " <addr_len>6</addr_len>"
+ + " <dev_id>0x0</dev_id>"
+ + " <ifalias/>"
+ + " <iflink>3</iflink>"
+ + " <ifindex>3</ifindex>"
+ + " <features>0x200041a0</features>"
+ + " <type>1</type>"
+ + " <link_mode>0</link_mode>"
+ + " <carrier>1</carrier>"
+ + " <speed>100</speed>"
+ + " <duplex>full</duplex>"
+ + " <dormant>0</dormant>"
+ + " <operstate>up</operstate>"
+ + " <mtu>1500</mtu>"
+ + " <flags>0x1903</flags>"
+ + " <tx_queue_len>1000</tx_queue_len>"
+ + " <netdev_group>0</netdev_group>"
+ + " <SysFSDev>"
+ + " <vendor>0x10ec</vendor>"
+ + " <device>0x8139</device>"
+ + " <subsystem_vendor>0x1af4</subsystem_vendor>"
+ + " <subsystem_device>0x1100</subsystem_device>"
+ + " <class>0x020000</class>"
+ + " </SysFSDev>"
+ + " </SysFS>"
+ + " <BootProto>none</BootProto>"
+ + " </Device>"
+ + " </Network>"
+ + " <Bonding>"
+ + " <Device Name=\"bond1\">"
+ + " <Bonding_Mode>active-backup</Bonding_Mode>"
+ + " <Primary_Slave>eth1 (primary_reselect always)</Primary_Slave>"
+ + " <Currently_Active_Slave>eth1</Currently_Active_Slave>"
+ + " <MII_Status>up</MII_Status>"
+ + " <MII_Polling_Interval>250</MII_Polling_Interval>"
+ + " <Up_Delay>500</Up_Delay>"
+ + " <Down_Delay>500</Down_Delay>"
+ + " <Slave_Interface Name=\"eth1\">"
+ + " <MII_Status>up</MII_Status>"
+ + " <Speed>100 Mbps</Speed>"
+ + " <Duplex>full</Duplex>"
+ + " <Link_Failure_Count>0</Link_Failure_Count>"
+ + " <Permanent_HW_addr>52:54:00:26:7f:a0</Permanent_HW_addr>"
+ + " </Slave_Interface>"
+ + " <Family Type=\"AF_INET\">"
+ + " <MAC>52:54:00:26:7F:A0</MAC>"
+ + " <mtu>1500</mtu>"
+ + " </Family>"
+ + " <BootProto>none</BootProto>"
+ + " </Device>"
+ + " </Bonding>"
+ + " <Bridges>"
+ + " <Device Name=\""
+ + INT
+ + "\">"
+ + " <Family Type=\"AF_INET\">"
+ + " <MAC>"
+ + MAC
+ + "</MAC>"
+ + " <Address>"
+ + IP
+ + "</Address>"
+ + " <Netmask>255.255.255.0</Netmask>"
+ + " <Broadcast>"
+ + BR
+ + "</Broadcast>"
+ + " </Family>"
+ + " <Interfaces>"
+ + " <PhyInterface>"
+ + PHY
+ + "</PhyInterface>"
+ + " </Interfaces>"
+ + " <BootProto>static</BootProto>"
+ + " </Device>"
+ + " <Device Name=\"xenbr1\">"
+ + " <Family Type=\"AF_INET\">"
+ + " <MAC>52:54:00:26:7F:A0</MAC>"
+ + " </Family>"
+ + " <Interfaces>"
+ + " <PhyInterface>bond1</PhyInterface>"
+ + " </Interfaces>"
+ + " <BootProto>none</BootProto>"
+ + " </Device>"
+ + " <Device Name=\""
+ + CONTROL
+ + "\">"
+ + " \"<Family Type=\"AF_INET\">"
+ + " <MAC>"
+ + CONTROLMAC
+ + "</MAC>"
+ + " </Family>"
+ + " <Interfaces>"
+ + " </Interfaces>"
+ + " <BootProto>none</BootProto>"
+ + " </Device>"
+ + " <Device Name=\"xenbr0.200\">"
+ + " <Family Type=\"AF_INET\">"
+ + " <MAC>52:54:00:26:7F:A0</MAC>"
+ + " </Family>"
+ + " <Interfaces>"
+ + " <PhyInterface>bond1.200</PhyInterface>"
+ + " </Interfaces>"
+ + " <BootProto>none</BootProto>"
+ + " </Device>"
+ + " </Bridges>"
+ + " <Infiniband>"
+ + " </Infiniband>"
+ + " </Active>"
+ + " </Network>"
+ + "</Discover_Network_Result>");
+
+ public String getDiscoverNetwork() {
+ return DISCOVERNETWORK;
+ }
+
+ @Test
+ public void testDiscoverNetwork() throws Ovm3ResourceException {
+ con.setResult(results.getNil());
+ results.basicBooleanTest(net.discoverNetwork(), false);
+ con.setResult(results.simpleResponseWrapWrapper(DISCOVERNETWORK));
+ results.basicBooleanTest(net.discoverNetwork());
+ results.basicStringTest(net.getBridgeByIp(IP).getName(), INT);
+ results.basicStringTest(net.getBridgeByName(INT).getAddress(), IP);
+ results.basicStringTest(net.getInterfaceByName(CONTROL).getMac(), CONTROLMAC);
+ net.getBridgeByIp("");
+ results.basicBooleanTest(net.getSuccess(), false);
+ net.getBridgeByName("");
+ results.basicBooleanTest(net.getSuccess(), false);
+ // results.basicStringTest(net.getBridgeByIp("").getName(), INT);
+ results.basicStringTest(net.getInterfaceByIp(IP).getName(), INT);
+ results.basicStringTest(net.getInterfaceByName(INT).getAddress(), IP);
+ results.basicStringTest(net.getInterfaceByName(INT).getBroadcast(), BR);
+ results.basicStringTest(net.getInterfaceByName(INT).getMac(), MAC);
+ results.basicStringTest(net.getPhysicalByBridgeName(INT), PHY);
+
+ }
+
+ @Test
+ public void testInterfacesNotFound() throws Ovm3ResourceException {
+ con.setResult(results.getNil());
+ results.basicBooleanTest(net.discoverNetwork(), false);
+ con.setResult(results.simpleResponseWrapWrapper(DISCOVERNETWORK));
+ results.basicBooleanTest(net.discoverNetwork());
+ if (net.getInterfaceByName(CONTROL+ "xx") == null) {
+ System.out.println("yay!");
+ };
+ }
+
+ @Test(expected = Ovm3ResourceException.class)
+ public void testLocalBreak() throws Ovm3ResourceException {
+ con.setResult(results
+ .errorResponseWrap(
+ 1,
+ "exceptions.RuntimeError:Command: ['/etc/xen/scripts/linuxbridge/ovs-local-bridge', 'start', 'bridge=control0'] failed (1): stderr: Start local network: Bridge control0 Is Busy"));
+ results.basicBooleanTest(net.startOvsLocalConfig(CONTROL), false);
+ }
+
+ @Test
+ public void testLocal() throws Ovm3ResourceException {
+ String resp = "local bridge " + CONTROL;
+ con.setResult(results.simpleResponseWrap("start " + resp));
+ results.basicBooleanTest(net.startOvsLocalConfig(CONTROL));
+ con.setResult(results.simpleResponseWrap("stop " + resp));
+ results.basicBooleanTest(net.stopOvsLocalConfig(CONTROL));
+ }
+
+ @Test(expected = Ovm3ResourceException.class)
+ public void testVlanBridgeBreak() throws Ovm3ResourceException {
+ con.setResult(results
+ .errorResponseWrap(
+ 1,
+ "exceptions.RuntimeError:Command: ['/etc/xen/scripts/linuxbridge/ovs-local-bridge', 'start', 'bridge=control0'] failed (1): stderr: Start local network: Bridge control0 Is Busy"));
+ results.basicBooleanTest(net.startOvsVlanBridge(
+ VLANINT + "." + VLAN.toString(), VLANBR, VLAN), false);
+ }
+
+ @Test
+ public void testVlanBridge() throws Ovm3ResourceException {
+ String resp = "bridge=" + VLANINT + "." + VLAN.toString() + " netdev="
+ + VLANBR + " vlan " + VLAN.toString();
+ con.setResult(results.simpleResponseWrap("start " + resp));
+ results.basicBooleanTest(net.startOvsVlanBridge(
+ VLANINT + "." + VLAN.toString(), VLANBR, VLAN));
+ con.setResult(results.simpleResponseWrap("stop " + resp));
+ results.basicBooleanTest(net.stopOvsVlanBridge(
+ VLANINT + "." + VLAN.toString(), VLANBR, VLAN));
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c27c6943/plugins/hypervisors/ovm3/src/test/java/com/cloud/hypervisor/ovm3/objects/NtpTest.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/ovm3/src/test/java/com/cloud/hypervisor/ovm3/objects/NtpTest.java b/plugins/hypervisors/ovm3/src/test/java/com/cloud/hypervisor/ovm3/objects/NtpTest.java
new file mode 100644
index 0000000..1c5d374
--- /dev/null
+++ b/plugins/hypervisors/ovm3/src/test/java/com/cloud/hypervisor/ovm3/objects/NtpTest.java
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * 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.ovm3.objects;
+import static org.junit.Assert.assertEquals;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Test;
+
+public class NtpTest {
+ ConnectionTest con = new ConnectionTest();
+ Ntp nTp = new Ntp(con);
+ XmlTestResultTest results = new XmlTestResultTest();
+ String details = results.simpleResponseWrapWrapper("<array>\n"
+ + "<data>\n"
+ + "<value>\n"
+ + "<array>\n"
+ + "<data>\n"
+ + "<value><string>ovm-1</string></value>\n"
+ + "<value><string>ovm-2</string></value>\n"
+ + "</data>\n"
+ + "</array>\n"
+ + "</value>\n"
+ + "<value><boolean>1</boolean></value>\n"
+ + "<value><boolean>1</boolean></value>\n"
+ + "</data>\n"
+ + "</array>\n");
+
+ public void testGetNtp() throws Ovm3ResourceException {
+ con.setResult(results.getNil());
+ results.basicBooleanTest(nTp.getDetails());
+ }
+
+ @Test
+ public void testEnableNtp() throws Ovm3ResourceException {
+ con.setResult(results.getNil());
+ results.basicBooleanTest(nTp.enableNtp());
+ }
+ @Test
+ public void testDisableNtp() throws Ovm3ResourceException {
+ con.setResult(results.getNil());
+ results.basicBooleanTest(nTp.disableNtp());
+ }
+
+ @Test
+ public void testGetDetails() throws Ovm3ResourceException {
+ con.setResult(details);
+ results.basicBooleanTest(nTp.getDetails());
+ results.basicBooleanTest(nTp.isRunning());
+ results.basicBooleanTest(nTp.isServer());
+ }
+
+ @Test
+ public void testSetNTP() throws Ovm3ResourceException {
+ con.setResult(results.getNil());
+ results.basicBooleanTest(nTp.setNtp("ovm-1", true));
+ con.setResult(details);
+ results.basicBooleanTest(nTp.getDetails());
+ List<String> ntpHosts = new ArrayList<String>();
+ nTp.setServers(ntpHosts);
+ results.basicBooleanTest(nTp.setNtp(true), false);
+ }
+
+ @Test
+ public void testServerAdditionRemoval() throws Ovm3ResourceException {
+ List<String> ntpHosts = new ArrayList<String>();
+ con.setResult(details);
+ nTp.getDetails();
+ ntpHosts = nTp.getServers();
+ assertEquals(ntpHosts.size(), 2);
+ nTp.removeServer("ovm-2");
+ ntpHosts = nTp.getServers();
+ assertEquals(ntpHosts.size(), 1);
+ nTp.removeServer("ovm-2");
+ ntpHosts = nTp.getServers();
+ assertEquals(ntpHosts.size(), 1);
+ nTp.addServer("ovm-1");
+ ntpHosts = nTp.getServers();
+ assertEquals(ntpHosts.size(), 1);
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c27c6943/plugins/hypervisors/ovm3/src/test/java/com/cloud/hypervisor/ovm3/objects/PoolOCFS2Test.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/ovm3/src/test/java/com/cloud/hypervisor/ovm3/objects/PoolOCFS2Test.java b/plugins/hypervisors/ovm3/src/test/java/com/cloud/hypervisor/ovm3/objects/PoolOCFS2Test.java
new file mode 100644
index 0000000..eed26da
--- /dev/null
+++ b/plugins/hypervisors/ovm3/src/test/java/com/cloud/hypervisor/ovm3/objects/PoolOCFS2Test.java
@@ -0,0 +1,111 @@
+/*******************************************************************************
+ * 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.ovm3.objects;
+
+import org.junit.Test;
+
+public class PoolOCFS2Test {
+ ConnectionTest con = new ConnectionTest();
+ PoolOCFS2 poolfs = new PoolOCFS2(con);
+ XmlTestResultTest results = new XmlTestResultTest();
+
+ private String TYPE = "nfs";
+ private String UUID = "f12842eb-f5ed-3fe7-8da1-eb0e17f5ede8";
+ private String BOGUSUUID = "deadbeef-dead-beef-dead-beef0000002d";
+ private String TARGET = "cs-mgmt:/volumes/cs-data/primary/ovm/VirtualMachines";
+ private String BASE = "f12842ebf5ed3fe78da1eb0e17f5ede8";
+ private String MANAGER = "d1a749d4295041fb99854f52ea4dea97";
+ private String CLUSTER = MANAGER.substring(0, 15);
+ private String VERSION = "3.0";
+ private String POOLUUID = "f12842eb-f5ed-3fe7-8da1-eb0e17f5ede8";
+ private String EMPTY = results.escapeOrNot("<?xml version=\"1.0\" ?>"
+ + "<Discover_Pool_Filesystem_Result>"
+ + "</Discover_Pool_Filesystem_Result>");
+ private String DISCOVERPOOLFS = results
+ .escapeOrNot("<?xml version=\"1.0\" ?>"
+ + "<Discover_Pool_Filesystem_Result>" + "<Pool_Filesystem>"
+ + "<Pool_Filesystem_Type>"
+ + TYPE
+ + "</Pool_Filesystem_Type>"
+ + "<Pool_Filesystem_Target>"
+ + TARGET
+ + "</Pool_Filesystem_Target>"
+ + "<Pool_Filesystem_Uuid>"
+ + UUID
+ + "</Pool_Filesystem_Uuid>"
+ + "<Pool_Filesystem_Nfsbase_Uuid>"
+ + BASE
+ + "</Pool_Filesystem_Nfsbase_Uuid>"
+ + "<Pool_Filesystem_Manager_Uuid>"
+ + MANAGER
+ + "</Pool_Filesystem_Manager_Uuid>"
+ + "<Pool_Filesystem_Version>"
+ + VERSION
+ + "</Pool_Filesystem_Version>"
+ + "<Pool_Filesystem_Pool_Uuid>"
+ + POOLUUID
+ + "</Pool_Filesystem_Pool_Uuid>"
+ + "</Pool_Filesystem>"
+ + "</Discover_Pool_Filesystem_Result>");
+
+ @Test
+ public void testDiscoverPoolFS() throws Ovm3ResourceException {
+ con.setResult(results.simpleResponseWrapWrapper(EMPTY));
+ results.basicBooleanTest(poolfs.hasAPoolFs(), false);
+ results.basicBooleanTest(poolfs.hasPoolFs(BOGUSUUID), false);
+ con.setResult(results.simpleResponseWrapWrapper(DISCOVERPOOLFS));
+ poolfs.discoverPoolFs();
+ results.basicStringTest(poolfs.getPoolFsId(), UUID);
+ results.basicStringTest(poolfs.getPoolFsManagerUuid(), MANAGER);
+ results.basicStringTest(poolfs.getPoolFsNFSBaseId(), BASE);
+ results.basicStringTest(poolfs.getPoolFsTarget(), TARGET);
+ results.basicStringTest(poolfs.getPoolFsUuid(), UUID);
+ results.basicStringTest(poolfs.getPoolFsVersion(), VERSION);
+ results.basicStringTest(poolfs.getPoolPoolFsId(), POOLUUID);
+ results.basicStringTest(poolfs.getPoolFsType(), TYPE);
+ results.basicBooleanTest(poolfs.hasAPoolFs());
+ results.basicBooleanTest(poolfs.hasPoolFs(UUID));
+ }
+
+ @Test
+ public void testCreatePoolFS() throws Ovm3ResourceException {
+ con.setResult(results.getNil());
+ poolfs.createPoolFs(TYPE, TARGET, CLUSTER, UUID, BASE, MANAGER);
+
+ con.setResult(results.simpleResponseWrapWrapper(DISCOVERPOOLFS));
+ results.basicBooleanTest(poolfs.hasPoolFs(UUID));
+ poolfs.createPoolFs(TYPE, TARGET, CLUSTER, UUID, BASE, MANAGER);
+ }
+
+ @Test
+ public void testDestroyPoolFS() throws Ovm3ResourceException {
+ con.setResult(results.getNil());
+ poolfs.destroyPoolFs(TYPE, TARGET, UUID, BASE);
+
+ con.setResult(results.simpleResponseWrapWrapper(DISCOVERPOOLFS));
+ results.basicBooleanTest(poolfs.hasPoolFs(UUID));
+ poolfs.createPoolFs(TYPE, TARGET, CLUSTER, UUID, BASE, MANAGER);
+ }
+
+ @Test(expected = Ovm3ResourceException.class)
+ public void testCreatePoolFSError() throws Ovm3ResourceException {
+ con.setResult(results.simpleResponseWrapWrapper(DISCOVERPOOLFS));
+ poolfs.createPoolFs(TYPE, TARGET, CLUSTER, BOGUSUUID, BASE, MANAGER);
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c27c6943/plugins/hypervisors/ovm3/src/test/java/com/cloud/hypervisor/ovm3/objects/PoolTest.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/ovm3/src/test/java/com/cloud/hypervisor/ovm3/objects/PoolTest.java b/plugins/hypervisors/ovm3/src/test/java/com/cloud/hypervisor/ovm3/objects/PoolTest.java
new file mode 100644
index 0000000..db4e340
--- /dev/null
+++ b/plugins/hypervisors/ovm3/src/test/java/com/cloud/hypervisor/ovm3/objects/PoolTest.java
@@ -0,0 +1,181 @@
+/*******************************************************************************
+ * 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.ovm3.objects;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Test;
+
+public class PoolTest {
+ ConnectionTest con = new ConnectionTest();
+ Pool pool = new Pool(con);
+ XmlTestResultTest results = new XmlTestResultTest();
+
+ private String UUID = "0004fb0000020000ba9aaf00ae5e2d73";
+ private String BOGUSUUID = "deadbeefdeadbeefdeadbeefdeadbeef";
+ private String VIP = "192.168.1.230";
+ private String ALIAS = "Pool 0";
+ private String HOST = "ovm-1";
+ private String HOST2 = "ovm-2";
+ private String IP = "192.168.1.64";
+ private String IP2 = "192.168.1.65";
+ private String EMPTY = results.escapeOrNot("<?xml version=\"1.0\" ?>"
+ + "<Discover_Server_Pool_Result/>");
+ private String DISCOVERPOOL = results
+ .escapeOrNot("<?xml version=\"1.0\" ?>"
+ + "<Discover_Server_Pool_Result>" + " <Server_Pool>"
+ + " <Unique_Id>"
+ + UUID
+ + "</Unique_Id>"
+ + " <Pool_Alias>"
+ + ALIAS
+ + "</Pool_Alias>"
+ + " <Master_Virtual_Ip>"
+ + VIP
+ + "</Master_Virtual_Ip>"
+ + " <Member_List>"
+ + " <Member>"
+ + " <Registered_IP>"
+ + IP
+ + "</Registered_IP>"
+ + " </Member>"
+ + " <Member>"
+ + " <Registered_IP>"
+ + IP2
+ + "</Registered_IP>"
+ + " </Member>"
+ + " </Member_List>"
+ + " </Server_Pool>" + "</Discover_Server_Pool_Result>");
+
+
+ @Test
+ public void testDiscoverServerPool() throws Ovm3ResourceException {
+ con.setResult(results.simpleResponseWrapWrapper(EMPTY));
+ results.basicBooleanTest(pool.isInAPool(), false);
+ results.basicBooleanTest(pool.isInPool(UUID), false);
+ results.basicBooleanTest(pool.discoverServerPool(), false);
+ results.basicBooleanTest(pool.isInPool(UUID), false);
+ con.setResult(results.simpleResponseWrapWrapper(DISCOVERPOOL));
+ results.basicBooleanTest(pool.discoverServerPool());
+ results.basicBooleanTest(pool.isInAPool(), true);
+ results.basicBooleanTest(pool.isInPool(UUID), true);
+ results.basicStringTest(pool.getPoolId(), UUID);
+ results.basicStringTest(pool.getPoolId(), UUID);
+ results.basicStringTest(pool.getPoolAlias(), ALIAS);
+ results.basicStringTest(pool.getPoolMasterVip(), VIP);
+ results.basicBooleanTest(pool.getPoolMemberList().contains(IP));
+ results.basicBooleanTest(pool.getPoolMemberList().contains(IP2));
+ }
+
+ @Test
+ public void poolMembers() throws Ovm3ResourceException {
+ List<String> poolHosts = new ArrayList<String>();
+ poolHosts.add(IP);
+ poolHosts.add(IP2);
+ con.setResult(results.simpleResponseWrapWrapper(EMPTY));
+ results.basicBooleanTest(pool.getPoolMemberList().contains(IP), false);
+
+ con.setResult(results.simpleResponseWrapWrapper(DISCOVERPOOL));
+ results.basicBooleanTest(pool.discoverServerPool());
+ con.setResult(results.getNil());
+ results.basicBooleanTest(pool.removePoolMember(IP), true);
+ results.basicBooleanTest(pool.addPoolMember(IP), true);
+ results.basicBooleanTest(pool.setPoolMemberList(poolHosts), true);
+ }
+
+ @Test
+ public void testCreateServerPool() throws Ovm3ResourceException {
+ con.setResult(results.getNil());
+ results.basicBooleanTest(
+ pool.createServerPool(ALIAS, UUID, VIP, 1, HOST, IP), true);
+ con.setResult(results.simpleResponseWrapWrapper(DISCOVERPOOL));
+ results.basicBooleanTest(pool.discoverServerPool());
+ results.basicBooleanTest(
+ pool.createServerPool(ALIAS, UUID, VIP, 1, HOST, IP), true);
+
+ }
+
+ @Test(expected = Ovm3ResourceException.class)
+ public void testCreateServerPoolFail1() throws Ovm3ResourceException {
+ con.setResult(results.simpleResponseWrapWrapper(DISCOVERPOOL));
+ results.basicBooleanTest(
+ pool.createServerPool(ALIAS, BOGUSUUID, VIP, 1, HOST, IP),
+ false);
+ }
+
+ @Test(expected = Ovm3ResourceException.class)
+ public void testCreateServerPoolFail2() throws Ovm3ResourceException {
+ con.setResult(results.errorResponseWrap(1,
+ "exceptions.Exception:Repository already exists"));
+ results.basicBooleanTest(
+ pool.createServerPool(ALIAS, UUID, VIP, 1, HOST, IP), false);
+ }
+
+ @Test
+ public void testJoinServerPool() throws Ovm3ResourceException {
+ con.setResult(results.getNil());
+ Integer poolsize = 2;
+ results.basicBooleanTest(
+ pool.joinServerPool(ALIAS, UUID, VIP, poolsize, HOST2, IP2),
+ true);
+ con.setResult(results.simpleResponseWrapWrapper(DISCOVERPOOL));
+ results.basicBooleanTest(pool.discoverServerPool());
+ results.basicBooleanTest(
+ pool.joinServerPool(ALIAS, UUID, VIP, poolsize, HOST2, IP2),
+ true);
+ }
+ @Test(expected = Ovm3ResourceException.class)
+ public void testJoinServerPoolFail1() throws Ovm3ResourceException {
+ Integer poolsize = 2;
+ con.setResult(results.simpleResponseWrapWrapper(DISCOVERPOOL));
+ results.basicBooleanTest(pool.joinServerPool(ALIAS, BOGUSUUID, VIP,
+ poolsize, HOST2, IP2), false);
+ }
+
+ @Test(expected = Ovm3ResourceException.class)
+ public void testJoinServerPoolFail() throws Ovm3ResourceException {
+ con.setResult(results
+ .errorResponseWrap(1,
+ "exceptions.Exception:Server already a member of pool: "
+ + UUID));
+ Integer poolsize = 2;
+ results.basicBooleanTest(pool.joinServerPool(ALIAS, UUID, VIP, poolsize,
+ HOST2, IP2), false);
+ }
+
+ @Test
+ public void testValidPoolRoles() throws Ovm3ResourceException {
+ con.setResult(results.getNil());
+ results.basicBooleanTest(pool.setServerRoles(pool.getValidRoles()),
+ true);
+
+ }
+
+ @Test(expected = Ovm3ResourceException.class)
+ public void testValidPoolRolesInvalid() throws Ovm3ResourceException {
+ String broken = "broken_token";
+ con.setResult(results
+ .errorResponseWrap(1,
+ "exceptions.Exception:Invalid roles: set(['xen', '" + broken
+ + "', 'utility'])"));
+ results.basicBooleanTest(pool.setServerRoles(pool.getValidRoles()),
+ false);
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c27c6943/plugins/hypervisors/ovm3/src/test/java/com/cloud/hypervisor/ovm3/objects/RemoteTest.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/ovm3/src/test/java/com/cloud/hypervisor/ovm3/objects/RemoteTest.java b/plugins/hypervisors/ovm3/src/test/java/com/cloud/hypervisor/ovm3/objects/RemoteTest.java
new file mode 100644
index 0000000..a5952ab
--- /dev/null
+++ b/plugins/hypervisors/ovm3/src/test/java/com/cloud/hypervisor/ovm3/objects/RemoteTest.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * 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.ovm3.objects;
+import org.junit.Test;
+
+public class RemoteTest {
+ ConnectionTest con = new ConnectionTest();
+ Remote rEm = new Remote(con);
+ XmlTestResultTest results = new XmlTestResultTest();
+
+ @Test
+ public void TestSysShutdown() throws Ovm3ResourceException {
+ con.setResult(results.getNil());
+ results.basicBooleanTest(rEm.sysShutdown());
+ }
+ @Test
+ public void TestSysReboot() throws Ovm3ResourceException {
+ con.setResult(results.getNil());
+ results.basicBooleanTest(rEm.sysReboot());
+ }
+}