From patchwork Thu Jul 29 12:22:10 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Goldish X-Patchwork-Id: 115136 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o6TCLglp028430 for ; Thu, 29 Jul 2010 12:21:42 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754475Ab0G2MVk (ORCPT ); Thu, 29 Jul 2010 08:21:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57324 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753125Ab0G2MVj (ORCPT ); Thu, 29 Jul 2010 08:21:39 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o6TCLcKO021747 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 29 Jul 2010 08:21:39 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o6TCLcfA005272; Thu, 29 Jul 2010 08:21:38 -0400 Received: from localhost.localdomain (dhcp-1-188.tlv.redhat.com [10.35.1.188]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o6TCLa6D016232; Thu, 29 Jul 2010 08:21:36 -0400 From: Michael Goldish To: autotest@test.kernel.org, kvm@vger.kernel.org Cc: Michael Goldish Subject: [KVM-AUTOTEST PATCH v3] [RFC] KVM test: add whql_client_install test Date: Thu, 29 Jul 2010 15:22:10 +0300 Message-Id: <1280406130-21354-1-git-send-email-mgoldish@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 29 Jul 2010 12:21:43 +0000 (UTC) diff --git a/client/tests/kvm/tests/whql_client_install.py b/client/tests/kvm/tests/whql_client_install.py new file mode 100644 index 0000000..d866df7 --- /dev/null +++ b/client/tests/kvm/tests/whql_client_install.py @@ -0,0 +1,116 @@ +import logging, time, os, re +from autotest_lib.client.common_lib import error +import kvm_subprocess, kvm_test_utils, kvm_utils, rss_file_transfer + + +def run_whql_client_install(test, params, env): + """ + WHQL DTM client installation: + 1) Log into the guest (the client machine) and into a DTM server machine + 2) Stop the DTM client service (wttsvc) on the client machine + 3) Delete the client machine from the server's data store + 4) Rename the client machine (give it a randomly generated name) + 5) Move the client machine into the server's workgroup + 6) Reboot the client machine + 7) Install the DTM client software + + @param test: kvm test object + @param params: Dictionary with the test parameters + @param env: Dictionary with test environment. + """ + vm = kvm_test_utils.get_living_vm(env, params.get("main_vm")) + session = kvm_test_utils.wait_for_login(vm, 0, 240) + + # Collect test params + server_address = params.get("server_address") + server_shell_port = int(params.get("server_shell_port")) + server_file_transfer_port = int(params.get("server_file_transfer_port")) + server_studio_path = params.get("server_studio_path", "%programfiles%\\ " + "Microsoft Driver Test Manager\\Studio") + server_username = params.get("server_username") + server_password = params.get("server_password") + dsso_delete_machine_binary = params.get("dsso_delete_machine_binary", + "deps/whql_delete_machine_15.exe") + dsso_delete_machine_binary = kvm_utils.get_path(test.bindir, + dsso_delete_machine_binary) + install_timeout = float(params.get("install_timeout", 600)) + install_cmd = params.get("install_cmd") + wtt_services = params.get("wtt_services") + + # Stop WTT service(s) on client + for svc in wtt_services.split(): + kvm_test_utils.stop_windows_service(session, svc) + + # Copy dsso_delete_machine_binary to server + rss_file_transfer.upload(server_address, server_file_transfer_port, + dsso_delete_machine_binary, server_studio_path, + timeout=60) + + # Open a shell session with server + server_session = kvm_utils.remote_login("nc", server_address, + server_shell_port, "", "", + session.prompt, session.linesep) + + # Get server and client information + cmd = "echo %computername%" + server_name = server_session.get_command_output(cmd).strip() + client_name = session.get_command_output(cmd).strip() + cmd = "wmic computersystem get domain" + server_workgroup = server_session.get_command_output(cmd).strip() + server_workgroup = server_workgroup.splitlines()[-1] + regkey = r"HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters" + cmd = "reg query %s /v Domain" % regkey + server_dns_suffix = server_session.get_command_output(cmd).split()[-1] + + # Delete the client machine from the server's data store (if it's there) + server_session.get_command_output("cd %s" % server_studio_path) + cmd = "%s %s %s" % (os.path.basename(dsso_delete_machine_binary), + server_name, client_name) + server_session.get_command_output(cmd, print_func=logging.info) + server_session.close() + + # Rename the client machine + client_name = "autotest_%s" % kvm_utils.generate_random_string(4) + logging.info("Renaming client machine to '%s'" % client_name) + cmd = ('wmic computersystem where name="%%computername%%" rename name="%s"' + % client_name) + if session.get_command_status(cmd, timeout=600) != 0: + raise error.TestError("Could not rename the client machine") + + # Join the server's workgroup + logging.info("Joining workgroup '%s'" % server_workgroup) + cmd = ('wmic computersystem where name="%%computername%%" call ' + 'joindomainorworkgroup name="%s"' % server_workgroup) + if session.get_command_status(cmd, timeout=600) != 0: + raise error.TestError("Could not change the client's workgroup") + + # Set the client machine's DNS suffix + logging.info("Setting DNS suffix to '%s'" % server_dns_suffix) + cmd = "reg add %s /v Domain /d %s /f" % (regkey, server_dns_suffix) + if session.get_command_status(cmd, timeout=300) != 0: + raise error.TestError("Could not set the client's DNS suffix") + + # Reboot + session = kvm_test_utils.reboot(vm, session) + + # Access shared resources on the server machine + logging.info("Attempting to access remote share on server") + cmd = r"net use \\%s /user:%s %s" % (server_name, server_username, + server_password) + end_time = time.time() + 120 + while time.time() < end_time: + s = session.get_command_status(cmd) + if s == 0: + break + time.sleep(5) + else: + raise error.TestError("Could not access server share from client " + "machine") + + # Install + logging.info("Installing DTM client (timeout=%ds)", install_timeout) + install_cmd = r"cmd /c \\%s\%s" % (server_name, install_cmd.lstrip("\\")) + if session.get_command_status(install_cmd, timeout=install_timeout) != 0: + raise error.TestError("Client installation failed") + + session.close()