Exemplo n.º 1
0
def test_get_devices_label():
    c = Disk('disk', None, {}, [{}])

    with mock.patch(
            "datadog_checks.disk.disk.get_subprocess_output",
            return_value=mock_blkid_output(),
            __name__='get_subprocess_output',
    ):
        labels = c._get_devices_label()
        assert labels.get("/dev/mapper/vagrant--vg-root") == "label:DATA"
Exemplo n.º 2
0
def test_get_devices_label_options():
    """
    Verify that
       - use_lsblk uses lsblk for labels,
       - blkid_cache_file not null makes it use the blkid_cache and
       - by default we use the blkid command.
    """
    c_lsblk = Disk('disk', {}, [{'use_lsblk': True}])
    c_blkid = Disk('disk', {}, [{}])
    c_blkid_cache = Disk('disk', {}, [{'blkid_cache_file': 'filepath'}])

    prefix_fun = "datadog_checks.disk.disk.Disk._get_devices_label_from_"
    with mock.patch(prefix_fun + "lsblk", return_value="lsblk"), mock.patch(
            prefix_fun + "blkid",
            return_value="blkid"), mock.patch(prefix_fun + "blkid_cache",
                                              return_value="blkid_cache"):
        assert c_lsblk._get_devices_label() == "lsblk"
        assert c_blkid._get_devices_label() == "blkid"
        assert c_blkid_cache._get_devices_label() == "blkid_cache"