def test_no_devices(self, aggregator):
     instance = self.INSTANCES['main']
     c = NfsStatCheck(self.CHECK_NAME, self.INIT_CONFIG, {}, [instance])
     with mock.patch('datadog_checks.nfsstat.nfsstat.get_subprocess_output',
                     return_value=('No NFS mount points were found', '',
                                   0)):
         c.check(instance)
Esempio n. 2
0
    def test_check(self, aggregator):
        instance = self.INSTANCES['main']
        c = NfsStatCheck(self.CHECK_NAME, self.INIT_CONFIG, {}, [instance])

        with open(os.path.join(FIXTURE_DIR, 'nfsiostat'), 'rb') as f:
            mock_output = ensure_unicode(f.read())

        with mock.patch('datadog_checks.nfsstat.nfsstat.get_subprocess_output',
                        return_value=(mock_output, '', 0)):
            c.check(instance)

        tags = list(instance['tags'])
        tags.extend([
            'nfs_server:192.168.34.1', 'nfs_export:/exports/nfs/datadog/two',
            'nfs_mount:/mnt/datadog/two'
        ])
        tags_unicode = list(instance['tags'])
        tags_unicode.extend([
            u'nfs_server:192.168.34.1',
            u'nfs_export:/exports/nfs/datadog/thr\u00E9\u00E9',
            u'nfs_mount:/mnt/datadog/thr\u00E9\u00E9',
        ])

        for metric in metrics:
            aggregator.assert_metric(metric, tags=tags)
            aggregator.assert_metric(metric, tags=tags_unicode)

        assert aggregator.metrics_asserted_pct == 100.0
Esempio n. 3
0
    def test_no_devices(self, aggregator):
        instance = self.INSTANCES['main']
        c = NfsStatCheck(self.CHECK_NAME, self.INIT_CONFIG, [instance])
        c.log = mock.MagicMock()

        with mock.patch(
                'datadog_checks.nfsstat.nfsstat.get_subprocess_output',
                return_value=('No NFS mount points were found', '', 0),
        ):
            c.check(instance)
        c.log.warning.assert_called_once_with(
            "No NFS mount points were found.", extra=mock.ANY)
Esempio n. 4
0
    def test_autofs_enabled(self, aggregator):
        instance = self.INSTANCES['main']
        init_config = deepcopy(self.INIT_CONFIG)
        init_config['autofs_enabled'] = True
        c = NfsStatCheck(self.CHECK_NAME, init_config, [instance])
        c.log = mock.MagicMock()

        with mock.patch(
                'datadog_checks.nfsstat.nfsstat.get_subprocess_output',
                return_value=('No NFS mount points were found', '', 0),
        ):
            c.check(instance)
        c.log.debug.assert_called_once_with(
            "AutoFS enabled: no mount points currently.")