OLD | NEW |
1 import logging, os, re | 1 import logging, os, re |
2 from autotest_lib.client.common_lib import error | 2 from autotest_lib.client.common_lib import error |
3 import kvm_subprocess, kvm_utils, rss_file_transfer | 3 from autotest_lib.client.virt import virt_utils, rss_client, aexpect |
4 | 4 |
5 | 5 |
6 def run_whql_submission(test, params, env): | 6 def run_whql_submission(test, params, env): |
7 """ | 7 """ |
8 WHQL submission test: | 8 WHQL submission test: |
9 1) Log into the client machines and into a DTM server machine | 9 1) Log into the client machines and into a DTM server machine |
10 2) Copy the automation program binary (dsso_test_binary) to the server machi
ne | 10 2) Copy the automation program binary (dsso_test_binary) to the server machi
ne |
11 3) Run the automation program | 11 3) Run the automation program |
12 4) Pass the program all relevant parameters (e.g. device_data) | 12 4) Pass the program all relevant parameters (e.g. device_data) |
13 5) Wait for the program to terminate | 13 5) Wait for the program to terminate |
(...skipping 21 matching lines...) Expand all Loading... |
35 s.close() | 35 s.close() |
36 | 36 |
37 # Collect parameters | 37 # Collect parameters |
38 server_address = params.get("server_address") | 38 server_address = params.get("server_address") |
39 server_shell_port = int(params.get("server_shell_port")) | 39 server_shell_port = int(params.get("server_shell_port")) |
40 server_file_transfer_port = int(params.get("server_file_transfer_port")) | 40 server_file_transfer_port = int(params.get("server_file_transfer_port")) |
41 server_studio_path = params.get("server_studio_path", "%programfiles%\\ " | 41 server_studio_path = params.get("server_studio_path", "%programfiles%\\ " |
42 "Microsoft Driver Test Manager\\Studio") | 42 "Microsoft Driver Test Manager\\Studio") |
43 dsso_test_binary = params.get("dsso_test_binary", | 43 dsso_test_binary = params.get("dsso_test_binary", |
44 "deps/whql_submission_15.exe") | 44 "deps/whql_submission_15.exe") |
45 dsso_test_binary = kvm_utils.get_path(test.bindir, dsso_test_binary) | 45 dsso_test_binary = virt_utils.get_path(test.bindir, dsso_test_binary) |
46 dsso_delete_machine_binary = params.get("dsso_delete_machine_binary", | 46 dsso_delete_machine_binary = params.get("dsso_delete_machine_binary", |
47 "deps/whql_delete_machine_15.exe") | 47 "deps/whql_delete_machine_15.exe") |
48 dsso_delete_machine_binary = kvm_utils.get_path(test.bindir, | 48 dsso_delete_machine_binary = virt_utils.get_path(test.bindir, |
49 dsso_delete_machine_binary) | 49 dsso_delete_machine_binary) |
50 test_timeout = float(params.get("test_timeout", 600)) | 50 test_timeout = float(params.get("test_timeout", 600)) |
51 | 51 |
52 # Copy dsso binaries to the server | 52 # Copy dsso binaries to the server |
53 for filename in dsso_test_binary, dsso_delete_machine_binary: | 53 for filename in dsso_test_binary, dsso_delete_machine_binary: |
54 rss_file_transfer.upload(server_address, server_file_transfer_port, | 54 rss_client.upload(server_address, server_file_transfer_port, |
55 filename, server_studio_path, timeout=60) | 55 filename, server_studio_path, timeout=60) |
56 | 56 |
57 # Open a shell session with the server | 57 # Open a shell session with the server |
58 server_session = kvm_utils.remote_login("nc", server_address, | 58 server_session = virt_utils.remote_login("nc", server_address, |
59 server_shell_port, "", "", | 59 server_shell_port, "", "", |
60 sessions[0].prompt, | 60 sessions[0].prompt, |
61 sessions[0].linesep) | 61 sessions[0].linesep) |
62 server_session.set_status_test_command(sessions[0].status_test_command) | 62 server_session.set_status_test_command(sessions[0].status_test_command) |
63 | 63 |
64 # Get the computer names of the server and clients | 64 # Get the computer names of the server and clients |
65 cmd = "echo %computername%" | 65 cmd = "echo %computername%" |
66 server_name = server_session.cmd_output(cmd).strip() | 66 server_name = server_session.cmd_output(cmd).strip() |
67 client_names = [session.cmd_output(cmd).strip() for session in sessions] | 67 client_names = [session.cmd_output(cmd).strip() for session in sessions] |
68 | 68 |
69 # Delete all client machines from the server's data store | 69 # Delete all client machines from the server's data store |
70 server_session.cmd("cd %s" % server_studio_path) | 70 server_session.cmd("cd %s" % server_studio_path) |
71 for client_name in client_names: | 71 for client_name in client_names: |
72 cmd = "%s %s %s" % (os.path.basename(dsso_delete_machine_binary), | 72 cmd = "%s %s %s" % (os.path.basename(dsso_delete_machine_binary), |
73 server_name, client_name) | 73 server_name, client_name) |
74 server_session.cmd(cmd, print_func=logging.debug) | 74 server_session.cmd(cmd, print_func=logging.debug) |
75 | 75 |
76 # Reboot the client machines | 76 # Reboot the client machines |
77 sessions = kvm_utils.parallel((vm.reboot, (session,)) | 77 sessions = virt_utils.parallel((vm.reboot, (session,)) |
78 for vm, session in zip(vms, sessions)) | 78 for vm, session in zip(vms, sessions)) |
79 | 79 |
80 # Check the NICs again | 80 # Check the NICs again |
81 for vm in vms: | 81 for vm in vms: |
82 nics = vm.params.objects("nics") | 82 nics = vm.params.objects("nics") |
83 for nic_index in range(len(nics)): | 83 for nic_index in range(len(nics)): |
84 s = vm.wait_for_login(nic_index, 600) | 84 s = vm.wait_for_login(nic_index, 600) |
85 s.close() | 85 s.close() |
86 | 86 |
87 # Run whql_pre_command and close the sessions | 87 # Run whql_pre_command and close the sessions |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 find_prompt(r"Parameter name\b.*:") | 164 find_prompt(r"Parameter name\b.*:") |
165 server_session.sendline() | 165 server_session.sendline() |
166 | 166 |
167 # Wait for the automation program to terminate | 167 # Wait for the automation program to terminate |
168 try: | 168 try: |
169 o = server_session.read_up_to_prompt(print_func=logging.info, | 169 o = server_session.read_up_to_prompt(print_func=logging.info, |
170 timeout=test_timeout + 300) | 170 timeout=test_timeout + 300) |
171 # (test_timeout + 300 is used here because the automation program is | 171 # (test_timeout + 300 is used here because the automation program is |
172 # supposed to terminate cleanly on its own when test_timeout expires) | 172 # supposed to terminate cleanly on its own when test_timeout expires) |
173 done = True | 173 done = True |
174 except kvm_subprocess.ExpectError, e: | 174 except aexpect.ExpectError, e: |
175 o = e.output | 175 o = e.output |
176 done = False | 176 done = False |
177 server_session.close() | 177 server_session.close() |
178 | 178 |
179 # Look for test results in the automation program's output | 179 # Look for test results in the automation program's output |
180 result_summaries = re.findall(r"---- \[.*?\] ----", o, re.DOTALL) | 180 result_summaries = re.findall(r"---- \[.*?\] ----", o, re.DOTALL) |
181 if not result_summaries: | 181 if not result_summaries: |
182 raise error.TestError("The automation program did not return any " | 182 raise error.TestError("The automation program did not return any " |
183 "results") | 183 "results") |
184 results = result_summaries[-1].strip("-") | 184 results = result_summaries[-1].strip("-") |
185 results = eval("".join(results.splitlines())) | 185 results = eval("".join(results.splitlines())) |
186 | 186 |
187 # Download logs and HTML reports from the server | 187 # Download logs and HTML reports from the server |
188 for i, r in enumerate(results): | 188 for i, r in enumerate(results): |
189 if "report" in r: | 189 if "report" in r: |
190 try: | 190 try: |
191 rss_file_transfer.download(server_address, | 191 rss_client.download(server_address, |
192 server_file_transfer_port, | 192 server_file_transfer_port, |
193 r["report"], test.debugdir) | 193 r["report"], test.debugdir) |
194 except rss_file_transfer.FileTransferNotFoundError: | 194 except rss_client.FileTransferNotFoundError: |
195 pass | 195 pass |
196 if "logs" in r: | 196 if "logs" in r: |
197 try: | 197 try: |
198 rss_file_transfer.download(server_address, | 198 rss_client.download(server_address, |
199 server_file_transfer_port, | 199 server_file_transfer_port, |
200 r["logs"], test.debugdir) | 200 r["logs"], test.debugdir) |
201 except rss_file_transfer.FileTransferNotFoundError: | 201 except rss_client.FileTransferNotFoundError: |
202 pass | 202 pass |
203 else: | 203 else: |
204 try: | 204 try: |
205 # Create symlinks to test log dirs to make it easier | 205 # Create symlinks to test log dirs to make it easier |
206 # to access them (their original names are not human | 206 # to access them (their original names are not human |
207 # readable) | 207 # readable) |
208 link_name = "logs_%s" % r["report"].split("\\")[-1] | 208 link_name = "logs_%s" % r["report"].split("\\")[-1] |
209 link_name = link_name.replace(" ", "_") | 209 link_name = link_name.replace(" ", "_") |
210 link_name = link_name.replace("/", "_") | 210 link_name = link_name.replace("/", "_") |
211 os.symlink(r["logs"].split("\\")[-1], | 211 os.symlink(r["logs"].split("\\")[-1], |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 for r in results: | 247 for r in results: |
248 print_summary_line(f, fmt % (r["id"], r["job"], r["status"], | 248 print_summary_line(f, fmt % (r["id"], r["job"], r["status"], |
249 r["pass"], r["fail"], r["notrun"], | 249 r["pass"], r["fail"], r["notrun"], |
250 r["notapplicable"])) | 250 r["notapplicable"])) |
251 f.close() | 251 f.close() |
252 logging.info("(see logs and HTML reports in %s)", test.debugdir) | 252 logging.info("(see logs and HTML reports in %s)", test.debugdir) |
253 | 253 |
254 # Kill the client VMs and fail if the automation program did not terminate | 254 # Kill the client VMs and fail if the automation program did not terminate |
255 # on time | 255 # on time |
256 if not done: | 256 if not done: |
257 kvm_utils.parallel(vm.destroy for vm in vms) | 257 virt_utils.parallel(vm.destroy for vm in vms) |
258 raise error.TestFail("The automation program did not terminate " | 258 raise error.TestFail("The automation program did not terminate " |
259 "on time") | 259 "on time") |
260 | 260 |
261 # Fail if there are failed or incomplete jobs (kill the client VMs if there | 261 # Fail if there are failed or incomplete jobs (kill the client VMs if there |
262 # are incomplete jobs) | 262 # are incomplete jobs) |
263 failed_jobs = [r["job"] for r in results | 263 failed_jobs = [r["job"] for r in results |
264 if r["status"].lower() == "investigate"] | 264 if r["status"].lower() == "investigate"] |
265 running_jobs = [r["job"] for r in results | 265 running_jobs = [r["job"] for r in results |
266 if r["status"].lower() == "inprogress"] | 266 if r["status"].lower() == "inprogress"] |
267 errors = [] | 267 errors = [] |
268 if failed_jobs: | 268 if failed_jobs: |
269 errors += ["Jobs failed: %s." % failed_jobs] | 269 errors += ["Jobs failed: %s." % failed_jobs] |
270 if running_jobs: | 270 if running_jobs: |
271 for vm in vms: | 271 for vm in vms: |
272 vm.destroy() | 272 vm.destroy() |
273 errors += ["Jobs did not complete on time: %s." % running_jobs] | 273 errors += ["Jobs did not complete on time: %s." % running_jobs] |
274 if errors: | 274 if errors: |
275 raise error.TestFail(" ".join(errors)) | 275 raise error.TestFail(" ".join(errors)) |
OLD | NEW |