wido commented on code in PR #6792:
URL: https://github.com/apache/cloudstack/pull/6792#discussion_r984535550


##########
plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/LibvirtStoragePoolXMLParserTest.java:
##########
@@ -0,0 +1,79 @@
+/*
+ * 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.kvm.resource;
+
+import junit.framework.TestCase;
+import org.junit.Assert;
+
+public class LibvirtStoragePoolXMLParserTest extends TestCase {
+
+    public void testParseNfsStoragePoolXML() {
+        String poolXML = "<pool type='netfs'>\n" +
+                "  <name>feff06b5-84b2-3258-b5f9-1953217295de</name>\n" +
+                "  <uuid>feff06b5-84b2-3258-b5f9-1953217295de</uuid>\n" +
+                "  <capacity unit='bytes'>111111111</capacity>\n" +
+                "  <allocation unit='bytes'>2222222</allocation>\n" +
+                "  <available unit='bytes'>3333333</available>\n" +
+                "  <source>\n" +
+                "    <host name='10.11.12.13'/>\n" +
+                "    <dir path='/mnt/primary1'/>\n" +
+                "    <format type='auto'/>\n" +
+                "  </source>\n" +
+                "  <target>\n" +
+                "    <path>/mnt/feff06b5-84b2-3258-b5f9-1953217295de</path>\n" 
+
+                "    <permissions>\n" +
+                "      <mode>0755</mode>\n" +
+                "      <owner>0</owner>\n" +
+                "      <group>0</group>\n" +
+                "    </permissions>\n" +
+                "  </target>\n" +
+                "</pool>";
+
+        LibvirtStoragePoolXMLParser parser = new LibvirtStoragePoolXMLParser();
+        LibvirtStoragePoolDef pool = parser.parseStoragePoolXML(poolXML);
+
+        Assert.assertEquals("10.11.12.13", pool.getSourceHost());

Review Comment:
   Another IPv6 test case?



##########
plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/LibvirtStoragePoolXMLParserTest.java:
##########
@@ -0,0 +1,79 @@
+/*
+ * 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.kvm.resource;
+
+import junit.framework.TestCase;
+import org.junit.Assert;
+
+public class LibvirtStoragePoolXMLParserTest extends TestCase {
+
+    public void testParseNfsStoragePoolXML() {
+        String poolXML = "<pool type='netfs'>\n" +
+                "  <name>feff06b5-84b2-3258-b5f9-1953217295de</name>\n" +
+                "  <uuid>feff06b5-84b2-3258-b5f9-1953217295de</uuid>\n" +
+                "  <capacity unit='bytes'>111111111</capacity>\n" +
+                "  <allocation unit='bytes'>2222222</allocation>\n" +
+                "  <available unit='bytes'>3333333</available>\n" +
+                "  <source>\n" +
+                "    <host name='10.11.12.13'/>\n" +
+                "    <dir path='/mnt/primary1'/>\n" +
+                "    <format type='auto'/>\n" +
+                "  </source>\n" +
+                "  <target>\n" +
+                "    <path>/mnt/feff06b5-84b2-3258-b5f9-1953217295de</path>\n" 
+
+                "    <permissions>\n" +
+                "      <mode>0755</mode>\n" +
+                "      <owner>0</owner>\n" +
+                "      <group>0</group>\n" +
+                "    </permissions>\n" +
+                "  </target>\n" +
+                "</pool>";
+
+        LibvirtStoragePoolXMLParser parser = new LibvirtStoragePoolXMLParser();
+        LibvirtStoragePoolDef pool = parser.parseStoragePoolXML(poolXML);
+
+        Assert.assertEquals("10.11.12.13", pool.getSourceHost());
+    }
+
+    public void testParseRbdStoragePoolXMLWithMultipleHosts() {
+        String poolXML = "<pool type='rbd'>\n" +
+                "  <name>feff06b5-84b2-3258-b5f9-1953217295de</name>\n" +
+                "  <uuid>feff06b5-84b2-3258-b5f9-1953217295de</uuid>\n" +
+                "  <source>\n" +
+                "    <name>rbdpool</name>\n" +
+                "    <host name='10.11.12.13' port='6789'/>\n" +
+                "    <host name='10.11.12.14' port='6789'/>\n" +
+                "    <host name='10.11.12.15' port='6789'/>\n" +
+                "    <format type='auto'/>\n" +
+                "    <auth username='admin' type='ceph'>\n" +
+                "      <secret 
uuid='262f743a-3726-11ed-aaee-93e90b39d5c4'/>\n" +
+                "    </auth>\n" +
+                "  </source>\n" +
+                "</pool>";
+
+        LibvirtStoragePoolXMLParser parser = new LibvirtStoragePoolXMLParser();
+        LibvirtStoragePoolDef pool = parser.parseStoragePoolXML(poolXML);
+
+        Assert.assertEquals(LibvirtStoragePoolDef.PoolType.RBD, 
pool.getPoolType());
+        Assert.assertEquals(LibvirtStoragePoolDef.AuthenticationType.CEPH, 
pool.getAuthType());
+        Assert.assertEquals("10.11.12.13,10.11.12.14,10.11.12.15", 
pool.getSourceHost());

Review Comment:
   Would be good if we have an IPv6 test case here as well



##########
plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/LibvirtVMDefTest.java:
##########
@@ -238,6 +238,39 @@ public void testDiskDefWithEncryption() {
         assertEquals(disk.toString(), expectedXML);
     }
 
+    @Test
+    public void testDiskDefWithMultipleHosts() {
+        String path = "/mnt/primary1";
+        String host = "10.11.12.13,10.11.12.14,10.11.12.15";

Review Comment:
   Could you also make a test-case with IPv6 addresses? Just to make sure we 
cover that as well



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to