fix test too many error messages.
Change-Id: Ib0438d4adf9ab1238be8b92bdd260770af2fcd22
This commit is contained in:
@@ -23,7 +23,7 @@ import time
|
|||||||
# from compass.apiclient.restful import Client
|
# from compass.apiclient.restful import Client
|
||||||
from restful import Client
|
from restful import Client
|
||||||
|
|
||||||
COMPASS_SERVER_URL = 'http://10.145.89.120/api'
|
COMPASS_SERVER_URL = 'http://10.145.89.100/api'
|
||||||
COMPASS_LOGIN_EMAIL = 'admin@huawei.com'
|
COMPASS_LOGIN_EMAIL = 'admin@huawei.com'
|
||||||
COMPASS_LOGIN_PASSWORD = 'admin'
|
COMPASS_LOGIN_PASSWORD = 'admin'
|
||||||
SWITCH_IP = '172.29.8.40'
|
SWITCH_IP = '172.29.8.40'
|
||||||
@@ -77,18 +77,19 @@ HOST_OS = 'CentOS-6.5-x86_64'
|
|||||||
|
|
||||||
LANGUAGE = 'EN'
|
LANGUAGE = 'EN'
|
||||||
TIMEZONE = 'GMT -7:00'
|
TIMEZONE = 'GMT -7:00'
|
||||||
HTTPS_PROXY = 'https://10.145.88.211:3128'
|
HTTPS_PROXY = 'https://10.145.89.100:3128'
|
||||||
NO_PROXY = ['127.0.0.1']
|
NO_PROXY = ['127.0.0.1']
|
||||||
DNS_SERVER = '10.145.88.211'
|
DNS_SERVER = '10.145.89.100'
|
||||||
DOMAIN = 'ods.com'
|
DOMAIN = 'ods.com'
|
||||||
|
|
||||||
PRESET_VALUES = {
|
PRESET_VALUES = {
|
||||||
'NAMESERVERS': ['10.145.88.211'],
|
'NAMESERVERS': ['10.145.89.100'],
|
||||||
'NTP_SERVER': '10.145.88.211',
|
'NTP_SERVER': '10.145.89.100',
|
||||||
'GATEWAY': '10.145.88.211',
|
'GATEWAY': '10.145.88.1',
|
||||||
'PROXY': 'http://10.145.88.211:3128',
|
'PROXY': 'http://10.145.89.100:3128',
|
||||||
'ROLES_LIST': ['allinone'],
|
'FLAVOR': 'allinone',
|
||||||
'MACHINES_TO_ADD': ['00:0c:29:05:bd:eb'],
|
'ROLES_LIST': ['allinone-compute'],
|
||||||
|
'MACHINES_TO_ADD': ['00:0c:29:a7:ea:4b'],
|
||||||
'BUILD_TIMEOUT': 60
|
'BUILD_TIMEOUT': 60
|
||||||
}
|
}
|
||||||
for v in PRESET_VALUES:
|
for v in PRESET_VALUES:
|
||||||
@@ -194,7 +195,6 @@ for supported_os in supported_oses:
|
|||||||
print '===================================='
|
print '===================================='
|
||||||
print 'use %s as host os, the os_id is %s' % (os_name, os_id)
|
print 'use %s as host os, the os_id is %s' % (os_name, os_id)
|
||||||
|
|
||||||
"""
|
|
||||||
# get flavor_id
|
# get flavor_id
|
||||||
flavor_id = None
|
flavor_id = None
|
||||||
flavors = adapter['flavors']
|
flavors = adapter['flavors']
|
||||||
@@ -202,28 +202,27 @@ print '=============================='
|
|||||||
print 'all flavors are: %s' % flavors
|
print 'all flavors are: %s' % flavors
|
||||||
|
|
||||||
for flavor in flavors:
|
for flavor in flavors:
|
||||||
if flavor['name'] == PRESET_VALUES['ROLES_LIST']:
|
if flavor['name'] == PRESET_VALUES['FLAVOR']:
|
||||||
flavor_id = flavor['id']
|
flavor_id = flavor['id']
|
||||||
break
|
break
|
||||||
|
|
||||||
print '===================================='
|
print '===================================='
|
||||||
print 'cluster info: adapter_id: %s, os_id: %s, flavor_id: %s' %
|
print 'cluster info: adapter_id: %s, os_id: %s, flavor_id: %s' % (
|
||||||
(adapter_id, os_id, flavor_id)
|
adapter_id, os_id, flavor_id)
|
||||||
"""
|
|
||||||
|
|
||||||
# add a cluster
|
# add a cluster
|
||||||
status, response = client.add_cluster(
|
status, response = client.add_cluster(
|
||||||
CLUSTER_NAME,
|
CLUSTER_NAME,
|
||||||
adapter_id,
|
adapter_id,
|
||||||
os_id,
|
os_id,
|
||||||
#flavor_id
|
flavor_id
|
||||||
)
|
)
|
||||||
|
print 'add cluster %s status %s: %s' % (CLUSTER_NAME, status, response)
|
||||||
if status < 400:
|
if status < 400:
|
||||||
print 'add cluster %s: %s' % (CLUSTER_NAME, response)
|
|
||||||
cluster = response
|
cluster = response
|
||||||
else:
|
else:
|
||||||
status, response = client.list_clusters(name=CLUSTER_NAME)
|
status, response = client.list_clusters(name=CLUSTER_NAME)
|
||||||
print response
|
print 'list clusters status %s: %s' % (status, response)
|
||||||
cluster = response[0]
|
cluster = response[0]
|
||||||
print 'cluster already exists, fetching it'
|
print 'cluster already exists, fetching it'
|
||||||
cluster_id = cluster['id']
|
cluster_id = cluster['id']
|
||||||
@@ -383,10 +382,12 @@ print '======================================='
|
|||||||
print 'cluster %s has been updated to: %s' % (cluster_id, response)
|
print 'cluster %s has been updated to: %s' % (cluster_id, response)
|
||||||
|
|
||||||
# Review and deploy
|
# Review and deploy
|
||||||
status, response = client.review_cluster(cluster_id)
|
status, response = client.review_cluster(
|
||||||
|
cluster_id, review={'hosts': [host_id]})
|
||||||
print '======================================='
|
print '======================================='
|
||||||
print 'reviewing cluster: %s' % response
|
print 'reviewing cluster status %s: %s' % (status, response)
|
||||||
|
|
||||||
status, response = client.deploy_cluster(cluster_id)
|
status, response = client.deploy_cluster(
|
||||||
|
cluster_id, deploy={'hosts': [host_id]})
|
||||||
print '======================================='
|
print '======================================='
|
||||||
print 'deploy cluster %s' % response
|
print 'deploy cluster status %s: %s' % (status, response)
|
||||||
|
@@ -555,12 +555,12 @@ class Client(object):
|
|||||||
return self._get('/clusters/%s' % cluster_id)
|
return self._get('/clusters/%s' % cluster_id)
|
||||||
|
|
||||||
def add_cluster(self, name, adapter_id, os_id,
|
def add_cluster(self, name, adapter_id, os_id,
|
||||||
flavor_id=None, raw_data=None):
|
flavor_id, raw_data=None):
|
||||||
data = {}
|
data = {}
|
||||||
if raw_data:
|
if raw_data:
|
||||||
data = raw_data
|
data = raw_data
|
||||||
else:
|
else:
|
||||||
#data['flavor_id'] = flavor_id
|
data['flavor_id'] = flavor_id
|
||||||
data['name'] = name
|
data['name'] = name
|
||||||
data['adapter_id'] = adapter_id
|
data['adapter_id'] = adapter_id
|
||||||
data['os_id'] = os_id
|
data['os_id'] = os_id
|
||||||
@@ -569,7 +569,7 @@ class Client(object):
|
|||||||
|
|
||||||
def update_cluster(self, cluster_id, name=None,
|
def update_cluster(self, cluster_id, name=None,
|
||||||
reinstall_distributed_system=None,
|
reinstall_distributed_system=None,
|
||||||
flavor=None, raw_data=None):
|
raw_data=None):
|
||||||
data = {}
|
data = {}
|
||||||
if raw_data:
|
if raw_data:
|
||||||
data = raw_data
|
data = raw_data
|
||||||
@@ -581,10 +581,6 @@ class Client(object):
|
|||||||
data['reinstall_distributed_system'] = (
|
data['reinstall_distributed_system'] = (
|
||||||
reinstall_distributed_system
|
reinstall_distributed_system
|
||||||
)
|
)
|
||||||
|
|
||||||
if flavor:
|
|
||||||
data['flavor'] = flavor
|
|
||||||
|
|
||||||
return self._put('/clusters/%s' % cluster_id, data=data)
|
return self._put('/clusters/%s' % cluster_id, data=data)
|
||||||
|
|
||||||
def delete_cluster(self, cluster_id):
|
def delete_cluster(self, cluster_id):
|
||||||
@@ -654,16 +650,12 @@ class Client(object):
|
|||||||
def review_cluster(self, cluster_id, review={}):
|
def review_cluster(self, cluster_id, review={}):
|
||||||
data = {}
|
data = {}
|
||||||
data['review'] = review
|
data['review'] = review
|
||||||
|
|
||||||
return self._post('/clusters/%s/action' % cluster_id, data=data)
|
return self._post('/clusters/%s/action' % cluster_id, data=data)
|
||||||
|
|
||||||
def deploy_cluster(self, cluster_id, deploy={}):
|
def deploy_cluster(self, cluster_id, deploy={}):
|
||||||
data = {}
|
data = {}
|
||||||
if deploy:
|
data['deploy'] = deploy
|
||||||
data['deploy'] = deploy
|
|
||||||
|
|
||||||
return self._post('/clusters/%s/action' % cluster_id, data=data)
|
return self._post('/clusters/%s/action' % cluster_id, data=data)
|
||||||
## end
|
|
||||||
|
|
||||||
def get_cluster_state(self, cluster_id):
|
def get_cluster_state(self, cluster_id):
|
||||||
return self._get('/clusters/%s/state' % cluster_id)
|
return self._get('/clusters/%s/state' % cluster_id)
|
||||||
|
@@ -483,10 +483,10 @@ def add_clusterhost_internal(
|
|||||||
host_by_name = utils.get_db_object(
|
host_by_name = utils.get_db_object(
|
||||||
session, models.Host, False, name=hostname
|
session, models.Host, False, name=hostname
|
||||||
)
|
)
|
||||||
if host_by_name:
|
if host_by_name and host_by_name.id != host.id:
|
||||||
raise exception.InvalidParameter(
|
raise exception.InvalidParameter(
|
||||||
'host name %s exists in host %s' % (
|
'host name %s exists in host %s' % (
|
||||||
hostname, host_by_name
|
hostname, host_by_name.to_dict()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
utils.update_db_object(
|
utils.update_db_object(
|
||||||
@@ -501,10 +501,10 @@ def add_clusterhost_internal(
|
|||||||
host = utils.get_db_object(
|
host = utils.get_db_object(
|
||||||
session, models.Host, False, name=hostname
|
session, models.Host, False, name=hostname
|
||||||
)
|
)
|
||||||
if host:
|
if host and host.machine_id != machine_id:
|
||||||
raise exception.InvalidParameter(
|
raise exception.InvalidParameter(
|
||||||
'host name %s exists in host %s' % (
|
'host name %s exists in host %s' % (
|
||||||
hostname, host
|
hostname, host.to_dict()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
host = utils.add_db_object(
|
host = utils.add_db_object(
|
||||||
|
@@ -274,7 +274,7 @@ def _update_host(session, updater, host_id, **kwargs):
|
|||||||
if host_by_name and host_by_name.id != host.id:
|
if host_by_name and host_by_name.id != host.id:
|
||||||
raise exception.InvalidParameter(
|
raise exception.InvalidParameter(
|
||||||
'hostname %s is already exists in host %s' % (
|
'hostname %s is already exists in host %s' % (
|
||||||
hostname, host_by_name
|
hostname, host_by_name.to_dict()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return utils.update_db_object(session, host, **kwargs)
|
return utils.update_db_object(session, host, **kwargs)
|
||||||
@@ -527,10 +527,15 @@ def _add_host_network(
|
|||||||
session, models.HostNetwork, False,
|
session, models.HostNetwork, False,
|
||||||
ip_int=ip_int
|
ip_int=ip_int
|
||||||
)
|
)
|
||||||
if host_network:
|
if (
|
||||||
|
host_network and not (
|
||||||
|
host_network.host_id == host_id and
|
||||||
|
host_network.interface == interface
|
||||||
|
)
|
||||||
|
):
|
||||||
raise exception.InvalidParameter(
|
raise exception.InvalidParameter(
|
||||||
'ip %s exists in host network %s' % (
|
'ip %s exists in host network %s' % (
|
||||||
ip, host_network
|
ip, host_network.to_dict()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
is_host_editable(session, host, creator)
|
is_host_editable(session, host, creator)
|
||||||
@@ -595,6 +600,30 @@ def add_host_networks(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@user_api.check_user_permission_in_session(
|
||||||
|
permission.PERMISSION_ADD_HOST_NETWORK
|
||||||
|
)
|
||||||
|
@utils.wrap_to_dict(RESP_NETWORK_FIELDS)
|
||||||
|
def _update_host_network(
|
||||||
|
session, updater, host_network, **kwargs
|
||||||
|
):
|
||||||
|
if 'ip' in kwargs:
|
||||||
|
ip = kwargs['ip']
|
||||||
|
ip_int = long(netaddr.IPAddress(ip))
|
||||||
|
host_network_by_ip = utils.get_db_object(
|
||||||
|
session, models.HostNetwork, False,
|
||||||
|
ip_int=ip_int
|
||||||
|
)
|
||||||
|
if host_network_by_ip and host_network_by_ip.id != host_network.id:
|
||||||
|
raise exception.InvalidParameter(
|
||||||
|
'ip %s exist in host network %s' % (
|
||||||
|
ip, host_network_by_ip.to_dict()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
is_host_editable(session, host_network.host, updater)
|
||||||
|
return utils.update_db_object(session, host_network, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
@utils.supported_filters(
|
@utils.supported_filters(
|
||||||
optional_support_keys=UPDATED_NETWORK_FIELDS,
|
optional_support_keys=UPDATED_NETWORK_FIELDS,
|
||||||
ignore_support_keys=IGNORED_NETWORK_FIELDS
|
ignore_support_keys=IGNORED_NETWORK_FIELDS
|
||||||
@@ -603,10 +632,6 @@ def add_host_networks(
|
|||||||
ip=utils.check_ip
|
ip=utils.check_ip
|
||||||
)
|
)
|
||||||
@database.run_in_session()
|
@database.run_in_session()
|
||||||
@user_api.check_user_permission_in_session(
|
|
||||||
permission.PERMISSION_ADD_HOST_NETWORK
|
|
||||||
)
|
|
||||||
@utils.wrap_to_dict(RESP_NETWORK_FIELDS)
|
|
||||||
def update_host_network(
|
def update_host_network(
|
||||||
session, updater, host_id, host_network_id, **kwargs
|
session, updater, host_id, host_network_id, **kwargs
|
||||||
):
|
):
|
||||||
@@ -621,26 +646,9 @@ def update_host_network(
|
|||||||
host_id, host_network_id
|
host_id, host_network_id
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
if 'ip' in kwargs:
|
return _update_host_network(
|
||||||
ip = kwargs['ip']
|
session, updater, host_network, **kwargs
|
||||||
ip_int = long(netaddr.IPAddress(ip))
|
)
|
||||||
host_network_by_ip = utils.get_db_object(
|
|
||||||
session, models.HostNetwork, False,
|
|
||||||
ip_int=ip_int
|
|
||||||
)
|
|
||||||
if host_network_by_ip and host_network_by_ip.id != host_network.id:
|
|
||||||
raise exception.InvalidParameter(
|
|
||||||
'ip %s exist in host network %s' % (
|
|
||||||
ip, host_network_by_ip
|
|
||||||
)
|
|
||||||
)
|
|
||||||
if host_network:
|
|
||||||
raise exception.InvalidParameter(
|
|
||||||
'ip %s exists in database' % ip
|
|
||||||
)
|
|
||||||
|
|
||||||
is_host_editable(session, host_network.host, updater)
|
|
||||||
return utils.update_db_object(session, host_network, **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
@utils.supported_filters(
|
@utils.supported_filters(
|
||||||
@@ -651,17 +659,14 @@ def update_host_network(
|
|||||||
ip=utils.check_ip
|
ip=utils.check_ip
|
||||||
)
|
)
|
||||||
@database.run_in_session()
|
@database.run_in_session()
|
||||||
@user_api.check_user_permission_in_session(
|
|
||||||
permission.PERMISSION_ADD_HOST_NETWORK
|
|
||||||
)
|
|
||||||
@utils.wrap_to_dict(RESP_NETWORK_FIELDS)
|
|
||||||
def update_hostnetwork(session, updater, host_network_id, **kwargs):
|
def update_hostnetwork(session, updater, host_network_id, **kwargs):
|
||||||
"""Update a host network."""
|
"""Update a host network."""
|
||||||
host_network = utils.get_db_object(
|
host_network = utils.get_db_object(
|
||||||
session, models.HostNetwork, id=host_network_id
|
session, models.HostNetwork, id=host_network_id
|
||||||
)
|
)
|
||||||
is_host_editable(session, host_network.host, updater)
|
return _update_host_network(
|
||||||
return utils.update_db_object(session, host_network, **kwargs)
|
session, updater, host_network, **kwargs
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@utils.supported_filters([])
|
@utils.supported_filters([])
|
||||||
|
@@ -1088,8 +1088,12 @@ class Cluster(BASE, TimestampMixin, HelperMixin):
|
|||||||
adapter = self.adapter
|
adapter = self.adapter
|
||||||
if adapter:
|
if adapter:
|
||||||
self.adapter_name = adapter.name
|
self.adapter_name = adapter.name
|
||||||
self.distributed_system = adapter.adapter_distributed_system
|
distributed_system = adapter.adapter_distributed_system
|
||||||
self.distributed_system_name = self.distributed_system.name
|
self.distributed_system = distributed_system
|
||||||
|
if distributed_system:
|
||||||
|
self.distributed_system_name = distributed_system.name
|
||||||
|
else:
|
||||||
|
self.distributed_system_name = None
|
||||||
flavor = self.flavor
|
flavor = self.flavor
|
||||||
if flavor:
|
if flavor:
|
||||||
self.flavor_name = flavor.name
|
self.flavor_name = flavor.name
|
||||||
|
@@ -18,6 +18,14 @@ import logging
|
|||||||
import os
|
import os
|
||||||
import unittest2
|
import unittest2
|
||||||
|
|
||||||
|
|
||||||
|
os.environ['COMPASS_IGNORE_SETTING'] = 'true'
|
||||||
|
|
||||||
|
|
||||||
|
from compass.utils import setting_wrapper as setting
|
||||||
|
reload(setting)
|
||||||
|
|
||||||
|
|
||||||
from compass.db.api import adapter_holder as adapter_api
|
from compass.db.api import adapter_holder as adapter_api
|
||||||
from compass.db.api import database
|
from compass.db.api import database
|
||||||
from compass.db.api import metadata_holder as metadata_api
|
from compass.db.api import metadata_holder as metadata_api
|
||||||
@@ -26,12 +34,6 @@ from compass.db.api import user as user_api
|
|||||||
from compass.db import exception
|
from compass.db import exception
|
||||||
from compass.utils import flags
|
from compass.utils import flags
|
||||||
from compass.utils import logsetting
|
from compass.utils import logsetting
|
||||||
from compass.utils import setting_wrapper as setting
|
|
||||||
|
|
||||||
os.environ['COMPASS_IGNORE_SETTING'] = 'true'
|
|
||||||
|
|
||||||
|
|
||||||
reload(setting)
|
|
||||||
|
|
||||||
|
|
||||||
class BaseTest(unittest2.TestCase):
|
class BaseTest(unittest2.TestCase):
|
||||||
|
@@ -17,6 +17,13 @@ import logging
|
|||||||
import os
|
import os
|
||||||
import unittest2
|
import unittest2
|
||||||
|
|
||||||
|
os.environ['COMPASS_IGNORE_SETTING'] = 'true'
|
||||||
|
|
||||||
|
|
||||||
|
from compass.utils import setting_wrapper as setting
|
||||||
|
reload(setting)
|
||||||
|
|
||||||
|
|
||||||
from base import BaseTest
|
from base import BaseTest
|
||||||
from compass.db.api import database
|
from compass.db.api import database
|
||||||
from compass.db.api import machine
|
from compass.db.api import machine
|
||||||
@@ -25,9 +32,6 @@ from compass.db.api import user as user_api
|
|||||||
from compass.db import exception
|
from compass.db import exception
|
||||||
from compass.utils import flags
|
from compass.utils import flags
|
||||||
from compass.utils import logsetting
|
from compass.utils import logsetting
|
||||||
from compass.utils import setting_wrapper as setting
|
|
||||||
|
|
||||||
os.environ['COMPASS_IGNORE_SETTING'] = 'true'
|
|
||||||
|
|
||||||
|
|
||||||
class TestGetMachine(BaseTest):
|
class TestGetMachine(BaseTest):
|
||||||
|
@@ -18,6 +18,14 @@ import logging
|
|||||||
import os
|
import os
|
||||||
import unittest2
|
import unittest2
|
||||||
|
|
||||||
|
|
||||||
|
os.environ['COMPASS_IGNORE_SETTING'] = 'true'
|
||||||
|
|
||||||
|
|
||||||
|
from compass.utils import setting_wrapper as setting
|
||||||
|
reload(setting)
|
||||||
|
|
||||||
|
|
||||||
from base import BaseTest
|
from base import BaseTest
|
||||||
from compass.db.api import adapter_holder as adapter
|
from compass.db.api import adapter_holder as adapter
|
||||||
from compass.db.api import database
|
from compass.db.api import database
|
||||||
@@ -26,10 +34,6 @@ from compass.db.api import user as user_api
|
|||||||
from compass.db import exception
|
from compass.db import exception
|
||||||
from compass.utils import flags
|
from compass.utils import flags
|
||||||
from compass.utils import logsetting
|
from compass.utils import logsetting
|
||||||
from compass.utils import setting_wrapper as setting
|
|
||||||
|
|
||||||
|
|
||||||
os.environ['COMPASS_IGNORE_SETTING'] = 'true'
|
|
||||||
|
|
||||||
|
|
||||||
class TestGetPackageMetadata(BaseTest):
|
class TestGetPackageMetadata(BaseTest):
|
||||||
|
@@ -18,6 +18,14 @@ import logging
|
|||||||
import os
|
import os
|
||||||
import unittest2
|
import unittest2
|
||||||
|
|
||||||
|
|
||||||
|
os.environ['COMPASS_IGNORE_SETTING'] = 'true'
|
||||||
|
|
||||||
|
|
||||||
|
from compass.utils import setting_wrapper as setting
|
||||||
|
reload(setting)
|
||||||
|
|
||||||
|
|
||||||
from base import BaseTest
|
from base import BaseTest
|
||||||
from compass.db.api import database
|
from compass.db.api import database
|
||||||
from compass.db.api import network
|
from compass.db.api import network
|
||||||
@@ -25,12 +33,6 @@ from compass.db.api import user as user_api
|
|||||||
from compass.db import exception
|
from compass.db import exception
|
||||||
from compass.utils import flags
|
from compass.utils import flags
|
||||||
from compass.utils import logsetting
|
from compass.utils import logsetting
|
||||||
from compass.utils import setting_wrapper as setting
|
|
||||||
|
|
||||||
reload(setting)
|
|
||||||
|
|
||||||
|
|
||||||
os.environ['COMPASS_IGNORE_SETTING'] = 'true'
|
|
||||||
|
|
||||||
|
|
||||||
class TestListSubnets(BaseTest):
|
class TestListSubnets(BaseTest):
|
||||||
|
@@ -17,6 +17,14 @@ import logging
|
|||||||
import os
|
import os
|
||||||
import unittest2
|
import unittest2
|
||||||
|
|
||||||
|
|
||||||
|
os.environ['COMPASS_IGNORE_SETTING'] = 'true'
|
||||||
|
|
||||||
|
|
||||||
|
from compass.utils import setting_wrapper as setting
|
||||||
|
reload(setting)
|
||||||
|
|
||||||
|
|
||||||
from base import BaseTest
|
from base import BaseTest
|
||||||
from compass.db.api import database
|
from compass.db.api import database
|
||||||
from compass.db.api import permission
|
from compass.db.api import permission
|
||||||
@@ -24,10 +32,6 @@ from compass.db.api import user as user_api
|
|||||||
from compass.db import exception
|
from compass.db import exception
|
||||||
from compass.utils import flags
|
from compass.utils import flags
|
||||||
from compass.utils import logsetting
|
from compass.utils import logsetting
|
||||||
from compass.utils import setting_wrapper as setting
|
|
||||||
|
|
||||||
os.environ['COMPASS_IGNORE_SETTING'] = 'true'
|
|
||||||
reload(setting)
|
|
||||||
|
|
||||||
|
|
||||||
class TestListPermissions(BaseTest):
|
class TestListPermissions(BaseTest):
|
||||||
|
@@ -18,6 +18,14 @@ import logging
|
|||||||
import os
|
import os
|
||||||
import unittest2
|
import unittest2
|
||||||
|
|
||||||
|
|
||||||
|
os.environ['COMPASS_IGNORE_SETTING'] = 'true'
|
||||||
|
|
||||||
|
|
||||||
|
from compass.utils import setting_wrapper as setting
|
||||||
|
reload(setting)
|
||||||
|
|
||||||
|
|
||||||
from base import BaseTest
|
from base import BaseTest
|
||||||
from compass.db.api import database
|
from compass.db.api import database
|
||||||
from compass.db.api import switch
|
from compass.db.api import switch
|
||||||
@@ -25,13 +33,6 @@ from compass.db.api import user as user_api
|
|||||||
from compass.db import exception
|
from compass.db import exception
|
||||||
from compass.utils import flags
|
from compass.utils import flags
|
||||||
from compass.utils import logsetting
|
from compass.utils import logsetting
|
||||||
from compass.utils import setting_wrapper as setting
|
|
||||||
|
|
||||||
|
|
||||||
os.environ['COMPASS_IGNORE_SETTING'] = 'true'
|
|
||||||
|
|
||||||
|
|
||||||
reload(setting)
|
|
||||||
|
|
||||||
|
|
||||||
class TestGetSwitch(BaseTest):
|
class TestGetSwitch(BaseTest):
|
||||||
|
@@ -17,15 +17,20 @@ import logging
|
|||||||
import os
|
import os
|
||||||
import unittest2
|
import unittest2
|
||||||
|
|
||||||
|
|
||||||
|
os.environ['COMPASS_IGNORE_SETTING'] = 'true'
|
||||||
|
|
||||||
|
|
||||||
|
from compass.utils import setting_wrapper as setting
|
||||||
|
reload(setting)
|
||||||
|
|
||||||
|
|
||||||
from base import BaseTest
|
from base import BaseTest
|
||||||
from compass.db.api import database
|
from compass.db.api import database
|
||||||
from compass.db.api import user as user_api
|
from compass.db.api import user as user_api
|
||||||
from compass.db import exception
|
from compass.db import exception
|
||||||
from compass.utils import flags
|
from compass.utils import flags
|
||||||
from compass.utils import logsetting
|
from compass.utils import logsetting
|
||||||
from compass.utils import setting_wrapper as setting
|
|
||||||
os.environ['COMPASS_IGNORE_SETTING'] = 'true'
|
|
||||||
reload(setting)
|
|
||||||
|
|
||||||
|
|
||||||
class TestGetUserObject(unittest2.TestCase):
|
class TestGetUserObject(unittest2.TestCase):
|
||||||
|
@@ -17,14 +17,15 @@ import logging
|
|||||||
import os
|
import os
|
||||||
import unittest2
|
import unittest2
|
||||||
|
|
||||||
|
|
||||||
os.environ['COMPASS_IGNORE_SETTING'] = 'true'
|
os.environ['COMPASS_IGNORE_SETTING'] = 'true'
|
||||||
|
|
||||||
|
|
||||||
from base import BaseTest
|
|
||||||
from compass.utils import setting_wrapper as setting
|
from compass.utils import setting_wrapper as setting
|
||||||
reload(setting)
|
reload(setting)
|
||||||
|
|
||||||
|
|
||||||
|
from base import BaseTest
|
||||||
from compass.db.api import database
|
from compass.db.api import database
|
||||||
from compass.db.api import user as user_api
|
from compass.db.api import user as user_api
|
||||||
from compass.db.api import user_log
|
from compass.db.api import user_log
|
||||||
|
@@ -180,8 +180,8 @@ class TestModelFilter(unittest2.TestCase):
|
|||||||
49,
|
49,
|
||||||
id=49
|
id=49
|
||||||
)
|
)
|
||||||
print 'expected: %s' % expected
|
logging.debug('expected: %s', expected)
|
||||||
print 'ret: %s' % ret
|
logging.debug('ret: %s', ret)
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
all(item in ret[0].items() for item in expected.items())
|
all(item in ret[0].items() for item in expected.items())
|
||||||
)
|
)
|
||||||
|
@@ -12,7 +12,7 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
import datetime
|
||||||
import os
|
import os
|
||||||
import unittest2
|
import unittest2
|
||||||
|
|
||||||
@@ -28,8 +28,6 @@ from compass.utils import flags
|
|||||||
from compass.utils import logsetting
|
from compass.utils import logsetting
|
||||||
from compass.utils import util
|
from compass.utils import util
|
||||||
|
|
||||||
import datetime
|
|
||||||
|
|
||||||
|
|
||||||
class TestParseDatetime(unittest2.TestCase):
|
class TestParseDatetime(unittest2.TestCase):
|
||||||
"""Test parse datetime."""
|
"""Test parse datetime."""
|
||||||
@@ -312,6 +310,7 @@ class TestLoadConfigs(unittest2.TestCase):
|
|||||||
loaded = util.load_configs(err_dir)
|
loaded = util.load_configs(err_dir)
|
||||||
self.assertEqual([], loaded)
|
self.assertEqual([], loaded)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
flags.init()
|
flags.init()
|
||||||
logsetting.init()
|
logsetting.init()
|
||||||
|
@@ -52,6 +52,9 @@ LOGLEVEL_MAPPING = {
|
|||||||
'critical': logging.CRITICAL,
|
'critical': logging.CRITICAL,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# disable logging when logsetting.init not called
|
||||||
|
logging.getLogger().setLevel(logging.CRITICAL)
|
||||||
|
|
||||||
|
|
||||||
def init():
|
def init():
|
||||||
"""Init loggsetting. It should be called after flags.init."""
|
"""Init loggsetting. It should be called after flags.init."""
|
||||||
|
Reference in New Issue
Block a user