mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
tests: qemublock: Add tests for qemuBlockBitmapsHandleBlockcopy
Use some of the existing bitmap data to add tests for qemuBlockBitmapsHandleBlockcopy. As the output depends on the ordering in the hash table we must also install the "virdeterministichash" mock preload library. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
26f07f6870
commit
9b13af73ac
@ -803,6 +803,56 @@ testQemuBlockBitmapValidate(const void *opaque)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static const char *blockcopyPrefix = "qemublocktestdata/bitmapblockcopy/";
|
||||||
|
|
||||||
|
struct testQemuBlockBitmapBlockcopyData {
|
||||||
|
const char *name;
|
||||||
|
bool shallow;
|
||||||
|
virStorageSourcePtr chain;
|
||||||
|
const char *nodedatafile;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
testQemuBlockBitmapBlockcopy(const void *opaque)
|
||||||
|
{
|
||||||
|
const struct testQemuBlockBitmapBlockcopyData *data = opaque;
|
||||||
|
g_autofree char *actual = NULL;
|
||||||
|
g_autofree char *expectpath = NULL;
|
||||||
|
g_autoptr(virJSONValue) actions = NULL;
|
||||||
|
g_autoptr(virJSONValue) nodedatajson = NULL;
|
||||||
|
g_autoptr(virHashTable) nodedata = NULL;
|
||||||
|
g_autoptr(virStorageSource) fakemirror = virStorageSourceNew();
|
||||||
|
|
||||||
|
if (!fakemirror)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
fakemirror->nodeformat = g_strdup("mirror-format-node");
|
||||||
|
|
||||||
|
expectpath = g_strdup_printf("%s/%s%s-out.json", abs_srcdir,
|
||||||
|
blockcopyPrefix, data->name);
|
||||||
|
|
||||||
|
if (!(nodedatajson = virTestLoadFileJSON(bitmapDetectPrefix, data->nodedatafile,
|
||||||
|
".json", NULL)))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (!(nodedata = qemuMonitorJSONBlockGetNamedNodeDataJSON(nodedatajson))) {
|
||||||
|
VIR_TEST_VERBOSE("failed to load nodedata JSON\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (qemuBlockBitmapsHandleBlockcopy(data->chain, fakemirror, nodedata,
|
||||||
|
data->shallow, &actions) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (actions &&
|
||||||
|
!(actual = virJSONValueToString(actions, true)))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return virTestCompareToFile(actual, expectpath);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
mymain(void)
|
mymain(void)
|
||||||
{
|
{
|
||||||
@ -814,6 +864,7 @@ mymain(void)
|
|||||||
struct testQemuBackupIncrementalBitmapCalculateData backupbitmapcalcdata;
|
struct testQemuBackupIncrementalBitmapCalculateData backupbitmapcalcdata;
|
||||||
struct testQemuCheckpointDeleteMergeData checkpointdeletedata;
|
struct testQemuCheckpointDeleteMergeData checkpointdeletedata;
|
||||||
struct testQemuBlockBitmapValidateData blockbitmapvalidatedata;
|
struct testQemuBlockBitmapValidateData blockbitmapvalidatedata;
|
||||||
|
struct testQemuBlockBitmapBlockcopyData blockbitmapblockcopydata;
|
||||||
char *capslatest_x86_64 = NULL;
|
char *capslatest_x86_64 = NULL;
|
||||||
virQEMUCapsPtr caps_x86_64 = NULL;
|
virQEMUCapsPtr caps_x86_64 = NULL;
|
||||||
g_autoptr(virStorageSource) bitmapSourceChain = NULL;
|
g_autoptr(virStorageSource) bitmapSourceChain = NULL;
|
||||||
@ -1124,6 +1175,24 @@ mymain(void)
|
|||||||
TEST_BITMAP_VALIDATE("snapshots-synthetic-broken", "d", false);
|
TEST_BITMAP_VALIDATE("snapshots-synthetic-broken", "d", false);
|
||||||
TEST_BITMAP_VALIDATE("snapshots-synthetic-broken", "current", true);
|
TEST_BITMAP_VALIDATE("snapshots-synthetic-broken", "current", true);
|
||||||
|
|
||||||
|
#define TEST_BITMAP_BLOCKCOPY(testname, shllw, ndf) \
|
||||||
|
do { \
|
||||||
|
blockbitmapblockcopydata.name = testname; \
|
||||||
|
blockbitmapblockcopydata.shallow = shllw; \
|
||||||
|
blockbitmapblockcopydata.nodedatafile = ndf; \
|
||||||
|
blockbitmapblockcopydata.chain = bitmapSourceChain;\
|
||||||
|
if (virTestRun("bitmap block copy " testname, \
|
||||||
|
testQemuBlockBitmapBlockcopy, \
|
||||||
|
&blockbitmapblockcopydata) < 0) \
|
||||||
|
ret = -1; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
TEST_BITMAP_BLOCKCOPY("basic-shallow", true, "basic");
|
||||||
|
TEST_BITMAP_BLOCKCOPY("basic-deep", false, "basic");
|
||||||
|
|
||||||
|
TEST_BITMAP_BLOCKCOPY("snapshots-shallow", true, "snapshots");
|
||||||
|
TEST_BITMAP_BLOCKCOPY("snapshots-deep", false, "snapshots");
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virHashFree(diskxmljsondata.schema);
|
virHashFree(diskxmljsondata.schema);
|
||||||
qemuTestDriverFree(&driver);
|
qemuTestDriverFree(&driver);
|
||||||
@ -1133,4 +1202,4 @@ mymain(void)
|
|||||||
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
VIR_TEST_MAIN(mymain)
|
VIR_TEST_MAIN_PRELOAD(mymain, VIR_TEST_MOCK("virdeterministichash"))
|
||||||
|
117
tests/qemublocktestdata/bitmapblockcopy/basic-deep-out.json
Normal file
117
tests/qemublocktestdata/bitmapblockcopy/basic-deep-out.json
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"type": "block-dirty-bitmap-add",
|
||||||
|
"data": {
|
||||||
|
"node": "mirror-format-node",
|
||||||
|
"name": "a",
|
||||||
|
"persistent": true,
|
||||||
|
"disabled": true,
|
||||||
|
"granularity": 65536
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "block-dirty-bitmap-merge",
|
||||||
|
"data": {
|
||||||
|
"node": "mirror-format-node",
|
||||||
|
"target": "a",
|
||||||
|
"bitmaps": [
|
||||||
|
{
|
||||||
|
"node": "libvirt-1-format",
|
||||||
|
"name": "a"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "block-dirty-bitmap-add",
|
||||||
|
"data": {
|
||||||
|
"node": "mirror-format-node",
|
||||||
|
"name": "b",
|
||||||
|
"persistent": true,
|
||||||
|
"disabled": true,
|
||||||
|
"granularity": 65536
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "block-dirty-bitmap-merge",
|
||||||
|
"data": {
|
||||||
|
"node": "mirror-format-node",
|
||||||
|
"target": "b",
|
||||||
|
"bitmaps": [
|
||||||
|
{
|
||||||
|
"node": "libvirt-1-format",
|
||||||
|
"name": "b"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "block-dirty-bitmap-add",
|
||||||
|
"data": {
|
||||||
|
"node": "mirror-format-node",
|
||||||
|
"name": "current",
|
||||||
|
"persistent": true,
|
||||||
|
"disabled": false,
|
||||||
|
"granularity": 65536
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "block-dirty-bitmap-merge",
|
||||||
|
"data": {
|
||||||
|
"node": "mirror-format-node",
|
||||||
|
"target": "current",
|
||||||
|
"bitmaps": [
|
||||||
|
{
|
||||||
|
"node": "libvirt-1-format",
|
||||||
|
"name": "current"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "block-dirty-bitmap-add",
|
||||||
|
"data": {
|
||||||
|
"node": "mirror-format-node",
|
||||||
|
"name": "c",
|
||||||
|
"persistent": true,
|
||||||
|
"disabled": true,
|
||||||
|
"granularity": 65536
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "block-dirty-bitmap-merge",
|
||||||
|
"data": {
|
||||||
|
"node": "mirror-format-node",
|
||||||
|
"target": "c",
|
||||||
|
"bitmaps": [
|
||||||
|
{
|
||||||
|
"node": "libvirt-1-format",
|
||||||
|
"name": "c"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "block-dirty-bitmap-add",
|
||||||
|
"data": {
|
||||||
|
"node": "mirror-format-node",
|
||||||
|
"name": "d",
|
||||||
|
"persistent": true,
|
||||||
|
"disabled": true,
|
||||||
|
"granularity": 65536
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "block-dirty-bitmap-merge",
|
||||||
|
"data": {
|
||||||
|
"node": "mirror-format-node",
|
||||||
|
"target": "d",
|
||||||
|
"bitmaps": [
|
||||||
|
{
|
||||||
|
"node": "libvirt-1-format",
|
||||||
|
"name": "d"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
117
tests/qemublocktestdata/bitmapblockcopy/basic-shallow-out.json
Normal file
117
tests/qemublocktestdata/bitmapblockcopy/basic-shallow-out.json
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"type": "block-dirty-bitmap-add",
|
||||||
|
"data": {
|
||||||
|
"node": "mirror-format-node",
|
||||||
|
"name": "a",
|
||||||
|
"persistent": true,
|
||||||
|
"disabled": true,
|
||||||
|
"granularity": 65536
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "block-dirty-bitmap-merge",
|
||||||
|
"data": {
|
||||||
|
"node": "mirror-format-node",
|
||||||
|
"target": "a",
|
||||||
|
"bitmaps": [
|
||||||
|
{
|
||||||
|
"node": "libvirt-1-format",
|
||||||
|
"name": "a"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "block-dirty-bitmap-add",
|
||||||
|
"data": {
|
||||||
|
"node": "mirror-format-node",
|
||||||
|
"name": "b",
|
||||||
|
"persistent": true,
|
||||||
|
"disabled": true,
|
||||||
|
"granularity": 65536
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "block-dirty-bitmap-merge",
|
||||||
|
"data": {
|
||||||
|
"node": "mirror-format-node",
|
||||||
|
"target": "b",
|
||||||
|
"bitmaps": [
|
||||||
|
{
|
||||||
|
"node": "libvirt-1-format",
|
||||||
|
"name": "b"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "block-dirty-bitmap-add",
|
||||||
|
"data": {
|
||||||
|
"node": "mirror-format-node",
|
||||||
|
"name": "current",
|
||||||
|
"persistent": true,
|
||||||
|
"disabled": false,
|
||||||
|
"granularity": 65536
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "block-dirty-bitmap-merge",
|
||||||
|
"data": {
|
||||||
|
"node": "mirror-format-node",
|
||||||
|
"target": "current",
|
||||||
|
"bitmaps": [
|
||||||
|
{
|
||||||
|
"node": "libvirt-1-format",
|
||||||
|
"name": "current"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "block-dirty-bitmap-add",
|
||||||
|
"data": {
|
||||||
|
"node": "mirror-format-node",
|
||||||
|
"name": "c",
|
||||||
|
"persistent": true,
|
||||||
|
"disabled": true,
|
||||||
|
"granularity": 65536
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "block-dirty-bitmap-merge",
|
||||||
|
"data": {
|
||||||
|
"node": "mirror-format-node",
|
||||||
|
"target": "c",
|
||||||
|
"bitmaps": [
|
||||||
|
{
|
||||||
|
"node": "libvirt-1-format",
|
||||||
|
"name": "c"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "block-dirty-bitmap-add",
|
||||||
|
"data": {
|
||||||
|
"node": "mirror-format-node",
|
||||||
|
"name": "d",
|
||||||
|
"persistent": true,
|
||||||
|
"disabled": true,
|
||||||
|
"granularity": 65536
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "block-dirty-bitmap-merge",
|
||||||
|
"data": {
|
||||||
|
"node": "mirror-format-node",
|
||||||
|
"target": "d",
|
||||||
|
"bitmaps": [
|
||||||
|
{
|
||||||
|
"node": "libvirt-1-format",
|
||||||
|
"name": "d"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
133
tests/qemublocktestdata/bitmapblockcopy/snapshots-deep-out.json
Normal file
133
tests/qemublocktestdata/bitmapblockcopy/snapshots-deep-out.json
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"type": "block-dirty-bitmap-add",
|
||||||
|
"data": {
|
||||||
|
"node": "mirror-format-node",
|
||||||
|
"name": "a",
|
||||||
|
"persistent": true,
|
||||||
|
"disabled": true,
|
||||||
|
"granularity": 65536
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "block-dirty-bitmap-merge",
|
||||||
|
"data": {
|
||||||
|
"node": "mirror-format-node",
|
||||||
|
"target": "a",
|
||||||
|
"bitmaps": [
|
||||||
|
{
|
||||||
|
"node": "libvirt-3-format",
|
||||||
|
"name": "a"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": "libvirt-4-format",
|
||||||
|
"name": "a"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": "libvirt-5-format",
|
||||||
|
"name": "a"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "block-dirty-bitmap-add",
|
||||||
|
"data": {
|
||||||
|
"node": "mirror-format-node",
|
||||||
|
"name": "b",
|
||||||
|
"persistent": true,
|
||||||
|
"disabled": true,
|
||||||
|
"granularity": 65536
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "block-dirty-bitmap-merge",
|
||||||
|
"data": {
|
||||||
|
"node": "mirror-format-node",
|
||||||
|
"target": "b",
|
||||||
|
"bitmaps": [
|
||||||
|
{
|
||||||
|
"node": "libvirt-3-format",
|
||||||
|
"name": "b"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "block-dirty-bitmap-add",
|
||||||
|
"data": {
|
||||||
|
"node": "mirror-format-node",
|
||||||
|
"name": "current",
|
||||||
|
"persistent": true,
|
||||||
|
"disabled": false,
|
||||||
|
"granularity": 65536
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "block-dirty-bitmap-merge",
|
||||||
|
"data": {
|
||||||
|
"node": "mirror-format-node",
|
||||||
|
"target": "current",
|
||||||
|
"bitmaps": [
|
||||||
|
{
|
||||||
|
"node": "libvirt-1-format",
|
||||||
|
"name": "current"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "block-dirty-bitmap-add",
|
||||||
|
"data": {
|
||||||
|
"node": "mirror-format-node",
|
||||||
|
"name": "c",
|
||||||
|
"persistent": true,
|
||||||
|
"disabled": true,
|
||||||
|
"granularity": 65536
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "block-dirty-bitmap-merge",
|
||||||
|
"data": {
|
||||||
|
"node": "mirror-format-node",
|
||||||
|
"target": "c",
|
||||||
|
"bitmaps": [
|
||||||
|
{
|
||||||
|
"node": "libvirt-2-format",
|
||||||
|
"name": "c"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": "libvirt-3-format",
|
||||||
|
"name": "c"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "block-dirty-bitmap-add",
|
||||||
|
"data": {
|
||||||
|
"node": "mirror-format-node",
|
||||||
|
"name": "d",
|
||||||
|
"persistent": true,
|
||||||
|
"disabled": true,
|
||||||
|
"granularity": 65536
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "block-dirty-bitmap-merge",
|
||||||
|
"data": {
|
||||||
|
"node": "mirror-format-node",
|
||||||
|
"target": "d",
|
||||||
|
"bitmaps": [
|
||||||
|
{
|
||||||
|
"node": "libvirt-1-format",
|
||||||
|
"name": "d"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": "libvirt-2-format",
|
||||||
|
"name": "d"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
@ -0,0 +1,48 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"type": "block-dirty-bitmap-add",
|
||||||
|
"data": {
|
||||||
|
"node": "mirror-format-node",
|
||||||
|
"name": "current",
|
||||||
|
"persistent": true,
|
||||||
|
"disabled": false,
|
||||||
|
"granularity": 65536
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "block-dirty-bitmap-merge",
|
||||||
|
"data": {
|
||||||
|
"node": "mirror-format-node",
|
||||||
|
"target": "current",
|
||||||
|
"bitmaps": [
|
||||||
|
{
|
||||||
|
"node": "libvirt-1-format",
|
||||||
|
"name": "current"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "block-dirty-bitmap-add",
|
||||||
|
"data": {
|
||||||
|
"node": "mirror-format-node",
|
||||||
|
"name": "d",
|
||||||
|
"persistent": true,
|
||||||
|
"disabled": true,
|
||||||
|
"granularity": 65536
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "block-dirty-bitmap-merge",
|
||||||
|
"data": {
|
||||||
|
"node": "mirror-format-node",
|
||||||
|
"target": "d",
|
||||||
|
"bitmaps": [
|
||||||
|
{
|
||||||
|
"node": "libvirt-1-format",
|
||||||
|
"name": "d"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
Loading…
Reference in New Issue
Block a user