@@ -2888,3 +2888,33 @@ def _get_nvmeof_daemons(sname) -> List[DaemonDescription]:
28882888 # on nvmeof.foo.foo's daemons
28892889 nvmeof_bar_blocking_hosts = NvmeofService (cephadm_module ).get_blocking_daemon_hosts ('nvmeof.bar.bar' )
28902890 assert set ([h .hostname for h in nvmeof_bar_blocking_hosts ]) == set (['host1' , 'host2' ])
2891+
2892+ @mock .patch ("cephadm.serve.CephadmServe._run_cephadm" , _run_cephadm ('{}' ))
2893+ @mock .patch ("cephadm.inventory.HostCache.get_daemons_by_type" )
2894+ def test_set_osd_spec_non_osd_service (self , _get_daemons_by_type , cephadm_module ):
2895+ with with_host (cephadm_module , 'test' ):
2896+ osd_daemon = DaemonDescription (daemon_type = 'osd' , daemon_id = '1' , hostname = 'test' )
2897+ _get_daemons_by_type .return_value = [osd_daemon ]
2898+
2899+ mgr_service = ServiceSpec ('mgr' , placement = PlacementSpec (hosts = ['test' ]))
2900+
2901+ with with_service (cephadm_module , mgr_service ):
2902+ with pytest .raises (OrchestratorError ) as e :
2903+ cephadm_module .set_osd_spec ('mgr' , ['1' ])
2904+
2905+ assert "Service 'mgr' is not an OSD service (type: mgr). OSDs can only be assigned to OSD service specs." in str (e .value )
2906+
2907+ # Move osd.1 to osd.foo service
2908+ spec = DriveGroupSpec (
2909+ service_id = 'foo' ,
2910+ placement = PlacementSpec (
2911+ host_pattern = '*' ,
2912+ ),
2913+ data_devices = DeviceSelection (
2914+ all = True
2915+ )
2916+ )
2917+ c = cephadm_module .apply ([spec ])
2918+ assert wait (cephadm_module , c ) == ['Scheduled osd.foo update...' ]
2919+
2920+ cephadm_module .set_osd_spec ('osd.foo' , ['1' ])
0 commit comments