Re: [Autotest] [Autotest PATCH] KVM-test: Add a subtest 'qemu_img'
On Wed, Mar 17, 2010 at 10:38:58AM -0300, Lucas Meneghel Rodrigues wrote: Copying Michael on the message. Hi Yolkfull, I have reviewed this patch and I have some comments to make on it, similar to the ones I made on an earlier version of it: One of the things that I noticed is that this patch doesn't work very well out of the box: [...@freedom kvm]$ ./scan_results.py Test Status Seconds Info -- --- (Result file: ../../results/default/status) smp2.Fedora.11.64.qemu_img.check GOOD47 completed successfully smp2.Fedora.11.64.qemu_img.create GOOD44 completed successfully smp2.Fedora.11.64.qemu_img.convert.to_qcow2 FAIL45 Image converted failed; Command: /usr/bin/qemu-img convert -f qcow2 -O qcow2 /tmp/kvm_autotest_root/images/fc11-64.qcow2 /tmp/kvm_autotest_root/images/fc11-64.qcow2.converted_qcow2;Output is: qemu-img: Could not open '/tmp/kvm_autotest_root/images/fc11-64.qcow2' smp2.Fedora.11.64.qemu_img.convert.to_raw FAIL46 Image converted failed; Command: /usr/bin/qemu-img convert -f qcow2 -O raw /tmp/kvm_autotest_root/images/fc11-64.qcow2 /tmp/kvm_autotest_root/images/fc11-64.qcow2.converted_raw;Output is: qemu-img: Could not open '/tmp/kvm_autotest_root/images/fc11-64.qcow2' smp2.Fedora.11.64.qemu_img.snapshot FAIL44 Create snapshot failed via command: /usr/bin/qemu-img snapshot -c snapshot0 /tmp/kvm_autotest_root/images/fc11-64.qcow2;Output is: qemu-img: Could not open '/tmp/kvm_autotest_root/images/fc11-64.qcow2' smp2.Fedora.11.64.qemu_img.commit GOOD44 completed successfully smp2.Fedora.11.64.qemu_img.info FAIL44 Unhandled str: Unhandled TypeError: argument of type 'NoneType' is not iterable smp2.Fedora.11.64.qemu_img.rebase TEST_NA 43 Current kvm user space version does not support 'rebase' subcommand GOOD412 We need to fix that before upstream inclusion. Hi Lucas, did you run the test on fedora or other box? I ran this test on my fedora 13 box for several times, worked fine: # ./scan_results.py TestStatus Seconds Info -- --- (Result file: ../../results/default/status) smp2.RHEL.5.4.i386.qemu_img.check GOOD132 completed successfully smp2.RHEL.5.4.i386.qemu_img.create GOOD144 completed successfully smp2.RHEL.5.4.i386.qemu_img.convert.to_qcow2GOOD251 completed successfully smp2.RHEL.5.4.i386.qemu_img.convert.to_raw GOOD245 completed successfully smp2.RHEL.5.4.i386.qemu_img.snapshotGOOD140 completed successfully smp2.RHEL.5.4.i386.qemu_img.commit GOOD146 completed successfully smp2.RHEL.5.4.i386.qemu_img.infoGOOD133 completed successfully smp2.RHEL.5.4.i386.qemu_img.rebase TEST_NA 137 Current kvm user space version does not support 'rebase' subcommand GOOD1392 [r...@afu kvm]# Weird why there are some case failed... Please test again based on the new patch I will send later. Also, one thing that I've noticed is that this test doesn't depend of any other variants, so we don't need to repeat it to every combination of guest and qemu command line options. Michael, does it occur to you a way to get this test out of the variants block, so it gets executed only once per job and not every combination of guest and other qemu options? Lucas and Michael, maybe we could add a parameter say 'ignore_vm_config = yes' to config file which let a test ignore all configurations combination. Another method is ugly adding following block into config file: --- qemu_img: only ide only qcow2 only up only ... (use 'only' to filter all configurations combination) --- But I don't think it's a good idea. What do you think? On Fri, Jan 29, 2010 at 4:00 AM, Yolkfull Chow yz...@redhat.com wrote: This is designed to test all subcommands of 'qemu-img' however so far 'commit' is not implemented. * For 'check' subcommand test, it will 'dd' to create a file with specified size and see whether it's supported to be checked. Then convert it to be supported formats ('qcow2' and 'raw' so far) to see whether there's error after convertion. * For
Re: [Autotest] [Autotest PATCH] KVM-test: Add a subtest 'qemu_img'
Copying Michael on the message. Hi Yolkfull, I have reviewed this patch and I have some comments to make on it, similar to the ones I made on an earlier version of it: One of the things that I noticed is that this patch doesn't work very well out of the box: [...@freedom kvm]$ ./scan_results.py TestStatus Seconds Info -- --- (Result file: ../../results/default/status) smp2.Fedora.11.64.qemu_img.checkGOOD47 completed successfully smp2.Fedora.11.64.qemu_img.create GOOD44 completed successfully smp2.Fedora.11.64.qemu_img.convert.to_qcow2 FAIL45 Image converted failed; Command: /usr/bin/qemu-img convert -f qcow2 -O qcow2 /tmp/kvm_autotest_root/images/fc11-64.qcow2 /tmp/kvm_autotest_root/images/fc11-64.qcow2.converted_qcow2;Output is: qemu-img: Could not open '/tmp/kvm_autotest_root/images/fc11-64.qcow2' smp2.Fedora.11.64.qemu_img.convert.to_raw FAIL46 Image converted failed; Command: /usr/bin/qemu-img convert -f qcow2 -O raw /tmp/kvm_autotest_root/images/fc11-64.qcow2 /tmp/kvm_autotest_root/images/fc11-64.qcow2.converted_raw;Output is: qemu-img: Could not open '/tmp/kvm_autotest_root/images/fc11-64.qcow2' smp2.Fedora.11.64.qemu_img.snapshot FAIL44 Create snapshot failed via command: /usr/bin/qemu-img snapshot -c snapshot0 /tmp/kvm_autotest_root/images/fc11-64.qcow2;Output is: qemu-img: Could not open '/tmp/kvm_autotest_root/images/fc11-64.qcow2' smp2.Fedora.11.64.qemu_img.commit GOOD44 completed successfully smp2.Fedora.11.64.qemu_img.info FAIL44 Unhandled str: Unhandled TypeError: argument of type 'NoneType' is not iterable smp2.Fedora.11.64.qemu_img.rebase TEST_NA 43 Current kvm user space version does not support 'rebase' subcommand GOOD412 We need to fix that before upstream inclusion. Also, one thing that I've noticed is that this test doesn't depend of any other variants, so we don't need to repeat it to every combination of guest and qemu command line options. Michael, does it occur to you a way to get this test out of the variants block, so it gets executed only once per job and not every combination of guest and other qemu options? On Fri, Jan 29, 2010 at 4:00 AM, Yolkfull Chow yz...@redhat.com wrote: This is designed to test all subcommands of 'qemu-img' however so far 'commit' is not implemented. * For 'check' subcommand test, it will 'dd' to create a file with specified size and see whether it's supported to be checked. Then convert it to be supported formats ('qcow2' and 'raw' so far) to see whether there's error after convertion. * For 'convert' subcommand test, it will convert both to 'qcow2' and 'raw' from the format specified in config file. And only check 'qcow2' after convertion. * For 'snapshot' subcommand test, it will create two snapshots and list them. Finally delete them if no errors found. * For 'info' subcommand test, it will check image format size according to output of 'info' subcommand at specified image file. * For 'rebase' subcommand test, it will create first snapshot 'sn1' based on original base_img, and create second snapshot based on sn1. And then rebase sn2 to base_img. After rebase check the baking_file of sn2. This supports two rebase mode: unsafe mode and safe mode: Unsafe mode: With -u an unsafe mode is enabled that doesn't require the backing files to exist. It merely changes the backing file reference in the COW image. This is useful for renaming or moving the backing file. The user is responsible to make sure that the new backing file has no changes compared to the old one, or corruption may occur. Safe Mode: Both the current and the new backing file need to exist, and after the rebase, the COW image is guaranteed to have the same guest visible content as before. To achieve this, old and new backing file are compared and, if necessary, data is copied from the old backing file into the COW image. Signed-off-by: Yolkfull Chow yz...@redhat.com --- client/tests/kvm/tests/qemu_img.py | 235 client/tests/kvm/tests_base.cfg.sample | 40 ++ 2 files changed, 275 insertions(+), 0 deletions(-) create mode 100644 client/tests/kvm/tests/qemu_img.py diff --git a/client/tests/kvm/tests/qemu_img.py b/client/tests/kvm/tests/qemu_img.py new file mode 100644 index 000..e6352a0 --- /dev/null +++ b/client/tests/kvm/tests/qemu_img.py @@ -0,0 +1,235 @@ +import re, os, logging, commands +from autotest_lib.client.common_lib import utils, error +import
Re: [Autotest] [Autotest PATCH] KVM-test: Add a subtest 'qemu_img'
On Tue, Jan 26, 2010 at 03:11:34PM -0200, Lucas Meneghel Rodrigues wrote: On Tue, 2010-01-26 at 11:25 +0800, Yolkfull Chow wrote: This is designed to test all subcommands of 'qemu-img' however so far 'commit' is not implemented. Hi Yolkful, this is very good! Seeing this test made me think about that stand alone autotest module we commited a while ago, that does qemu_iotests testsuite on the host. Perhaps we could 'port' this module to the kvm test, since it is more convenient to execute it inside a kvm test job (in a job where we test more than 2 build types, for example, we need to execute qemu_img and qemu_io_tests for every qemu-img built). Could you look at implementing this? * For 'check' subcommand test, it will 'dd' to create a file with specified size and see whether it's supported to be checked. Then convert it to be supported formats (qcow2 and raw so far) to see whether there's error after convertion. * For 'convert' subcommand test, it will convert both to 'qcow2' and 'raw' from the format specified in config file. And only check 'qcow2' after convertion. * For 'snapshot' subcommand test, it will create two snapshots and list them. Finally delete them if no errors found. * For 'info' subcommand test, it simply get output from specified image file. Signed-off-by: Yolkfull Chow yz...@redhat.com --- client/tests/kvm/tests/qemu_img.py | 155 client/tests/kvm/tests_base.cfg.sample | 36 2 files changed, 191 insertions(+), 0 deletions(-) create mode 100644 client/tests/kvm/tests/qemu_img.py diff --git a/client/tests/kvm/tests/qemu_img.py b/client/tests/kvm/tests/qemu_img.py new file mode 100644 index 000..1ae04f0 --- /dev/null +++ b/client/tests/kvm/tests/qemu_img.py @@ -0,0 +1,155 @@ +import os, logging, commands +from autotest_lib.client.common_lib import error +import kvm_vm + + +def run_qemu_img(test, params, env): + +`qemu-img' functions test: +1) Judge what subcommand is going to be tested +2) Run subcommand test + +@param test: kvm test object +@param params: Dictionary with the test parameters +@param env: Dictionary with test environment. + +cmd = params.get(qemu_img_binary) It is a good idea to verify if cmd above resolves to an absolute path, to avoid problems. If it doesn't resolve, verify if there's the symbolic link under kvm test dir pointing to qemu-img, and if it does exist, make sure it points to a valid file (ie, symlink is not broken). +subcommand = params.get(subcommand) +image_format = params.get(image_format) +image_name = kvm_vm.get_image_filename(params, test.bindir) + +def check(img): +global cmd +cmd += check %s % img +logging.info(Checking image '%s'... % img) +s, o = commands.getstatusoutput(cmd) +if not (s == 0 or does not support checks in o): +return (False, o) +return (True, ) Please use utils.system_output here instead of the equivalent commands API on the above code. This comment applies to all further uses of commands.[function]. + +# Subcommand 'qemu-img check' test +# This tests will 'dd' to create a specified size file, and check it. +# Then convert it to supported image_format in each loop and check again. +def check_test(): +size = params.get(dd_image_size) +test_image = params.get(dd_image_name) +create_image_cmd = params.get(create_image_cmd) +create_image_cmd = create_image_cmd % (test_image, size) +s, o = commands.getstatusoutput(create_image_cmd) +if s != 0: +raise error.TestError(Failed command: %s; Output is: %s % + (create_image_cmd, o)) +s, o = check(test_image) +if not s: +raise error.TestFail(Failed to check image '%s' with error: %s % + (test_image, o)) +for fmt in params.get(supported_image_formats).split(): +output_image = test_image + .%s % fmt +convert(fmt, test_image, output_image) +s, o = check(output_image) +if not s: +raise error.TestFail(Check image '%s' got error: %s % + (output_image, o)) +commands.getoutput(rm -f %s % output_image) +commands.getoutput(rm -f %s % test_image) +#Subcommand 'qemu-img create' test +def create_test(): +global cmd I don't like very much this idea of using a global variable, instead it should be preferrable to use a class and have a class attribute with 'cmd'. This way it would be safer, since the usage of cmd is encapsulated. This
Re: [Autotest] [Autotest PATCH] KVM-test: Add a subtest 'qemu_img'
On Thu, 2010-01-28 at 17:37 +0800, Yolkfull Chow wrote: On Tue, Jan 26, 2010 at 03:11:34PM -0200, Lucas Meneghel Rodrigues wrote: That said, I was wondering if we could consolidate all qemu-img tests to a single execution, instead of splitting it to several variants. We could keep a failure record, execute all tests and fail the entire test if any of them failed. It's not like terribly important, but it seems more logical to group all qemu-img subcommands testing under a single test. Hi Lucas, After considering above suggestion about merging all qemu-img tests into single test, I did decision that keep current method due to reason that: 1) it's convenient to maintain so many parameters of each test variant. 2) current method does not affect global results since even if one subtest of 'qemu-img' failes, it will nor block following subtests (we can still get whole test results) 3) it's possible for user to run single subtest of qemu-img, say only test 'rebase' subcommand As you also said this is not terribly important, let's keep it going. What's your opinion? Ok, I am fine with it! Lucas -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[Autotest PATCH] KVM-test: Add a subtest 'qemu_img'
This is designed to test all subcommands of 'qemu-img' however so far 'commit' is not implemented. * For 'check' subcommand test, it will 'dd' to create a file with specified size and see whether it's supported to be checked. Then convert it to be supported formats ('qcow2' and 'raw' so far) to see whether there's error after convertion. * For 'convert' subcommand test, it will convert both to 'qcow2' and 'raw' from the format specified in config file. And only check 'qcow2' after convertion. * For 'snapshot' subcommand test, it will create two snapshots and list them. Finally delete them if no errors found. * For 'info' subcommand test, it will check image format size according to output of 'info' subcommand at specified image file. * For 'rebase' subcommand test, it will create first snapshot 'sn1' based on original base_img, and create second snapshot based on sn1. And then rebase sn2 to base_img. After rebase check the baking_file of sn2. This supports two rebase mode: unsafe mode and safe mode: Unsafe mode: With -u an unsafe mode is enabled that doesn't require the backing files to exist. It merely changes the backing file reference in the COW image. This is useful for renaming or moving the backing file. The user is responsible to make sure that the new backing file has no changes compared to the old one, or corruption may occur. Safe Mode: Both the current and the new backing file need to exist, and after the rebase, the COW image is guaranteed to have the same guest visible content as before. To achieve this, old and new backing file are compared and, if necessary, data is copied from the old backing file into the COW image. Signed-off-by: Yolkfull Chow yz...@redhat.com --- client/tests/kvm/tests/qemu_img.py | 235 client/tests/kvm/tests_base.cfg.sample | 40 ++ 2 files changed, 275 insertions(+), 0 deletions(-) create mode 100644 client/tests/kvm/tests/qemu_img.py diff --git a/client/tests/kvm/tests/qemu_img.py b/client/tests/kvm/tests/qemu_img.py new file mode 100644 index 000..e6352a0 --- /dev/null +++ b/client/tests/kvm/tests/qemu_img.py @@ -0,0 +1,235 @@ +import re, os, logging, commands +from autotest_lib.client.common_lib import utils, error +import kvm_vm, kvm_utils + + +def run_qemu_img(test, params, env): + +`qemu-img' functions test: +1) Judge what subcommand is going to be tested +2) Run subcommand test + +@param test: kvm test object +@param params: Dictionary with the test parameters +@param env: Dictionary with test environment. + +cmd = kvm_utils.get_path(test.bindir, params.get(qemu_img_binary)) +if not os.path.exists(cmd): +raise error.TestError(Binary of 'qemu-img' not found) +image_format = params.get(image_format) +image_size = params.get(image_size, 10G) +image_name = kvm_vm.get_image_filename(params, test.bindir) + +def check(cmd, img): +cmd += check %s % img +logging.info(Checking image '%s'... % img) +o = commands.getoutput(cmd) +if does not support checks in o or No errors in o: +return (True, ) +return (False, o) + +# Subcommand 'qemu-img check' test +# This tests will 'dd' to create a specified size file, and check it. +# Then convert it to supported image_format in each loop and check again. +def check_test(cmd): +test_image = params.get(image_name_dd) +create_image_cmd = params.get(create_image_cmd) +create_image_cmd = create_image_cmd % test_image +s, o = commands.getstatusoutput(create_image_cmd) +if s != 0: +raise error.TestError(Failed command: %s; Output is: %s % + (create_image_cmd, o)) +s, o = check(cmd, test_image) +if not s: +raise error.TestFail(Check image '%s' failed with error: %s % + (test_image, o)) +for fmt in params.get(supported_image_formats).split(): +output_image = test_image + .%s % fmt +convert(cmd, fmt, test_image, output_image) +s, o = check(cmd, output_image) +if not s: +raise error.TestFail(Check image '%s' got error: %s % + (output_image, o)) +os.remove(output_image) +os.remove(test_image) + +def create(cmd, img_name, fmt, img_size=None, base_img=None, + base_img_fmt=None, encrypted=no): +cmd += create +if encrypted == yes: +cmd += -e +if base_img: +cmd += -b %s % base_img +if base_img_fmt: +cmd += -F %s % base_img_fmt +cmd += -f %s % fmt +cmd += %s % img_name +if img_size: +cmd += %s % img_size +s, o = commands.getstatusoutput(cmd) +if s != 0: +
Re: [Autotest PATCH] KVM-test: Add a subtest 'qemu_img'
On Fri, Jan 29, 2010 at 03:00:09PM +0800, Yolkfull Chow wrote: This is designed to test all subcommands of 'qemu-img' however so far 'commit' is not implemented. * For 'check' subcommand test, it will 'dd' to create a file with specified size and see whether it's supported to be checked. Then convert it to be supported formats ('qcow2' and 'raw' so far) to see whether there's error after convertion. * For 'convert' subcommand test, it will convert both to 'qcow2' and 'raw' from the format specified in config file. And only check 'qcow2' after convertion. * For 'snapshot' subcommand test, it will create two snapshots and list them. Finally delete them if no errors found. * For 'info' subcommand test, it will check image format size according to output of 'info' subcommand at specified image file. * For 'rebase' subcommand test, it will create first snapshot 'sn1' based on original base_img, and create second snapshot based on sn1. And then rebase sn2 to base_img. After rebase check the baking_file of sn2. This supports two rebase mode: unsafe mode and safe mode: Unsafe mode: With -u an unsafe mode is enabled that doesn't require the backing files to exist. It merely changes the backing file reference in the COW image. This is useful for renaming or moving the backing file. The user is responsible to make sure that the new backing file has no changes compared to the old one, or corruption may occur. Safe Mode: Both the current and the new backing file need to exist, and after the rebase, the COW image is guaranteed to have the same guest visible content as before. To achieve this, old and new backing file are compared and, if necessary, data is copied from the old backing file into the COW image. Signed-off-by: Yolkfull Chow yz...@redhat.com --- client/tests/kvm/tests/qemu_img.py | 235 client/tests/kvm/tests_base.cfg.sample | 40 ++ 2 files changed, 275 insertions(+), 0 deletions(-) create mode 100644 client/tests/kvm/tests/qemu_img.py diff --git a/client/tests/kvm/tests/qemu_img.py b/client/tests/kvm/tests/qemu_img.py new file mode 100644 index 000..e6352a0 --- /dev/null +++ b/client/tests/kvm/tests/qemu_img.py @@ -0,0 +1,235 @@ +import re, os, logging, commands +from autotest_lib.client.common_lib import utils, error +import kvm_vm, kvm_utils + + +def run_qemu_img(test, params, env): + +`qemu-img' functions test: +1) Judge what subcommand is going to be tested +2) Run subcommand test + +@param test: kvm test object +@param params: Dictionary with the test parameters +@param env: Dictionary with test environment. + +cmd = kvm_utils.get_path(test.bindir, params.get(qemu_img_binary)) +if not os.path.exists(cmd): +raise error.TestError(Binary of 'qemu-img' not found) +image_format = params.get(image_format) +image_size = params.get(image_size, 10G) +image_name = kvm_vm.get_image_filename(params, test.bindir) + +def check(cmd, img): +cmd += check %s % img +logging.info(Checking image '%s'... % img) +o = commands.getoutput(cmd) +if does not support checks in o or No errors in o: +return (True, ) +return (False, o) + +# Subcommand 'qemu-img check' test +# This tests will 'dd' to create a specified size file, and check it. +# Then convert it to supported image_format in each loop and check again. +def check_test(cmd): +test_image = params.get(image_name_dd) +create_image_cmd = params.get(create_image_cmd) +create_image_cmd = create_image_cmd % test_image +s, o = commands.getstatusoutput(create_image_cmd) +if s != 0: +raise error.TestError(Failed command: %s; Output is: %s % + (create_image_cmd, o)) +s, o = check(cmd, test_image) +if not s: +raise error.TestFail(Check image '%s' failed with error: %s % + (test_image, o)) +for fmt in params.get(supported_image_formats).split(): +output_image = test_image + .%s % fmt +convert(cmd, fmt, test_image, output_image) +s, o = check(cmd, output_image) +if not s: +raise error.TestFail(Check image '%s' got error: %s % + (output_image, o)) +os.remove(output_image) +os.remove(test_image) + +def create(cmd, img_name, fmt, img_size=None, base_img=None, + base_img_fmt=None, encrypted=no): +cmd += create +if encrypted == yes: +cmd += -e +if base_img: +cmd += -b %s % base_img +if base_img_fmt: +cmd += -F %s % base_img_fmt +
Re: [Autotest] [Autotest PATCH] KVM-test: Add a subtest 'qemu_img'
On Tue, Jan 26, 2010 at 03:11:34PM -0200, Lucas Meneghel Rodrigues wrote: On Tue, 2010-01-26 at 11:25 +0800, Yolkfull Chow wrote: This is designed to test all subcommands of 'qemu-img' however so far 'commit' is not implemented. Hi Yolkful, this is very good! Seeing this test made me think about that stand alone autotest module we commited a while ago, that does qemu_iotests testsuite on the host. Perhaps we could 'port' this module to the kvm test, since it is more Lucas, do you mean the client-side 'kvmtest' ? And thanks for comments. :) convenient to execute it inside a kvm test job (in a job where we test more than 2 build types, for example, we need to execute qemu_img and qemu_io_tests for every qemu-img built). Could you look at implementing this? * For 'check' subcommand test, it will 'dd' to create a file with specified size and see whether it's supported to be checked. Then convert it to be supported formats (qcow2 and raw so far) to see whether there's error after convertion. * For 'convert' subcommand test, it will convert both to 'qcow2' and 'raw' from the format specified in config file. And only check 'qcow2' after convertion. * For 'snapshot' subcommand test, it will create two snapshots and list them. Finally delete them if no errors found. * For 'info' subcommand test, it simply get output from specified image file. Signed-off-by: Yolkfull Chow yz...@redhat.com --- client/tests/kvm/tests/qemu_img.py | 155 client/tests/kvm/tests_base.cfg.sample | 36 2 files changed, 191 insertions(+), 0 deletions(-) create mode 100644 client/tests/kvm/tests/qemu_img.py diff --git a/client/tests/kvm/tests/qemu_img.py b/client/tests/kvm/tests/qemu_img.py new file mode 100644 index 000..1ae04f0 --- /dev/null +++ b/client/tests/kvm/tests/qemu_img.py @@ -0,0 +1,155 @@ +import os, logging, commands +from autotest_lib.client.common_lib import error +import kvm_vm + + +def run_qemu_img(test, params, env): + +`qemu-img' functions test: +1) Judge what subcommand is going to be tested +2) Run subcommand test + +@param test: kvm test object +@param params: Dictionary with the test parameters +@param env: Dictionary with test environment. + +cmd = params.get(qemu_img_binary) It is a good idea to verify if cmd above resolves to an absolute path, to avoid problems. If it doesn't resolve, verify if there's the symbolic link under kvm test dir pointing to qemu-img, and if it does exist, make sure it points to a valid file (ie, symlink is not broken). +subcommand = params.get(subcommand) +image_format = params.get(image_format) +image_name = kvm_vm.get_image_filename(params, test.bindir) + +def check(img): +global cmd +cmd += check %s % img +logging.info(Checking image '%s'... % img) +s, o = commands.getstatusoutput(cmd) +if not (s == 0 or does not support checks in o): +return (False, o) +return (True, ) Please use utils.system_output here instead of the equivalent commands API on the above code. This comment applies to all further uses of commands.[function]. + +# Subcommand 'qemu-img check' test +# This tests will 'dd' to create a specified size file, and check it. +# Then convert it to supported image_format in each loop and check again. +def check_test(): +size = params.get(dd_image_size) +test_image = params.get(dd_image_name) +create_image_cmd = params.get(create_image_cmd) +create_image_cmd = create_image_cmd % (test_image, size) +s, o = commands.getstatusoutput(create_image_cmd) +if s != 0: +raise error.TestError(Failed command: %s; Output is: %s % + (create_image_cmd, o)) +s, o = check(test_image) +if not s: +raise error.TestFail(Failed to check image '%s' with error: %s % + (test_image, o)) +for fmt in params.get(supported_image_formats).split(): +output_image = test_image + .%s % fmt +convert(fmt, test_image, output_image) +s, o = check(output_image) +if not s: +raise error.TestFail(Check image '%s' got error: %s % + (output_image, o)) +commands.getoutput(rm -f %s % output_image) +commands.getoutput(rm -f %s % test_image) +#Subcommand 'qemu-img create' test +def create_test(): +global cmd I don't like very much this idea of using a global variable, instead it should be preferrable to use a class and have a class attribute with 'cmd'.
Re: [Autotest] [Autotest PATCH] KVM-test: Add a subtest 'qemu_img'
On Wed, 2010-01-27 at 17:41 +0800, Yolkfull Chow wrote: On Tue, Jan 26, 2010 at 03:11:34PM -0200, Lucas Meneghel Rodrigues wrote: On Tue, 2010-01-26 at 11:25 +0800, Yolkfull Chow wrote: This is designed to test all subcommands of 'qemu-img' however so far 'commit' is not implemented. Hi Yolkful, this is very good! Seeing this test made me think about that stand alone autotest module we commited a while ago, that does qemu_iotests testsuite on the host. Perhaps we could 'port' this module to the kvm test, since it is more Lucas, do you mean the client-side 'kvmtest' ? I mean, client/tests/kvm. Sorry I wasn't clear enough. -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [Autotest] [Autotest PATCH] KVM-test: Add a subtest 'qemu_img'
- Yolkfull Chow yz...@redhat.com wrote: On Tue, Jan 26, 2010 at 03:11:34PM -0200, Lucas Meneghel Rodrigues wrote: On Tue, 2010-01-26 at 11:25 +0800, Yolkfull Chow wrote: This is designed to test all subcommands of 'qemu-img' however so far 'commit' is not implemented. Hi Yolkful, this is very good! Seeing this test made me think about that stand alone autotest module we commited a while ago, that does qemu_iotests testsuite on the host. Perhaps we could 'port' this module to the kvm test, since it is more Lucas, do you mean the client-side 'kvmtest' ? And thanks for comments. :) convenient to execute it inside a kvm test job (in a job where we test more than 2 build types, for example, we need to execute qemu_img and qemu_io_tests for every qemu-img built). Could you look at implementing this? * For 'check' subcommand test, it will 'dd' to create a file with specified size and see whether it's supported to be checked. Then convert it to be supported formats (qcow2 and raw so far) to see whether there's error after convertion. * For 'convert' subcommand test, it will convert both to 'qcow2' and 'raw' from the format specified in config file. And only check 'qcow2' after convertion. * For 'snapshot' subcommand test, it will create two snapshots and list them. Finally delete them if no errors found. * For 'info' subcommand test, it simply get output from specified image file. Signed-off-by: Yolkfull Chow yz...@redhat.com --- client/tests/kvm/tests/qemu_img.py | 155 client/tests/kvm/tests_base.cfg.sample | 36 2 files changed, 191 insertions(+), 0 deletions(-) create mode 100644 client/tests/kvm/tests/qemu_img.py diff --git a/client/tests/kvm/tests/qemu_img.py b/client/tests/kvm/tests/qemu_img.py new file mode 100644 index 000..1ae04f0 --- /dev/null +++ b/client/tests/kvm/tests/qemu_img.py @@ -0,0 +1,155 @@ +import os, logging, commands +from autotest_lib.client.common_lib import error +import kvm_vm + + +def run_qemu_img(test, params, env): + +`qemu-img' functions test: +1) Judge what subcommand is going to be tested +2) Run subcommand test + +@param test: kvm test object +@param params: Dictionary with the test parameters +@param env: Dictionary with test environment. + +cmd = params.get(qemu_img_binary) It is a good idea to verify if cmd above resolves to an absolute path, to avoid problems. If it doesn't resolve, verify if there's the symbolic link under kvm test dir pointing to qemu-img, and if it does exist, make sure it points to a valid file (ie, symlink is not broken). This can be done quickly using kvm_utils.get_path() and os.path.exists(), like this: cmd = kvm_utils.get_path(params.get(qemu_img_binary)) if not os.path.exists(cmd): raise error.TestError(qemu-img binary not found) kvm_utils.get_path() is the standard way of getting both absolute and relative paths, and os.path.exists() checks whether the file exists and makes sure it's not a broken symlink. +subcommand = params.get(subcommand) +image_format = params.get(image_format) +image_name = kvm_vm.get_image_filename(params, test.bindir) + +def check(img): +global cmd +cmd += check %s % img +logging.info(Checking image '%s'... % img) +s, o = commands.getstatusoutput(cmd) +if not (s == 0 or does not support checks in o): +return (False, o) +return (True, ) Please use utils.system_output here instead of the equivalent commands API on the above code. This comment applies to all further uses of commands.[function]. + +# Subcommand 'qemu-img check' test +# This tests will 'dd' to create a specified size file, and check it. +# Then convert it to supported image_format in each loop and check again. +def check_test(): +size = params.get(dd_image_size) +test_image = params.get(dd_image_name) +create_image_cmd = params.get(create_image_cmd) +create_image_cmd = create_image_cmd % (test_image, size) +s, o = commands.getstatusoutput(create_image_cmd) +if s != 0: +raise error.TestError(Failed command: %s; Output is: %s % + (create_image_cmd, o)) +s, o = check(test_image) +if not s: +raise error.TestFail(Failed to check image '%s' with error: %s % + (test_image, o)) +for fmt in params.get(supported_image_formats).split(): +output_image = test_image + .%s % fmt +convert(fmt, test_image, output_image) +s,
Re: [Autotest] [Autotest PATCH] KVM-test: Add a subtest 'qemu_img'
On Wed, Jan 27, 2010 at 07:37:46AM -0500, Michael Goldish wrote: - Yolkfull Chow yz...@redhat.com wrote: On Tue, Jan 26, 2010 at 03:11:34PM -0200, Lucas Meneghel Rodrigues wrote: On Tue, 2010-01-26 at 11:25 +0800, Yolkfull Chow wrote: This is designed to test all subcommands of 'qemu-img' however so far 'commit' is not implemented. Hi Yolkful, this is very good! Seeing this test made me think about that stand alone autotest module we commited a while ago, that does qemu_iotests testsuite on the host. Perhaps we could 'port' this module to the kvm test, since it is more Lucas, do you mean the client-side 'kvmtest' ? And thanks for comments. :) convenient to execute it inside a kvm test job (in a job where we test more than 2 build types, for example, we need to execute qemu_img and qemu_io_tests for every qemu-img built). Could you look at implementing this? * For 'check' subcommand test, it will 'dd' to create a file with specified size and see whether it's supported to be checked. Then convert it to be supported formats (qcow2 and raw so far) to see whether there's error after convertion. * For 'convert' subcommand test, it will convert both to 'qcow2' and 'raw' from the format specified in config file. And only check 'qcow2' after convertion. * For 'snapshot' subcommand test, it will create two snapshots and list them. Finally delete them if no errors found. * For 'info' subcommand test, it simply get output from specified image file. Signed-off-by: Yolkfull Chow yz...@redhat.com --- client/tests/kvm/tests/qemu_img.py | 155 client/tests/kvm/tests_base.cfg.sample | 36 2 files changed, 191 insertions(+), 0 deletions(-) create mode 100644 client/tests/kvm/tests/qemu_img.py diff --git a/client/tests/kvm/tests/qemu_img.py b/client/tests/kvm/tests/qemu_img.py new file mode 100644 index 000..1ae04f0 --- /dev/null +++ b/client/tests/kvm/tests/qemu_img.py @@ -0,0 +1,155 @@ +import os, logging, commands +from autotest_lib.client.common_lib import error +import kvm_vm + + +def run_qemu_img(test, params, env): + +`qemu-img' functions test: +1) Judge what subcommand is going to be tested +2) Run subcommand test + +@param test: kvm test object +@param params: Dictionary with the test parameters +@param env: Dictionary with test environment. + +cmd = params.get(qemu_img_binary) It is a good idea to verify if cmd above resolves to an absolute path, to avoid problems. If it doesn't resolve, verify if there's the symbolic link under kvm test dir pointing to qemu-img, and if it does exist, make sure it points to a valid file (ie, symlink is not broken). This can be done quickly using kvm_utils.get_path() and os.path.exists(), like this: cmd = kvm_utils.get_path(params.get(qemu_img_binary)) if not os.path.exists(cmd): raise error.TestError(qemu-img binary not found) kvm_utils.get_path() is the standard way of getting both absolute and relative paths, and os.path.exists() checks whether the file exists and makes sure it's not a broken symlink. Yes, thanks for pointing that out. +subcommand = params.get(subcommand) +image_format = params.get(image_format) +image_name = kvm_vm.get_image_filename(params, test.bindir) + +def check(img): +global cmd +cmd += check %s % img +logging.info(Checking image '%s'... % img) +s, o = commands.getstatusoutput(cmd) +if not (s == 0 or does not support checks in o): +return (False, o) +return (True, ) Please use utils.system_output here instead of the equivalent commands API on the above code. This comment applies to all further uses of commands.[function]. + +# Subcommand 'qemu-img check' test +# This tests will 'dd' to create a specified size file, and check it. +# Then convert it to supported image_format in each loop and check again. +def check_test(): +size = params.get(dd_image_size) +test_image = params.get(dd_image_name) +create_image_cmd = params.get(create_image_cmd) +create_image_cmd = create_image_cmd % (test_image, size) +s, o = commands.getstatusoutput(create_image_cmd) +if s != 0: +raise error.TestError(Failed command: %s; Output is: %s % + (create_image_cmd, o)) +s, o = check(test_image) +if not s: +raise error.TestFail(Failed to check image '%s' with error: %s % +
Re: [Autotest] [Autotest PATCH] KVM-test: Add a subtest 'qemu_img'
Yolkfull, Good test. Did never come to my mind to add such a test to autotest. I would like to test your latest patch!! On Thu, Jan 28, 2010 at 8:37 AM, Yolkfull Chow yz...@redhat.com wrote: On Wed, Jan 27, 2010 at 07:37:46AM -0500, Michael Goldish wrote: - Yolkfull Chow yz...@redhat.com wrote: On Tue, Jan 26, 2010 at 03:11:34PM -0200, Lucas Meneghel Rodrigues wrote: On Tue, 2010-01-26 at 11:25 +0800, Yolkfull Chow wrote: This is designed to test all subcommands of 'qemu-img' however so far 'commit' is not implemented. Hi Yolkful, this is very good! Seeing this test made me think about that stand alone autotest module we commited a while ago, that does qemu_iotests testsuite on the host. Perhaps we could 'port' this module to the kvm test, since it is more Lucas, do you mean the client-side 'kvmtest' ? And thanks for comments. :) convenient to execute it inside a kvm test job (in a job where we test more than 2 build types, for example, we need to execute qemu_img and qemu_io_tests for every qemu-img built). Could you look at implementing this? * For 'check' subcommand test, it will 'dd' to create a file with specified size and see whether it's supported to be checked. Then convert it to be supported formats (qcow2 and raw so far) to see whether there's error after convertion. * For 'convert' subcommand test, it will convert both to 'qcow2' and 'raw' from the format specified in config file. And only check 'qcow2' after convertion. * For 'snapshot' subcommand test, it will create two snapshots and list them. Finally delete them if no errors found. * For 'info' subcommand test, it simply get output from specified image file. Signed-off-by: Yolkfull Chow yz...@redhat.com --- client/tests/kvm/tests/qemu_img.py | 155 client/tests/kvm/tests_base.cfg.sample | 36 2 files changed, 191 insertions(+), 0 deletions(-) create mode 100644 client/tests/kvm/tests/qemu_img.py diff --git a/client/tests/kvm/tests/qemu_img.py b/client/tests/kvm/tests/qemu_img.py new file mode 100644 index 000..1ae04f0 --- /dev/null +++ b/client/tests/kvm/tests/qemu_img.py @@ -0,0 +1,155 @@ +import os, logging, commands +from autotest_lib.client.common_lib import error +import kvm_vm + + +def run_qemu_img(test, params, env): + + `qemu-img' functions test: + 1) Judge what subcommand is going to be tested + 2) Run subcommand test + + �...@param test: kvm test object + �...@param params: Dictionary with the test parameters + �...@param env: Dictionary with test environment. + + cmd = params.get(qemu_img_binary) It is a good idea to verify if cmd above resolves to an absolute path, to avoid problems. If it doesn't resolve, verify if there's the symbolic link under kvm test dir pointing to qemu-img, and if it does exist, make sure it points to a valid file (ie, symlink is not broken). This can be done quickly using kvm_utils.get_path() and os.path.exists(), like this: cmd = kvm_utils.get_path(params.get(qemu_img_binary)) if not os.path.exists(cmd): raise error.TestError(qemu-img binary not found) kvm_utils.get_path() is the standard way of getting both absolute and relative paths, and os.path.exists() checks whether the file exists and makes sure it's not a broken symlink. Yes, thanks for pointing that out. + subcommand = params.get(subcommand) + image_format = params.get(image_format) + image_name = kvm_vm.get_image_filename(params, test.bindir) + + def check(img): + global cmd + cmd += check %s % img + logging.info(Checking image '%s'... % img) + s, o = commands.getstatusoutput(cmd) + if not (s == 0 or does not support checks in o): + return (False, o) + return (True, ) Please use utils.system_output here instead of the equivalent commands API on the above code. This comment applies to all further uses of commands.[function]. + + # Subcommand 'qemu-img check' test + # This tests will 'dd' to create a specified size file, and check it. + # Then convert it to supported image_format in each loop and check again. + def check_test(): + size = params.get(dd_image_size) + test_image = params.get(dd_image_name) + create_image_cmd = params.get(create_image_cmd) + create_image_cmd = create_image_cmd % (test_image, size) + s, o = commands.getstatusoutput(create_image_cmd) + if s != 0: + raise error.TestError(Failed command: %s; Output is: %s % + (create_image_cmd, o)) + s, o = check(test_image) + if not
Re: [Autotest] [Autotest PATCH] KVM-test: Add a subtest 'qemu_img'
On Tue, 2010-01-26 at 11:25 +0800, Yolkfull Chow wrote: This is designed to test all subcommands of 'qemu-img' however so far 'commit' is not implemented. Hi Yolkful, this is very good! Seeing this test made me think about that stand alone autotest module we commited a while ago, that does qemu_iotests testsuite on the host. Perhaps we could 'port' this module to the kvm test, since it is more convenient to execute it inside a kvm test job (in a job where we test more than 2 build types, for example, we need to execute qemu_img and qemu_io_tests for every qemu-img built). Could you look at implementing this? * For 'check' subcommand test, it will 'dd' to create a file with specified size and see whether it's supported to be checked. Then convert it to be supported formats (qcow2 and raw so far) to see whether there's error after convertion. * For 'convert' subcommand test, it will convert both to 'qcow2' and 'raw' from the format specified in config file. And only check 'qcow2' after convertion. * For 'snapshot' subcommand test, it will create two snapshots and list them. Finally delete them if no errors found. * For 'info' subcommand test, it simply get output from specified image file. Signed-off-by: Yolkfull Chow yz...@redhat.com --- client/tests/kvm/tests/qemu_img.py | 155 client/tests/kvm/tests_base.cfg.sample | 36 2 files changed, 191 insertions(+), 0 deletions(-) create mode 100644 client/tests/kvm/tests/qemu_img.py diff --git a/client/tests/kvm/tests/qemu_img.py b/client/tests/kvm/tests/qemu_img.py new file mode 100644 index 000..1ae04f0 --- /dev/null +++ b/client/tests/kvm/tests/qemu_img.py @@ -0,0 +1,155 @@ +import os, logging, commands +from autotest_lib.client.common_lib import error +import kvm_vm + + +def run_qemu_img(test, params, env): + +`qemu-img' functions test: +1) Judge what subcommand is going to be tested +2) Run subcommand test + +@param test: kvm test object +@param params: Dictionary with the test parameters +@param env: Dictionary with test environment. + +cmd = params.get(qemu_img_binary) It is a good idea to verify if cmd above resolves to an absolute path, to avoid problems. If it doesn't resolve, verify if there's the symbolic link under kvm test dir pointing to qemu-img, and if it does exist, make sure it points to a valid file (ie, symlink is not broken). +subcommand = params.get(subcommand) +image_format = params.get(image_format) +image_name = kvm_vm.get_image_filename(params, test.bindir) + +def check(img): +global cmd +cmd += check %s % img +logging.info(Checking image '%s'... % img) +s, o = commands.getstatusoutput(cmd) +if not (s == 0 or does not support checks in o): +return (False, o) +return (True, ) Please use utils.system_output here instead of the equivalent commands API on the above code. This comment applies to all further uses of commands.[function]. + +# Subcommand 'qemu-img check' test +# This tests will 'dd' to create a specified size file, and check it. +# Then convert it to supported image_format in each loop and check again. +def check_test(): +size = params.get(dd_image_size) +test_image = params.get(dd_image_name) +create_image_cmd = params.get(create_image_cmd) +create_image_cmd = create_image_cmd % (test_image, size) +s, o = commands.getstatusoutput(create_image_cmd) +if s != 0: +raise error.TestError(Failed command: %s; Output is: %s % + (create_image_cmd, o)) +s, o = check(test_image) +if not s: +raise error.TestFail(Failed to check image '%s' with error: %s % + (test_image, o)) +for fmt in params.get(supported_image_formats).split(): +output_image = test_image + .%s % fmt +convert(fmt, test_image, output_image) +s, o = check(output_image) +if not s: +raise error.TestFail(Check image '%s' got error: %s % + (output_image, o)) +commands.getoutput(rm -f %s % output_image) +commands.getoutput(rm -f %s % test_image) +#Subcommand 'qemu-img create' test +def create_test(): +global cmd I don't like very much this idea of using a global variable, instead it should be preferrable to use a class and have a class attribute with 'cmd'. This way it would be safer, since the usage of cmd is encapsulated. This comment applies to all further usage of 'global cmd'. +cmd += create +if params.get(encrypted) == yes: +cmd += -e +if params.get(base_image): +cmd +=
[Autotest PATCH] KVM-test: Add a subtest 'qemu_img'
This is designed to test all subcommands of 'qemu-img' however so far 'commit' is not implemented. * For 'check' subcommand test, it will 'dd' to create a file with specified size and see whether it's supported to be checked. Then convert it to be supported formats (qcow2 and raw so far) to see whether there's error after convertion. * For 'convert' subcommand test, it will convert both to 'qcow2' and 'raw' from the format specified in config file. And only check 'qcow2' after convertion. * For 'snapshot' subcommand test, it will create two snapshots and list them. Finally delete them if no errors found. * For 'info' subcommand test, it simply get output from specified image file. Signed-off-by: Yolkfull Chow yz...@redhat.com --- client/tests/kvm/tests/qemu_img.py | 155 client/tests/kvm/tests_base.cfg.sample | 36 2 files changed, 191 insertions(+), 0 deletions(-) create mode 100644 client/tests/kvm/tests/qemu_img.py diff --git a/client/tests/kvm/tests/qemu_img.py b/client/tests/kvm/tests/qemu_img.py new file mode 100644 index 000..1ae04f0 --- /dev/null +++ b/client/tests/kvm/tests/qemu_img.py @@ -0,0 +1,155 @@ +import os, logging, commands +from autotest_lib.client.common_lib import error +import kvm_vm + + +def run_qemu_img(test, params, env): + +`qemu-img' functions test: +1) Judge what subcommand is going to be tested +2) Run subcommand test + +@param test: kvm test object +@param params: Dictionary with the test parameters +@param env: Dictionary with test environment. + +cmd = params.get(qemu_img_binary) +subcommand = params.get(subcommand) +image_format = params.get(image_format) +image_name = kvm_vm.get_image_filename(params, test.bindir) + +def check(img): +global cmd +cmd += check %s % img +logging.info(Checking image '%s'... % img) +s, o = commands.getstatusoutput(cmd) +if not (s == 0 or does not support checks in o): +return (False, o) +return (True, ) + +# Subcommand 'qemu-img check' test +# This tests will 'dd' to create a specified size file, and check it. +# Then convert it to supported image_format in each loop and check again. +def check_test(): +size = params.get(dd_image_size) +test_image = params.get(dd_image_name) +create_image_cmd = params.get(create_image_cmd) +create_image_cmd = create_image_cmd % (test_image, size) +s, o = commands.getstatusoutput(create_image_cmd) +if s != 0: +raise error.TestError(Failed command: %s; Output is: %s % + (create_image_cmd, o)) +s, o = check(test_image) +if not s: +raise error.TestFail(Failed to check image '%s' with error: %s % + (test_image, o)) +for fmt in params.get(supported_image_formats).split(): +output_image = test_image + .%s % fmt +convert(fmt, test_image, output_image) +s, o = check(output_image) +if not s: +raise error.TestFail(Check image '%s' got error: %s % + (output_image, o)) +commands.getoutput(rm -f %s % output_image) +commands.getoutput(rm -f %s % test_image) + +#Subcommand 'qemu-img create' test +def create_test(): +global cmd +cmd += create +if params.get(encrypted) == yes: +cmd += -e +if params.get(base_image): +cmd += -F %s -b %s % (params.get(base_image_format), + params.get(base_image)) +format = params.get(image_format) +cmd += -f %s % format +image_name_test = os.path.join(test.bindir, + params.get(image_name_test)) + '.' + format +cmd += %s %s % (image_name_test, params.get(image_size_test)) +s, o = commands.getstatusoutput(cmd) +if s != 0: +raise error.TestFail(Create image '%s' failed: %s % +(image_name_test, o)) +commands.getoutput(rm -f %s % image_name_test) + +def convert(output_format, image_name, output_filename, +format=None, compressed=no, encrypted=no): +global cmd +cmd += convert +if compressed == yes: +cmd += -c +if encrypted == yes: +cmd += -e +if format: +cmd += -f %s % image_format +cmd += -O %s % params.get(dest_image_format) +cmd += %s %s % (image_name, output_filename) +s, o = commands.getstatusoutput(cmd) +if s != 0: +raise error.TestFail(Image converted failed; Command: %s; + Output is: %s % (cmd, o)) + +#Subcommand 'qemu-img convert' test +def