コード例 #1
0
    def test_invalid_retentions(self):
        retention_map = (
            # From getUnitString
            ('10x:10', ValueError("Invalid unit 'x'")),
            ('60:10x', ValueError("Invalid unit 'x'")),

            # From parseRetentionDef
            ('10X:10', ValueError("Invalid precision specification '10X'")),
            ('10:10$', ValueError("Invalid retention specification '10$'")),
            ('60:10', (60, 10)),
        )
        for retention, expected_exc in retention_map:
            try:
                results = parseRetentionDef(retention)
            except expected_exc.__class__ as exc:
                self.assertEqual(
                    str(expected_exc),
                    str(exc),
                )
                self.assertEqual(
                    expected_exc.__class__,
                    exc.__class__,
                )
            else:
                # When there isn't an exception raised
                self.assertEqual(results, expected_exc)
コード例 #2
0
 def test_valid_retentions(self):
     retention_map = (
         ('60:10', (60, 10)),
         ('10:60', (10, 60)),
         ('10s:10h', (10, 3600)),
     )
     for retention, expected in retention_map:
         results = parseRetentionDef(retention)
         self.assertEqual(results, expected)
コード例 #3
0
    def _get_retentions_from_storage_schemas(self, opts):
        """Parse storage-schemas.conf and returns all retentions."""
        ret = []

        config_parser = ConfigParser()
        if not config_parser.read(opts.storage_schemas):
            raise SystemExit("Error: Couldn't read config file: %s" %
                             opts.storage_schemas)
        for section in config_parser.sections():
            options = dict(config_parser.items(section))
            retentions = options['retentions'].split(',')
            archives = [carbon_util.parseRetentionDef(s) for s in retentions]
            ret.append(bg_accessor.Retention.from_carbon(archives))

        return ret
コード例 #4
0
ファイル: command_syncdb.py プロジェクト: Thib17/biggraphite
    def _get_retentions_from_storage_schemas(self, opts):
        """Parse storage-schemas.conf and returns all retentions."""
        ret = []

        config_parser = ConfigParser()
        if not config_parser.read(opts.storage_schemas):
            raise SystemExit(
                "Error: Couldn't read config file: %s" % opts.storage_schemas
            )
        for section in config_parser.sections():
            options = dict(config_parser.items(section))
            retentions = options["retentions"].split(",")
            archives = [carbon_util.parseRetentionDef(s) for s in retentions]
            ret.append(bg_metric.Retention.from_carbon(archives))

        return ret
コード例 #5
0
ファイル: storage.py プロジェクト: drawks/carbon
 def fromString(retentionDef):
   (secondsPerPoint, points) = parseRetentionDef(retentionDef)
   return Archive(secondsPerPoint, points)
コード例 #6
0
ファイル: storage.py プロジェクト: pexip/os-graphite-carbon
 def fromString(retentionDef):
     (secondsPerPoint, points) = parseRetentionDef(retentionDef)
     return Archive(secondsPerPoint, points)