From patchwork Tue Dec 1 22:37:02 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: 64065 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 nB1MbIMd003182 for ; Tue, 1 Dec 2009 22:37:18 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753258AbZLAWhF (ORCPT ); Tue, 1 Dec 2009 17:37:05 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753141AbZLAWhF (ORCPT ); Tue, 1 Dec 2009 17:37:05 -0500 Received: from mx1.redhat.com ([209.132.183.28]:3452 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751352AbZLAWhD (ORCPT ); Tue, 1 Dec 2009 17:37:03 -0500 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nB1Mb6ue019388 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 1 Dec 2009 17:37:06 -0500 Received: from localhost.localdomain (vpn-9-160.rdu.redhat.com [10.11.9.160]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nB1Mb4Wo025883; Tue, 1 Dec 2009 17:37:04 -0500 From: Lucas Meneghel Rodrigues To: autotest@test.kernel.org Cc: kvm@vger.kernel.org, jadmanski@google.com, Lucas Meneghel Rodrigues Subject: [PATCH] Fix autotest client when checking only client from svn Date: Tue, 1 Dec 2009 20:37:02 -0200 Message-Id: <1259707022-27417-1-git-send-email-lmr@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org diff --git a/client/bin/autotest b/client/bin/autotest index 285be4e..c83e755 100755 --- a/client/bin/autotest +++ b/client/bin/autotest @@ -61,7 +61,8 @@ if len(args) != 1: drop_caches = global_config.global_config.get_config_value('CLIENT', 'drop_caches', - type=bool) + type=bool, + default=True) # JOB: run the specified job control file. job.runjob(os.path.realpath(args[0]), drop_caches, options) diff --git a/client/bin/harness_autoserv.py b/client/bin/harness_autoserv.py index 4ea16e4..0bfbcdd 100644 --- a/client/bin/harness_autoserv.py +++ b/client/bin/harness_autoserv.py @@ -1,5 +1,6 @@ -import os, logging +import os, logging, ConfigParser from autotest_lib.client.common_lib import autotemp, base_packages, error +from autotest_lib.client.common_lib import global_config from autotest_lib.client.bin import harness @@ -20,6 +21,18 @@ class harness_autoserv(harness.harness): super(harness_autoserv, self).__init__(job) self.status = os.fdopen(3, 'w', 0) + # If a bug on the client run code prevents global_config.ini + # from being copied to the client machine, the client will run + # without a global config, relying only on the defaults of the + # config items. To avoid that happening silently, the check below + # was written. + try: + cfg = global_config.global_config.get_section_values("CLIENT") + except ConfigParser.NoSectionError: + logging.error("Empty CLIENT configuration session. " + "global_config.ini missing. This probably means " + "a bug on the server code. Please verify.") + def run_start(self): # set up the package fetcher for direct-from-autoserv fetches diff --git a/client/bin/job.py b/client/bin/job.py index 7021105..f879100 100755 --- a/client/bin/job.py +++ b/client/bin/job.py @@ -233,7 +233,7 @@ class base_client_job(base_job.base_job): self.drop_caches_between_iterations = ( global_config.global_config.get_config_value('CLIENT', 'drop_caches_between_iterations', - type=bool)) + type=bool, default=True)) self.drop_caches = drop_caches if self.drop_caches: logging.debug("Dropping caches") diff --git a/client/common_lib/global_config.py b/client/common_lib/global_config.py index 04ab7ff..24a93ea 100644 --- a/client/common_lib/global_config.py +++ b/client/common_lib/global_config.py @@ -5,7 +5,7 @@ provides access to global configuration file __author__ = 'raphtee@google.com (Travis Miller)' -import os, sys, ConfigParser +import os, sys, ConfigParser, logging from autotest_lib.client.common_lib import error @@ -44,11 +44,9 @@ elif config_in_client: DEFAULT_SHADOW_FILE = None RUNNING_STAND_ALONE_CLIENT = True else: - raise ConfigError("Could not find configuration files " - "needed for this program to function. Please refer to " - "http://autotest.kernel.org/wiki/GlobalConfig " - "for more info.") - + DEFAULT_CONFIG_FILE = None + DEFAULT_SHADOW_FILE = None + RUNNING_STAND_ALONE_CLIENT = True class global_config(object): _NO_DEFAULT_SPECIFIED = object() @@ -145,10 +143,11 @@ class global_config(object): def parse_config_file(self): - if not os.path.exists(self.config_file): - raise ConfigError('%s not found' % (self.config_file)) self.config = ConfigParser.ConfigParser() - self.config.read(self.config_file) + if self.config_file and os.path.exists(self.config_file): + self.config.read(self.config_file) + else: + raise ConfigError('%s not found' % (self.config_file)) # now also read the shadow file if there is one # this will overwrite anything that is found in the diff --git a/client/common_lib/host_protections.py b/client/common_lib/host_protections.py index 7c9e6a0..b5b2156 100644 --- a/client/common_lib/host_protections.py +++ b/client/common_lib/host_protections.py @@ -29,16 +29,15 @@ try: default_protection = global_config.global_config.get_config_value( 'HOSTS', 'default_protection', default=_bad_value) if default_protection == _bad_value: - if running_client: - logging.debug('Client stand alone run detected. ' - 'host_protection.default will not be set.') - else: + if not running_client: raise global_config.ConfigError( 'No HOSTS.default_protection defined in global_config.ini') else: default = Protection.get_value(default_protection) +# It is OK to have an empty global configuration object (stand alone client) +# so we trap this exception. except global_config.ConfigError: - raise global_config.ConfigError('No global_config.ini exists, aborting') + pass choices = Protection.choices()