Merge "minor polling cleaning"

This commit is contained in:
Zuul 2017-12-04 04:18:33 +00:00 committed by Gerrit Code Review
commit 6d940c5e56
3 changed files with 15 additions and 24 deletions

View File

@ -144,6 +144,14 @@ class Sample(object):
def get_iso_timestamp(self):
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):
# NOTE(sileht): Instead of passing the cfg.CONF everywhere in ceilometer

View File

@ -31,24 +31,7 @@ from ceilometer import service
from ceilometer.tests import base
class TestSample(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(
default_test_data = sample.Sample(
name='test',
type=sample.TYPE_CUMULATIVE,
unit='',
@ -134,7 +117,7 @@ class BaseAgentManagerTestCase(base.BaseTestCase):
class PollsterAnother(TestPollster):
samples = []
resources = []
test_data = TestSample(
test_data = sample.Sample(
name='testanother',
type=default_test_data.type,
unit=default_test_data.unit,
@ -148,7 +131,7 @@ class BaseAgentManagerTestCase(base.BaseTestCase):
class PollsterException(TestPollsterException):
samples = []
resources = []
test_data = TestSample(
test_data = sample.Sample(
name='testexception',
type=default_test_data.type,
unit=default_test_data.unit,
@ -162,7 +145,7 @@ class BaseAgentManagerTestCase(base.BaseTestCase):
class PollsterExceptionAnother(TestPollsterException):
samples = []
resources = []
test_data = TestSample(
test_data = sample.Sample(
name='testexceptionanother',
type=default_test_data.type,
unit=default_test_data.unit,
@ -258,7 +241,6 @@ class BaseAgentManagerTestCase(base.BaseTestCase):
self.mgr.hashrings = mock.MagicMock()
self.mgr.hashrings.__getitem__.return_value = self.hashring
self.mgr.tg = mock.MagicMock()
self.polling_cfg = {
'sources': [{
'name': 'test_polling',

View File

@ -23,6 +23,7 @@ from ceilometer.compute import discovery as nova_discover
from ceilometer.hardware import discovery
from ceilometer.polling import manager
from ceilometer.polling import plugin_base
from ceilometer import sample
from ceilometer import service
from ceilometer.tests.unit.polling import agentbase
@ -166,7 +167,7 @@ class TestRunTasks(agentbase.BaseAgentManagerTestCase):
class PollsterKeystone(TestPollsterKeystone):
samples = []
resources = []
test_data = agentbase.TestSample(
test_data = sample.Sample(
name='testkeystone',
type=agentbase.default_test_data.type,
unit=agentbase.default_test_data.unit,
@ -180,7 +181,7 @@ class TestRunTasks(agentbase.BaseAgentManagerTestCase):
class PollsterPollingException(TestPollsterPollingException):
samples = []
resources = []
test_data = agentbase.TestSample(
test_data = sample.Sample(
name='testpollingexception',
type=agentbase.default_test_data.type,
unit=agentbase.default_test_data.unit,