diff --git a/ceilometer/tests/pipeline_base.py b/ceilometer/tests/pipeline_base.py index 5359486ba..b7a3f4814 100644 --- a/ceilometer/tests/pipeline_base.py +++ b/ceilometer/tests/pipeline_base.py @@ -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({ diff --git a/ceilometer/transformer/conversions.py b/ceilometer/transformer/conversions.py index 543432b55..8954608e3 100644 --- a/ceilometer/transformer/conversions.py +++ b/ceilometer/transformer/conversions.py @@ -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)