Esempio n. 1
0
class TestIPVSCollector(CollectorTestCase):
    def setUp(self):
        config = get_collector_config('IPVSCollector', {
            'interval': 10,
            'bin' : 'true',
            'use_sudo' : False
        })

        self.collector = IPVSCollector(config, None)

    @patch('os.access', Mock(return_value=True))
    @patch.object(Collector, 'publish')
    def test_should_work_with_real_data(self, publish_mock):
        with patch('subprocess.Popen.communicate', Mock(return_value =
            ( self.getFixture('ipvsadm').getvalue() , '')
        )):
            self.collector.collect()

        metrics = {
            "172_16_1_56:80.total.conns" : 116,
            "172_16_1_56:443.total.conns" : 59,
            "172_16_1_56:443.10_68_15_66:443.conns" : 59,
            "172_16_1_56:443.10_68_15_66:443.outbytes" : 216873,
        }
        
        self.setDocExample(self.collector.__class__.__name__, metrics)
        self.assertPublishedMany(publish_mock, metrics)
Esempio n. 2
0
class TestIPVSCollector(CollectorTestCase):
    def setUp(self):
        config = get_collector_config('IPVSCollector', {
            'interval': 10,
            'bin': 'true',
            'use_sudo': False
        })

        self.collector = IPVSCollector(config, None)

    def test_import(self):
        self.assertTrue(IPVSCollector)

    @patch('os.access', Mock(return_value=True))
    @patch.object(Collector, 'publish')
    def test_should_work_with_real_data(self, publish_mock):
        patch_communicate = patch(
            'subprocess.Popen.communicate',
            Mock(return_value=(self.getFixture('ipvsadm').getvalue(), '')))

        patch_communicate.start()
        self.collector.collect()
        patch_communicate.stop()

        metrics = {
            "TCP_172_16_1_56:80.total.conns": 116,
            "TCP_172_16_1_56:443.total.conns": 59,
            "TCP_172_16_1_56:443.10_68_15_66:443.conns": 59,
            "TCP_172_16_1_56:443.10_68_15_66:443.outbytes": 216873,
        }

        self.setDocExample(collector=self.collector.__class__.__name__,
                           metrics=metrics,
                           defaultpath=self.collector.config['path'])
        self.assertPublishedMany(publish_mock, metrics)
Esempio n. 3
0
    def setUp(self):
        config = get_collector_config('IPVSCollector', {
            'interval': 10,
            'bin': 'true',
            'use_sudo': False
        })

        self.collector = IPVSCollector(config, None)
Esempio n. 4
0
    def setUp(self):
        config = get_collector_config('IPVSCollector', {
            'interval': 10,
            'bin' : 'true',
            'use_sudo' : False
        })

        self.collector = IPVSCollector(config, None)