From patchwork Tue Oct 6 01:03:05 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Meneghel Rodrigues X-Patchwork-Id: 51843 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n9615nnO013038 for ; Tue, 6 Oct 2009 01:05:49 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755732AbZJFBDm (ORCPT ); Mon, 5 Oct 2009 21:03:42 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755731AbZJFBDl (ORCPT ); Mon, 5 Oct 2009 21:03:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58440 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755689AbZJFBDl (ORCPT ); Mon, 5 Oct 2009 21:03:41 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n9613EDN005094; Mon, 5 Oct 2009 21:03:14 -0400 Received: from localhost.localdomain (vpn-12-223.rdu.redhat.com [10.11.12.223]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n9613AV9029434; Mon, 5 Oct 2009 21:03:13 -0400 From: Lucas Meneghel Rodrigues To: autotest@test.kernel.org Cc: kvm@vger.kernel.org, Lucas Meneghel Rodrigues Subject: [PATCH 2/6] KVM test: Introducing unattended install subtest Date: Mon, 5 Oct 2009 22:03:05 -0300 Message-Id: <1254790989-14204-2-git-send-email-lmr@redhat.com> In-Reply-To: <1254790989-14204-1-git-send-email-lmr@redhat.com> References: <1254790989-14204-1-git-send-email-lmr@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org diff --git a/client/tests/kvm/tests/unattended_install.py b/client/tests/kvm/tests/unattended_install.py new file mode 100644 index 0000000..60e2a35 --- /dev/null +++ b/client/tests/kvm/tests/unattended_install.py @@ -0,0 +1,45 @@ +import logging, time, socket +from autotest_lib.client.common_lib import error +import kvm_utils, kvm_test_utils + + +def run_unattended_install(test, params, env): + """ + Unattended install test: + 1) Starts a VM with an appropriated setup to start an unattended OS install. + 2) Wait until the install reports to the install watcher its end. + + @param test: KVM test object. + @param params: Dictionary with the test parameters. + @param env: Dictionary with test environment. + """ + vm = kvm_utils.env_get_vm(env, params.get("main_vm")) + if not vm: + raise error.TestError("VM object not found in environment") + if not vm.is_alive(): + raise error.TestError("VM seems to be dead; Test requires a living VM") + + logging.info("Starting unattended install watch process") + server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + server.bind(('', 12323)) + server.listen(1) + + end_time = time.time() + float(params.get("timeout", 3000)) + + while True: + server.settimeout(end_time - time.time()) + try: + (client, addr) = server.accept() + except socket.timeout: + server.close() + raise error.TestFail('Timeout elapsed while waiting for install to ' + 'finish.') + msg = client.recv(1024) + logging.debug("Received '%s' from %s", msg, addr) + if msg == 'done': + logging.info('Guest reported successful installation') + server.close() + break + else: + logging.error('Got invalid string from client: %s.' % msg) +