Merge "Fixes aggregator transformer timestamp and user input handling"
This commit is contained in:
commit
5a0f043377
@ -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({
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user