src/test: misc python -> python3

Signed-off-by: Sage Weil <sage@redhat.com>
This commit is contained in:
Sage Weil 2019-12-19 16:31:34 -06:00
parent c87a76096e
commit 13cbfaaea8
7 changed files with 51 additions and 51 deletions

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
import json
import sys

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
import json
import sys

View File

@ -1,7 +1,7 @@
Plain create with various options specified via usual cli arguments
===================================================================
$ rbd create -s 1 test
$ rbd info test --format json | python -mjson.tool | sed 's/,$/, /'
$ rbd info test --format json | python3 -mjson.tool | sed 's/,$/, /'
{
"block_name_prefix": "rb.0.*", (glob)
"format": 1,
@ -13,7 +13,7 @@ Plain create with various options specified via usual cli arguments
}
$ rbd rm test --no-progress
$ rbd create -s 1 --object-size 1M test
$ rbd info test --format json | python -mjson.tool | sed 's/,$/, /'
$ rbd info test --format json | python3 -mjson.tool | sed 's/,$/, /'
{
"block_name_prefix": "rb.0.*", (glob)
"format": 1,
@ -25,7 +25,7 @@ Plain create with various options specified via usual cli arguments
}
$ rbd rm test --no-progress
$ rbd create -s 1G --object-size 4K test
$ rbd info test --format json | python -mjson.tool | sed 's/,$/, /'
$ rbd info test --format json | python3 -mjson.tool | sed 's/,$/, /'
{
"block_name_prefix": "rb.0.*", (glob)
"format": 1,
@ -37,7 +37,7 @@ Plain create with various options specified via usual cli arguments
}
$ rbd rm test --no-progress
$ rbd create -s 1 test --image-format 2
$ rbd info test --format json | python -mjson.tool | sed 's/,$/, /'
$ rbd info test --format json | python3 -mjson.tool | sed 's/,$/, /'
{
"block_name_prefix": "rbd_data.*", (glob)
"features": [
@ -54,7 +54,7 @@ Plain create with various options specified via usual cli arguments
}
$ rbd rm test --no-progress
$ rbd create -s 1G test --image-format 2
$ rbd info test --format json | python -mjson.tool | sed 's/,$/, /'
$ rbd info test --format json | python3 -mjson.tool | sed 's/,$/, /'
{
"block_name_prefix": "rbd_data.*", (glob)
"features": [
@ -71,7 +71,7 @@ Plain create with various options specified via usual cli arguments
}
$ rbd rm test --no-progress
$ rbd create -s 1 test --image-format 2 --object-size 1M
$ rbd info test --format json | python -mjson.tool | sed 's/,$/, /'
$ rbd info test --format json | python3 -mjson.tool | sed 's/,$/, /'
{
"block_name_prefix": "rbd_data.*", (glob)
"features": [
@ -88,7 +88,7 @@ Plain create with various options specified via usual cli arguments
}
$ rbd rm test --no-progress
$ rbd create -s 1 test --image-format 2 --stripe-unit 1048576 --stripe-count 8
$ rbd info test --format json | python -mjson.tool | sed 's/,$/, /'
$ rbd info test --format json | python3 -mjson.tool | sed 's/,$/, /'
{
"block_name_prefix": "rbd_data.*", (glob)
"features": [
@ -107,7 +107,7 @@ Plain create with various options specified via usual cli arguments
}
$ rbd rm test --no-progress
$ rbd create -s 1 test --image-format 2 --stripe-unit 1048576B --stripe-count 8
$ rbd info test --format json | python -mjson.tool | sed 's/,$/, /'
$ rbd info test --format json | python3 -mjson.tool | sed 's/,$/, /'
{
"block_name_prefix": "rbd_data.*", (glob)
"features": [
@ -126,7 +126,7 @@ Plain create with various options specified via usual cli arguments
}
$ rbd rm test --no-progress
$ rbd create -s 1G test --image-format 2 --stripe-unit 4K --stripe-count 8
$ rbd info test --format json | python -mjson.tool | sed 's/,$/, /'
$ rbd info test --format json | python3 -mjson.tool | sed 's/,$/, /'
{
"block_name_prefix": "rbd_data.*", (glob)
"features": [
@ -145,7 +145,7 @@ Plain create with various options specified via usual cli arguments
}
$ rbd rm test --no-progress
$ rbd create -s 1G test --image-format 2 --stripe-unit 1M --stripe-count 8
$ rbd info test --format json | python -mjson.tool | sed 's/,$/, /'
$ rbd info test --format json | python3 -mjson.tool | sed 's/,$/, /'
{
"block_name_prefix": "rbd_data.*", (glob)
"features": [
@ -167,7 +167,7 @@ Plain create with various options specified via usual cli arguments
Format 2 Usual arguments with custom rbd_default_* params
=========================================================
$ rbd create -s 1 test --image-format 2 --stripe-unit 1048576 --stripe-count 8 --rbd-default-order 21
$ rbd info test --format json | python -mjson.tool | sed 's/,$/, /'
$ rbd info test --format json | python3 -mjson.tool | sed 's/,$/, /'
{
"block_name_prefix": "rbd_data.*", (glob)
"features": [
@ -186,7 +186,7 @@ Format 2 Usual arguments with custom rbd_default_* params
}
$ rbd rm test --no-progress
$ rbd create -s 1 test --image-format 2 --stripe-unit 1048576 --stripe-count 8 --object-size 8M --rbd-default-order 20
$ rbd info test --format json | python -mjson.tool | sed 's/,$/, /'
$ rbd info test --format json | python3 -mjson.tool | sed 's/,$/, /'
{
"block_name_prefix": "rbd_data.*", (glob)
"features": [
@ -205,7 +205,7 @@ Format 2 Usual arguments with custom rbd_default_* params
}
$ rbd rm test --no-progress
$ rbd create -s 1 test --image-format 2 --rbd-default-stripe-unit 1048576 --rbd-default-stripe-count 8
$ rbd info test --format json | python -mjson.tool | sed 's/,$/, /'
$ rbd info test --format json | python3 -mjson.tool | sed 's/,$/, /'
{
"block_name_prefix": "rbd_data.*", (glob)
"features": [
@ -227,7 +227,7 @@ Format 2 Usual arguments with custom rbd_default_* params
Format 1 Usual arguments with custom rbd_default_* params
=========================================================
$ rbd create -s 1 test --rbd-default-order 20
$ rbd info test --format json | python -mjson.tool | sed 's/,$/, /'
$ rbd info test --format json | python3 -mjson.tool | sed 's/,$/, /'
{
"block_name_prefix": "rb.0.*", (glob)
"format": 1,
@ -239,7 +239,7 @@ Format 1 Usual arguments with custom rbd_default_* params
}
$ rbd rm test --no-progress
$ rbd create -s 1 test --rbd-default-format 2
$ rbd info test --format json | python -mjson.tool | sed 's/,$/, /'
$ rbd info test --format json | python3 -mjson.tool | sed 's/,$/, /'
{
"block_name_prefix": "rbd_data.*", (glob)
"features": [
@ -256,7 +256,7 @@ Format 1 Usual arguments with custom rbd_default_* params
}
$ rbd rm test --no-progress
$ rbd create -s 1 test --rbd-default-format 2 --rbd-default-order 20
$ rbd info test --format json | python -mjson.tool | sed 's/,$/, /'
$ rbd info test --format json | python3 -mjson.tool | sed 's/,$/, /'
{
"block_name_prefix": "rbd_data.*", (glob)
"features": [
@ -273,7 +273,7 @@ Format 1 Usual arguments with custom rbd_default_* params
}
$ rbd rm test --no-progress
$ rbd create -s 1 test --rbd-default-format 2 --rbd-default-order 20 --rbd-default-features 1
$ rbd info test --format json | python -mjson.tool | sed 's/,$/, /'
$ rbd info test --format json | python3 -mjson.tool | sed 's/,$/, /'
{
"block_name_prefix": "rbd_data.*", (glob)
"features": [
@ -290,7 +290,7 @@ Format 1 Usual arguments with custom rbd_default_* params
}
$ rbd rm test --no-progress
$ rbd create -s 1 test --rbd-default-format 2 --stripe-unit 1048576 --stripe-count 8
$ rbd info test --format json | python -mjson.tool | sed 's/,$/, /'
$ rbd info test --format json | python3 -mjson.tool | sed 's/,$/, /'
{
"block_name_prefix": "rbd_data.*", (glob)
"features": [

View File

@ -61,7 +61,7 @@ For now, use a more inclusive regex.
\tsnapshot_count: 1 (esc)
[^^]+ (re)
\tformat: 1 (esc)
$ rbd info foo --format json | python -mjson.tool | sed 's/,$/, /'
$ rbd info foo --format json | python3 -mjson.tool | sed 's/,$/, /'
{
"block_name_prefix": "rb.0.*", (glob)
"format": 1,
@ -95,7 +95,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 | python -mjson.tool | sed 's/,$/, /'
$ rbd info foo@snap --format json | python3 -mjson.tool | sed 's/,$/, /'
{
"block_name_prefix": "rb.0.*", (glob)
"format": 1,
@ -135,7 +135,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 | python -mjson.tool | sed 's/,$/, /'
$ rbd info bar --format json | python3 -mjson.tool | sed 's/,$/, /'
{
"access_timestamp": "*", (glob)
"block_name_prefix": "rbd_data.*", (glob)
@ -198,7 +198,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 | python -mjson.tool | sed 's/,$/, /'
$ rbd info bar@snap --format json | python3 -mjson.tool | sed 's/,$/, /'
{
"access_timestamp": "*", (glob)
"block_name_prefix": "rbd_data.*", (glob)
@ -263,7 +263,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 | python -mjson.tool | sed 's/,$/, /'
$ rbd info bar@snap2 --format json | python3 -mjson.tool | sed 's/,$/, /'
{
"access_timestamp": "*", (glob)
"block_name_prefix": "rbd_data.*", (glob)
@ -327,7 +327,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 | python -mjson.tool | sed 's/,$/, /'
$ rbd info baz --format json | python3 -mjson.tool | sed 's/,$/, /'
{
"access_timestamp": "*", (glob)
"block_name_prefix": "rbd_data.*", (glob)
@ -374,7 +374,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 | python -mjson.tool | sed 's/,$/, /'
$ rbd info quux --format json | python3 -mjson.tool | sed 's/,$/, /'
{
"block_name_prefix": "rb.0.*", (glob)
"format": 1,
@ -412,7 +412,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 | python -mjson.tool | sed 's/,$/, /'
$ rbd info rbd_other/child --format json | python3 -mjson.tool | sed 's/,$/, /'
{
"access_timestamp": "*", (glob)
"block_name_prefix": "rbd_data.*", (glob)
@ -475,7 +475,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 | python -mjson.tool | sed 's/,$/, /'
$ rbd info rbd_other/child@snap --format json | python3 -mjson.tool | sed 's/,$/, /'
{
"access_timestamp": "*", (glob)
"block_name_prefix": "rbd_data.*", (glob)
@ -555,7 +555,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 | python -mjson.tool | sed 's/,$/, /'
$ rbd info rbd_other/deep-flatten-child --format json | python3 -mjson.tool | sed 's/,$/, /'
{
"access_timestamp": "*", (glob)
"block_name_prefix": "rbd_data.*", (glob)
@ -618,7 +618,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 | python -mjson.tool | sed 's/,$/, /'
$ rbd info rbd_other/deep-flatten-child@snap --format json | python3 -mjson.tool | sed 's/,$/, /'
{
"access_timestamp": "*", (glob)
"block_name_prefix": "rbd_data.*", (glob)
@ -674,7 +674,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros.
bar
baz
quuy
$ rbd list --format json | python -mjson.tool | sed 's/,$/, /'
$ rbd list --format json | python3 -mjson.tool | sed 's/,$/, /'
[
"foo",
"quux",
@ -700,7 +700,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 | python -mjson.tool | sed 's/,$/, /'
$ rbd list -l --format json | python3 -mjson.tool | sed 's/,$/, /'
[
{
"format": 1,
@ -827,7 +827,7 @@ 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 | python -mjson.tool | sed 's/,$/, /'
$ rbd list rbd_other --format json | python3 -mjson.tool | sed 's/,$/, /'
[
"child",
"deep-flatten-child"
@ -843,7 +843,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 | python -mjson.tool | sed 's/,$/, /'
$ rbd list rbd_other -l --format json | python3 -mjson.tool | sed 's/,$/, /'
[
{
"format": 2,
@ -922,7 +922,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros.
</snapshot>
</images>
$ rbd lock list foo
$ rbd lock list foo --format json | python -mjson.tool | sed 's/,$/, /'
$ rbd lock list foo --format json | python3 -mjson.tool | sed 's/,$/, /'
[]
$ rbd lock list foo --format xml | xml_pp 2>&1 | grep -v '^new version at /usr/bin/xml_pp'
<locks></locks>
@ -930,7 +930,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros.
There is 1 exclusive lock on this image.
Locker*ID*Address* (glob)
client.* id * (glob)
$ rbd lock list quux --format json | python -mjson.tool | sed 's/,$/, /'
$ rbd lock list quux --format json | python3 -mjson.tool | sed 's/,$/, /'
[
{
"address": "*", (glob)
@ -953,7 +953,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 | python -mjson.tool | sed 's/,$/, /'
$ rbd lock list baz --format json | python3 -mjson.tool | sed 's/,$/, /'
[
{
"address": "*", (glob)
@ -992,7 +992,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 | python -mjson.tool | sed 's/,$/, /'
$ rbd snap list foo --format json | python3 -mjson.tool | sed 's/,$/, /'
[
{
"id": *, (glob)
@ -1016,7 +1016,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros.
SNAPID*NAME*SIZE*PROTECTED*TIMESTAMP* (glob)
*snap*512 MiB*yes* (glob)
*snap2*1 GiB* (glob)
$ rbd snap list bar --format json | python -mjson.tool | sed 's/,$/, /'
$ rbd snap list bar --format json | python3 -mjson.tool | sed 's/,$/, /'
[
{
"id": *, (glob)
@ -1051,14 +1051,14 @@ whenever it is run. grep -v to ignore it, but still work on other distros.
</snapshot>
</snapshots>
$ rbd snap list baz
$ rbd snap list baz --format json | python -mjson.tool | sed 's/,$/, /'
$ rbd snap list baz --format json | python3 -mjson.tool | sed 's/,$/, /'
[]
$ rbd snap list baz --format xml | xml_pp 2>&1 | grep -v '^new version at /usr/bin/xml_pp'
<snapshots></snapshots>
$ rbd snap list rbd_other/child
SNAPID*NAME*SIZE*PROTECTED*TIMESTAMP* (glob)
*snap*512 MiB* (glob)
$ rbd snap list rbd_other/child --format json | python -mjson.tool | sed 's/,$/, /'
$ rbd snap list rbd_other/child --format json | python3 -mjson.tool | sed 's/,$/, /'
[
{
"id": *, (glob)
@ -1085,7 +1085,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
<TOTAL> 1 GiB 4 MiB
$ rbd disk-usage --pool rbd_other --format json | python -mjson.tool | sed 's/,$/, /'
$ rbd disk-usage --pool rbd_other --format json | python3 -mjson.tool | sed 's/,$/, /'
{
"images": [
{

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
"""
Loop writing/reading the first 4k of image argv[1] in pool rbd,
after acquiring exclusive lock named argv[2]. When an exception

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
import os
import sys
import time

View File

@ -18,31 +18,31 @@ function json_extract {
var=""
[ "$1" != "" ] && var=$(var_to_python_json_index $1)
shift
python - <<END
python3 - <<END
import json
s='$@'
data = json.loads(s)
print data$var
print(data$var)
END
}
function python_array_len {
python - <<END
python3 - <<END
arr=$@
print len(arr)
print(len(arr))
END
}
function project_python_array_field {
var=$(var_to_python_json_index $1)
shift
python - <<END
python3 - <<END
arr=$@
s='( '
for x in arr:
s += '"' + str(x$var) + '" '
s += ')'
print s
print(s)
END
}