예제 #1
0
 def test_number_of_points(self):
     """
     number of points
     """
     whisper.validateArchiveList(self.retention)
     with AssertRaisesException(whisper.InvalidConfiguration("Each archive must have at least enough points to consolidate to the next archive (archive1 consolidates 60 of archive0's points but it has only 30 total points)")):
         whisper.validateArchiveList([(1, 30), (60, 60)])
예제 #2
0
파일: storage.py 프로젝트: celik0311/carbon
def loadStorageSchemas():
  schemaList = []
  config = OrderedConfigParser()
  config.read(STORAGE_SCHEMAS_CONFIG)

  for section in config.sections():
    options = dict( config.items(section) )
    pattern = options.get('pattern')

    retentions = options['retentions'].split(',')
    archives = [ Archive.fromString(s) for s in retentions ]

    if pattern:
      mySchema = PatternSchema(section, pattern, archives)
    else:
      log.err("Section missing 'pattern': %s" % section)
      continue

    archiveList = [a.getTuple() for a in archives]

    try:
      whisper.validateArchiveList(archiveList)
      schemaList.append(mySchema)
    except whisper.InvalidConfiguration, e:
      log.msg("Invalid schemas found in %s: %s" % (section, e) )
예제 #3
0
 def test_even_precision_division(self):
     """
     even precision division
     """
     whisper.validateArchiveList([(60, 60), (6, 60)])
     with AssertRaisesException(whisper.InvalidConfiguration("Higher precision archives' precision must evenly divide all lower precision archives' precision (archive0: 7, archive1: 60)")):
         whisper.validateArchiveList([(60, 60), (7, 60)])
예제 #4
0
 def test_timespan_coverage(self):
     """
     timespan coverage
     """
     whisper.validateArchiveList(self.retention)
     with AssertRaisesException(whisper.InvalidConfiguration('Lower precision archives must cover larger time intervals than higher precision archives (archive0: 60 seconds, archive1: 10 seconds)')):
         whisper.validateArchiveList([(1, 60), (10, 1)])
예제 #5
0
파일: storage.py 프로젝트: devsfr/carbon
def loadStorageSchemas():
  schemaList = []
  config = OrderedConfigParser()
  config.read(STORAGE_SCHEMAS_CONFIG)

  for section in config.sections():
    options = dict(config.items(section))
    matchAll = options.get('match-all')
    pattern = options.get('pattern')
    listName = options.get('list')

    retentions = options['retentions'].split(',')
    archives = [Archive.fromString(s) for s in retentions]

    if matchAll:
      mySchema = DefaultSchema(section, archives)

    elif pattern:
      mySchema = PatternSchema(section, pattern, archives)

    elif listName:
      mySchema = ListSchema(section, listName, archives)

    archiveList = [a.getTuple() for a in archives]

    try:
      whisper.validateArchiveList(archiveList)
      schemaList.append(mySchema)
    except whisper.InvalidConfiguration, e:
      log.msg("Invalid schemas found in %s: %s" % (section, e))
예제 #6
0
 def test_validate_archive_list(self):
     """
     blank archive config
     """
     with AssertRaisesException(
             whisper.InvalidConfiguration(
                 'You must specify at least one archive configuration!')):
         whisper.validateArchiveList([])
예제 #7
0
    def test_duplicate(self):
        """
        Checking duplicates
        """
        # TODO: Fix the lies with whisper.validateArchiveList() saying it returns True/False
        self.assertIsNone(whisper.validateArchiveList(self.retention))

        with AssertRaisesException(whisper.InvalidConfiguration('A Whisper database may not be configured having two archives with the same precision (archive0: (1, 60), archive1: (1, 60))')):
            whisper.validateArchiveList([(1, 60), (60, 60), (1, 60)])
예제 #8
0
 def test_timespan_coverage(self):
     """
     timespan coverage
     """
     whisper.validateArchiveList(self.retention)
     with AssertRaisesException(
             whisper.InvalidConfiguration(
                 'Lower precision archives must cover larger time intervals than higher precision archives (archive0: 60 seconds, archive1: 10 seconds)'
             )):
         whisper.validateArchiveList([(1, 60), (10, 1)])
예제 #9
0
 def test_number_of_points(self):
     """
     number of points
     """
     whisper.validateArchiveList(self.retention)
     with AssertRaisesException(
             whisper.InvalidConfiguration(
                 "Each archive must have at least enough points to consolidate to the next archive (archive1 consolidates 60 of archive0's points but it has only 30 total points)"
             )):
         whisper.validateArchiveList([(1, 30), (60, 60)])
예제 #10
0
 def test_even_precision_division(self):
     """
     even precision division
     """
     whisper.validateArchiveList([(60, 60), (6, 60)])
     with AssertRaisesException(
             whisper.InvalidConfiguration(
                 "Higher precision archives' precision must evenly divide all lower precision archives' precision (archive0: 7, archive1: 60)"
             )):
         whisper.validateArchiveList([(60, 60), (7, 60)])
예제 #11
0
    def test_duplicate(self):
        """
        Checking duplicates
        """
        # TODO: Fix the lies with whisper.validateArchiveList() saying it returns True/False
        self.assertIsNone(whisper.validateArchiveList(self.retention))

        with AssertRaisesException(
                whisper.InvalidConfiguration(
                    'A Whisper database may not be configured having two archives with the same precision (archive0: (1, 60), archive1: (1, 60))'
                )):
            whisper.validateArchiveList([(1, 60), (60, 60), (1, 60)])
예제 #12
0
def loadStorageSchemas():
    schemaList = []
    config = OrderedConfigParser()
    config.read(STORAGE_SCHEMAS_CONFIG)

    for section in config.sections():
        options = dict(config.items(section))
        matchAll = options.get('match-all')
        pattern = options.get('pattern')
        listName = options.get('list')

        retentions = options['retentions'].split(',')
        archives = [Archive.fromString(s) for s in retentions]

        if matchAll:
            mySchema = DefaultSchema(section, archives)

        elif pattern:
            mySchema = PatternSchema(section, pattern, archives)

        elif listName:
            mySchema = ListSchema(section, listName, archives)

        archiveList = [a.getTuple() for a in archives]

        validSchema = whisper.validateArchiveList(archiveList)

        if validSchema:
            schemaList.append(mySchema)
        else:
            log.msg("Invalid schemas found in %s." % section)

    schemaList.append(defaultSchema)
    return schemaList
예제 #13
0
 def test_duplicate(self):
     """Checking duplicates"""
     whisper.validateArchiveList([(1, 60), (60, 60)])
     with self.assertRaises(whisper.InvalidConfiguration):
         whisper.validateArchiveList([(1, 60), (60, 60), (1, 60)])
예제 #14
0
 def validateArchiveList(self, archiveList):
     try:
         whisper.validateArchiveList(archiveList)
     except whisper.InvalidConfiguration, e:
         raise ValueError("%s" % e)
예제 #15
0
 def test_validate_archive_list(self):
     """blank archive config"""
     with self.assertRaises(whisper.InvalidConfiguration):
         whisper.validateArchiveList([])
예제 #16
0
 def test_even_precision_division(self):
     """even precision division"""
     whisper.validateArchiveList([(60, 60), (6, 60)])
     with self.assertRaises(whisper.InvalidConfiguration):
         whisper.validateArchiveList([(60, 60), (7, 60)])
예제 #17
0
 def test_duplicate(self):
     """Checking duplicates"""
     whisper.validateArchiveList([(1, 60), (60, 60)])
     with self.assertRaises(whisper.InvalidConfiguration):
         whisper.validateArchiveList([(1, 60), (60, 60), (1, 60)])
예제 #18
0
 def test_timespan_coverage(self):
     """timespan coverage"""
     whisper.validateArchiveList([(1, 60), (60, 60)])
     with self.assertRaises(whisper.InvalidConfiguration):
         whisper.validateArchiveList([(1, 60), (10, 1)])
예제 #19
0
 def test_number_of_points(self):
     """number of points"""
     whisper.validateArchiveList([(1, 60), (60, 60)])
     with self.assertRaises(whisper.InvalidConfiguration):
         whisper.validateArchiveList([(1, 30), (60, 60)])
예제 #20
0
 def test_even_precision_division(self):
     """even precision division"""
     whisper.validateArchiveList([(60, 60), (6, 60)])
     with self.assertRaises(whisper.InvalidConfiguration):
         whisper.validateArchiveList([(60, 60), (7, 60)])
예제 #21
0
 def test_validate_archive_list(self):
     """blank archive config"""
     with self.assertRaises(whisper.InvalidConfiguration):
         whisper.validateArchiveList([])
예제 #22
0
 def test_number_of_points(self):
     """number of points"""
     whisper.validateArchiveList([(1, 60), (60, 60)])
     with self.assertRaises(whisper.InvalidConfiguration):
         whisper.validateArchiveList([(1, 30), (60, 60)])
예제 #23
0
 def test_timespan_coverage(self):
     """timespan coverage"""
     whisper.validateArchiveList([(1, 60), (60, 60)])
     with self.assertRaises(whisper.InvalidConfiguration):
         whisper.validateArchiveList([(1, 60), (10, 1)])
예제 #24
0
 def validateArchiveList(self, archiveList):
   try:
     whisper.validateArchiveList(archiveList)
   except whisper.InvalidConfiguration, e:
     raise ValueError("%s" % e)
예제 #25
0
  archives = []
  section_failed = False
  for retention in retentions:
    try:
      archives.append(whisper.parseRetentionDef(retention))
    except ValueError as e:
      print(
        "  - Error: Section '%s' contains an invalid item in its retention definition ('%s')" %
        (section, retention)
      )
      print("    %s" % e)
      section_failed = True

  if not section_failed:
    try:
      whisper.validateArchiveList(archives)
    except whisper.InvalidConfiguration as e:
      print(
        "  - Error: Section '%s' contains an invalid retention definition ('%s')" %
        (section, ','.join(retentions))
      )
      print("    %s" % e)

  if section_failed:
    errors_found += 1
  else:
    print("  OK")

if errors_found:
  raise SystemExit("Storage-schemas configuration '%s' failed validation" % SCHEMAS_FILE)
예제 #26
0
 def test_validate_archive_list(self):
     """
     blank archive config
     """
     with AssertRaisesException(whisper.InvalidConfiguration('You must specify at least one archive configuration!')):
         whisper.validateArchiveList([])