コード例 #1
0
ファイル: test_consumers.py プロジェクト: aurrelhebert/sauna
 def test_get_all_consumers(self):
     Sauna.import_submodules('sauna.consumers.ext')
     consumers = ConsumerRegister.all_consumers
     self.assertIsInstance(consumers, dict)
     self.assertGreater(len(consumers), 1)
     for consumer_name, consumer_info in consumers.items():
         self.assertIn('consumer_cls', consumer_info)
         self.assert_(
             issubclass(consumer_info['consumer_cls'], base.Consumer))
コード例 #2
0
ファイル: test_consumers.py プロジェクト: bewiwi/sauna
 def test_get_all_consumers(self):
     Sauna.import_submodules('sauna.consumers.ext')
     consumers = ConsumerRegister.all_consumers
     self.assertIsInstance(consumers, dict)
     self.assertGreater(len(consumers), 1)
     for consumer_name, consumer_info in consumers.items():
         self.assertIn('consumer_cls', consumer_info)
         self.assert_(issubclass(consumer_info['consumer_cls'],
                                 base.Consumer))
コード例 #3
0
 def test_assemble_config_sample(self):
     mock_open = mock.mock_open()
     sauna_instance = Sauna()
     with mock.patch('builtins.open', mock_open):
         sauna_instance.assemble_config_sample('/foo')
     mock_open.assert_called_once_with('/foo/sauna-sample.yml', 'w')
     f = mock_open()
     generated_yaml_string = f.write.call_args[0][0]
     # Will raise a yaml error if generated content is not valid yaml
     yaml.safe_load(generated_yaml_string)
コード例 #4
0
ファイル: test_config.py プロジェクト: wayt/sauna
 def test_dict_conf(self):
     dict_conf = {
         "plugins": {
             "Disk": {
                 "config": {
                     "myconf": "myvalue"
                 },
                 "checks": [{
                     "type": "used_percent",
                     "warn": "80%",
                     "crit": "90%"
                 }]
             }
         }
     }
     expected_result = [{
         'type':
         'Disk',
         "config": {
             "myconf": "myvalue"
         },
         "checks": [{
             "type": "used_percent",
             "warn": "80%",
             "crit": "90%"
         }]
     }]
     sauna = Sauna(config=dict_conf)
     self.assertEqual(sauna.plugins_checks, expected_result)
コード例 #5
0
 def test_conf_without_concurrency_no_threadpool(self):
     original = {
         'periodicity': 60,
         'consumers': {
             'Stdout': {},
         },
         'plugins': []
     }
     sauna = Sauna(config=original)
     self.assertIsNone(sauna._thread_pool)
コード例 #6
0
 def test_consumers_list_conf(self):
     list_conf = {
         'consumers': [
             {
                 'type': 'NSCA',
                 'foo': 'bar'
             },
             {
                 'type': 'Stdout',
             }
         ]
     }
     sauna = Sauna(config=list_conf)
     for r in list_conf['consumers']:
         self.assert_(r in sauna.consumers)
コード例 #7
0
ファイル: test_config.py プロジェクト: wayt/sauna
    def test_list_conf(self):
        list_conf = {
            "plugins": [{
                'type':
                'Disk',
                "config": {
                    "myconf": "myvalue"
                },
                "checks": [{
                    "type": "used_percent",
                    "warn": "80%",
                    "crit": "90%"
                }]
            }]
        }

        sauna = Sauna(config=list_conf)
        self.assertEqual(sauna.plugins_checks, list_conf['plugins'])
コード例 #8
0
 def test_consumers_dict_conf(self):
     dict_conf = {
         'consumers': {
             'NSCA': {
                 'foo': 'bar'
             },
             'Stdout': None
         }
     }
     expected_result = [
         {
             'type': 'NSCA',
             'foo': 'bar'
         },
         {
             'type': 'Stdout',
         }
     ]
     sauna = Sauna(config=dict_conf)
     for r in expected_result:
         self.assert_(r in sauna.consumers)
コード例 #9
0
ファイル: test_config.py プロジェクト: wayt/sauna
 def test_complex_dict_conf(self):
     dict_conf = {
         "plugins": {
             "Disk": {
                 "config": {
                     "myconf": "myvalue"
                 },
                 "checks": [{
                     "type": "used_percent",
                     "warn": "80%",
                     "crit": "90%"
                 }, {
                     "type": "used_percent",
                     "warn": "80%",
                     "crit": "90%"
                 }]
             },
             "Memory": {
                 "config": {
                     "myconf": "myvalue"
                 },
                 "checks": [
                     {
                         "type": "used_percent",
                         "warn": "80%",
                         "crit": "90%"
                     },
                 ]
             }
         }
     }
     expected_result = [{
         'type':
         'Disk',
         "config": {
             "myconf": "myvalue"
         },
         "checks": [{
             "type": "used_percent",
             "warn": "80%",
             "crit": "90%"
         }, {
             "type": "used_percent",
             "warn": "80%",
             "crit": "90%"
         }]
     }, {
         "type":
         "Memory",
         "config": {
             "myconf": "myvalue"
         },
         "checks": [
             {
                 "type": "used_percent",
                 "warn": "80%",
                 "crit": "90%"
             },
         ]
     }]
     sauna = Sauna(config=dict_conf)
     self.assertEqual(len(sauna.plugins_checks), len(expected_result))
     for elem in sauna.plugins_checks:
         self.assertIn(elem, expected_result, 'missing element')