Exemple #1
0
def assert_rm_daemon(cephadm: CephadmOrchestrator, prefix, host):
    dds: List[DaemonDescription] = wait(cephadm, cephadm.list_daemons(host=host))
    d_names = [dd.name() for dd in dds if dd.name().startswith(prefix)]
    assert d_names
    c = cephadm.remove_daemons(d_names)
    [out] = wait(cephadm, c)
    match_glob(out, f"Removed {d_names}* from host '{host}'")
Exemple #2
0
def assert_rm_daemon(cephadm: CephadmOrchestrator, prefix, host):
    dds: List[DaemonDescription] = wait(cephadm, cephadm.list_daemons(host=host))
    d_names = [dd.name() for dd in dds if dd.name().startswith(prefix)]
    assert d_names
    # there should only be one daemon (if not match_glob will throw mismatch)
    assert len(d_names) == 1

    c = cephadm.remove_daemons(d_names)
    [out] = wait(cephadm, c)
    # picking the 1st element is needed, rather than passing the list when the daemon
    # name contains '-' char. If not, the '-' is treated as a range i.e. cephadm-exporter
    # is treated like a m-e range which is invalid. rbd-mirror (d-m) and node-exporter (e-e)
    # are valid, so pass without incident! Also, match_gob acts on strings anyway!
    match_glob(out, f"Removed {d_names[0]}* from host '{host}'")
Exemple #3
0
    def test_apply_save(self, spec: ServiceSpec, meth, cephadm_module: CephadmOrchestrator):
        with with_host(cephadm_module, 'test'):
            if not spec.placement:
                spec.placement = PlacementSpec(hosts=['test'], count=1)
            c = meth(cephadm_module, spec)
            assert wait(cephadm_module, c) == f'Scheduled {spec.service_name()} update...'
            assert [d.spec for d in wait(cephadm_module, cephadm_module.describe_service())] == [spec]

            cephadm_module._apply_all_services()

            dds = wait(cephadm_module, cephadm_module.list_daemons())
            for dd in dds:
                assert dd.service_name() == spec.service_name()


            assert_rm_service(cephadm_module, spec.service_name())
Exemple #4
0
def with_service(cephadm_module: CephadmOrchestrator, spec: ServiceSpec, meth, host: str):
    if spec.placement.is_empty():
        spec.placement = PlacementSpec(hosts=[host], count=1)
    c = meth(cephadm_module, spec)
    assert wait(cephadm_module, c) == f'Scheduled {spec.service_name()} update...'
    specs = [d.spec for d in wait(cephadm_module, cephadm_module.describe_service())]
    assert spec in specs

    cephadm_module._apply_all_services()

    dds = wait(cephadm_module, cephadm_module.list_daemons())
    names = {dd.service_name() for dd in dds}
    assert spec.service_name() in names

    yield

    assert_rm_service(cephadm_module, spec.service_name())
Exemple #5
0
    def test_daemon_action(self, _ceph_get, cephadm_module: CephadmOrchestrator):
        cephadm_module.service_cache_timeout = 10
        with with_host(cephadm_module, 'test'):
            c = cephadm_module.list_daemons(refresh=True)
            wait(cephadm_module, c)
            c = cephadm_module.daemon_action('redeploy', 'rgw', 'myrgw.foobar')
            assert wait(cephadm_module, c) == ["Deployed rgw.myrgw.foobar on host 'test'"]

            for what in ('start', 'stop', 'restart'):
                c = cephadm_module.daemon_action(what, 'rgw', 'myrgw.foobar')
                assert wait(cephadm_module, c) == [what + " rgw.myrgw.foobar from host 'test'"]

            now = datetime.datetime.utcnow().strftime(CEPH_DATEFMT)
            _ceph_get.return_value = {'modified': now}

            cephadm_module._check_daemons()

            assert_rm_daemon(cephadm_module, 'rgw.myrgw.foobar', 'test')
Exemple #6
0
    def test_daemon_action(self, cephadm_module: CephadmOrchestrator):

        cephadm_module.service_cache_timeout = 10
        with with_host(cephadm_module, 'test'):
            c = cephadm_module.list_daemons(refresh=True)
            wait(cephadm_module, c)
            assert len(c.result) == 1
            c = cephadm_module.daemon_action('redeploy', 'rgw', 'myrgw.foobar')
            assert wait(cephadm_module, c) == ["Deployed rgw.myrgw.foobar on host 'test'"]

            for what in ('start', 'stop', 'restart'):
                c = cephadm_module.daemon_action(what, 'rgw', 'myrgw.foobar')
                assert wait(cephadm_module, c) == [what + " rgw.myrgw.foobar from host 'test'"]

            # Make sure, _check_daemons does a redeploy due to monmap change:
            cephadm_module._store['_ceph_get/mon_map'] = {
                'modified': datetime.datetime.utcnow().strftime(CEPH_DATEFMT),
                'fsid': 'foobar',
            }
            cephadm_module.notify('mon_map', None)

            cephadm_module._check_daemons()

            assert_rm_daemon(cephadm_module, 'rgw.myrgw.foobar', 'test')
Exemple #7
0
 def test_list_daemons(self, cephadm_module: CephadmOrchestrator):
     cephadm_module.service_cache_timeout = 10
     with with_host(cephadm_module, 'test'):
         CephadmServe(cephadm_module)._refresh_host_daemons('test')
         c = cephadm_module.list_daemons()
         assert wait(cephadm_module, c)[0].name() == 'rgw.myrgw.foobar'