Skip to content

Commit

Permalink
tests: align tests and use --best-controller
Browse files Browse the repository at this point in the history
Add parameter tests for new command: --best-controller.
Use new method to choose best controller for device. It is especially
needed when VMD and NPEM are available on one platform. Skip IBPI test
when drives are connected to better controller, than used to test.
Test multipath drives only with best controller connected.

Signed-off-by: Kinga Stefaniuk <kinga.stefaniuk@intel.com>
  • Loading branch information
ktanska committed Sep 4, 2024
1 parent ec36c85 commit 99cad22
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 18 deletions.
11 changes: 11 additions & 0 deletions tests/ledctl/ledctl_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,17 @@ def get_slot_by_device(self, slot: Slot):
]).stdout
return self.parse_slot_line(slot.cntrl_type, out)

def get_slot_by_device_cntrl(self, dev_node, cntrl):
out = self.run_ledctl_cmd_valid(
["--get-slot", "--controller-type", cntrl, "--device",
dev_node]).stdout
return self.parse_slot_line(cntrl, out)

def best_controller_by_device(self, dev_node):
result = self.run_ledctl_cmd_valid(
["--best-controller", "--device", dev_node]).stdout
return result.rstrip()

def list_slots(self, controller_type):
rc = []
out = self.run_ledctl_cmd_valid(
Expand Down
3 changes: 2 additions & 1 deletion tests/ledctl/parameters_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ def test_parameters_are_valid_long_test_flag(ledctl_binary):
"-G -n vmd -p 1 -r state -T",
"--get-slot --controller-type=vmd --slot=1 --print=state -T",
"-S -n vmd -p 1 -s normal -T",
"--set-slot --controller-type=vmd --slot=1 --state=normal -T"
"--set-slot --controller-type=vmd --slot=1 --state=normal -T",
"-B -d /dev/nvme0n1 -T", "--best-controller --device /dev/nvme0n1 -T"
],
)
def test_parameters_are_valid_short_test_flag(ledctl_binary,
Expand Down
38 changes: 21 additions & 17 deletions tests/ledctl/slot_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ def get_slots_with_device_or_skip(cmd: LedctlCmd, cntrl):
return slots_with_device_node


def filter_by_best_controller(cmd: LedctlCmd, slots_to_test):
for slot in slots_to_test:
best_cntrl = cmd.best_controller_by_device(slot.device_node)
if best_cntrl != slot.cntrl_type:
slots_to_test.remove(slot)
return slots_to_test


def verify_state(slot, current, expected, msg):
if slot.cntrl_type == "SCSI" and expected == "rebuild":
# No good way to validate this one as read value won't match what we sent down.
Expand All @@ -43,9 +51,15 @@ def test_ibpi(ledctl_binary, slot_filters, controller_filters, cntrl):
"""

cmd = LedctlCmd(ledctl_binary, slot_filters, controller_filters)
slots_with_device_node = get_slots_with_device_or_skip(cmd, cntrl)
slots_to_test = get_slots_with_device_or_skip(cmd, cntrl)
slots_to_test = filter_by_best_controller(cmd, slots_to_test)

for slot in slots_with_device_node:
if not slots_to_test:
pytest.skip(
"Devices detected but this is not primary controller for any drive, skipping"
)

for slot in slots_to_test:
for state in LedctlCmd.base_states:
cmd.set_ibpi(slot.device_node, state)
cur = cmd.get_slot(slot)
Expand Down Expand Up @@ -105,9 +119,8 @@ def test_set_slot_by_device(ledctl_binary, slot_filters, controller_filters,
slot_set_and_get_by_device_all(cmd, slot)


@pytest.mark.parametrize("cntrl", ["VMD", "NPEM"])
def test_nvme_multipath_drives(ledctl_binary, slot_filters, controller_filters,
cntrl):
def test_nvme_multipath_drives(ledctl_binary, slot_filters,
controller_filters):
"""
Special test for multipath drives using both set methods and get via device. We need to check
if ledctl provides nvme multipath minimal support.
Expand All @@ -118,15 +131,9 @@ def test_nvme_multipath_drives(ledctl_binary, slot_filters, controller_filters,
if len(mp_drives) == 0:
pytest.skip("No nvme multipath drives found")

slots_with_device_node = get_slots_with_device_or_skip(cmd, cntrl)
any_found = False

for slot in slots_with_device_node:
if slot.device_node not in mp_drives:
continue
any_found = True

LOGGER.debug(f"Found nvme multipath drive {slot}")
for mp_drive in mp_drives:
mp_cntrl = cmd.best_controller_by_device(mp_drive)
slot = cmd.get_slot_by_device_cntrl(mp_drive, mp_cntrl)

for state in cmd.base_states:
cmd.set_ibpi(slot.device_node, state)
Expand All @@ -137,6 +144,3 @@ def test_nvme_multipath_drives(ledctl_binary, slot_filters, controller_filters,
)

slot_set_and_get_by_device_all(cmd, slot)

if not any_found:
pytest.skip("Multipath drives are not connected to tested controller")

0 comments on commit 99cad22

Please sign in to comment.