Re: [Autotest] [PATCH] Fix autotest client when checking only client from svn

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Dec 1, 2009 at 8:42 PM, Martin Bligh <mbligh@xxxxxxxxxx> wrote:
> yup, seems important - lmr, do you want to go ahead and apply this? I'm stuck
> in a meeting for a while

Alright, already applied:

http://autotest.kernel.org/changeset/3981

> On Tue, Dec 1, 2009 at 2:39 PM, John Admanski <jadmanski@xxxxxxxxxx> wrote:
>> This looks good to me.
>>
>> -- John
>>
>> On Tue, Dec 1, 2009 at 2:37 PM, Lucas Meneghel Rodrigues <lmr@xxxxxxxxxx> wrote:
>>> When the client was made configurable through
>>> global_config.ini, the scenario "developer
>>> checking out client directory only" wasn't
>>> considered, and an exception will be thrown
>>> due to the lack of a global_config.ini present.
>>>
>>> In order to fix this, instead of throwing an
>>> exception, just print a warning on cases that
>>> matter, and make all the values that are
>>> supposed to be grabbed from the config file
>>> to have a sensible default.
>>>
>>> 2nd try: Now a warning is printed only when
>>> autotest is being run through autoserv, since
>>> it's probably the only case worth printing
>>> a warning.
>>>
>>> Signed-off-by: Lucas Meneghel Rodrigues <lmr@xxxxxxxxxx>
>>> ---
>>>  client/bin/autotest                   |    3 ++-
>>>  client/bin/harness_autoserv.py        |   15 ++++++++++++++-
>>>  client/bin/job.py                     |    2 +-
>>>  client/common_lib/global_config.py    |   17 ++++++++---------
>>>  client/common_lib/host_protections.py |    9 ++++-----
>>>  5 files changed, 29 insertions(+), 17 deletions(-)
>>>
>>> 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@xxxxxxxxxx (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()
>>> --
>>> 1.6.5.2
>>>
>>>
>> _______________________________________________
>> Autotest mailing list
>> Autotest@xxxxxxxxxxxxxxx
>> http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
>>
> _______________________________________________
> Autotest mailing list
> Autotest@xxxxxxxxxxxxxxx
> http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
>



-- 
Lucas
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux