コード例 #1
0
def status_for_index(index_name):
    try:
        res = es.indices.status(index=index_name, human=True)
        info = es.indices.get(index_name)
    except TransportError as e:
        return _get_an_error_message(e), e.status_code

    return convert_es_status(index_name, res, info), 200
コード例 #2
0
def status_for_index(index_name):
    try:
        res = es.indices.status(index=index_name, human=True)
        info = es.indices.get(index_name)
    except TransportError as e:
        return _get_an_error_message(e), e.status_code

    return convert_es_status(index_name, res, info), 200
def test_should_build_status_response_from_es_response():
    res = convert_es_status("g-cloud", STATUS_JSON, INDEX_INFO_JSON)
    assert_equal(res, {
        "num_docs": 10380,
        "primary_size": "16.8mb",
        "mapping_version": "2015-09-28",
        "aliases": ["galias"],
    })
def test_should_build_status_response_from_es_response():
    res = convert_es_status("g-cloud", STATUS_JSON, INDEX_INFO_JSON)
    assert_equal(
        res, {
            "num_docs": 10380,
            "primary_size": "16.8mb",
            "mapping_version": "2015-09-28",
            "aliases": ["galias"],
        })
コード例 #5
0
def status_for_index(index_name):
    try:
        with logged_duration_for_external_request('es'):
            res = es.indices.stats(index=index_name, human=True)
        with logged_duration_for_external_request('es'):
            info = es.indices.get(index_name)
    except TransportError as e:
        return _get_an_error_message(e), e.status_code

    return convert_es_status(index_name, res, info), 200
def test_should_build_status_response_from_es_response_with_empty_index():
    status_json_with_no_docs = dict(STATUS_JSON)
    del status_json_with_no_docs["indices"]["g-cloud"]["docs"]
    res = convert_es_status("g-cloud", status_json_with_no_docs)
    assert_equal(res, {
        "aliases": [],
        "mapping_version": None,
        "num_docs": None,
        "primary_size": "16.8mb",
    })
コード例 #7
0
def test_should_build_status_response_from_es_response():
    res = convert_es_status("g-cloud-12", STATS_JSON, SERVICES_INDEX_INFO_JSON)
    assert res == {
        "num_docs": 36311,
        "primary_size": "73.7mb",
        "mapping_version": "17.13.1",
        "mapping_generated_from_framework": "g-cloud-12",
        "max_result_window": "50000",
        "aliases": [],
    }
def test_should_build_status_response_from_es_response_with_empty_index():
    status_json_with_no_docs = dict(STATUS_JSON)
    del status_json_with_no_docs["indices"]["g-cloud"]["docs"]
    res = convert_es_status("g-cloud", status_json_with_no_docs)
    assert_equal(
        res, {
            "aliases": [],
            "mapping_version": None,
            "num_docs": None,
            "primary_size": "16.8mb",
        })
コード例 #9
0
def test_should_build_status_response_from_briefs_es_response():
    res = convert_es_status("briefs-digital-outcomes-and-specialists",
                            STATS_JSON, BRIEFS_INDEX_INFO_JSON)
    assert res == {
        "num_docs": 1192,
        "primary_size": "2mb",
        "mapping_version": "11.0.0",
        "mapping_generated_from_framework":
        "digital-outcomes-and-specialists-2",
        "max_result_window": "10000",
        "aliases": [],
    }
コード例 #10
0
def test_should_build_status_response_from_es_response_with_empty_index():
    stats_json_with_no_docs = dict(STATS_JSON)
    del stats_json_with_no_docs["indices"]["g-cloud-12"]["primaries"]["docs"]
    res = convert_es_status("g-cloud-12", stats_json_with_no_docs)
    assert res == {
        "aliases": [],
        "mapping_version": None,
        "mapping_generated_from_framework": None,
        "max_result_window": None,
        "num_docs": None,
        "primary_size": "73.7mb",
    }
def test_should_build_status_response_from_es_response_with_empty_index():
    status_json_with_no_docs = dict(STATUS_JSON)
    del status_json_with_no_docs["indices"]["g-cloud"]["docs"]
    res = convert_es_status(status_json_with_no_docs, "g-cloud")
    assert_equal("num_docs" in res, False)
    assert_equal(res["primary_size"], "16.8mb")
def test_should_build_status_response_from_es_response():
    res = convert_es_status(STATUS_JSON, "g-cloud")
    assert_equal(res["num_docs"], 10380)
    assert_equal(res["primary_size"], "16.8mb")