With this test cases, we can create and verity a libvirt pool, and virt-v2v
also may reuse the test case to build a pool for converting later.

Signed-off-by: Alex Jia <a...@redhat.com>
---
 client/tests/libvirt/tests/virsh_pool_create_as.py |   52 ++++++++++++++++++++
 1 file changed, 52 insertions(+)
 create mode 100644 client/tests/libvirt/tests/virsh_pool_create_as.py

diff --git a/client/tests/libvirt/tests/virsh_pool_create_as.py 
b/client/tests/libvirt/tests/virsh_pool_create_as.py
new file mode 100644
index 0000000..cf2660b
--- /dev/null
+++ b/client/tests/libvirt/tests/virsh_pool_create_as.py
@@ -0,0 +1,52 @@
+import os, logging
+from autotest.client.shared import error
+from autotest.client.virt import libvirt_vm as virt
+
+
+def run_virsh_pool_create_as(test, params, env):
+    '''
+    Test the command virsh pool-create-as
+
+    (1) Call virsh pool-create-as
+    (2) Call virsh -c remote_uri pool-create-as
+    (3) Call virsh pool-create-as with an unexpected option
+    '''
+
+    # Run test case
+    if not params.has_key('pool_name') or not params.has_key('pool_target'):
+        logging.error("Please give a 'name' and 'target'")
+
+    pool_options = ''
+    if params.has_key('pool_options'):
+        pool_options = params.get('pool_options')
+
+    pool_name = params.get('pool_name')
+    pool_type = params.get('pool_type')
+    pool_target = params.get('pool_target')
+
+    if not os.path.isdir(pool_target):
+        logging.warning('<target> must be a directory')
+
+    if not os.path.exists(pool_target):
+        os.makedirs(pool_target)
+
+    logging.info('Creating a %s type pool %s' % (pool_type, pool_name))
+    status = virt.virsh_pool_create_as(pool_name, pool_type, pool_target,
+                                       pool_options)
+
+    # Check status_error
+    status_error = params.get('status_error')
+    if status_error == 'yes':
+        if status:
+            raise error.TestFail("%d not a expected command return value" % 
status)
+        else:
+            logging.info("It's a expected error")
+    elif status_error == 'no':
+        if not virt.virsh_pool_info(pool_name):
+            raise error.TestFail('Failed to check pool information')
+        else:
+            logging.info('Pool %s is running' % pool_name)
+        if not status:
+            raise error.TestFail('%d not a expected command return value' % 
status)
+        else:
+            logging.info('Succeed to create pool %s' % pool_name)
-- 
1.7.10.2

_______________________________________________
Autotest mailing list
Autotest@test.kernel.org
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to