Beispiel #1
0
    def test_remove_osds(self, cephadm_module):
        with with_host(cephadm_module, 'test'):
            CephadmServe(cephadm_module)._refresh_host_daemons('test')
            c = cephadm_module.list_daemons()
            wait(cephadm_module, c)

            c = cephadm_module.remove_daemons(['osd.0'])
            out = wait(cephadm_module, c)
            assert out == ["Removed osd.0 from host 'test'"]

            cephadm_module.to_remove_osds.enqueue(
                OSD(osd_id=0,
                    replace=False,
                    force=False,
                    hostname='test',
                    fullname='osd.0',
                    process_started_at=datetime_now(),
                    remove_util=cephadm_module.to_remove_osds.rm_util))
            cephadm_module.to_remove_osds.process_removal_queue()
            assert cephadm_module.to_remove_osds == OSDRemovalQueue(
                cephadm_module)

            c = cephadm_module.remove_osds_status()
            out = wait(cephadm_module, c)
            assert out == []
Beispiel #2
0
 def test_ready_to_drain_osds(self, max_osd_draining_count, draining_osds,
                              idling_osds, ok_to_stop, expected):
     with with_cephadm_module(
         {'max_osd_draining_count': max_osd_draining_count}) as m:
         with mock.patch(
                 "cephadm.services.osd.OSDRemovalQueue.draining_osds",
                 return_value=draining_osds):
             with mock.patch(
                     "cephadm.services.osd.OSDRemovalQueue.idling_osds",
                     return_value=idling_osds):
                 with mock.patch(
                         "cephadm.services.osd.RemoveUtil.ok_to_stop",
                         side_effect=ok_to_stop):
                     removal_queue = OSDRemovalQueue(m)
                     assert len(
                         removal_queue._ready_to_drain_osds()) == expected
Beispiel #3
0
    def test_load(self, cephadm_module, rm_util):
        data = json.dumps([{
            "osd_id": 35,
            "started": True,
            "draining": True,
            "stopped": False,
            "replace": False,
            "force": False,
            "nodename": "node2",
            "drain_started_at": "2020-09-14T11:41:53.960463",
            "drain_stopped_at": None,
            "drain_done_at": None,
            "process_started_at": "2020-09-14T11:41:52.245832"
        }])
        cephadm_module.set_store('osd_remove_queue', data)
        cephadm_module.to_remove_osds.load_from_store()

        expected = OSDRemovalQueue(cephadm_module)
        expected.osds.add(OSD(osd_id=35, remove_util=rm_util, draining=True))
        assert cephadm_module.to_remove_osds == expected
Beispiel #4
0
 def test_rm(self, exist, stop, osd_obj):
     q = OSDRemovalQueue(mock.Mock())
     q.osds.add(osd_obj)
     q.rm(osd_obj)
     osd_obj.stop.assert_called_once()
Beispiel #5
0
 def test_rm_raise(self, exist, stop, osd_obj):
     q = OSDRemovalQueue(mock.Mock())
     with pytest.raises(KeyError):
         q.rm(osd_obj)
         osd_obj.stop.assert_called_once()
Beispiel #6
0
 def test_enqueue(self, exist, start, osd_obj):
     q = OSDRemovalQueue(mock.Mock())
     q.enqueue(osd_obj)
     osd_obj.start.assert_called_once()
Beispiel #7
0
 def test_queue_size(self, osd_obj):
     q = OSDRemovalQueue(mock.Mock())
     assert q.queue_size() == 0
     q.osds.add(osd_obj)
     assert q.queue_size() == 1