Beispiel #1
0
    def test_corrupted_data(self):
        self.incoming.add_measures(self.metric.id, [
            incoming.Measure(datetime64(2014, 1, 1, 12, 0, 1), 69),
        ])
        self.trigger_processing()

        self.incoming.add_measures(self.metric.id, [
            incoming.Measure(datetime64(2014, 1, 1, 13, 0, 1), 1),
        ])

        with mock.patch('gnocchi.carbonara.AggregatedTimeSerie.unserialize',
                        side_effect=carbonara.InvalidData()):
            with mock.patch('gnocchi.carbonara.BoundTimeSerie.unserialize',
                            side_effect=carbonara.InvalidData()):
                self.trigger_processing()

        granularities = [
            numpy.timedelta64(1, 'D'),
            numpy.timedelta64(1, 'h'),
            numpy.timedelta64(5, 'm'),
        ]

        m = self.storage.get_measures(self.metric, granularities)
        self.assertIn((datetime64(2014, 1, 1), numpy.timedelta64(1, 'D'), 1),
                      m)
        self.assertIn(
            (datetime64(2014, 1, 1, 13), numpy.timedelta64(1, 'h'), 1), m)
        self.assertIn(
            (datetime64(2014, 1, 1, 13), numpy.timedelta64(5, 'm'), 1), m)
Beispiel #2
0
    def test_corrupted_data(self):
        if not isinstance(self.storage, _carbonara.CarbonaraBasedStorage):
            self.skipTest("This driver is not based on Carbonara")

        self.incoming.add_measures(self.metric, [
            storage.Measure(utils.dt_to_unix_ns(2014, 1, 1, 12, 0, 1), 69),
        ])
        self.trigger_processing()

        self.incoming.add_measures(self.metric, [
            storage.Measure(utils.dt_to_unix_ns(2014, 1, 1, 13, 0, 1), 1),
        ])

        with mock.patch('gnocchi.carbonara.AggregatedTimeSerie.unserialize',
                        side_effect=carbonara.InvalidData()):
            with mock.patch('gnocchi.carbonara.BoundTimeSerie.unserialize',
                            side_effect=carbonara.InvalidData()):
                self.trigger_processing()

        m = self.storage.get_measures(self.metric)
        self.assertIn((utils.datetime_utc(2014, 1, 1), 86400.0, 1), m)
        self.assertIn((utils.datetime_utc(2014, 1, 1, 13), 3600.0, 1), m)
        self.assertIn((utils.datetime_utc(2014, 1, 1, 13), 300.0, 1), m)