Re: [PATCH 05/14] iotests.py: filter compression type out

2021-07-16 Thread Vladimir Sementsov-Ogievskiy

16.07.2021 14:15, Max Reitz wrote:

On 05.07.21 11:15, Vladimir Sementsov-Ogievskiy wrote:

We want iotests pass with both the default zlib compression and with
IMGOPTS='compression_type=zstd'.

Actually the only test that is interested in real compression type in
test output is 287 (test for qcow2 compression type) and it's in bash.
So for now we can safely filter out compression type in all qcow2
tests.

Signed-off-by: Vladimir Sementsov-Ogievskiy 
---
  tests/qemu-iotests/206.out    | 10 +++---
  tests/qemu-iotests/242.out    | 10 +++---
  tests/qemu-iotests/255.out    |  8 ++---
  tests/qemu-iotests/274.out    | 68 +--
  tests/qemu-iotests/280.out    |  2 +-
  tests/qemu-iotests/iotests.py | 13 ++-
  6 files changed, 61 insertions(+), 50 deletions(-)


Looks OK, though I wonder if it weren’t better to have a filter that only 
prints some options and explicitly filters out everything else.


That means larger work and larger audit of what actually each test wants to see 
in the output..

 (Well, actually, I’d prefer not to have the “Formatting…” line in the 
reference output at all, because I don’t see the point, but I suppose that can 
be considered a different problem.)

Hmm. I like the idea of dropping this line, I don't remember any bug that this 
line helped to catch, but we have to update it every time we add some new 
option. I can make a separate patch in v2 to just filter it out everywhere.



[...]


diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index 80f0cb4f42..6a8cc1bad7 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -224,9 +224,18 @@ def qemu_img_verbose(*args):
   % (-exitcode, ' '.join(qemu_img_args + list(args
  return exitcode
+def filter_img_create(text: str) -> str:
+    return re.sub('(compression_type=)(zlib|zstd)', r'\1COMPRESSION_TYPE',
+  text)
+
  def qemu_img_pipe(*args: str) -> str:
  '''Run qemu-img and return its output'''
-    return qemu_img_pipe_and_status(*args)[0]
+    output =  qemu_img_pipe_and_status(*args)[0]


There’s a superfluous space after '='.


+
+    if args[0] == 'create':
+    return filter_img_create(output)
+
+    return output


Wouldn’t it make more sense to have this filter be in 
qemu_img_pipe_and_status()?



Hmm probably someone want to not filter information out, then 
qemu_img_pipe_and_status() will be a way to get unfiltered output..

But I tend to agree, as in 02 I do generic logic in qemu_img_pipe_and_status(), 
so until we have a good reason, it's better to keep all generic logic in one 
place. OK, will move it to qemu_img_pipe_and_status()




  def qemu_img_log(*args):
  result = qemu_img_pipe(*args)
@@ -479,6 +488,8 @@ def filter_img_info(output, filename):
    'uuid: ----',
    line)
  line = re.sub('cid: [0-9]+', 'cid: XX', line)
+    line = re.sub('(compression type: )(zlib|zstd)', r'\1COMPRESSION_TYPE',
+  line)
  lines.append(line)
  return '\n'.join(lines)





--
Best regards,
Vladimir



Re: [PATCH 05/14] iotests.py: filter compression type out

2021-07-16 Thread Max Reitz

On 05.07.21 11:15, Vladimir Sementsov-Ogievskiy wrote:

We want iotests pass with both the default zlib compression and with
IMGOPTS='compression_type=zstd'.

Actually the only test that is interested in real compression type in
test output is 287 (test for qcow2 compression type) and it's in bash.
So for now we can safely filter out compression type in all qcow2
tests.

Signed-off-by: Vladimir Sementsov-Ogievskiy 
---
  tests/qemu-iotests/206.out| 10 +++---
  tests/qemu-iotests/242.out| 10 +++---
  tests/qemu-iotests/255.out|  8 ++---
  tests/qemu-iotests/274.out| 68 +--
  tests/qemu-iotests/280.out|  2 +-
  tests/qemu-iotests/iotests.py | 13 ++-
  6 files changed, 61 insertions(+), 50 deletions(-)


Looks OK, though I wonder if it weren’t better to have a filter that 
only prints some options and explicitly filters out everything else.  
(Well, actually, I’d prefer not to have the “Formatting…” line in the 
reference output at all, because I don’t see the point, but I suppose 
that can be considered a different problem.)


[...]


diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index 80f0cb4f42..6a8cc1bad7 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -224,9 +224,18 @@ def qemu_img_verbose(*args):
   % (-exitcode, ' '.join(qemu_img_args + list(args
  return exitcode
  
+def filter_img_create(text: str) -> str:

+return re.sub('(compression_type=)(zlib|zstd)', r'\1COMPRESSION_TYPE',
+  text)
+
  def qemu_img_pipe(*args: str) -> str:
  '''Run qemu-img and return its output'''
-return qemu_img_pipe_and_status(*args)[0]
+output =  qemu_img_pipe_and_status(*args)[0]


There’s a superfluous space after '='.


+
+if args[0] == 'create':
+return filter_img_create(output)
+
+return output


Wouldn’t it make more sense to have this filter be in 
qemu_img_pipe_and_status()?


Max


  def qemu_img_log(*args):
  result = qemu_img_pipe(*args)
@@ -479,6 +488,8 @@ def filter_img_info(output, filename):
'uuid: ----',
line)
  line = re.sub('cid: [0-9]+', 'cid: XX', line)
+line = re.sub('(compression type: )(zlib|zstd)', r'\1COMPRESSION_TYPE',
+  line)
  lines.append(line)
  return '\n'.join(lines)
  





[PATCH 05/14] iotests.py: filter compression type out

2021-07-05 Thread Vladimir Sementsov-Ogievskiy
We want iotests pass with both the default zlib compression and with
IMGOPTS='compression_type=zstd'.

Actually the only test that is interested in real compression type in
test output is 287 (test for qcow2 compression type) and it's in bash.
So for now we can safely filter out compression type in all qcow2
tests.

Signed-off-by: Vladimir Sementsov-Ogievskiy 
---
 tests/qemu-iotests/206.out| 10 +++---
 tests/qemu-iotests/242.out| 10 +++---
 tests/qemu-iotests/255.out|  8 ++---
 tests/qemu-iotests/274.out| 68 +--
 tests/qemu-iotests/280.out|  2 +-
 tests/qemu-iotests/iotests.py | 13 ++-
 6 files changed, 61 insertions(+), 50 deletions(-)

diff --git a/tests/qemu-iotests/206.out b/tests/qemu-iotests/206.out
index b68c443867..253209eca9 100644
--- a/tests/qemu-iotests/206.out
+++ b/tests/qemu-iotests/206.out
@@ -18,7 +18,7 @@ virtual size: 128 MiB (134217728 bytes)
 cluster_size: 65536
 Format specific information:
 compat: 1.1
-compression type: zlib
+compression type: COMPRESSION_TYPE
 lazy refcounts: false
 refcount bits: 16
 corrupt: false
@@ -42,7 +42,7 @@ virtual size: 64 MiB (67108864 bytes)
 cluster_size: 65536
 Format specific information:
 compat: 1.1
-compression type: zlib
+compression type: COMPRESSION_TYPE
 lazy refcounts: false
 refcount bits: 16
 corrupt: false
@@ -66,7 +66,7 @@ virtual size: 32 MiB (33554432 bytes)
 cluster_size: 2097152
 Format specific information:
 compat: 1.1
-compression type: zlib
+compression type: COMPRESSION_TYPE
 lazy refcounts: true
 refcount bits: 1
 corrupt: false
@@ -92,7 +92,7 @@ backing file: TEST_IMG.base
 backing file format: IMGFMT
 Format specific information:
 compat: 0.10
-compression type: zlib
+compression type: COMPRESSION_TYPE
 refcount bits: 16
 
 === Successful image creation (encrypted) ===
@@ -109,7 +109,7 @@ encrypted: yes
 cluster_size: 65536
 Format specific information:
 compat: 1.1
-compression type: zlib
+compression type: COMPRESSION_TYPE
 lazy refcounts: false
 refcount bits: 16
 encrypt:
diff --git a/tests/qemu-iotests/242.out b/tests/qemu-iotests/242.out
index 3759c99284..ce231424a7 100644
--- a/tests/qemu-iotests/242.out
+++ b/tests/qemu-iotests/242.out
@@ -12,7 +12,7 @@ virtual size: 1 MiB (1048576 bytes)
 cluster_size: 65536
 Format specific information:
 compat: 1.1
-compression type: zlib
+compression type: COMPRESSION_TYPE
 lazy refcounts: false
 refcount bits: 16
 corrupt: false
@@ -34,7 +34,7 @@ virtual size: 1 MiB (1048576 bytes)
 cluster_size: 65536
 Format specific information:
 compat: 1.1
-compression type: zlib
+compression type: COMPRESSION_TYPE
 lazy refcounts: false
 bitmaps:
 [0]:
@@ -68,7 +68,7 @@ virtual size: 1 MiB (1048576 bytes)
 cluster_size: 65536
 Format specific information:
 compat: 1.1
-compression type: zlib
+compression type: COMPRESSION_TYPE
 lazy refcounts: false
 bitmaps:
 [0]:
@@ -110,7 +110,7 @@ virtual size: 1 MiB (1048576 bytes)
 cluster_size: 65536
 Format specific information:
 compat: 1.1
-compression type: zlib
+compression type: COMPRESSION_TYPE
 lazy refcounts: false
 bitmaps:
 [0]:
@@ -161,7 +161,7 @@ virtual size: 1 MiB (1048576 bytes)
 cluster_size: 65536
 Format specific information:
 compat: 1.1
-compression type: zlib
+compression type: COMPRESSION_TYPE
 lazy refcounts: false
 bitmaps:
 [0]:
diff --git a/tests/qemu-iotests/255.out b/tests/qemu-iotests/255.out
index 33b7f22de3..bd3b13474e 100644
--- a/tests/qemu-iotests/255.out
+++ b/tests/qemu-iotests/255.out
@@ -3,9 +3,9 @@ Finishing a commit job with background reads
 
 === Create backing chain and start VM ===
 
-Formatting 'TEST_DIR/PID-t.qcow2.mid', fmt=qcow2 cluster_size=65536 
extended_l2=off compression_type=zlib size=134217728 lazy_refcounts=off 
refcount_bits=16
+Formatting 'TEST_DIR/PID-t.qcow2.mid', fmt=qcow2 cluster_size=65536 
extended_l2=off compression_type=COMPRESSION_TYPE size=134217728 
lazy_refcounts=off refcount_bits=16
 
-Formatting 'TEST_DIR/PID-t.qcow2', fmt=qcow2 cluster_size=65536 
extended_l2=off compression_type=zlib size=134217728 lazy_refcounts=off 
refcount_bits=16
+Formatting 'TEST_DIR/PID-t.qcow2', fmt=qcow2 cluster_size=65536 
extended_l2=off compression_type=COMPRESSION_TYPE size=134217728 
lazy_refcounts=off refcount_bits=16
 
 === Start background read requests ===
 
@@ -23,9 +23,9 @@ Closing the VM while a job is being cancelled
 
 === Create images and start VM ===
 
-Formatting 'TEST_DIR/PID-src.qcow2', fmt=qcow2 cluster_size=65536 
extended_l2=off compression_type=zlib size=134217728 lazy_refcounts=off 
refcount_bits=16
+Formatting 'TEST_DIR/PID-src.qcow2', fmt=qcow2 cluster_size=65536 
extended_l2=off compression_type=COMPRESSION_TYPE size=134217728 
lazy_refcounts=off refcount_bits=16