Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: client/tests/kvm/tests/physical_resources_check.py

Issue 6124004: Revert "Merge remote branch 'cros/upstream' into autotest-rebase" (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/autotest.git@master
Patch Set: Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « client/tests/kvm/tests/pci_hotplug.py ('k') | client/tests/kvm/tests/qemu_img.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 import re, string, logging 1 import re, string, logging
2 from autotest_lib.client.common_lib import error 2 from autotest_lib.client.common_lib import error
3 import kvm_test_utils, kvm_utils, kvm_monitor 3 import kvm_test_utils, kvm_utils, kvm_monitor
4 4
5 5
6 def run_physical_resources_check(test, params, env): 6 def run_physical_resources_check(test, params, env):
7 """ 7 """
8 Check physical resources assigned to KVM virtual machines: 8 Check physical resources assigned to KVM virtual machines:
9 1) Log into the guest 9 1) Log into the guest
10 2) Verify whether cpu counts ,memory size, nics' model, 10 2) Verify whether cpu counts ,memory size, nics' model,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 actual_mem = vm.get_memory_size() 44 actual_mem = vm.get_memory_size()
45 if actual_mem != expected_mem: 45 if actual_mem != expected_mem:
46 n_fail += 1 46 n_fail += 1
47 logging.error("Memory size mismatch:") 47 logging.error("Memory size mismatch:")
48 logging.error(" Assigned to VM: %s" % expected_mem) 48 logging.error(" Assigned to VM: %s" % expected_mem)
49 logging.error(" Reported by OS: %s" % actual_mem) 49 logging.error(" Reported by OS: %s" % actual_mem)
50 50
51 # Define a function for checking number of hard drivers & NICs 51 # Define a function for checking number of hard drivers & NICs
52 def check_num(devices, info_cmd, check_str): 52 def check_num(devices, info_cmd, check_str):
53 f_fail = 0 53 f_fail = 0
54 expected_num = params.objects(devices).__len__() 54 expected_num = kvm_utils.get_sub_dict_names(params, devices).__len__()
55 try: 55 try:
56 o = vm.monitor.info(info_cmd) 56 o = vm.monitor.info(info_cmd)
57 except kvm_monitor.MonitorError, e: 57 except kvm_monitor.MonitorError, e:
58 f_fail += 1 58 f_fail += 1
59 logging.error(e) 59 logging.error(e)
60 logging.error("info/query monitor command failed (%s)", info_cmd) 60 logging.error("info/query monitor command failed (%s)", info_cmd)
61 61
62 actual_num = string.count(o, check_str) 62 actual_num = string.count(o, check_str)
63 if expected_num != actual_num: 63 if expected_num != actual_num:
64 f_fail += 1 64 f_fail += 1
65 logging.error("%s number mismatch:") 65 logging.error("%s number mismatch:")
66 logging.error(" Assigned to VM: %d" % expected_num) 66 logging.error(" Assigned to VM: %d" % expected_num)
67 logging.error(" Reported by OS: %d" % actual_num) 67 logging.error(" Reported by OS: %d" % actual_num)
68 return expected_num, f_fail 68 return expected_num, f_fail
69 69
70 logging.info("Hard drive count check") 70 logging.info("Hard drive count check")
71 drives_num, f_fail = check_num("images", "block", "type=hd") 71 drives_num, f_fail = check_num("images", "block", "type=hd")
72 n_fail += f_fail 72 n_fail += f_fail
73 73
74 logging.info("NIC count check") 74 logging.info("NIC count check")
75 nics_num, f_fail = check_num("nics", "network", "model=") 75 nics_num, f_fail = check_num("nics", "network", "model=")
76 n_fail += f_fail 76 n_fail += f_fail
77 77
78 # Define a function for checking hard drives & NICs' model 78 # Define a function for checking hard drives & NICs' model
79 def chk_fmt_model(device, fmt_model, info_cmd, str): 79 def chk_fmt_model(device, fmt_model, info_cmd, str):
80 f_fail = 0 80 f_fail = 0
81 devices = params.objects(device) 81 devices = kvm_utils.get_sub_dict_names(params, device)
82 for chk_device in devices: 82 for chk_device in devices:
83 expected = params.object_params(chk_device).get(fmt_model) 83 expected = kvm_utils.get_sub_dict(params, chk_device).get(fmt_model)
84 if not expected: 84 if not expected:
85 expected = "rtl8139" 85 expected = "rtl8139"
86 try: 86 try:
87 o = vm.monitor.info(info_cmd) 87 o = vm.monitor.info(info_cmd)
88 except kvm_monitor.MonitorError, e: 88 except kvm_monitor.MonitorError, e:
89 f_fail += 1 89 f_fail += 1
90 logging.error(e) 90 logging.error(e)
91 logging.error("info/query monitor command failed (%s)", 91 logging.error("info/query monitor command failed (%s)",
92 info_cmd) 92 info_cmd)
93 93
(...skipping 22 matching lines...) Expand all
116 logging.info("Network card MAC check") 116 logging.info("Network card MAC check")
117 try: 117 try:
118 o = vm.monitor.info("network") 118 o = vm.monitor.info("network")
119 except kvm_monitor.MonitorError, e: 119 except kvm_monitor.MonitorError, e:
120 n_fail += 1 120 n_fail += 1
121 logging.error(e) 121 logging.error(e)
122 logging.error("info/query monitor command failed (network)") 122 logging.error("info/query monitor command failed (network)")
123 found_mac_addresses = re.findall("macaddr=(\S+)", o) 123 found_mac_addresses = re.findall("macaddr=(\S+)", o)
124 logging.debug("Found MAC adresses: %s" % found_mac_addresses) 124 logging.debug("Found MAC adresses: %s" % found_mac_addresses)
125 125
126 num_nics = len(params.objects("nics")) 126 num_nics = len(kvm_utils.get_sub_dict_names(params, "nics"))
127 for nic_index in range(num_nics): 127 for nic_index in range(num_nics):
128 mac = vm.get_mac_address(nic_index) 128 mac = vm.get_mac_address(nic_index)
129 if not string.lower(mac) in found_mac_addresses: 129 if not string.lower(mac) in found_mac_addresses:
130 n_fail += 1 130 n_fail += 1
131 logging.error("MAC address mismatch:") 131 logging.error("MAC address mismatch:")
132 logging.error(" Assigned to VM (not found): %s" % mac) 132 logging.error(" Assigned to VM (not found): %s" % mac)
133 133
134 # Define a function to verify UUID & Serial number 134 # Define a function to verify UUID & Serial number
135 def verify_device(expect, name, verify_cmd): 135 def verify_device(expect, name, verify_cmd):
136 f_fail = 0 136 f_fail = 0
137 if verify_cmd: 137 if verify_cmd:
138 actual = session.cmd_output(verify_cmd) 138 actual = session.get_command_output(verify_cmd)
139 if not string.upper(expect) in actual: 139 if not string.upper(expect) in actual:
140 f_fail += 1 140 f_fail += 1
141 logging.error("%s mismatch:") 141 logging.error("%s mismatch:")
142 logging.error(" Assigned to VM: %s" % string.upper(expect)) 142 logging.error(" Assigned to VM: %s" % string.upper(expect))
143 logging.error(" Reported by OS: %s" % actual) 143 logging.error(" Reported by OS: %s" % actual)
144 return f_fail 144 return f_fail
145 145
146 logging.info("UUID check") 146 logging.info("UUID check")
147 if vm.get_uuid(): 147 if vm.get_uuid():
148 f_fail = verify_device(vm.get_uuid(), "UUID", 148 f_fail = verify_device(vm.get_uuid(), "UUID",
149 params.get("catch_uuid_cmd")) 149 params.get("catch_uuid_cmd"))
150 n_fail += f_fail 150 n_fail += f_fail
151 151
152 logging.info("Hard Disk serial number check") 152 logging.info("Hard Disk serial number check")
153 catch_serial_cmd = params.get("catch_serial_cmd") 153 catch_serial_cmd = params.get("catch_serial_cmd")
154 f_fail = verify_device(params.get("drive_serial"), "Serial", 154 f_fail = verify_device(params.get("drive_serial"), "Serial",
155 catch_serial_cmd) 155 catch_serial_cmd)
156 n_fail += f_fail 156 n_fail += f_fail
157 157
158 if n_fail != 0: 158 if n_fail != 0:
159 raise error.TestFail("Physical resources check test reported %s " 159 raise error.TestFail("Physical resources check test reported %s "
160 "failures. Please verify the test logs." % n_fail) 160 "failures. Please verify the test logs." % n_fail)
161 161
162 session.close() 162 session.close()
OLDNEW
« no previous file with comments | « client/tests/kvm/tests/pci_hotplug.py ('k') | client/tests/kvm/tests/qemu_img.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698