Пример #1
0
 def get_dst(name):
     dst_index = build_index_name(name)
     mapping_fp = current_search.mappings[name]
     dst_index_aliases = find_aliases_for_index(
         name, current_search.aliases) or []
     return dict(
         index=dst_index if dry_run else name,
         aliases=dst_index_aliases,
         mapping=mapping_fp,
         doc_type=extract_doctype_from_mapping(mapping_fp),
     )
Пример #2
0
def test_remap_two_indexex(inspire_app, cli):
    indexes_before = set(current_search.client.indices.get("*").keys())
    current_search._current_suffix = f"-{random.getrandbits(64)}"
    result = cli.invoke([
        "index",
        "remap",
        "--index",
        "records-data",
        "--index",
        "records-authors",
        "--yes-i-know",
    ])
    current_search.flush_and_refresh("*")

    assert result.exit_code == 0
    indexes_after = set(current_search.client.indices.get("*").keys())
    difference = sorted(list(indexes_after - indexes_before))

    assert len(difference) == 2
    assert build_index_name("records-authors") == difference[0]
    assert build_index_name("records-data") == difference[1]

    current_search._current_suffix = None
Пример #3
0
def test_remap_index_which_is_missing_in_es_but_ignore_checks(
        inspire_app, cli, override_config):
    config = {"SEARCH_INDEX_PREFIX": f"{random.getrandbits(64)}-"}
    with override_config(**config):
        indexes_before = set(current_search.client.indices.get("*").keys())
        result = cli.invoke([
            "index",
            "remap",
            "--index",
            "records-authors",
            "--yes-i-know",
            "--ignore-checks",
        ])
    current_search.flush_and_refresh("*")

    assert result.exit_code == 0
    indexes_after = set(current_search.client.indices.get("*").keys())
    difference = sorted(indexes_after - indexes_before)
    assert len(difference) == 1
    with override_config(**config):
        assert build_index_name("records-authors") == difference[0]

    list(current_search.delete("*"))
    current_search._current_suffix = None
Пример #4
0
def _build_percolator_index_name(index):
    """Build percolator index name."""
    suffix = "-percolators"
    if ES_VERSION[0] < 7:
        suffix = ""
    return build_index_name(index, suffix=suffix, app=current_app)
Пример #5
0
def test_build_suffix_index_name(app, parts, prefix, suffix, expected):
    app.config.update(SEARCH_INDEX_PREFIX=prefix)
    assert build_index_name(parts, suffix=suffix, app=app) == expected