From 2ec6317c7c490ea98011dcd4d8345eaf23891aed Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Thu, 16 Jan 2020 12:18:04 -0500 Subject: [PATCH] test/cli-integration/rbd: fixed EL8 json and xml incompatibilities Python 3 doesn't sort keys by default and xml_pp is not available under EL8. Signed-off-by: Jason Dillaman --- .../cli-integration/rbd/formatted-output.t | 148 +++++++++--------- src/test/cli-integration/rbd/snap-diff.t | 2 +- 2 files changed, 74 insertions(+), 76 deletions(-) diff --git a/src/test/cli-integration/rbd/formatted-output.t b/src/test/cli-integration/rbd/formatted-output.t index 9eba5d49e006f..04c6ebdb31ef6 100644 --- a/src/test/cli-integration/rbd/formatted-output.t +++ b/src/test/cli-integration/rbd/formatted-output.t @@ -61,7 +61,7 @@ For now, use a more inclusive regex. \tsnapshot_count: 1 (esc) [^^]+ (re) \tformat: 1 (esc) - $ rbd info foo --format json | python3 -mjson.tool | sed 's/,$/, /' + $ rbd info foo --format json | python3 -mjson.tool --sort-keys | sed 's/,$/, /' { "block_name_prefix": "rb.0.*", (glob) "format": 1, @@ -73,12 +73,10 @@ For now, use a more inclusive regex. "size": 1073741824, "snapshot_count": 1 } -The version of xml_pp included in ubuntu precise always prints a 'warning' -whenever it is run. grep -v to ignore it, but still work on other distros. - $ rbd info foo --format xml | xml_pp 2>&1 | grep -v '^new version at /usr/bin/xml_pp' + $ rbd info foo --format xml | xmlstarlet format -s 2 -o || true foo - + 1073741824 256 22 @@ -95,7 +93,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. [^^]+ (re) \tformat: 1 (esc) \tprotected: False (esc) - $ rbd info foo@snap --format json | python3 -mjson.tool | sed 's/,$/, /' + $ rbd info foo@snap --format json | python3 -mjson.tool --sort-keys | sed 's/,$/, /' { "block_name_prefix": "rb.0.*", (glob) "format": 1, @@ -108,10 +106,10 @@ whenever it is run. grep -v to ignore it, but still work on other distros. "size": 1073741824, "snapshot_count": 1 } - $ rbd info foo@snap --format xml | xml_pp 2>&1 | grep -v '^new version at /usr/bin/xml_pp' + $ rbd info foo@snap --format xml | xmlstarlet format -s 2 -o || true foo - + 1073741824 256 22 @@ -135,7 +133,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. \tcreate_timestamp:* (glob) \taccess_timestamp:* (glob) \tmodify_timestamp:* (glob) - $ rbd info bar --format json | python3 -mjson.tool | sed 's/,$/, /' + $ rbd info bar --format json | python3 -mjson.tool --sort-keys | sed 's/,$/, /' { "access_timestamp": "*", (glob) "block_name_prefix": "rbd_data.*", (glob) @@ -159,7 +157,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. "size": 1073741824, "snapshot_count": 2 } - $ rbd info bar --format xml | xml_pp 2>&1 | grep -v '^new version at /usr/bin/xml_pp' + $ rbd info bar --format xml | xmlstarlet format -s 2 -o || true bar * (glob) @@ -177,8 +175,8 @@ whenever it is run. grep -v to ignore it, but still work on other distros. fast-diff deep-flatten - - + + * (glob) * (glob) * (glob) @@ -198,7 +196,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. \taccess_timestamp:* (glob) \tmodify_timestamp:* (glob) \tprotected: True (esc) - $ rbd info bar@snap --format json | python3 -mjson.tool | sed 's/,$/, /' + $ rbd info bar@snap --format json | python3 -mjson.tool --sort-keys | sed 's/,$/, /' { "access_timestamp": "*", (glob) "block_name_prefix": "rbd_data.*", (glob) @@ -223,7 +221,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. "size": 536870912, "snapshot_count": 2 } - $ rbd info bar@snap --format xml | xml_pp 2>&1 | grep -v '^new version at /usr/bin/xml_pp' + $ rbd info bar@snap --format xml | xmlstarlet format -s 2 -o || true bar * (glob) @@ -241,8 +239,8 @@ whenever it is run. grep -v to ignore it, but still work on other distros. fast-diff deep-flatten - - + + * (glob) * (glob) * (glob) @@ -263,7 +261,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. \taccess_timestamp:* (glob) \tmodify_timestamp:* (glob) \tprotected: False (esc) - $ rbd info bar@snap2 --format json | python3 -mjson.tool | sed 's/,$/, /' + $ rbd info bar@snap2 --format json | python3 -mjson.tool --sort-keys | sed 's/,$/, /' { "access_timestamp": "*", (glob) "block_name_prefix": "rbd_data.*", (glob) @@ -288,7 +286,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. "size": 1073741824, "snapshot_count": 2 } - $ rbd info bar@snap2 --format xml | xml_pp 2>&1 | grep -v '^new version at /usr/bin/xml_pp' + $ rbd info bar@snap2 --format xml | xmlstarlet format -s 2 -o || true bar * (glob) @@ -306,8 +304,8 @@ whenever it is run. grep -v to ignore it, but still work on other distros. fast-diff deep-flatten - - + + * (glob) * (glob) * (glob) @@ -327,7 +325,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. \tcreate_timestamp:* (glob) \taccess_timestamp:* (glob) \tmodify_timestamp:* (glob) - $ rbd info baz --format json | python3 -mjson.tool | sed 's/,$/, /' + $ rbd info baz --format json | python3 -mjson.tool --sort-keys | sed 's/,$/, /' { "access_timestamp": "*", (glob) "block_name_prefix": "rbd_data.*", (glob) @@ -347,7 +345,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. "size": 2147483648, "snapshot_count": 0 } - $ rbd info baz --format xml | xml_pp 2>&1 | grep -v '^new version at /usr/bin/xml_pp' + $ rbd info baz --format xml | xmlstarlet format -s 2 -o || true baz * (glob) @@ -361,8 +359,8 @@ whenever it is run. grep -v to ignore it, but still work on other distros. layering - - + + * (glob) * (glob) * (glob) @@ -374,7 +372,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. \tsnapshot_count: 0 (esc) [^^]+ (re) \tformat: 1 (esc) - $ rbd info quux --format json | python3 -mjson.tool | sed 's/,$/, /' + $ rbd info quux --format json | python3 -mjson.tool --sort-keys | sed 's/,$/, /' { "block_name_prefix": "rb.0.*", (glob) "format": 1, @@ -386,10 +384,10 @@ whenever it is run. grep -v to ignore it, but still work on other distros. "size": 1048576, "snapshot_count": 0 } - $ rbd info quux --format xml | xml_pp 2>&1 | grep -v '^new version at /usr/bin/xml_pp' + $ rbd info quux --format xml | xmlstarlet format -s 2 -o || true quux - + 1048576 1 22 @@ -412,7 +410,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. \tcreate_timestamp:* (glob) \taccess_timestamp:* (glob) \tmodify_timestamp:* (glob) - $ rbd info rbd_other/child --format json | python3 -mjson.tool | sed 's/,$/, /' + $ rbd info rbd_other/child --format json | python3 -mjson.tool --sort-keys | sed 's/,$/, /' { "access_timestamp": "*", (glob) "block_name_prefix": "rbd_data.*", (glob) @@ -435,7 +433,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. "size": 536870912, "snapshot_count": 1 } - $ rbd info rbd_other/child --format xml | xml_pp 2>&1 | grep -v '^new version at /usr/bin/xml_pp' + $ rbd info rbd_other/child --format xml | xmlstarlet format -s 2 -o || true child * (glob) @@ -452,8 +450,8 @@ whenever it is run. grep -v to ignore it, but still work on other distros. object-map fast-diff - - + + * (glob) * (glob) * (glob) @@ -475,7 +473,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. \tprotected: False (esc) \tparent: rbd/bar@snap (esc) \toverlap: 512 MiB (esc) - $ rbd info rbd_other/child@snap --format json | python3 -mjson.tool | sed 's/,$/, /' + $ rbd info rbd_other/child@snap --format json | python3 -mjson.tool --sort-keys | sed 's/,$/, /' { "access_timestamp": "*", (glob) "block_name_prefix": "rbd_data.*", (glob) @@ -508,7 +506,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. "size": 536870912, "snapshot_count": 1 } - $ rbd info rbd_other/child@snap --format xml | xml_pp 2>&1 | grep -v '^new version at /usr/bin/xml_pp' + $ rbd info rbd_other/child@snap --format xml | xmlstarlet format -s 2 -o || true child * (glob) @@ -525,15 +523,15 @@ whenever it is run. grep -v to ignore it, but still work on other distros. object-map fast-diff - - + + * (glob) * (glob) * (glob) false rbd - + bar * (glob) snap @@ -555,7 +553,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. \tcreate_timestamp:* (glob) \taccess_timestamp:* (glob) \tmodify_timestamp:* (glob) - $ rbd info rbd_other/deep-flatten-child --format json | python3 -mjson.tool | sed 's/,$/, /' + $ rbd info rbd_other/deep-flatten-child --format json | python3 -mjson.tool --sort-keys | sed 's/,$/, /' { "access_timestamp": "*", (glob) "block_name_prefix": "rbd_data.*", (glob) @@ -579,7 +577,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. "size": 536870912, "snapshot_count": 1 } - $ rbd info rbd_other/deep-flatten-child --format xml | xml_pp 2>&1 | grep -v '^new version at /usr/bin/xml_pp' + $ rbd info rbd_other/deep-flatten-child --format xml | xmlstarlet format -s 2 -o || true deep-flatten-child * (glob) @@ -597,8 +595,8 @@ whenever it is run. grep -v to ignore it, but still work on other distros. fast-diff deep-flatten - - + + * (glob) * (glob) * (glob) @@ -618,7 +616,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. \taccess_timestamp:* (glob) \tmodify_timestamp:* (glob) \tprotected: False (esc) - $ rbd info rbd_other/deep-flatten-child@snap --format json | python3 -mjson.tool | sed 's/,$/, /' + $ rbd info rbd_other/deep-flatten-child@snap --format json | python3 -mjson.tool --sort-keys | sed 's/,$/, /' { "access_timestamp": "*", (glob) "block_name_prefix": "rbd_data.*", (glob) @@ -643,7 +641,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. "size": 536870912, "snapshot_count": 1 } - $ rbd info rbd_other/deep-flatten-child@snap --format xml | xml_pp 2>&1 | grep -v '^new version at /usr/bin/xml_pp' + $ rbd info rbd_other/deep-flatten-child@snap --format xml | xmlstarlet format -s 2 -o || true deep-flatten-child * (glob) @@ -661,8 +659,8 @@ whenever it is run. grep -v to ignore it, but still work on other distros. fast-diff deep-flatten - - + + * (glob) * (glob) * (glob) @@ -674,7 +672,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. bar baz quuy - $ rbd list --format json | python3 -mjson.tool | sed 's/,$/, /' + $ rbd list --format json | python3 -mjson.tool --sort-keys | sed 's/,$/, /' [ "foo", "quux", @@ -682,7 +680,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. "baz", "quuy" ] - $ rbd list --format xml | xml_pp 2>&1 | grep -v '^new version at /usr/bin/xml_pp' + $ rbd list --format xml | xmlstarlet format -s 2 -o || true foo quux @@ -700,7 +698,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. bar@snap2 1 GiB 2 baz 2 GiB 2 shr quuy 2 GiB 2 - $ rbd list -l --format json | python3 -mjson.tool | sed 's/,$/, /' + $ rbd list -l --format json | python3 -mjson.tool --sort-keys | sed 's/,$/, /' [ { "format": 1, @@ -762,17 +760,17 @@ whenever it is run. grep -v to ignore it, but still work on other distros. "size": 2147483648 } ] - $ rbd list -l --format xml | xml_pp 2>&1 | grep -v '^new version at /usr/bin/xml_pp' + $ rbd list -l --format xml | xmlstarlet format -s 2 -o || true foo - + 1073741824 1 foo - + snap * (glob) 1073741824 @@ -781,7 +779,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. quux - + 1048576 1 exclusive @@ -827,12 +825,12 @@ whenever it is run. grep -v to ignore it, but still work on other distros. $ rbd list rbd_other child deep-flatten-child - $ rbd list rbd_other --format json | python3 -mjson.tool | sed 's/,$/, /' + $ rbd list rbd_other --format json | python3 -mjson.tool --sort-keys | sed 's/,$/, /' [ "child", "deep-flatten-child" ] - $ rbd list rbd_other --format xml | xml_pp 2>&1 | grep -v '^new version at /usr/bin/xml_pp' + $ rbd list rbd_other --format xml | xmlstarlet format -s 2 -o || true child deep-flatten-child @@ -843,7 +841,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. child@snap 512 MiB rbd/bar@snap 2 deep-flatten-child 512 MiB 2 deep-flatten-child@snap 512 MiB 2 - $ rbd list rbd_other -l --format json | python3 -mjson.tool | sed 's/,$/, /' + $ rbd list rbd_other -l --format json | python3 -mjson.tool --sort-keys | sed 's/,$/, /' [ { "format": 2, @@ -882,7 +880,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. "snapshot_id": * (glob) } ] - $ rbd list rbd_other -l --format xml | xml_pp 2>&1 | grep -v '^new version at /usr/bin/xml_pp' + $ rbd list rbd_other -l --format xml | xmlstarlet format -s 2 -o || true child @@ -898,7 +896,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. 536870912 rbd - + bar snap @@ -922,15 +920,15 @@ whenever it is run. grep -v to ignore it, but still work on other distros. $ rbd lock list foo - $ rbd lock list foo --format json | python3 -mjson.tool | sed 's/,$/, /' + $ rbd lock list foo --format json | python3 -mjson.tool --sort-keys | sed 's/,$/, /' [] - $ rbd lock list foo --format xml | xml_pp 2>&1 | grep -v '^new version at /usr/bin/xml_pp' - + $ rbd lock list foo --format xml | xmlstarlet format -s 2 -o || true + $ rbd lock list quux There is 1 exclusive lock on this image. Locker*ID*Address* (glob) client.* id * (glob) - $ rbd lock list quux --format json | python3 -mjson.tool | sed 's/,$/, /' + $ rbd lock list quux --format json | python3 -mjson.tool --sort-keys | sed 's/,$/, /' [ { "address": "*", (glob) @@ -938,7 +936,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. "locker": "client.*" (glob) } ] - $ rbd lock list quux --format xml | xml_pp 2>&1 | grep -v '^new version at /usr/bin/xml_pp' + $ rbd lock list quux --format xml | xmlstarlet format -s 2 -o || true id @@ -953,7 +951,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. client.*id[123].* (re) client.*id[123].* (re) client.*id[123].* (re) - $ rbd lock list baz --format json | python3 -mjson.tool | sed 's/,$/, /' + $ rbd lock list baz --format json | python3 -mjson.tool --sort-keys | sed 's/,$/, /' [ { "address": "*", (glob) @@ -971,7 +969,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. "locker": "client.*" (glob) } ] - $ rbd lock list baz --format xml | xml_pp 2>&1 | grep -v '^new version at /usr/bin/xml_pp' + $ rbd lock list baz --format xml | xmlstarlet format -s 2 -o || true id* (glob) @@ -992,7 +990,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. $ rbd snap list foo SNAPID*NAME*SIZE*PROTECTED*TIMESTAMP* (glob) *snap*1 GiB* (glob) - $ rbd snap list foo --format json | python3 -mjson.tool | sed 's/,$/, /' + $ rbd snap list foo --format json | python3 -mjson.tool --sort-keys | sed 's/,$/, /' [ { "id": *, (glob) @@ -1002,21 +1000,21 @@ whenever it is run. grep -v to ignore it, but still work on other distros. "timestamp": "" } ] - $ rbd snap list foo --format xml | xml_pp 2>&1 | grep -v '^new version at /usr/bin/xml_pp' + $ rbd snap list foo --format xml | xmlstarlet format -s 2 -o || true * (glob) snap 1073741824 false - + $ rbd snap list bar SNAPID*NAME*SIZE*PROTECTED*TIMESTAMP* (glob) *snap*512 MiB*yes* (glob) *snap2*1 GiB* (glob) - $ rbd snap list bar --format json | python3 -mjson.tool | sed 's/,$/, /' + $ rbd snap list bar --format json | python3 -mjson.tool --sort-keys | sed 's/,$/, /' [ { "id": *, (glob) @@ -1033,7 +1031,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. "timestamp": * (glob) } ] - $ rbd snap list bar --format xml | xml_pp 2>&1 | grep -v '^new version at /usr/bin/xml_pp' + $ rbd snap list bar --format xml | xmlstarlet format -s 2 -o || true * (glob) @@ -1051,14 +1049,14 @@ whenever it is run. grep -v to ignore it, but still work on other distros. $ rbd snap list baz - $ rbd snap list baz --format json | python3 -mjson.tool | sed 's/,$/, /' + $ rbd snap list baz --format json | python3 -mjson.tool --sort-keys | sed 's/,$/, /' [] - $ rbd snap list baz --format xml | xml_pp 2>&1 | grep -v '^new version at /usr/bin/xml_pp' - + $ rbd snap list baz --format xml | xmlstarlet format -s 2 -o || true + $ rbd snap list rbd_other/child SNAPID*NAME*SIZE*PROTECTED*TIMESTAMP* (glob) *snap*512 MiB* (glob) - $ rbd snap list rbd_other/child --format json | python3 -mjson.tool | sed 's/,$/, /' + $ rbd snap list rbd_other/child --format json | python3 -mjson.tool --sort-keys | sed 's/,$/, /' [ { "id": *, (glob) @@ -1068,7 +1066,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. "timestamp": * (glob) } ] - $ rbd snap list rbd_other/child --format xml | xml_pp 2>&1 | grep -v '^new version at /usr/bin/xml_pp' + $ rbd snap list rbd_other/child --format xml | xmlstarlet format -s 2 -o || true * (glob) @@ -1085,7 +1083,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. deep-flatten-child@snap 512 MiB 0 B deep-flatten-child 512 MiB 0 B 1 GiB 4 MiB - $ rbd disk-usage --pool rbd_other --format json | python3 -mjson.tool | sed 's/,$/, /' + $ rbd disk-usage --pool rbd_other --format json | python3 -mjson.tool --sort-keys | sed 's/,$/, /' { "images": [ { @@ -1120,7 +1118,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. "total_provisioned_size": 1073741824, "total_used_size": 4194304 } - $ rbd disk-usage --pool rbd_other --format xml | xml_pp 2>&1 | grep -v '^new version at /usr/bin/xml_pp' + $ rbd disk-usage --pool rbd_other --format xml | xmlstarlet format -s 2 -o || true diff --git a/src/test/cli-integration/rbd/snap-diff.t b/src/test/cli-integration/rbd/snap-diff.t index 86d1671de2d77..ba9c0d6fed612 100644 --- a/src/test/cli-integration/rbd/snap-diff.t +++ b/src/test/cli-integration/rbd/snap-diff.t @@ -19,7 +19,7 @@ $ rbd diff --from-snap=allzeroes xrbddiff1/xtestdiff1 --format json [{"offset":0,"length":1048576,"exists":"true"}] $ rbd snap create xrbddiff1/xtestdiff1 --snap=snap1 - $ rbd snap list xrbddiff1/xtestdiff1 --format json | python3 -mjson.tool | sed 's/,$/, /' + $ rbd snap list xrbddiff1/xtestdiff1 --format json | python3 -mjson.tool --sort-keys | sed 's/,$/, /' [ { "id": *, (glob) -- 2.39.5