| 1 |
# --- BEGIN COPYRIGHT BLOCK --- |
| 2 |
# Copyright (C) 2019 Red Hat, Inc. |
| 3 |
# All rights reserved. |
| 4 |
# |
| 5 |
# License: GPL (version 3 or any later version). |
| 6 |
# See LICENSE for details. |
| 7 |
# --- END COPYRIGHT BLOCK --- |
| 8 |
import pytest |
| 9 |
from lib389.monitor import MonitorDiskSpace |
| 10 |
from test389.topologies import topology_st as topo |
| 11 |
|
| 12 |
pytestmark = pytest.mark.tier2 |
| 13 |
|
| 14 |
def test_basic(topo): |
| 15 |
"""Test that the cn=disk space,cn=monitor gives at least one value |
| 16 |
|
| 17 |
:id: f1962762-2c6c-4e50-97af-a00012a7486d |
| 18 |
:setup: Standalone |
| 19 |
:steps: |
| 20 |
1. Get cn=disk space,cn=monitor entry |
| 21 |
2. Check it has at least one dsDisk attribute |
| 22 |
3. Check dsDisk attribute has the partition and sizes |
| 23 |
4. Check the numbers are valid integers |
| 24 |
:expectedresults: |
| 25 |
1. It should succeed |
| 26 |
2. It should succeed |
| 27 |
3. It should succeed |
| 28 |
4. It should succeed |
| 29 |
""" |
| 30 |
|
| 31 |
inst = topo.standalone |
| 32 |
|
| 33 |
# Turn off disk monitoring |
| 34 |
disk_space_mon = MonitorDiskSpace(inst) |
| 35 |
disk_str = disk_space_mon.get_disks()[0] |
| 36 |
|
| 37 |
inst.log.info('Check that "partition", "size", "used", "available", "use%" words are present in the string') |
| 38 |
words = ["partition", "size", "used", "available", "use%"] |
| 39 |
assert all(map(lambda word: word in disk_str, words)) |
| 40 |
|
| 41 |
inst.log.info("Check that the sizes are numbers") |
| 42 |
for word in words[1:]: |
| 43 |
number = disk_str.split(f'{word}="')[1].split('"')[0] |
| 44 |
try: |
| 45 |
int(number) |
| 46 |
except ValueError: |
| 47 |
raise ValueError(f'A "{word}" value is not a number') |