Merge "Fixes aggregator transformer timestamp and user input handling"

This commit is contained in:
Jenkins 2014-07-18 21:28:07 +00:00 committed by Gerrit Code Review
commit 5a0f043377
2 changed files with 12 additions and 4 deletions

View File

@ -1205,6 +1205,15 @@ class BasePipelineTestCase(test.BaseTestCase):
self.assertEqual(expected_length, len(publisher.samples))
return sorted(publisher.samples, key=lambda s: s.volume)
def test_aggregator_input_validation(self):
aggregator = conversions.AggregatorTransformer("1", "15", None,
None, None)
self.assertEqual(1, aggregator.size)
self.assertEqual(15, aggregator.retention_time)
self.assertRaises(ValueError, conversions.AggregatorTransformer,
"abc", "cde", None, None, None)
def test_aggregator_metadata(self):
for conf, expected_version in [('last', '2.0'), ('first', '1.0')]:
samples = self._do_test_aggregator({

View File

@ -188,8 +188,8 @@ class AggregatorTransformer(ScalingTransformer):
**kwargs):
super(AggregatorTransformer, self).__init__(**kwargs)
self.samples = {}
self.size = size
self.retention_time = retention_time
self.size = int(size) if size else None
self.retention_time = float(retention_time) if retention_time else None
self.initial_timestamp = None
self.aggregated_samples = 0
@ -225,8 +225,7 @@ class AggregatorTransformer(ScalingTransformer):
def handle_sample(self, context, sample):
if not self.initial_timestamp:
self.initial_timestamp = timeutils.parse_strtime(
sample.timestamp)
self.initial_timestamp = timeutils.parse_isotime(sample.timestamp)
self.aggregated_samples += 1
key = self._get_unique_key(sample)