From e5d3f57b9f4dcb5d0e2aaef547313562e0f78ae6 Mon Sep 17 00:00:00 2001 From: Adam King Date: Tue, 1 Nov 2022 15:35:52 -0400 Subject: [PATCH] cephadm/tests: test for command_agent function Part of: https://tracker.ceph.com/issues/57621 Signed-off-by: Adam King --- src/cephadm/tests/test_agent.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/cephadm/tests/test_agent.py b/src/cephadm/tests/test_agent.py index c1c6ec792f38..f579729405a8 100644 --- a/src/cephadm/tests/test_agent.py +++ b/src/cephadm/tests/test_agent.py @@ -784,3 +784,17 @@ def test_gatherer_run(_wait, _time, _agent_wakeup, cephadm_fs): assert agent.ls_gatherer.ack == agent.ack # should not have gotten to end of loop _clear.assert_not_called() + + +@mock.patch("cephadm.CephadmAgent.run") +def test_command_agent(_agent_run, cephadm_fs): + with with_cephadm_ctx([]) as ctx: + ctx.fsid = FSID + ctx.daemon_id = AGENT_ID + + with pytest.raises(Exception, match=f"Agent daemon directory {AGENT_DIR} does not exist. Perhaps agent was never deployed?"): + _cephadm.command_agent(ctx) + + cephadm_fs.create_dir(AGENT_DIR) + _cephadm.command_agent(ctx) + _agent_run.assert_called() -- 2.47.3