]> git.proxmox.com Git - ceph.git/blame - ceph/src/cephadm/tests/test_enclosure.py
update ceph source to reef 18.2.1
[ceph.git] / ceph / src / cephadm / tests / test_enclosure.py
CommitLineData
1e59de90
TL
1import pytest
2
3from unittest import mock
4from tests.fixtures import host_sysfs, import_cephadm
5
6_cephadm = import_cephadm()
7
8
9@pytest.fixture
10def enclosure(host_sysfs):
11 e = _cephadm.Enclosure(
12 enc_id='1',
13 enc_path='/sys/class/scsi_generic/sg2/device/enclosure/0:0:1:0',
14 dev_path='/sys/class/scsi_generic/sg2')
15 yield e
16
17
18class TestEnclosure:
19
20 def test_enc_metadata(self, enclosure):
21 """Check metadata for the enclosure e.g. vendor and model"""
22
23 assert enclosure.vendor == "EnclosuresInc"
24 assert enclosure.components == '12'
25 assert enclosure.model == "D12"
26 assert enclosure.enc_id == '1'
27
28 assert enclosure.ses_paths == ['sg2']
29 assert enclosure.path_count == 1
30
31 def test_enc_slots(self, enclosure):
32 """Check slot count"""
33
34 assert len(enclosure.slot_map) == 12
35
36 def test_enc_slot_format(self, enclosure):
37 """Check the attributes of a slot are as expected"""
38
39 assert all(k in ['fault', 'locate', 'serial', 'status']
40 for k, _v in enclosure.slot_map['0'].items())
41
42 def test_enc_slot_status(self, enclosure):
43 """Check the number of occupied slots is correct"""
44
45 occupied_slots = [slot_id for slot_id in enclosure.slot_map
46 if enclosure.slot_map[slot_id].get('status').upper() == 'OK']
47
48 assert len(occupied_slots) == 6
49
50 def test_enc_disk_count(self, enclosure):
51 """Check the disks found matches the slot info"""
52
53 assert len(enclosure.device_lookup) == 6
54 assert enclosure.device_count == 6
55
56 def test_enc_device_serial(self, enclosure):
57 """Check the device serial numbers are as expected"""
58
59 assert all(fake_serial in enclosure.device_lookup.keys()
60 for fake_serial in [
61 'fake000',
62 'fake001',
63 'fake002',
64 'fake003',
65 'fake004',
66 'fake005'])
67
68 def test_enc_slot_to_serial(self, enclosure):
69 """Check serial number to slot matches across slot_map and device_lookup"""
70
71 for serial, slot in enclosure.device_lookup.items():
72 assert enclosure.slot_map[slot].get('serial') == serial