* [PATCH 0/2] KVM test: Image copy test v2
@ 2010-12-29 14:35 Lucas Meneghel Rodrigues
2010-12-29 14:35 ` [PATCH 1/2] KVM-test: Add mount utility functions Lucas Meneghel Rodrigues
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Lucas Meneghel Rodrigues @ 2010-12-29 14:35 UTC (permalink / raw)
To: autotest; +Cc: kvm, Lucas Meneghel Rodrigues
This is a respin of Amos's patch for image_copy test. In this
version, small cleanups and consistency fixes were made, specially
with regards to using utils.system instead of functions on the
commands API.
Amos Kong (2):
KVM-test: Add mount utility functions
KVM-test: Add image_copy subtest to prepare images
client/tests/kvm/kvm_utils.py | 55 ++++++++++++++++++++++++++++++++
client/tests/kvm/tests/image_copy.py | 46 ++++++++++++++++++++++++++
client/tests/kvm/tests_base.cfg.sample | 9 +++++
3 files changed, 110 insertions(+), 0 deletions(-)
create mode 100644 client/tests/kvm/tests/image_copy.py
--
1.7.2.3
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] KVM-test: Add mount utility functions
2010-12-29 14:35 [PATCH 0/2] KVM test: Image copy test v2 Lucas Meneghel Rodrigues
@ 2010-12-29 14:35 ` Lucas Meneghel Rodrigues
2010-12-29 14:35 ` [PATCH 2/2] KVM-test: Add image_copy subtest to prepare images Lucas Meneghel Rodrigues
2010-12-29 15:24 ` [PATCH 0/2] KVM test: Image copy test v2 Lucas Meneghel Rodrigues
2 siblings, 0 replies; 4+ messages in thread
From: Lucas Meneghel Rodrigues @ 2010-12-29 14:35 UTC (permalink / raw)
To: autotest; +Cc: kvm, Amos Kong
From: Amos Kong <akong@redhat.com>
Add mount and umount function, you can assign source, mount_point, type
and permission.
Changes from v1:
- Make better use of autotest API to control subprocesses
Signed-off-by: Amos Kong <akong@redhat.com>
---
client/tests/kvm/kvm_utils.py | 55 +++++++++++++++++++++++++++++++++++++++++
1 files changed, 55 insertions(+), 0 deletions(-)
diff --git a/client/tests/kvm/kvm_utils.py b/client/tests/kvm/kvm_utils.py
index 8805449..de362d5 100644
--- a/client/tests/kvm/kvm_utils.py
+++ b/client/tests/kvm/kvm_utils.py
@@ -1536,3 +1536,58 @@ class KojiDownloader(object):
rpm_paths.append(r)
return rpm_paths
+
+
+def umount(src, mount_point, type):
+ """
+ Umount the src mounted in mount_point.
+
+ @src: mount source
+ @mount_point: mount point
+ @type: file system type
+ """
+
+ mount_string = "%s %s %s" % (src, mount_point, type)
+ if mount_string in file("/etc/mtab").read():
+ umount_cmd = "umount %s" % mount_point
+ try:
+ utils.system(umount_cmd)
+ return True
+ except error.CmdError:
+ return False
+ else:
+ logging.debug("%s is not mounted under %s" % (src, mount_point))
+ return True
+
+
+def mount(src, mount_point, type, perm="rw"):
+ """
+ Mount the src into mount_point of the host.
+
+ @src: mount source
+ @mount_point: mount point
+ @type: file system type
+ @perm: mount premission
+ """
+ umount(src, mount_point, type)
+ mount_string = "%s %s %s %s" % (src, mount_point, type, perm)
+
+ if mount_string in file("/etc/mtab").read():
+ logging.debug("%s is already mounted in %s with %s" %
+ (src, mount_point, perm))
+ return True
+
+ mount_cmd = "mount -t %s %s %s -o %s" % (type, src, mount_point, perm)
+ try:
+ utils.system(mount_cmd)
+ except error.CmdError:
+ return False
+
+ logging.debug("Verify the mount through /etc/mtab")
+ if mount_string in file("/etc/mtab").read():
+ logging.debug("%s is successfully mounted" % src)
+ return True
+ else:
+ logging.error("Can't find mounted NFS share - /etc/mtab contents \n%s" %
+ file("/etc/mtab").read())
+ return False
--
1.7.2.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] KVM-test: Add image_copy subtest to prepare images
2010-12-29 14:35 [PATCH 0/2] KVM test: Image copy test v2 Lucas Meneghel Rodrigues
2010-12-29 14:35 ` [PATCH 1/2] KVM-test: Add mount utility functions Lucas Meneghel Rodrigues
@ 2010-12-29 14:35 ` Lucas Meneghel Rodrigues
2010-12-29 15:24 ` [PATCH 0/2] KVM test: Image copy test v2 Lucas Meneghel Rodrigues
2 siblings, 0 replies; 4+ messages in thread
From: Lucas Meneghel Rodrigues @ 2010-12-29 14:35 UTC (permalink / raw)
To: autotest; +Cc: kvm
From: Amos Kong <akong@redhat.com>
image_copy is used to copy guests' images from NFS server to test
machines. It takes too much time for installing guests everytime.
You can config NFS server directory in tests_base.cfg.
Changes from v1:
- Make better use of autotest API to control subprocesses
- Do not use hardcoded images location. Instead, use the
final destination of the image that is going to be used
by the other tests anyway.
Signed-off-by: Amos Kong <akong@redhat.com>
---
client/tests/kvm/tests/image_copy.py | 46 ++++++++++++++++++++++++++++++++
client/tests/kvm/tests_base.cfg.sample | 9 ++++++
2 files changed, 55 insertions(+), 0 deletions(-)
create mode 100644 client/tests/kvm/tests/image_copy.py
diff --git a/client/tests/kvm/tests/image_copy.py b/client/tests/kvm/tests/image_copy.py
new file mode 100644
index 0000000..87bafea
--- /dev/null
+++ b/client/tests/kvm/tests/image_copy.py
@@ -0,0 +1,46 @@
+import os, logging, commands
+from autotest_lib.client.common_lib import error
+from autotest_lib.client.bin import utils
+import kvm_utils
+
+
+def run_image_copy(test, params, env):
+ """
+ Copy guest images from nfs server.
+ 1) Mount the NFS share directory
+ 2) Check the existence of source image
+ 3) If it exists, copy the image from NFS
+
+ @param test: kvm test object
+ @param params: Dictionary with the test parameters
+ @param env: Dictionary with test environment.
+ """
+ mount_dest_dir = params.get('dst_dir', '/mnt/images')
+ if not os.path.exists(mount_dest_dir):
+ try:
+ os.makedirs(mount_dest_dir)
+ except OSError, err:
+ logging.warning('mkdir %s error:\n%s', mount_dest_dir, err)
+
+ if not os.path.exists(mount_dest_dir):
+ raise error.TestError('Failed to create NFS share dir %s' %
+ mount_dest_dir)
+
+ src = params.get('images_good')
+ mnt_cmd = 'mount %s %s -o ro' % (src, mount_dest_dir)
+ image = '%s.%s' % (os.path.split(params['image_name'])[1],
+ params['image_format'])
+ src_path = os.path.join(mount_dest_dir, image)
+ dst_path = '%s.%s' % (params['image_name'], params['image_format'])
+ cmd = 'cp %s %s' % (src_path, dst_path)
+
+ if not kvm_utils.mount(src, mount_dest_dir, 'nfs', 'ro'):
+ raise error.TestError('Could not mount NFS share %s to %s' %
+ (src, mount_dest_dir))
+
+ # Check the existence of source image
+ if not os.path.exists(src_path):
+ raise error.TestError('Could not find %s in NFS share' % src_path)
+
+ logging.debug('Copying image %s...' % image)
+ utils.system(cmd)
diff --git a/client/tests/kvm/tests_base.cfg.sample b/client/tests/kvm/tests_base.cfg.sample
index d3275c8..1a260b4 100644
--- a/client/tests/kvm/tests_base.cfg.sample
+++ b/client/tests/kvm/tests_base.cfg.sample
@@ -63,6 +63,9 @@ profilers = kvm_stat
login_timeout = 360
image_raw_device = no
+# NFS directory of guests' images
+images_good = 0.0.0.0:/autotest/images_good
+
# Tests
variants:
- install:
@@ -75,6 +78,12 @@ variants:
kill_vm_timeout = 60
kill_vm_timeout_on_error = 0
+ - image_copy:
+ type = image_copy
+ vms = ''
+ parallel = no
+ profilers =
+
- setup: install
type = steps
fail_if_stuck_for = 300
--
1.7.2.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2] KVM test: Image copy test v2
2010-12-29 14:35 [PATCH 0/2] KVM test: Image copy test v2 Lucas Meneghel Rodrigues
2010-12-29 14:35 ` [PATCH 1/2] KVM-test: Add mount utility functions Lucas Meneghel Rodrigues
2010-12-29 14:35 ` [PATCH 2/2] KVM-test: Add image_copy subtest to prepare images Lucas Meneghel Rodrigues
@ 2010-12-29 15:24 ` Lucas Meneghel Rodrigues
2 siblings, 0 replies; 4+ messages in thread
From: Lucas Meneghel Rodrigues @ 2010-12-29 15:24 UTC (permalink / raw)
To: autotest; +Cc: kvm, Amos Kong
On Wed, 2010-12-29 at 12:35 -0200, Lucas Meneghel Rodrigues wrote:
> This is a respin of Amos's patch for image_copy test. In this
> version, small cleanups and consistency fixes were made, specially
> with regards to using utils.system instead of functions on the
> commands API.
Amos, FYI, image_copy test commited:
http://autotest.kernel.org/changeset/5042
Thanks!
> Amos Kong (2):
> KVM-test: Add mount utility functions
> KVM-test: Add image_copy subtest to prepare images
>
> client/tests/kvm/kvm_utils.py | 55 ++++++++++++++++++++++++++++++++
> client/tests/kvm/tests/image_copy.py | 46 ++++++++++++++++++++++++++
> client/tests/kvm/tests_base.cfg.sample | 9 +++++
> 3 files changed, 110 insertions(+), 0 deletions(-)
> create mode 100644 client/tests/kvm/tests/image_copy.py
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-12-29 15:24 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-29 14:35 [PATCH 0/2] KVM test: Image copy test v2 Lucas Meneghel Rodrigues
2010-12-29 14:35 ` [PATCH 1/2] KVM-test: Add mount utility functions Lucas Meneghel Rodrigues
2010-12-29 14:35 ` [PATCH 2/2] KVM-test: Add image_copy subtest to prepare images Lucas Meneghel Rodrigues
2010-12-29 15:24 ` [PATCH 0/2] KVM test: Image copy test v2 Lucas Meneghel Rodrigues
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox