minor polling cleaning
- remove custom Sample object from test - remove mock of threadgroup that does not exist. Change-Id: I1a55df5533b978c4c56dee37502fdb9f961cf91d
This commit is contained in:
parent
2455ddda1e
commit
fcf78b1e96
@ -144,6 +144,14 @@ class Sample(object):
|
|||||||
def get_iso_timestamp(self):
|
def get_iso_timestamp(self):
|
||||||
return timeutils.parse_isotime(self.timestamp)
|
return timeutils.parse_isotime(self.timestamp)
|
||||||
|
|
||||||
|
def __eq__(self, other):
|
||||||
|
if isinstance(other, self.__class__):
|
||||||
|
return self.__dict__ == other.__dict__
|
||||||
|
return False
|
||||||
|
|
||||||
|
def __ne__(self, other):
|
||||||
|
return not self.__eq__(other)
|
||||||
|
|
||||||
|
|
||||||
def setup(conf):
|
def setup(conf):
|
||||||
# NOTE(sileht): Instead of passing the cfg.CONF everywhere in ceilometer
|
# NOTE(sileht): Instead of passing the cfg.CONF everywhere in ceilometer
|
||||||
|
@ -31,24 +31,7 @@ from ceilometer import service
|
|||||||
from ceilometer.tests import base
|
from ceilometer.tests import base
|
||||||
|
|
||||||
|
|
||||||
class TestSample(sample.Sample):
|
default_test_data = sample.Sample(
|
||||||
def __init__(self, name, type, unit, volume, user_id, project_id,
|
|
||||||
resource_id, timestamp=None, resource_metadata=None,
|
|
||||||
source=None):
|
|
||||||
super(TestSample, self).__init__(name, type, unit, volume, user_id,
|
|
||||||
project_id, resource_id, timestamp,
|
|
||||||
resource_metadata, source)
|
|
||||||
|
|
||||||
def __eq__(self, other):
|
|
||||||
if isinstance(other, self.__class__):
|
|
||||||
return self.__dict__ == other.__dict__
|
|
||||||
return False
|
|
||||||
|
|
||||||
def __ne__(self, other):
|
|
||||||
return not self.__eq__(other)
|
|
||||||
|
|
||||||
|
|
||||||
default_test_data = TestSample(
|
|
||||||
name='test',
|
name='test',
|
||||||
type=sample.TYPE_CUMULATIVE,
|
type=sample.TYPE_CUMULATIVE,
|
||||||
unit='',
|
unit='',
|
||||||
@ -134,7 +117,7 @@ class BaseAgentManagerTestCase(base.BaseTestCase):
|
|||||||
class PollsterAnother(TestPollster):
|
class PollsterAnother(TestPollster):
|
||||||
samples = []
|
samples = []
|
||||||
resources = []
|
resources = []
|
||||||
test_data = TestSample(
|
test_data = sample.Sample(
|
||||||
name='testanother',
|
name='testanother',
|
||||||
type=default_test_data.type,
|
type=default_test_data.type,
|
||||||
unit=default_test_data.unit,
|
unit=default_test_data.unit,
|
||||||
@ -148,7 +131,7 @@ class BaseAgentManagerTestCase(base.BaseTestCase):
|
|||||||
class PollsterException(TestPollsterException):
|
class PollsterException(TestPollsterException):
|
||||||
samples = []
|
samples = []
|
||||||
resources = []
|
resources = []
|
||||||
test_data = TestSample(
|
test_data = sample.Sample(
|
||||||
name='testexception',
|
name='testexception',
|
||||||
type=default_test_data.type,
|
type=default_test_data.type,
|
||||||
unit=default_test_data.unit,
|
unit=default_test_data.unit,
|
||||||
@ -162,7 +145,7 @@ class BaseAgentManagerTestCase(base.BaseTestCase):
|
|||||||
class PollsterExceptionAnother(TestPollsterException):
|
class PollsterExceptionAnother(TestPollsterException):
|
||||||
samples = []
|
samples = []
|
||||||
resources = []
|
resources = []
|
||||||
test_data = TestSample(
|
test_data = sample.Sample(
|
||||||
name='testexceptionanother',
|
name='testexceptionanother',
|
||||||
type=default_test_data.type,
|
type=default_test_data.type,
|
||||||
unit=default_test_data.unit,
|
unit=default_test_data.unit,
|
||||||
@ -258,7 +241,6 @@ class BaseAgentManagerTestCase(base.BaseTestCase):
|
|||||||
|
|
||||||
self.mgr.hashrings = mock.MagicMock()
|
self.mgr.hashrings = mock.MagicMock()
|
||||||
self.mgr.hashrings.__getitem__.return_value = self.hashring
|
self.mgr.hashrings.__getitem__.return_value = self.hashring
|
||||||
self.mgr.tg = mock.MagicMock()
|
|
||||||
self.polling_cfg = {
|
self.polling_cfg = {
|
||||||
'sources': [{
|
'sources': [{
|
||||||
'name': 'test_polling',
|
'name': 'test_polling',
|
||||||
|
@ -23,6 +23,7 @@ from ceilometer.compute import discovery as nova_discover
|
|||||||
from ceilometer.hardware import discovery
|
from ceilometer.hardware import discovery
|
||||||
from ceilometer.polling import manager
|
from ceilometer.polling import manager
|
||||||
from ceilometer.polling import plugin_base
|
from ceilometer.polling import plugin_base
|
||||||
|
from ceilometer import sample
|
||||||
from ceilometer import service
|
from ceilometer import service
|
||||||
from ceilometer.tests.unit.polling import agentbase
|
from ceilometer.tests.unit.polling import agentbase
|
||||||
|
|
||||||
@ -166,7 +167,7 @@ class TestRunTasks(agentbase.BaseAgentManagerTestCase):
|
|||||||
class PollsterKeystone(TestPollsterKeystone):
|
class PollsterKeystone(TestPollsterKeystone):
|
||||||
samples = []
|
samples = []
|
||||||
resources = []
|
resources = []
|
||||||
test_data = agentbase.TestSample(
|
test_data = sample.Sample(
|
||||||
name='testkeystone',
|
name='testkeystone',
|
||||||
type=agentbase.default_test_data.type,
|
type=agentbase.default_test_data.type,
|
||||||
unit=agentbase.default_test_data.unit,
|
unit=agentbase.default_test_data.unit,
|
||||||
@ -180,7 +181,7 @@ class TestRunTasks(agentbase.BaseAgentManagerTestCase):
|
|||||||
class PollsterPollingException(TestPollsterPollingException):
|
class PollsterPollingException(TestPollsterPollingException):
|
||||||
samples = []
|
samples = []
|
||||||
resources = []
|
resources = []
|
||||||
test_data = agentbase.TestSample(
|
test_data = sample.Sample(
|
||||||
name='testpollingexception',
|
name='testpollingexception',
|
||||||
type=agentbase.default_test_data.type,
|
type=agentbase.default_test_data.type,
|
||||||
unit=agentbase.default_test_data.unit,
|
unit=agentbase.default_test_data.unit,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user