Esempio n. 1
0
def test_rename_index_works(sm_config, test_db):
    es_config = sm_config['elasticsearch']
    alias = es_config['index']
    yin_index = f'{alias}-yin'
    yang_index = f'{alias}-yang'
    es_man = ESIndexManager(es_config)
    # Clean up previous test runs if needed
    es_man.delete_index(alias)
    es_man.delete_index(yin_index)
    es_man.delete_index(yang_index)

    try:
        es_man.create_index(yin_index)
        es_man.remap_alias(yin_index, alias=alias)

        assert es_man.exists_index(alias)
        assert es_man.exists_index(yin_index)
        assert not es_man.exists_index(yang_index)

        es_man.create_index(yang_index)
        es_man.remap_alias(yang_index, alias=alias)

        assert es_man.exists_index(alias)
        assert es_man.exists_index(yang_index)
        assert es_man.exists_index(yin_index)
    finally:
        es_man.delete_index(alias)
        es_man.delete_index(yin_index)
        es_man.delete_index(yang_index)
Esempio n. 2
0
def test_rename_index_works(test_db, sm_config):
    es_config = sm_config['elasticsearch']
    alias = es_config['index']
    es_man = ESIndexManager(es_config)

    es_man.create_index('{}-yin'.format(alias))
    es_man.remap_alias('{}-yin'.format(alias), alias=alias)

    assert es_man.exists_index(alias)
    assert es_man.exists_index('{}-yin'.format(alias))
    assert not es_man.exists_index('{}-yang'.format(alias))

    es_man.create_index('{}-yang'.format(alias))
    es_man.remap_alias('{}-yang'.format(alias), alias=alias)

    assert es_man.exists_index(alias)
    assert es_man.exists_index('{}-yang'.format(alias))
    assert not es_man.exists_index('{}-yin'.format(alias))
def test_rename_index_works(test_db, sm_config):
    es_config = sm_config['elasticsearch']
    alias = es_config['index']
    es_man = ESIndexManager(es_config)

    es_man.create_index('{}-yin'.format(alias))
    es_man.remap_alias('{}-yin'.format(alias), alias=alias)

    assert es_man.exists_index(alias)
    assert es_man.exists_index('{}-yin'.format(alias))
    assert not es_man.exists_index('{}-yang'.format(alias))

    es_man.create_index('{}-yang'.format(alias))
    es_man.remap_alias('{}-yang'.format(alias), alias=alias)

    assert es_man.exists_index(alias)
    assert es_man.exists_index('{}-yang'.format(alias))
    assert not es_man.exists_index('{}-yin'.format(alias))