You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by wi...@apache.org on 2014/01/22 00:04:43 UTC

git commit: updated refs/heads/master to f7ee27c

Updated Branches:
  refs/heads/master c0da0a884 -> f7ee27cd1


test: Add Unit Test for LibvirtVMDef DiskDef


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/f7ee27cd
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/f7ee27cd
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/f7ee27cd

Branch: refs/heads/master
Commit: f7ee27cd1c750a69f4096f83c83e3393b4d7f394
Parents: c0da0a8
Author: Wido den Hollander <wi...@42on.com>
Authored: Wed Jan 22 00:04:03 2014 +0100
Committer: Wido den Hollander <wi...@42on.com>
Committed: Wed Jan 22 00:04:29 2014 +0100

----------------------------------------------------------------------
 .../kvm/resource/LibvirtVMDefTest.java          | 25 ++++++++++++++++++++
 1 file changed, 25 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f7ee27cd/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtVMDefTest.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtVMDefTest.java b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtVMDefTest.java
index 90b8c3b..aa7570c 100644
--- a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtVMDefTest.java
+++ b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtVMDefTest.java
@@ -20,6 +20,7 @@
 package com.cloud.hypervisor.kvm.resource;
 
 import junit.framework.TestCase;
+import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.DiskDef;
 
 public class LibvirtVMDefTest extends TestCase {
 
@@ -65,4 +66,28 @@ public class LibvirtVMDefTest extends TestCase {
 
     }
 
+    public void testDiskDef() {
+        String filePath = "/var/lib/libvirt/images/disk.qcow2";
+        String diskLabel = "vda";
+
+        DiskDef disk = new DiskDef();
+        DiskDef.diskBus bus = DiskDef.diskBus.VIRTIO;
+        DiskDef.diskFmtType type = DiskDef.diskFmtType.QCOW2;
+        DiskDef.diskCacheMode cacheMode = DiskDef.diskCacheMode.WRITEBACK;
+
+        disk.defFileBasedDisk(filePath, diskLabel, bus, type);
+        disk.setCacheMode(cacheMode);
+
+        assertEquals(filePath, disk.getDiskPath());
+        assertEquals(diskLabel, disk.getDiskLabel());
+        assertEquals(bus, disk.getBusType());
+        assertEquals(DiskDef.deviceType.DISK, disk.getDeviceType());
+
+        String xmlDef = disk.toString();
+        String expectedXml = "<disk  device='disk' type='file'>\n<driver name='qemu' type='" + type.toString() + "' cache='" + cacheMode.toString() + "' />\n" +
+                             "<source file='" + filePath + "'/>\n<target dev='" + diskLabel + "' bus='" + bus.toString() + "'/>\n</disk>\n";
+
+        assertEquals(xmlDef, expectedXml);
+    }
+
 }