Fix autotest client when checking only client from svn
PATCH 1/1 Fix autotest client when checking only client from svn
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.
--- 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(-)
client/bin/autotest +2 -1
@@ -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)
client/bin/harness_autoserv.py +14 -1
@@ -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
client/bin/job.py +1 -1
@@ -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")
client/common_lib/global_config.py +8 -9
@@ -5,7 +5,7 @@ provides access to global configuration file __author__ = '[email protected] (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
client/common_lib/host_protections.py +4 -5
@@ -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()
Signature · 1 line
1.6.5.2
This looks good to me.
-- John
Quoted 156 lines · Lucas Meneghel Rodrigues
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 <[email protected]>---
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(-)client/bin/autotest +2
-1@@ -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)client/bin/harness_autoserv.py +1
-1@@ -1,5 +1,6 @@ -import os, logging +import os, logging, ConfigParserfrom autotest_lib.client.common_lib import autotemp,
base_packages, error +from autotest_lib.client.common_lib importglobal_config
from autotest_lib.client.bin import harnessclient/bin/harness_autoserv.py +12
-0@@ -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 fetchesclient/bin/job.py +0
-0@@ -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")client/common_lib/global_config.py +0
-0@@ -5,7 +5,7 @@ provides access to global configuration file__author__ = '[email protected] (Travis Miller)'
client/common_lib/global_config.py +1
-1-import os, sys, ConfigParser +import os, sys, ConfigParser, loggingfrom autotest_lib.client.common_lib import error
client/common_lib/global_config.py +0
-0@@ -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 = Trueclass
global_config(object):
_NO_DEFAULT_SPECIFIED=object()client/common_lib/global_config.py +0
-0@@ -145,10 +143,11 @@ class global_config(object):def
parse_config_file(self):
- if notos.path.exists(self.config_file):
- raiseConfigError('%s not found' % (self.config_file))self.config =ConfigParser.ConfigParser()
- self.config.read(self.config_file)
+ if self.config_file andos.path.exists(self.config_file):
+ self.config.read(self.config_file)
+ else:
+ raiseConfigError('%s not found' % (self.config_file))# now also read the shadow file if there is one # this will overwrite anything that is found in theclient/common_lib/host_protections.py +0
-0@@ -29,16 +29,15 @@ try:
default_protection=global_config.global_config.get_config_value( 'HOSTS', 'default_protection', default=_bad_value)ifdefault_protection==_bad_value:
- ifrunning_client:
- logging.debug('Client stand alone run detected. '
- 'host_protection.default will not be set.')
- else:
+ if notrunning_client:
raise global_config.ConfigError(
'No HOSTS.default_protection defined in global_config.ini') else:
default =Protection.get_value(default_protection)client/common_lib/host_protections.py +2
-0+# It is OK to have an empty global configuration object (stand alone client) +# so we trap this exception.except global_config.ConfigError:
- raiseglobal_config.ConfigError('No global_config.ini exists, aborting')
+ passchoices =
Protection.choices()
--
1.6.5.2
yup, seems important - lmr, do you want to go ahead and apply this? I'm stuck in a meeting for a while
Quoted 166 lines · John Admanski
This looks good to me.
-- John
Quoted 151 lines · Lucas Meneghel Rodrigues
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 <[email protected]>---
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(-)client/bin/autotest +2
-1@@ -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)client/bin/harness_autoserv.py +1
-1@@ -1,5 +1,6 @@ -import os, logging +import os, logging, ConfigParserfrom autotest_lib.client.common_lib import autotemp,
base_packages, error +from autotest_lib.client.common_lib importglobal_config
from autotest_lib.client.bin import harnessclient/bin/harness_autoserv.py +12
-0@@ -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 fetchesclient/bin/job.py +0
-0@@ -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")client/common_lib/global_config.py +0
-0@@ -5,7 +5,7 @@ provides access to global configuration file__author__ = '[email protected] (Travis Miller)'
client/common_lib/global_config.py +1
-1-import os, sys, ConfigParser +import os, sys, ConfigParser, loggingfrom autotest_lib.client.common_lib import error
client/common_lib/global_config.py +0
-0@@ -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 = Trueclass
global_config(object):
_NO_DEFAULT_SPECIFIED=object()client/common_lib/global_config.py +0
-0@@ -145,10 +143,11 @@ class global_config(object):def
parse_config_file(self):
- if notos.path.exists(self.config_file):
- raiseConfigError('%s not found' % (self.config_file))self.config =ConfigParser.ConfigParser()
- self.config.read(self.config_file)
+ if self.config_file andos.path.exists(self.config_file):
+ self.config.read(self.config_file)
+ else:
+ raiseConfigError('%s not found' % (self.config_file))# now also read the shadow file if there is one # this will overwrite anything that is found in theclient/common_lib/host_protections.py +0
-0@@ -29,16 +29,15 @@ try:
default_protection=global_config.global_config.get_config_value( 'HOSTS', 'default_protection', default=_bad_value)ifdefault_protection==_bad_value:
- ifrunning_client:
- logging.debug('Client stand alone run detected. '
- 'host_protection.default will not be set.')
- else:
+ if notrunning_client:
raise global_config.ConfigError(
'No HOSTS.default_protection defined in global_config.ini') else:
default =Protection.get_value(default_protection)client/common_lib/host_protections.py +2
-0+# It is OK to have an empty global configuration object (stand alone client) +# so we trap this exception.except global_config.ConfigError:
- raiseglobal_config.ConfigError('No global_config.ini exists, aborting')
+ passQuoted 5 lines
choices =
Protection.choices()
--
1.6.5.2_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
Quoted 2 lines · Martin Bligh
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
Quoted 172 lines · John Admanski
Quoted 156 lines
This looks good to me.
-- John
Quoted 151 lines · Lucas Meneghel Rodrigues
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 <[email protected]>---
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(-)client/bin/autotest +2
-1@@ -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)client/bin/harness_autoserv.py +1
-1@@ -1,5 +1,6 @@ -import os, logging +import os, logging, ConfigParserfrom autotest_lib.client.common_lib import autotemp,
base_packages, error +from autotest_lib.client.common_lib importglobal_config
from autotest_lib.client.bin import harnessclient/bin/harness_autoserv.py +12
-0@@ -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 fetchesclient/bin/job.py +0
-0@@ -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")client/common_lib/global_config.py +0
-0@@ -5,7 +5,7 @@ provides access to global configuration file__author__ = '[email protected] (Travis Miller)'
client/common_lib/global_config.py +1
-1-import os, sys, ConfigParser +import os, sys, ConfigParser, loggingfrom autotest_lib.client.common_lib import error
client/common_lib/global_config.py +0
-0@@ -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 = Trueclass
global_config(object):
_NO_DEFAULT_SPECIFIED=object()client/common_lib/global_config.py +0
-0@@ -145,10 +143,11 @@ class global_config(object):def
parse_config_file(self):
- if notos.path.exists(self.config_file):
- raiseConfigError('%s not found' % (self.config_file))self.config =ConfigParser.ConfigParser()
- self.config.read(self.config_file)
+ if self.config_file andos.path.exists(self.config_file):
+ self.config.read(self.config_file)
+ else:
+ raiseConfigError('%s not found' % (self.config_file))# now also read the shadow file if there is one # this will overwrite anything that is found in theclient/common_lib/host_protections.py +0
-0@@ -29,16 +29,15 @@ try:
default_protection=global_config.global_config.get_config_value( 'HOSTS', 'default_protection', default=_bad_value)ifdefault_protection==_bad_value:
- ifrunning_client:
- logging.debug('Client stand alone run detected. '
- 'host_protection.default will not be set.')
- else:
+ if notrunning_client:
raise global_config.ConfigError(
'No HOSTS.default_protection defined in global_config.ini') else:
default =Protection.get_value(default_protection)client/common_lib/host_protections.py +2
-0+# It is OK to have an empty global configuration object (stand alone client) +# so we trap this exception.except global_config.ConfigError:
- raiseglobal_config.ConfigError('No global_config.ini exists, aborting')
+ passQuoted 10 lines
Quoted 5 lines
choices =
Protection.choices()
--
1.6.5.2_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
Signature · 1 line
Lucas