Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ovirt-img: command testing #134

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

aesteve-rh
Copy link
Member

@aesteve-rh aesteve-rh commented Aug 24, 2022

Add the required testing infrastructure to test
ovirt-img command with a local setup.

Engine configuration needs to be set in a configuration
file, and then the tests will read this configuration
and run normally through tox.

The test are run through a new tox environment, namely
client (as it tests commands contained in the client
folder):
tox -e client

It will read the configuration in the default location
run the tests in the test/client folder.
Configuration location can be set through an env
variable:
CLIENT_TEST_CONF=/path/to/test.conf tox -e client

Currently, it only tests upload and download commands,
with different formats and comparing resulting images.
Example:

$ CLIENT_TEST_CONF=~/.config/ovirt-img.conf tox -e client -- --log-cli-level=debug

collected 2 items

test/client/upload_download_test.py::test_upload_download[raw] Formatting '/var/tmp/imageio-tests/test_upload_download_raw_0/image.raw', fmt=raw size=10737418240

12:26:37,374 INFO    (MainThread) [test] Upload raw image to SD nfs-01
[ 100% ] 10.00 GiB, 19.08 s, 536.59 MiB/s | upload completed
12:26:56,595 INFO    (MainThread) [test] Download image d27c0e2f-35d1-4106-96e6-215022e022bf
[ 100% ] 10.00 GiB, 2.47 s, 4.05 GiB/s | download completed
12:26:59,202 INFO    (MainThread) [test] Comparing images
12:26:59,539 INFO    (MainThread) [test] Upload raw image to SD iscsi-01
[ 100% ] 10.00 GiB, 24.73 s, 414.15 MiB/s | upload completed
12:27:24,405 INFO    (MainThread) [test] Download image a3b48896-33bc-4f62-b3af-159b56686a29
[ 100% ] 10.00 GiB, 4.73 s, 2.11 GiB/s | download completed
12:27:29,277 INFO    (MainThread) [test] Comparing images
PASSED
test/client/upload_download_test.py::test_upload_download[qcow2] Formatting '/var/tmp/imageio-tests/test_upload_download_qcow2_0/image.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=10737418240 lazy_refcounts=off refcount_bits=16

12:27:30,103 INFO    (MainThread) [test] Upload qcow2 image to SD nfs-01
[ 100% ] 10.00 GiB, 11.92 s, 858.81 MiB/s | upload completed
12:27:42,175 INFO    (MainThread) [test] Download image 9cb8da7a-6169-4020-8233-9f20aeeef56e
[ 100% ] 10.00 GiB, 2.44 s, 4.09 GiB/s | download completed
12:27:44,765 INFO    (MainThread) [test] Comparing images
12:27:45,956 INFO    (MainThread) [test] Upload qcow2 image to SD iscsi-01
[ 100% ] 10.00 GiB, 29.13 s, 351.49 MiB/s | upload completed
12:28:15,236 INFO    (MainThread) [test] Download image ae41f54d-0345-40ac-bf40-197430c671f5
[ 100% ] 10.00 GiB, 2.92 s, 3.43 GiB/s | download completed
12:28:18,290 INFO    (MainThread) [test] Comparing images
PASSED

Fixes: #124
Signed-off-by: Albert Esteve aesteve@redhat.com

@aesteve-rh aesteve-rh added this to the ovirt-4.5.3 milestone Aug 24, 2022
@aesteve-rh aesteve-rh self-assigned this Aug 24, 2022
@aesteve-rh aesteve-rh requested a review from nirs as a code owner August 24, 2022 08:01
@aesteve-rh aesteve-rh force-pushed the aesteve/ovirt-img-test branch 4 times, most recently from 8e84a59 to 88a629b Compare August 24, 2022 10:20
@aesteve-rh aesteve-rh force-pushed the aesteve/ovirt-img-test branch 3 times, most recently from 80b2748 to 05a380b Compare September 9, 2022 11:31
@aesteve-rh
Copy link
Member Author

@barpavel could you please try the test described in this branch and provide some feedback? You can test it with your local engine setup, similar to how you would test python sdk scripts.

If you have any questions, it will be a good indicative that the documentation would need some improvement :)

Add the required testing infrastructure to test
ovirt-img command with a local setup.

Engine configuration needs to be set in a configuration
file, and then the tests will read this configuration
and run normally through tox.

The test are run through a new tox environment, namely
client (as it tests commands contained in the client
folder):
tox -e client

It will read the configuration in the default location
run the tests in the test/client folder.
Configuration location can be set through an env
variable:
CLIENT_TEST_CONF=/path/to/test.conf tox -e client

Currently, it only tests upload and download commands,
with different formats and comparing resulting images.
Example:

$ CLIENT_TEST_CONF=~/.config/ovirt-img.conf tox -e client --
--log-cli-level=debug

collected 2 items

test/client/upload_download_test.py::test_upload_download[raw] Formatting '/var/tmp/imageio-tests/test_upload_download_raw_0/image.raw', fmt=raw size=10737418240

12:26:37,374 INFO    (MainThread) [test] Upload raw image to SD nfs-01
[ 100% ] 10.00 GiB, 19.08 s, 536.59 MiB/s | upload completed
12:26:56,595 INFO    (MainThread) [test] Download image d27c0e2f-35d1-4106-96e6-215022e022bf
[ 100% ] 10.00 GiB, 2.47 s, 4.05 GiB/s | download completed
12:26:59,202 INFO    (MainThread) [test] Comparing images
12:26:59,539 INFO    (MainThread) [test] Upload raw image to SD iscsi-01
[ 100% ] 10.00 GiB, 24.73 s, 414.15 MiB/s | upload completed
12:27:24,405 INFO    (MainThread) [test] Download image a3b48896-33bc-4f62-b3af-159b56686a29
[ 100% ] 10.00 GiB, 4.73 s, 2.11 GiB/s | download completed
12:27:29,277 INFO    (MainThread) [test] Comparing images
PASSED
test/client/upload_download_test.py::test_upload_download[qcow2] Formatting '/var/tmp/imageio-tests/test_upload_download_qcow2_0/image.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=10737418240 lazy_refcounts=off refcount_bits=16

12:27:30,103 INFO    (MainThread) [test] Upload qcow2 image to SD nfs-01
[ 100% ] 10.00 GiB, 11.92 s, 858.81 MiB/s | upload completed
12:27:42,175 INFO    (MainThread) [test] Download image 9cb8da7a-6169-4020-8233-9f20aeeef56e
[ 100% ] 10.00 GiB, 2.44 s, 4.09 GiB/s | download completed
12:27:44,765 INFO    (MainThread) [test] Comparing images
12:27:45,956 INFO    (MainThread) [test] Upload qcow2 image to SD iscsi-01
[ 100% ] 10.00 GiB, 29.13 s, 351.49 MiB/s | upload completed
12:28:15,236 INFO    (MainThread) [test] Download image ae41f54d-0345-40ac-bf40-197430c671f5
[ 100% ] 10.00 GiB, 2.92 s, 3.43 GiB/s | download completed
12:28:18,290 INFO    (MainThread) [test] Comparing images
PASSED

Fixes: oVirt#124
Signed-off-by: Albert Esteve <aesteve@redhat.com>
@rokkbert
Copy link

On my system, with locally running ovirt, the test seems to be too slow to complete within the timeout, when ran for the first time. Maybe my internet connection is not fast enough. Maybe we could use a smaller image?

client run-test: commands[0] | pytest -vs --timeout 200 --log-cli-level=debug test/client
==================================== test session starts ====================================
platform linux -- Python 3.6.8, pytest-7.0.1, pluggy-1.0.0 -- /home/rob/share/git/aesteve-rh/ovirt-imageio2/.tox/client/bin/python
cachedir: .tox/client/.pytest_cache
rootdir: /home/rob/share/git/aesteve-rh/ovirt-imageio2, configfile: tox.ini
plugins: timeout-2.1.0
timeout: 200.0s
timeout method: thread
timeout func_only: False
collected 2 items

test/client/upload_download_test.py::test_upload_download[raw] [ 0.9] Downloading: http://builder.libguestfs.org/fedora-36.xz
###################################################################################### 100.0%######################################################## 65.4%
++++++++++++++++++++++++++++++++++++++++++ Timeout ++++++++++++++++++++++++++++++++++++++++++

########################################################                                65.4%  File "/home/rob/share/git/aesteve-rh/ovirt-imageio2/.tox/client/bin/pytest", line 8, in <module>
    sys.exit(console_main())
  File "/home/rob/share/git/aesteve-rh/ovirt-imageio2/.tox/client/lib/python3.6/site-packages/_pytest/config/__init__.py", line 188, in console_main
    code = main()

@rokkbert
Copy link

rokkbert commented Oct 28, 2022

[SOLVED]: the problem below happened because of a misconfiguration. After fixing that, and making more space, it continues past that (but then later fails the download test because there's also not enough space for that).

Also, the test freezes for me, maybe because I don't have enough space to upload the image:

               Output file: /var/tmp/imageio-tests/test_upload_download_raw_0/image.raw
               Output size: 6.0G
             Output format: raw
        Total usable space: 6.0G
                Free space: 4.7G (79%)

-------------------------------------------------------------------------------- live log call ---------------------------------------------------------------------------------
15:02:42,352 INFO (MainThread) [test] Upload raw image to SD nfs1
[ ---- ] 0 bytes, 0.01 s, 0 bytes/s | creating disk

@aesteve-rh
Copy link
Member Author

@rokkbert thank you for trying the test!

The initial timeout is due to virt-builder, probably I had the image already cached and is faster, I didn't think that the first time it will take a while to download. The disk could be smaller, but the idea was to try a realistic disk with data. I could increase the timeout for the tox env, or maybe it would be better to use qemu-img and write a few bytes into it before uploading, that will be a lot faster. I'll think about it.

About the freeze, no sure the reason. How much free space do you have in the nfs1 SD? Does it consistently freeze in the same step?

@rokkbert
Copy link

rokkbert commented Oct 28, 2022

The initial timeout is due to virt-builder, probably I had the image already cached and is faster, I didn't think that the first time it will take a while to download.

Yes, the second time it is fast. Maybe not worth the effort of finding a workaround, but maybe the image could be downloaded in advance, before the test and its timeout become active.

The disk could be smaller, but the idea was to try a realistic disk with data.

Makes sense.

I could increase the timeout for the tox env, or maybe it would be better to use qemu-img and write a few bytes into it before uploading, that will be a lot faster. I'll think about it.

I think 400-500 seconds would be enough for my case, but internet in germany isn't that fast, so maybe not even an issue for others. ;-)

About the freeze, no sure the reason.

Reason was that I made a mistake in the configuration :)

But now I'm out of space on my test-VM, which is a bit more work to fix.

@rokkbert
Copy link

After changing the tmp-path in tox.ini to somewhere with more space the tests run successfully.

I just get 2 deprecation warnings, everything else is fine:

.tox/client/lib/python3.6/site-packages/_pytest/config/init.py:1196
/home/rob/share/git/aesteve-rh/ovirt-imageio2/.tox/client/lib/python3.6/site-packages/_pytest/config/init.py:1196: PytestRemovedIn8Warning: The --strict option is deprecated, use --strict-markers instead.
_pytest.deprecated.STRICT_OPTION, stacklevel=2

.tox/client/lib/python3.6/site-packages/userstorage/config.py:21
/home/rob/share/git/aesteve-rh/ovirt-imageio2/.tox/client/lib/python3.6/site-packages/userstorage/config.py:21: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
import imp

@aesteve-rh
Copy link
Member Author

But now I'm out of space on my test-VM, which is a bit more work to fix. That's too bad! It can be tested from your local development machine (at least I do test from there). As long as the engine configuration is correct, it should be fine.

After changing the tmp-path in tox.ini to somewhere with more space the tests run successfully. Which path do you mean?

Warnings are "ok", is not related to this PR. The pytest flags in tox.ini need an update.

Again, thanks for testing!

@rokkbert
Copy link

rokkbert commented Nov 2, 2022

I mean this path, basetemp, in tox.ini:
addopts = -rsxX --basetemp=/var/tmp/imageio-tests

Copy link

@rokkbert rokkbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works for me and looks fine.

@sandrobonazzola sandrobonazzola removed this from the ovirt-4.5.4 milestone Jan 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add tests for ovirt-img sub commands
3 participants