Skip to contentSkip to conversation

KVM test: Add a subtest physical_resources_check

PATCH New Lucas Meneghel Rodrigues 1 participant 1 message Dec 1, 2009 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 KVM test: Add a subtest physical_resources_check

This test will test following parameters of a VM:
1) count of CPU, hard disks and NICs
2) memory size
3) model of hard disks and NICs
4) NICs' mac address
5) UUID and serial number (if defined the command in config file)

---
 client/tests/kvm/kvm_tests.cfg.sample              |   11 ++
 client/tests/kvm/kvm_vm.py                         |   39 ++++++
 client/tests/kvm/tests/physical_resources_check.py |  140 ++++++++++++++++++++
 3 files changed, 190 insertions(+), 0 deletions(-)
 create mode 100644 client/tests/kvm/tests/physical_resources_check.py
client/tests/kvm/kvm_tests.cfg.sample +11 -0
index 5e15b30..9fb1ba8 100644
@@ -255,6 +255,10 @@ variants:
         kill_vm_gracefully_vm2 = no
         address_index_vm2 = 1
 
+    - physical_resources_check: install setup unattended_install
+        type = physical_resources_check
+        catch_uuid_cmd = dmidecode | awk -F: '/UUID/ {print $2}'
+
 # NICs
 variants:
     - @rtl8139:
@@ -280,6 +284,8 @@ variants:
         shell_port = 22
         file_transfer_client = scp
         file_transfer_port = 22
+        mem_chk_cmd = dmidecode -t 17 | awk -F: '/Size/ {print $2}'
+        cpu_chk_cmd = grep -c processor /proc/cpuinfo
 
         variants:
             - Fedora:
@@ -553,6 +559,9 @@ variants:
         # This ISO will be used for all tests except install:
         cdrom = windows/winutils.iso
 
+        cpu_chk_cmd = echo %NUMBER_OF_PROCESSORS%
+        mem_chk_cmd = wmic memphysical
+
         migrate:
             migration_test_command = ver && vol
             migration_bg_command = start ping -t localhost
@@ -594,6 +603,8 @@ variants:
             reference_cmd = wmic diskdrive list brief
             find_pci_cmd = wmic diskdrive list brief
             pci_test_cmd = echo select disk 1 > dt && echo online >> dt && echo detail disk >> dt && echo exit >> dt && diskpart /s dt
+        physical_resources_check:
+            catch_uuid_cmd = 
 
         variants:
             - Win2000:
client/tests/kvm/kvm_vm.py +39 -0
index 100b567..cc314d4 100755
@@ -821,3 +821,42 @@ class VM:
             return self.uuid
         else:
             return self.params.get("uuid", None)
+
+
+    def get_cpu_count(self):
+        """
+        Get the cpu count of the VM.
+        """
+        try:
+            session = self.remote_login()
+            if session:
+                cmd = self.params.get("cpu_chk_cmd")
+                s, count = session.get_command_status_output(cmd)
+                if s == 0:
+                    return int(count)
+            return None
+        finally:
+            session.close()
+
+
+    def get_memory_size(self):
+        """
+        Get memory size of the VM.
+        """
+        try:
+            session = self.remote_login()
+            if session:
+                cmd = self.params.get("mem_chk_cmd")
+                s, mem_str = session.get_command_status_output(cmd)
+                if s != 0:
+                    return None
+                mem = re.findall("([0-9][0-9][0-9]+)", mem_str)
+                mem_size = 0
+                for m in mem:
+                    mem_size += int(m)
+                if not "MB" in mem_str:
+                    mem_size /= 1024
+                return int(mem_size)
+            return None
+        finally:
+            session.close()
client/tests/kvm/tests/physical_resources_check.py new file +140 -0

140 lines not on this page · raw message

Signature · 1 line
1.6.5.2