[PATCH v5 00/18] iotests: add enhanced debugging info to qemu-img failures

John Snow posted 18 patches 2 years, 1 month ago
Test checkpatch failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20220321201618.903471-1-jsnow@redhat.com
Maintainers: John Snow <jsnow@redhat.com>, Cleber Rosa <crosa@redhat.com>, Beraldo Leal <bleal@redhat.com>, Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>
python/qemu/utils/__init__.py                 | 117 ++++++++++++
tests/qemu-iotests/041                        |   5 +-
tests/qemu-iotests/065                        |   7 +-
tests/qemu-iotests/149                        |   7 +-
tests/qemu-iotests/149.out                    |  21 ---
tests/qemu-iotests/163                        |   9 +-
tests/qemu-iotests/194                        |   4 +-
tests/qemu-iotests/202                        |   4 +-
tests/qemu-iotests/203                        |   4 +-
tests/qemu-iotests/211                        |   6 +-
tests/qemu-iotests/211.out                    |  10 +-
tests/qemu-iotests/216                        |   6 +-
tests/qemu-iotests/218                        |   2 +-
tests/qemu-iotests/224                        |  11 +-
tests/qemu-iotests/228                        |  12 +-
tests/qemu-iotests/234                        |   4 +-
tests/qemu-iotests/237                        |   3 +-
tests/qemu-iotests/237.out                    |   3 -
tests/qemu-iotests/242                        |   7 +-
tests/qemu-iotests/255                        |   8 +-
tests/qemu-iotests/255.out                    |   4 -
tests/qemu-iotests/257                        |  11 +-
tests/qemu-iotests/258                        |   4 +-
tests/qemu-iotests/262                        |   2 +-
tests/qemu-iotests/266                        |   2 +-
tests/qemu-iotests/274                        |  17 +-
tests/qemu-iotests/274.out                    |  29 ---
tests/qemu-iotests/280                        |   2 +-
tests/qemu-iotests/280.out                    |   1 -
tests/qemu-iotests/296                        |  12 +-
tests/qemu-iotests/303                        |   2 +-
tests/qemu-iotests/310                        |  13 +-
tests/qemu-iotests/iotests.py                 | 170 +++++++++++++-----
tests/qemu-iotests/tests/block-status-cache   |  14 +-
.../qemu-iotests/tests/graph-changes-while-io |   7 +-
tests/qemu-iotests/tests/image-fleecing       |  10 +-
.../tests/mirror-ready-cancel-error           |   6 +-
tests/qemu-iotests/tests/mirror-top-perms     |   3 +-
.../qemu-iotests/tests/parallels-read-bitmap  |   6 +-
.../tests/remove-bitmap-from-backing          |  14 +-
.../qemu-iotests/tests/stream-error-on-reset  |   4 +-
41 files changed, 354 insertions(+), 229 deletions(-)
[PATCH v5 00/18] iotests: add enhanced debugging info to qemu-img failures
Posted by John Snow 2 years, 1 month ago
V5 hotfix:
 - Quote the subprocess.CompletedProcess[str] type annotations,
   Python 3.6 chokes on them at runtime :(
 - Reduce line length in the text decoration fn,
   even though check-patch still doesn't like it.
 - Reflow docstring for qemu_img.*

V5 CI: https://gitlab.com/jsnow/qemu/-/pipelines/496050668

[*] Didn't re-run CI for this tiny change. If it breaks something I WILL
cry.

Hiya!

This series effectively replaces qemu_img_pipe_and_status() with a
rewritten function named qemu_img() that raises an exception on non-zero
return code by default. By the end of the series, every last invocation
of the qemu-img binary ultimately goes through qemu_img().

The exception that this function raises includes stdout/stderr output
when the traceback is printed in a a little decorated text box so that
it stands out from the jargony Python traceback readout.

(You can test what this looks like for yourself, or at least you could,
by disabling ztsd support and then running qcow2 iotest 065.)

Negative tests are still possible in two ways:

- Passing check=False to qemu_img, qemu_img_log, or img_info_log
- Catching and handling the CalledProcessError exception at the callsite.

Here's a summary of the changes to help you update any tests you may
have in flight:

qemu_img()                   => qemu_img().returncode
qemu_img_pipe()              => qemu_img().stdout
qemu_img_pipe_and_status()   => qemu_img()
json.loads(qemu_img_pipe())) => qemu_img_json()
qemu_img_log()               => qemu_img_log()

v4:

- Combine both series into one big series again.

002/18:[0007] [FC] 'python/utils: add VerboseProcessError'
  Added a comment and a temporary var to explain the
  "elif stderr is not None" thing.
  (Kept R-Bs because I live dangerously.)

006/18:[0014] [FC] 'iotests: add qemu_img_json()'
  Made this wayyyy less stupid. Thanks Hanna.

010/18:[0010] [FC] 'iotests: add qemu_img_map() function'
  Fixed test output for 211.

018/18:[down] 'iotests: make qemu_img_log and img_info_log raise on error'
  New, enforce a good return code by default for *all*
  qemu-img calls, logged or not.

John Snow (18):
  python/utils: add add_visual_margin() text decoration utility
  python/utils: add VerboseProcessError
  iotests: Remove explicit checks for qemu_img() == 0
  iotests: make qemu_img raise on non-zero rc by default
  iotests: fortify compare_images() against crashes
  iotests: add qemu_img_json()
  iotests: use qemu_img_json() when applicable
  iotests: add qemu_img_info()
  iotests/remove-bitmap-from-backing: use qemu_img_info()
  iotests: add qemu_img_map() function
  iotests: change supports_quorum to use qemu_img
  iotests: replace unchecked calls to qemu_img_pipe()
  iotests/149: Remove qemu_img_pipe() call
  iotests: remove remaining calls to qemu_img_pipe()
  iotests: use qemu_img() in has_working_luks()
  iotests: replace qemu_img_log('create', ...) calls
  iotests: remove qemu_img_pipe_and_status()
  iotests: make qemu_img_log and img_info_log raise on error

 python/qemu/utils/__init__.py                 | 117 ++++++++++++
 tests/qemu-iotests/041                        |   5 +-
 tests/qemu-iotests/065                        |   7 +-
 tests/qemu-iotests/149                        |   7 +-
 tests/qemu-iotests/149.out                    |  21 ---
 tests/qemu-iotests/163                        |   9 +-
 tests/qemu-iotests/194                        |   4 +-
 tests/qemu-iotests/202                        |   4 +-
 tests/qemu-iotests/203                        |   4 +-
 tests/qemu-iotests/211                        |   6 +-
 tests/qemu-iotests/211.out                    |  10 +-
 tests/qemu-iotests/216                        |   6 +-
 tests/qemu-iotests/218                        |   2 +-
 tests/qemu-iotests/224                        |  11 +-
 tests/qemu-iotests/228                        |  12 +-
 tests/qemu-iotests/234                        |   4 +-
 tests/qemu-iotests/237                        |   3 +-
 tests/qemu-iotests/237.out                    |   3 -
 tests/qemu-iotests/242                        |   7 +-
 tests/qemu-iotests/255                        |   8 +-
 tests/qemu-iotests/255.out                    |   4 -
 tests/qemu-iotests/257                        |  11 +-
 tests/qemu-iotests/258                        |   4 +-
 tests/qemu-iotests/262                        |   2 +-
 tests/qemu-iotests/266                        |   2 +-
 tests/qemu-iotests/274                        |  17 +-
 tests/qemu-iotests/274.out                    |  29 ---
 tests/qemu-iotests/280                        |   2 +-
 tests/qemu-iotests/280.out                    |   1 -
 tests/qemu-iotests/296                        |  12 +-
 tests/qemu-iotests/303                        |   2 +-
 tests/qemu-iotests/310                        |  13 +-
 tests/qemu-iotests/iotests.py                 | 170 +++++++++++++-----
 tests/qemu-iotests/tests/block-status-cache   |  14 +-
 .../qemu-iotests/tests/graph-changes-while-io |   7 +-
 tests/qemu-iotests/tests/image-fleecing       |  10 +-
 .../tests/mirror-ready-cancel-error           |   6 +-
 tests/qemu-iotests/tests/mirror-top-perms     |   3 +-
 .../qemu-iotests/tests/parallels-read-bitmap  |   6 +-
 .../tests/remove-bitmap-from-backing          |  14 +-
 .../qemu-iotests/tests/stream-error-on-reset  |   4 +-
 41 files changed, 354 insertions(+), 229 deletions(-)

-- 
2.34.1

Re: [PATCH v5 00/18] iotests: add enhanced debugging info to qemu-img failures
Posted by Hanna Reitz 2 years, 1 month ago
On 21.03.22 21:16, John Snow wrote:
> V5 hotfix:
>   - Quote the subprocess.CompletedProcess[str] type annotations,
>     Python 3.6 chokes on them at runtime :(
>   - Reduce line length in the text decoration fn,
>     even though check-patch still doesn't like it.
>   - Reflow docstring for qemu_img.*
>
> V5 CI: https://gitlab.com/jsnow/qemu/-/pipelines/496050668
>
> [*] Didn't re-run CI for this tiny change. If it breaks something I WILL
> cry.

Don’t worry, I won’t tell you.

Thanks for the quick fix!  I swapped v4 for this new version in my block 
branch.

Hanna