a41c76
From 8528b76210e54f664f2098e0127dac811f12800a Mon Sep 17 00:00:00 2001
a41c76
Message-Id: <8528b76210e54f664f2098e0127dac811f12800a@dist-git>
a41c76
From: Peter Krempa <pkrempa@redhat.com>
a41c76
Date: Tue, 23 Jun 2020 12:23:59 +0200
a41c76
Subject: [PATCH] qemublocktest: Add 'snapshots' tests for backup bitmap
a41c76
 handling
a41c76
MIME-Version: 1.0
a41c76
Content-Type: text/plain; charset=UTF-8
a41c76
Content-Transfer-Encoding: 8bit
a41c76
a41c76
The 'snapshots' case has multiple layers so we need to make sure that
a41c76
the bitmaps are merged with the appropriate temporary bitmaps formatted
a41c76
from the allocation bitmap for any backing chain layer above.
a41c76
a41c76
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
a41c76
Reviewed-by: Eric Blake <eblake@redhat.com>
a41c76
(cherry picked from commit b630cf4c0d8446a301fd23e87c9e8d60d547b5e8)
a41c76
https://bugzilla.redhat.com/show_bug.cgi?id=1804593
a41c76
Message-Id: <3ef354322f829f47c91738060dd6557462e6d6d5.1592906423.git.pkrempa@redhat.com>
a41c76
Reviewed-by: Ján Tomko <jtomko@redhat.com>
a41c76
---
a41c76
 tests/qemublocktest.c                         |  4 ++
a41c76
 .../backupmerge/snapshots-deep-out.json       | 41 +++++++++++++++++++
a41c76
 .../backupmerge/snapshots-flat-out.json       | 25 +++++++++++
a41c76
 .../snapshots-intermediate-out.json           | 29 +++++++++++++
a41c76
 4 files changed, 99 insertions(+)
a41c76
 create mode 100644 tests/qemublocktestdata/backupmerge/snapshots-deep-out.json
a41c76
 create mode 100644 tests/qemublocktestdata/backupmerge/snapshots-flat-out.json
a41c76
 create mode 100644 tests/qemublocktestdata/backupmerge/snapshots-intermediate-out.json
a41c76
a41c76
diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c
a41c76
index 7a0159f659..8ce878f15b 100644
a41c76
--- a/tests/qemublocktest.c
a41c76
+++ b/tests/qemublocktest.c
a41c76
@@ -1266,6 +1266,10 @@ mymain(void)
a41c76
     TEST_BACKUP_BITMAP_CALCULATE("basic-intermediate", bitmapSourceChain, "d", "basic");
a41c76
     TEST_BACKUP_BITMAP_CALCULATE("basic-deep", bitmapSourceChain, "a", "basic");
a41c76
 
a41c76
+    TEST_BACKUP_BITMAP_CALCULATE("snapshots-flat", bitmapSourceChain, "current", "snapshots");
a41c76
+    TEST_BACKUP_BITMAP_CALCULATE("snapshots-intermediate", bitmapSourceChain, "d", "snapshots");
a41c76
+    TEST_BACKUP_BITMAP_CALCULATE("snapshots-deep", bitmapSourceChain, "a", "snapshots");
a41c76
+
a41c76
 #define TEST_CHECKPOINT_DELETE(testname, delbmp, named) \
a41c76
     do { \
a41c76
         checkpointdeletedata.name = testname; \
a41c76
diff --git a/tests/qemublocktestdata/backupmerge/snapshots-deep-out.json b/tests/qemublocktestdata/backupmerge/snapshots-deep-out.json
a41c76
new file mode 100644
a41c76
index 0000000000..d678507b85
a41c76
--- /dev/null
a41c76
+++ b/tests/qemublocktestdata/backupmerge/snapshots-deep-out.json
a41c76
@@ -0,0 +1,41 @@
a41c76
+[
a41c76
+  {
a41c76
+    "type": "block-dirty-bitmap-add",
a41c76
+    "data": {
a41c76
+      "node": "target_node",
a41c76
+      "name": "target-bitmap-name",
a41c76
+      "persistent": false,
a41c76
+      "disabled": true,
a41c76
+      "granularity": 65536
a41c76
+    }
a41c76
+  },
a41c76
+  {
a41c76
+    "type": "block-dirty-bitmap-merge",
a41c76
+    "data": {
a41c76
+      "node": "target_node",
a41c76
+      "target": "target-bitmap-name",
a41c76
+      "bitmaps": [
a41c76
+        {
a41c76
+          "node": "libvirt-1-format",
a41c76
+          "name": "a"
a41c76
+        },
a41c76
+        {
a41c76
+          "node": "libvirt-2-format",
a41c76
+          "name": "a"
a41c76
+        },
a41c76
+        {
a41c76
+          "node": "libvirt-3-format",
a41c76
+          "name": "a"
a41c76
+        },
a41c76
+        {
a41c76
+          "node": "libvirt-4-format",
a41c76
+          "name": "a"
a41c76
+        },
a41c76
+        {
a41c76
+          "node": "libvirt-5-format",
a41c76
+          "name": "a"
a41c76
+        }
a41c76
+      ]
a41c76
+    }
a41c76
+  }
a41c76
+]
a41c76
diff --git a/tests/qemublocktestdata/backupmerge/snapshots-flat-out.json b/tests/qemublocktestdata/backupmerge/snapshots-flat-out.json
a41c76
new file mode 100644
a41c76
index 0000000000..4637bbc377
a41c76
--- /dev/null
a41c76
+++ b/tests/qemublocktestdata/backupmerge/snapshots-flat-out.json
a41c76
@@ -0,0 +1,25 @@
a41c76
+[
a41c76
+  {
a41c76
+    "type": "block-dirty-bitmap-add",
a41c76
+    "data": {
a41c76
+      "node": "target_node",
a41c76
+      "name": "target-bitmap-name",
a41c76
+      "persistent": false,
a41c76
+      "disabled": true,
a41c76
+      "granularity": 65536
a41c76
+    }
a41c76
+  },
a41c76
+  {
a41c76
+    "type": "block-dirty-bitmap-merge",
a41c76
+    "data": {
a41c76
+      "node": "target_node",
a41c76
+      "target": "target-bitmap-name",
a41c76
+      "bitmaps": [
a41c76
+        {
a41c76
+          "node": "libvirt-1-format",
a41c76
+          "name": "current"
a41c76
+        }
a41c76
+      ]
a41c76
+    }
a41c76
+  }
a41c76
+]
a41c76
diff --git a/tests/qemublocktestdata/backupmerge/snapshots-intermediate-out.json b/tests/qemublocktestdata/backupmerge/snapshots-intermediate-out.json
a41c76
new file mode 100644
a41c76
index 0000000000..30d8bcd8b7
a41c76
--- /dev/null
a41c76
+++ b/tests/qemublocktestdata/backupmerge/snapshots-intermediate-out.json
a41c76
@@ -0,0 +1,29 @@
a41c76
+[
a41c76
+  {
a41c76
+    "type": "block-dirty-bitmap-add",
a41c76
+    "data": {
a41c76
+      "node": "target_node",
a41c76
+      "name": "target-bitmap-name",
a41c76
+      "persistent": false,
a41c76
+      "disabled": true,
a41c76
+      "granularity": 65536
a41c76
+    }
a41c76
+  },
a41c76
+  {
a41c76
+    "type": "block-dirty-bitmap-merge",
a41c76
+    "data": {
a41c76
+      "node": "target_node",
a41c76
+      "target": "target-bitmap-name",
a41c76
+      "bitmaps": [
a41c76
+        {
a41c76
+          "node": "libvirt-1-format",
a41c76
+          "name": "d"
a41c76
+        },
a41c76
+        {
a41c76
+          "node": "libvirt-2-format",
a41c76
+          "name": "d"
a41c76
+        }
a41c76
+      ]
a41c76
+    }
a41c76
+  }
a41c76
+]
a41c76
-- 
a41c76
2.27.0
a41c76