Zhou Zheng Sheng has uploaded a new change for review.

Change subject: add simple VM creation functional test
......................................................................

add simple VM creation functional test

Create a VM using existing host kernel and initramfs, then destroy it.

Change-Id: Icb0d86ce20a547ef809d5407fe12d6ade474c4d2
Signed-off-by: Zhou Zheng Sheng <[email protected]>
---
M tests/functional/Makefile.am
A tests/functional/vmTests.py
2 files changed, 91 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/96/7396/1

diff --git a/tests/functional/Makefile.am b/tests/functional/Makefile.am
index 4c3792c..2b34677 100644
--- a/tests/functional/Makefile.am
+++ b/tests/functional/Makefile.am
@@ -23,5 +23,6 @@
 dist_vdsmfunctests_PYTHON = \
        momTests.py \
        restTests.py \
-       sosPluginTests.py
+       sosPluginTests.py \
+       vmTests.py
 
diff --git a/tests/functional/vmTests.py b/tests/functional/vmTests.py
new file mode 100644
index 0000000..145ba60
--- /dev/null
+++ b/tests/functional/vmTests.py
@@ -0,0 +1,89 @@
+#
+# Copyright 2012 Zhou Zheng Sheng, IBM Corporation
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+#
+# Refer to the README and COPYING files for full details of the license
+#
+
+import os
+import time
+import uuid
+from testrunner import VdsmTestCase as TestCaseBase
+import testValidation
+
+from vdsm import vdscli
+
+
+def assertVdsOK(vdsResult):
+    if vdsResult['status']['code']:
+        raise Exception(vdsResult['status']['message'])
+    return vdsResult
+
+
+class vmTests(TestCaseBase):
+    @testValidation.ValidateRunningAsRoot
+    def testCreateSimpleVM(self):
+        kernelVer = os.uname()[2]
+        kernelPath = "/boot/vmlinuz-" + kernelVer
+        initramfsPath = "/boot/initramfs-%s.img" % kernelVer
+        vmid = str(uuid.uuid4())
+        conf = {'acpiEnable': 'True',
+                'display': 'vnc',
+                'initrd': initramfsPath,
+                'kernel': kernelPath,
+                # Fedora uses dracut to create initramfs. The following
+                # arguments will be interpreted by init scripts created by
+                # dracut.
+                'kernelArgs': 'rd.break=cmdline rd.shell rd.skipfsck',
+                'kvmEnable': 'true',
+                'memSize': '256',
+                'vmId': vmid,
+                'vmName': 'vdsm_testVM',
+                'vmType': 'kvm'}
+
+        self.s = vdscli.connect()
+
+        try:
+            assertVdsOK(self.s.create(conf))
+
+            timeout = 60  # seconds
+            # wait for VM to come up until timeout
+            start = time.time()
+            while True:
+                if self.isVMUp(vmid):
+                    break
+                now = time.time()
+                if now - start > timeout:
+                    raise Exception("Creating VM timeout, configuration %r" %
+                                    conf)
+                time.sleep(1)
+        except Exception:
+            raise
+        finally:
+            assertVdsOK(self.s.destroy(vmid))
+
+    def isVMUp(self, vmid):
+        vmList = assertVdsOK(self.s.list())['vmList']
+        for vm in vmList:
+            if vm['vmId'] == vmid and vm['status'] == 'Up':
+                break
+        else:
+            return False
+        statsList = assertVdsOK(self.s.getVmStats(vmid))['statsList']
+        vm = statsList[0]
+        if vm['status'] == 'Up':
+            return True
+        return False


--
To view, visit http://gerrit.ovirt.org/7396
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icb0d86ce20a547ef809d5407fe12d6ade474c4d2
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Zhou Zheng Sheng <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to