Пример #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
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
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([])