From 17cdcdc73094f4cb4f45575e02434234cf9cebd8 Mon Sep 17 00:00:00 2001 From: Sebastian Wagner Date: Mon, 31 Aug 2020 15:11:24 +0200 Subject: [PATCH] mgr/cephadm: Add extensive test for blink_device_light Signed-off-by: Sebastian Wagner --- src/pybind/mgr/cephadm/tests/test_cephadm.py | 26 +++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/pybind/mgr/cephadm/tests/test_cephadm.py b/src/pybind/mgr/cephadm/tests/test_cephadm.py index ebddee226cb40..9243294644ae2 100644 --- a/src/pybind/mgr/cephadm/tests/test_cephadm.py +++ b/src/pybind/mgr/cephadm/tests/test_cephadm.py @@ -581,11 +581,29 @@ class TestCephadm(object): # automatically. assert_rm_service(cephadm_module, 'iscsi.name') - @mock.patch("cephadm.module.CephadmOrchestrator._run_cephadm", _run_cephadm('{}')) - def test_blink_device_light(self, cephadm_module): + @pytest.mark.parametrize( + "on_bool", + [ + True, + False + ] + ) + @pytest.mark.parametrize( + "fault_ident", + [ + 'fault', + 'ident' + ] + ) + @mock.patch("cephadm.module.CephadmOrchestrator._run_cephadm") + def test_blink_device_light(self, _run_cephadm, on_bool, fault_ident, cephadm_module): + _run_cephadm.return_value = '{}', '', 0 with with_host(cephadm_module, 'test'): - c = cephadm_module.blink_device_light('ident', True, [('test', '', '')]) - assert wait(cephadm_module, c) == ['Set ident light for test: on'] + c = cephadm_module.blink_device_light(fault_ident, on_bool, [('test', '', 'dev')]) + on_off = 'on' if on_bool else 'off' + assert wait(cephadm_module, c) == [f'Set {fault_ident} light for test: {on_off}'] + _run_cephadm.assert_called_with('test', 'osd', 'shell', [ + '--', 'lsmcli', f'local-disk-{fault_ident}-led-{on_off}', '--path', 'dev'], error_ok=True) @pytest.mark.parametrize( "spec, meth", -- 2.39.5