fix python tests depending on /etc/compass/seting file bug.
Change-Id: Ia9aff7654e5720942a78acc0334e782e5022b4da
This commit is contained in:
parent
2f5c551505
commit
f009619f9a
@ -1,10 +1,18 @@
|
||||
import simplejson as json
|
||||
from copy import deepcopy
|
||||
from celery import current_app
|
||||
|
||||
from mock import Mock
|
||||
import simplejson as json
|
||||
import os
|
||||
import unittest2
|
||||
|
||||
|
||||
os.environ['COMPASS_IGNORE_SETTING'] = 'true'
|
||||
|
||||
|
||||
from compass.utils import setting_wrapper as setting
|
||||
reload(setting)
|
||||
|
||||
|
||||
from compass.api import app
|
||||
from compass.db import database
|
||||
from compass.db.model import Switch
|
||||
@ -15,6 +23,8 @@ from compass.db.model import HostState
|
||||
from compass.db.model import Adapter
|
||||
from compass.db.model import Role
|
||||
from compass.db.model import SwitchConfig
|
||||
from compass.utils import flags
|
||||
from compass.utils import logsetting
|
||||
|
||||
|
||||
class ApiTestCase(unittest2.TestCase):
|
||||
@ -1120,4 +1130,6 @@ class TestAPIWorkFlow(ApiTestCase):
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
flags.init()
|
||||
logsetting.init()
|
||||
unittest2.main()
|
||||
|
@ -1,6 +1,17 @@
|
||||
import os
|
||||
import unittest2
|
||||
|
||||
|
||||
os.environ['COMPASS_IGNORE_SETTING'] = 'true'
|
||||
|
||||
|
||||
from compass.utils import setting_wrapper as setting
|
||||
reload(setting)
|
||||
|
||||
|
||||
from compass.config_management.installers import os_installer
|
||||
from compass.utils import flags
|
||||
from compass.utils import logsetting
|
||||
|
||||
|
||||
class DummyInstaller(os_installer.Installer):
|
||||
@ -40,4 +51,6 @@ class TestInstallerFunctions(unittest2.TestCase):
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
flags.init()
|
||||
logsetting.init()
|
||||
unittest2.main()
|
||||
|
@ -1,6 +1,17 @@
|
||||
import os
|
||||
import unittest2
|
||||
|
||||
|
||||
os.environ['COMPASS_IGNORE_SETTING'] = 'true'
|
||||
|
||||
|
||||
from compass.utils import setting_wrapper as setting
|
||||
reload(setting)
|
||||
|
||||
|
||||
from compass.config_management.installers import package_installer
|
||||
from compass.utils import flags
|
||||
from compass.utils import logsetting
|
||||
|
||||
|
||||
class DummyInstaller(package_installer.Installer):
|
||||
@ -42,4 +53,6 @@ class TestInstallerFunctions(unittest2.TestCase):
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
flags.init()
|
||||
logsetting.init()
|
||||
unittest2.main()
|
||||
|
@ -1,6 +1,17 @@
|
||||
import os
|
||||
import unittest2
|
||||
|
||||
|
||||
os.environ['COMPASS_IGNORE_SETTING'] = 'true'
|
||||
|
||||
|
||||
from compass.utils import setting_wrapper as setting
|
||||
reload(setting)
|
||||
|
||||
|
||||
from compass.config_management.providers import config_provider
|
||||
from compass.utils import flags
|
||||
from compass.utils import logsetting
|
||||
|
||||
|
||||
class DummyProvider(config_provider.ConfigProvider):
|
||||
@ -41,4 +52,6 @@ class TestProviderRegisterFunctions(unittest2.TestCase):
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
flags.init()
|
||||
logsetting.init()
|
||||
unittest2.main()
|
||||
|
@ -1,19 +0,0 @@
|
||||
PROVIDER_NAME = 'mix'
|
||||
GLOBAL_CONFIG_PROVIDER = 'file'
|
||||
CLUSTER_CONFIG_PROVIDER = 'db'
|
||||
HOST_CONFIG_PROVIDER = 'db'
|
||||
GLOBAL_CONFIG_FILENAME = 'global_config'
|
||||
CONFIG_FILE_FORMAT = 'python'
|
||||
SQLALCHEMY_DATABASE_URI = 'sqlite://'
|
||||
OS_INSTALLER = 'cobbler'
|
||||
COBBLER_INSTALLER_URL = 'http://localhost/cobbler_api'
|
||||
COBBLER_INSTALLER_TOKEN = ['cobbler', 'cobbler']
|
||||
PACKAGE_INSTALLER = 'chef'
|
||||
CHEF_INSTALLER_URL = 'https://localhost/'
|
||||
CHEF_GLOBAL_DATABAG_NAME = 'env_default'
|
||||
INSTALLATION_LOGDIR = '/var/log/cobbler/anamon'
|
||||
DEFAULT_LOGLEVEL = 'info'
|
||||
DEFAULT_LOGDIR = ''
|
||||
DEFAULT_LOGINTERVAL = 1
|
||||
DEFAULT_LOGINTERVAL_UNIT = 'h'
|
||||
DEFAULT_LOGFORMAT = '%(asctime)s - %(filename)s - %(lineno)d - %(levelname)s - %(message)s'
|
@ -9,12 +9,17 @@ import xmlrpclib
|
||||
from mock import Mock
|
||||
|
||||
|
||||
os.environ['COMPASS_SETTING'] = '%s/data/setting' % os.path.dirname(os.path.abspath(__file__))
|
||||
os.environ['COMPASS_IGNORE_SETTING'] = 'true'
|
||||
|
||||
|
||||
from compass.utils import setting_wrapper as setting
|
||||
reload(setting)
|
||||
|
||||
|
||||
setting.OS_INSTALLER = 'cobbler'
|
||||
setting.COBBLER_INSTALLER_URL = 'http://localhost/cobbler_api'
|
||||
setting.PACKAGE_INSTALLER = 'chef'
|
||||
setting.CHEF_INSTALLER_URL = 'https://localhost/'
|
||||
setting.CONFIG_DIR = '%s/data' % os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
|
||||
|
@ -1,5 +1,16 @@
|
||||
import os
|
||||
import unittest2
|
||||
|
||||
|
||||
os.environ['COMPASS_IGNORE_SETTING'] = 'true'
|
||||
|
||||
|
||||
from compass.utils import setting_wrapper as setting
|
||||
reload(setting)
|
||||
|
||||
|
||||
from compass.utils import flags
|
||||
from compass.utils import logsetting
|
||||
from compass.utils import util
|
||||
|
||||
|
||||
@ -125,4 +136,6 @@ class TestGetListWithPossibility(unittest2.TestCase):
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
flags.init()
|
||||
logsetting.init()
|
||||
unittest2.main()
|
||||
|
@ -5,10 +5,19 @@ import os.path
|
||||
from compass.utils import setting_wrapper as setting
|
||||
|
||||
|
||||
CELERY_RESULT_BACKEND = 'amqp://'
|
||||
|
||||
BROKER_URL = 'amqp://guest:guest@localhost:5672//'
|
||||
|
||||
CELERY_IMPORTS = ('compass.tasks.tasks',)
|
||||
|
||||
|
||||
if setting.CELERYCONFIG_FILE:
|
||||
CELERY_CONFIG = os.path.join(setting.CELERYCONFIG_DIR,
|
||||
setting.CELERYCONFIG_FILE)
|
||||
|
||||
try:
|
||||
logging.info('load celery config from %s', CELERY_CONFIG)
|
||||
execfile(CELERY_CONFIG, globals(), locals())
|
||||
except Exception as error:
|
||||
logging.exception(error)
|
||||
|
@ -3,13 +3,51 @@ import logging
|
||||
import os
|
||||
|
||||
|
||||
# default setting
|
||||
PROVIDER_NAME = 'mix'
|
||||
GLOBAL_CONFIG_PROVIDER = 'file'
|
||||
CLUSTER_CONFIG_PROVIDER = 'db'
|
||||
HOST_CONFIG_PROVIDER = 'db'
|
||||
CONFIG_DIR = '/etc/compass'
|
||||
GLOBAL_CONFIG_FILENAME = 'global_config'
|
||||
CONFIG_FILE_FORMAT = 'python'
|
||||
DATABASE_TYPE = 'file'
|
||||
DATABASE_FILE = ''
|
||||
SQLALCHEMY_DATABASE_URI = 'sqlite://'
|
||||
OS_INSTALLER = 'cobbler'
|
||||
COBBLER_INSTALLER_URL = ''
|
||||
COBBLER_INSTALLER_TOKEN = ['cobbler', 'cobbler']
|
||||
PACKAGE_INSTALLER = 'chef'
|
||||
CHEF_INSTALLER_URL = ''
|
||||
CHEF_GLOBAL_DATABAG_NAME = 'env_default'
|
||||
INSTALLATION_LOGDIR = ''
|
||||
DEFAULT_LOGLEVEL = 'info'
|
||||
DEFAULT_LOGDIR = ''
|
||||
DEFAULT_LOGINTERVAL = 1
|
||||
DEFAULT_LOGINTERVAL_UNIT = 'h'
|
||||
DEFAULT_LOGFORMAT = (
|
||||
'%(asctime)s - %(filename)s - %(lineno)d - %(levelname)s - %(message)s')
|
||||
WEB_LOGFILE = ''
|
||||
CELERY_LOGFILE = ''
|
||||
CELERYCONFIG_DIR = ''
|
||||
CELERYCONFIG_FILE = ''
|
||||
PROGRESS_UPDATE_INTERVAL = 30
|
||||
POLLSWITCH_INTERVAL = 60
|
||||
SWITCHES = [
|
||||
]
|
||||
|
||||
|
||||
if ('COMPASS_IGNORE_SETTING' in os.environ and
|
||||
os.environ['COMPASS_IGNORE_SETTING']):
|
||||
pass
|
||||
else:
|
||||
if 'COMPASS_SETTING' in os.environ:
|
||||
SETTING = os.environ['COMPASS_SETTING']
|
||||
else:
|
||||
SETTING = '/etc/compass/setting'
|
||||
|
||||
try:
|
||||
print 'load setting from %s' % SETTING
|
||||
logging.info('load setting from %s', SETTING)
|
||||
execfile(SETTING, globals(), locals())
|
||||
except Exception as error:
|
||||
logging.exception(error)
|
||||
|
@ -15,7 +15,7 @@ PACKAGE_INSTALLER = 'chef'
|
||||
CHEF_INSTALLER_URL = 'https://localhost'
|
||||
CHEF_GLOBAL_DATABAG_NAME = 'env_default'
|
||||
INSTALLATION_LOGDIR = '/var/log/cobbler/anamon'
|
||||
DEFAULT_LOGLEVEL = 'debug'
|
||||
DEFAULT_LOGLEVEL = 'info'
|
||||
DEFAULT_LOGDIR = '/var/log/compass'
|
||||
DEFAULT_LOGINTERVAL = 1
|
||||
DEFAULT_LOGINTERVAL_UNIT = 'h'
|
||||
|
Loading…
Reference in New Issue
Block a user