Add a test for creating a QCOW2 image with a backing file

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

Branch: refs/heads/qemu-img
Commit: 2e2750f90a133007ff7b9788cb0e846ad1b5a2d3
Parents: 281f25c
Author: Wido den Hollander <[email protected]>
Authored: Mon Feb 25 15:11:58 2013 +0100
Committer: Wido den Hollander <[email protected]>
Committed: Mon Feb 25 15:11:58 2013 +0100

----------------------------------------------------------------------
 .../apache/cloudstack/utils/qemu/QemuImgTest.java  |   23 +++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2e2750f9/utils/test/org/apache/cloudstack/utils/qemu/QemuImgTest.java
----------------------------------------------------------------------
diff --git a/utils/test/org/apache/cloudstack/utils/qemu/QemuImgTest.java 
b/utils/test/org/apache/cloudstack/utils/qemu/QemuImgTest.java
index 86237ba..e89ab91 100644
--- a/utils/test/org/apache/cloudstack/utils/qemu/QemuImgTest.java
+++ b/utils/test/org/apache/cloudstack/utils/qemu/QemuImgTest.java
@@ -214,6 +214,29 @@ public class QemuImgTest {
     }
 
     @Test
+    public void testCreateWithBackingFile() {
+        String firstFileName = "/tmp/" + UUID.randomUUID() + ".qcow2";
+        String secondFileName = "/tmp/" + UUID.randomUUID() + ".qcow2";
+
+        QemuImgFile firstFile = new QemuImgFile(firstFileName, 20480, 
PhysicalDiskFormat.QCOW2);
+        QemuImgFile secondFile = new QemuImgFile(secondFileName, 
PhysicalDiskFormat.QCOW2);
+
+        QemuImg qemu = new QemuImg();
+        qemu.create(firstFile);
+        qemu.create(secondFile, firstFile);
+
+        Map<String, String> info = qemu.info(secondFile);
+        if (info == null) {
+            fail("We didn't get any information back from qemu-img");
+        }
+
+        String backingFile = info.get(new String("backing_file"));
+        if (backingFile == null) {
+            fail("The second file does not have a property backing_file! 
Create failed?");
+        }
+    }
+
+    @Test
     public void testConvertBasic() {
         long srcSize = 20480;
         String srcFileName = "/tmp/" + UUID.randomUUID() + ".qcow2";

Reply via email to