diff mbox

Fix autotest client when checking only client from svn

Message ID 1259707022-27417-1-git-send-email-lmr@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Lucas Meneghel Rodrigues Dec. 1, 2009, 10:37 p.m. UTC
None
diff mbox

Patch

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()