@mock.patch("cephadm.module.CephadmOrchestrator._get_connection")
@mock.patch("cephadm.module.CephadmOrchestrator._run_cephadm", _run_cephadm('[]'))
- def test_host(self, _get_connection, cephadm_module):
+ @mock.patch("cephadm.module.CephadmOrchestrator._daemon_cache_save_host")
+ @mock.patch("cephadm.module.CephadmOrchestrator._daemon_cache_rm_host")
+ def test_host(self, _get_connection, _save_host, _rm_host, cephadm_module):
with self._with_host(cephadm_module, 'test'):
assert wait(cephadm_module, cephadm_module.get_hosts()) == [InventoryNode('test')]
c = cephadm_module.get_hosts()
assert wait(cephadm_module, c) == []
@mock.patch("cephadm.module.CephadmOrchestrator._run_cephadm", _run_cephadm('[]'))
- def test_service_ls(self, cephadm_module):
+ @mock.patch("cephadm.module.CephadmOrchestrator._daemon_cache_save_host")
+ @mock.patch("cephadm.module.CephadmOrchestrator._daemon_cache_rm_host")
+ def test_service_ls(self, _save_host, _rm_host, cephadm_module):
with self._with_host(cephadm_module, 'test'):
c = cephadm_module.list_daemons(refresh=True)
assert wait(cephadm_module, c) == []
@mock.patch("cephadm.module.CephadmOrchestrator._run_cephadm", _run_cephadm('[]'))
- def test_device_ls(self, cephadm_module):
+ @mock.patch("cephadm.module.CephadmOrchestrator._daemon_cache_save_host")
+ @mock.patch("cephadm.module.CephadmOrchestrator._daemon_cache_rm_host")
+ def test_device_ls(self, _save_host, _rm_host, cephadm_module):
with self._with_host(cephadm_module, 'test'):
c = cephadm_module.get_inventory()
assert wait(cephadm_module, c) == [InventoryNode('test')]
@mock.patch("cephadm.module.CephadmOrchestrator.send_command")
@mock.patch("cephadm.module.CephadmOrchestrator.mon_command", mon_command)
@mock.patch("cephadm.module.CephadmOrchestrator._get_connection")
- def test_daemon_action(self, _send_command, _get_connection, cephadm_module):
+ @mock.patch("cephadm.module.CephadmOrchestrator._daemon_cache_save_host")
+ @mock.patch("cephadm.module.CephadmOrchestrator._daemon_cache_rm_host")
+ def test_daemon_action(self, _send_command, _get_connection, _save_host, _rm_host, cephadm_module):
cephadm_module.service_cache_timeout = 10
with self._with_host(cephadm_module, 'test'):
c = cephadm_module.list_daemons(refresh=True)
@mock.patch("cephadm.module.CephadmOrchestrator.send_command")
@mock.patch("cephadm.module.CephadmOrchestrator.mon_command", mon_command)
@mock.patch("cephadm.module.CephadmOrchestrator._get_connection")
- def test_mon_update(self, _send_command, _get_connection, cephadm_module):
+ @mock.patch("cephadm.module.CephadmOrchestrator._daemon_cache_save_host")
+ @mock.patch("cephadm.module.CephadmOrchestrator._daemon_cache_rm_host")
+ def test_mon_update(self, _send_command, _get_connection, _save_host, _rm_host, cephadm_module):
with self._with_host(cephadm_module, 'test'):
ps = PlacementSpec(hosts=['test:0.0.0.0=a'], count=1)
c = cephadm_module.apply_mon(ServiceSpec(placement=ps))
@mock.patch("cephadm.module.CephadmOrchestrator.send_command")
@mock.patch("cephadm.module.CephadmOrchestrator.mon_command", mon_command)
@mock.patch("cephadm.module.CephadmOrchestrator._get_connection")
- def test_mgr_update(self, _send_command, _get_connection, cephadm_module):
+ @mock.patch("cephadm.module.CephadmOrchestrator._daemon_cache_save_host")
+ @mock.patch("cephadm.module.CephadmOrchestrator._daemon_cache_rm_host")
+ def test_mgr_update(self, _send_command, _get_connection, _save_host, _rm_host, cephadm_module):
with self._with_host(cephadm_module, 'test'):
ps = PlacementSpec(hosts=['test:0.0.0.0=a'], count=1)
c = cephadm_module.apply_mgr(ServiceSpec(placement=ps))
@mock.patch("cephadm.module.CephadmOrchestrator.send_command")
@mock.patch("cephadm.module.CephadmOrchestrator.mon_command", mon_command)
@mock.patch("cephadm.module.CephadmOrchestrator._get_connection")
- def test_create_osds(self, _send_command, _get_connection, cephadm_module):
+ @mock.patch("cephadm.module.CephadmOrchestrator._daemon_cache_save_host")
+ @mock.patch("cephadm.module.CephadmOrchestrator._daemon_cache_rm_host")
+ def test_create_osds(self, _send_command, _get_connection, _save_host, _rm_host, cephadm_module):
with self._with_host(cephadm_module, 'test'):
dg = DriveGroupSpec('test', data_devices=DeviceSelection(paths=['']))
c = cephadm_module.create_osds([dg])
)
])
))
- def test_remove_osds(self, cephadm_module):
+ @mock.patch("cephadm.module.CephadmOrchestrator._daemon_cache_save_host")
+ @mock.patch("cephadm.module.CephadmOrchestrator._daemon_cache_rm_host")
+ def test_remove_osds(self, _save_host, _rm_host, cephadm_module):
with self._with_host(cephadm_module, 'test'):
c = cephadm_module.list_daemons(refresh=True)
wait(cephadm_module, c)
@mock.patch("cephadm.module.CephadmOrchestrator.send_command")
@mock.patch("cephadm.module.CephadmOrchestrator.mon_command", mon_command)
@mock.patch("cephadm.module.CephadmOrchestrator._get_connection")
- def test_mds(self, _send_command, _get_connection, cephadm_module):
+ @mock.patch("cephadm.module.CephadmOrchestrator._daemon_cache_save_host")
+ @mock.patch("cephadm.module.CephadmOrchestrator._daemon_cache_rm_host")
+ def test_mds(self, _send_command, _get_connection, _save_host, _rm_host, cephadm_module):
with self._with_host(cephadm_module, 'test'):
ps = PlacementSpec(hosts=['test'], count=1)
c = cephadm_module.add_mds(ServiceSpec('name', placement=ps))
@mock.patch("cephadm.module.CephadmOrchestrator.send_command")
@mock.patch("cephadm.module.CephadmOrchestrator.mon_command", mon_command)
@mock.patch("cephadm.module.CephadmOrchestrator._get_connection")
- def test_rgw(self, _send_command, _get_connection, cephadm_module):
+ @mock.patch("cephadm.module.CephadmOrchestrator._daemon_cache_save_host")
+ @mock.patch("cephadm.module.CephadmOrchestrator._daemon_cache_rm_host")
+ def test_rgw(self, _send_command, _get_connection, _save_host, _rm_host, cephadm_module):
with self._with_host(cephadm_module, 'test'):
ps = PlacementSpec(hosts=['test'], count=1)
@mock.patch("cephadm.module.CephadmOrchestrator.send_command")
@mock.patch("cephadm.module.CephadmOrchestrator.mon_command", mon_command)
@mock.patch("cephadm.module.CephadmOrchestrator._get_connection")
- def test_rgw_update(self, _send_command, _get_connection, cephadm_module):
+ @mock.patch("cephadm.module.CephadmOrchestrator._daemon_cache_save_host")
+ @mock.patch("cephadm.module.CephadmOrchestrator._daemon_cache_rm_host")
+ def test_rgw_update(self, _send_command, _get_connection, _save_host, _rm_host, cephadm_module):
with self._with_host(cephadm_module, 'host1'):
with self._with_host(cephadm_module, 'host2'):
@mock.patch("cephadm.module.CephadmOrchestrator.send_command")
@mock.patch("cephadm.module.CephadmOrchestrator.mon_command", mon_command)
@mock.patch("cephadm.module.CephadmOrchestrator._get_connection")
- def test_rgw_update_fail(self, _send_command, _get_connection, cephadm_module):
+ @mock.patch("cephadm.module.CephadmOrchestrator._daemon_cache_save_host")
+ @mock.patch("cephadm.module.CephadmOrchestrator._daemon_cache_rm_host")
+ @mock.patch("cephadm.module.CephadmOrchestrator.serve", None)
+ def test_rgw_update_fail(self, _send_command, _get_connection, _save_host, _rm_host, cephadm_module):
with self._with_host(cephadm_module, 'host1'):
with self._with_host(cephadm_module, 'host2'):
[out] = wait(cephadm_module, c)
match_glob(out, "Deployed rgw.realm.zone2.host2.* on host 'host2'")
+ c = cephadm_module.list_daemons()
+ r = wait(cephadm_module, c)
+ assert len(r) == 2
+
with pytest.raises(OrchestratorError):
ps = PlacementSpec(hosts=['host1', 'host2'], count=2)
- c = cephadm_module.apply_rgw(RGWSpec('realm', 'zone1', placement=ps))
+ c = cephadm_module.add_rgw(RGWSpec('realm', 'zone1', placement=ps))
[out] = wait(cephadm_module, c)
)
])
))
- def test_remove_daemon(self, cephadm_module):
+ @mock.patch("cephadm.module.CephadmOrchestrator._daemon_cache_save_host")
+ @mock.patch("cephadm.module.CephadmOrchestrator._daemon_cache_rm_host")
+ def test_remove_daemon(self, _save_host, _rm_host, cephadm_module):
with self._with_host(cephadm_module, 'test'):
c = cephadm_module.list_daemons(refresh=True)
wait(cephadm_module, c)
)
])
))
- def test_remove_service(self, cephadm_module):
+ @mock.patch("cephadm.module.CephadmOrchestrator._daemon_cache_save_host")
+ @mock.patch("cephadm.module.CephadmOrchestrator._daemon_cache_rm_host")
+ def test_remove_service(self, _save_host, _rm_host, cephadm_module):
with self._with_host(cephadm_module, 'test'):
c = cephadm_module.list_daemons(refresh=True)
wait(cephadm_module, c)
@mock.patch("cephadm.module.CephadmOrchestrator.send_command")
@mock.patch("cephadm.module.CephadmOrchestrator.mon_command", mon_command)
@mock.patch("cephadm.module.CephadmOrchestrator._get_connection")
- def test_rbd_mirror(self, _send_command, _get_connection, cephadm_module):
+ @mock.patch("cephadm.module.CephadmOrchestrator._daemon_cache_save_host")
+ @mock.patch("cephadm.module.CephadmOrchestrator._daemon_cache_rm_host")
+ def test_rbd_mirror(self, _send_command, _get_connection, _save_host, _rm_host, cephadm_module):
with self._with_host(cephadm_module, 'test'):
ps = PlacementSpec(hosts=['test'], count=1)
c = cephadm_module.add_rbd_mirror(ServiceSpec(name='name', placement=ps))
@mock.patch("cephadm.module.CephadmOrchestrator.send_command")
@mock.patch("cephadm.module.CephadmOrchestrator.mon_command", mon_command)
@mock.patch("cephadm.module.CephadmOrchestrator._get_connection")
- def test_prometheus(self, _send_command, _get_connection, cephadm_module):
+ @mock.patch("cephadm.module.CephadmOrchestrator._daemon_cache_save_host")
+ @mock.patch("cephadm.module.CephadmOrchestrator._daemon_cache_rm_host")
+ def test_prometheus(self, _send_command, _get_connection, _save_host, _rm_host, cephadm_module):
with self._with_host(cephadm_module, 'test'):
ps = PlacementSpec(hosts=['test'], count=1)
c = cephadm_module.add_prometheus(ServiceSpec(placement=ps))
[out] = wait(cephadm_module, c)
- assert "Deployed prometheus." in out
- assert " on host 'test'" in out
-
- ps = PlacementSpec(hosts=['test'], count=2)
- c = cephadm_module.apply_prometheus(ServiceSpec(placement=ps))
- [out] = wait(cephadm_module, c)
- assert "Deployed prometheus." in out
- assert " on host 'test'" in out
+ match_glob(out, "Deployed prometheus.* on host 'test'")
@mock.patch("cephadm.module.CephadmOrchestrator._run_cephadm", _run_cephadm('{}'))
@mock.patch("cephadm.module.CephadmOrchestrator.send_command")
@mock.patch("cephadm.module.CephadmOrchestrator.mon_command", mon_command)
@mock.patch("cephadm.module.CephadmOrchestrator._get_connection")
- def test_blink_device_light(self, _send_command, _get_connection, cephadm_module):
+ @mock.patch("cephadm.module.CephadmOrchestrator._daemon_cache_save_host")
+ @mock.patch("cephadm.module.CephadmOrchestrator._daemon_cache_rm_host")
+ def test_blink_device_light(self, _send_command, _get_connection, _save_host, _rm_host, cephadm_module):
with self._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']