better error messages on missing/malformed configs

This commit is contained in:
Clay Gerrard 2011-02-24 11:59:34 -06:00
parent 49ea0201f7
commit c1b3c8d799
2 changed files with 15 additions and 13 deletions

View File

@ -17,11 +17,11 @@ def get_config():
try:
config = readconf(config_file, 'func_test')
except SystemExit:
print >>sys.stderr, 'SKIPPING FUNCTIONAL TESTS DUE TO NO CONFIG'
print >>sys.stderr, 'UNABLE TO READ FUNCTIONAL TESTS CONFIG FILE'
except MissingSectionHeaderError:
# rather than mock the stream to spoof a section header, display an
# error to the user and let them fix it.
print >>sys.stderr, 'SKIPPING FUNCTIONAL TESTS DUE TO NO ' \
'[func_test] CONFIG SECTION'
print >>sys.stderr, 'UNABLE TO READ FUNCTIONAL TESTS CONFIG FILE ' \
'DUE TO NO [func_test] SECTION'
return config

View File

@ -11,22 +11,24 @@ from test import get_config
from swift.common.client import get_auth, http_connection
conf = get_config()
swift_test_auth = os.environ.get('SWIFT_TEST_AUTH')
swift_test_user = [os.environ.get('SWIFT_TEST_USER'), None, None]
swift_test_key = [os.environ.get('SWIFT_TEST_KEY'), None, None]
# If no environment set, fall back to old school conf file
if not all([swift_test_auth, swift_test_user[0], swift_test_key[0]]):
conf = get_config()
if not conf:
# If no conf was read, fall back to old school env
swift_test_auth = os.environ.get('SWIFT_TEST_AUTH')
swift_test_user = [os.environ.get('SWIFT_TEST_USER'), None, None]
swift_test_key = [os.environ.get('SWIFT_TEST_KEY'), None, None]
else:
swift_test_auth = 'http'
if conf.get('auth_ssl', 'no').lower() in ('yes', 'true', 'on', '1'):
swift_test_auth = 'https'
if 'auth_prefix' not in conf:
conf['auth_prefix'] = '/'
swift_test_auth += \
'://%(auth_host)s:%(auth_port)s%(auth_prefix)sv1.0' % conf
try:
swift_test_auth += \
'://%(auth_host)s:%(auth_port)s%(auth_prefix)sv1.0' % conf
except KeyError:
pass # skip
if 'account' in conf:
swift_test_user[0] = '%(account)s:%(username)s' % conf
else: