Skip to content

Commit

Permalink
Added rest api integration test.
Browse files Browse the repository at this point in the history
  • Loading branch information
fulmicoton committed Jun 13, 2024
1 parent 5e8128b commit 291d582
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ impl From<SplitMetadata> for ElasticsearchCatIndexResponse {
#[derive(Debug, Clone, Default, Serialize)]
pub struct ElasticsearchResolveIndexResponse {
pub indices: Vec<ElasticsearchResolveIndexEntryResponse>,
// Unused for the moment.
pub aliases: Vec<serde_json::Value>,
pub data_streams: Vec<serde_json::Value>,
}

#[derive(Debug, Clone, Default, Serialize)]
Expand Down
7 changes: 5 additions & 2 deletions quickwit/quickwit-serve/src/elasticsearch_api/rest_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -576,9 +576,12 @@ async fn es_compat_resolve_index(
.map(|metadata| metadata.into())
.collect();

indices.sort_by(|a, b| a.name.cmp(&b.name));
indices.sort_by(|left, right| left.name.cmp(&right.name));

Ok(ElasticsearchResolveIndexResponse { indices })
Ok(ElasticsearchResolveIndexResponse {
indices,
..Default::default()
})
}

async fn es_compat_index_field_capabilities(
Expand Down
5 changes: 4 additions & 1 deletion quickwit/rest-api-tests/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,15 @@ def run_request_step(method, step, previous_result):
kvargs["data"] = "\n".join([json.dumps(doc) for doc in ndjson]) + "\n"
kvargs.setdefault("headers")["Content-Type"] = "application/json"
expected_status_code = step.get("status_code", 200)
debug = step.get("debug", False)
num_retries = step.get("num_retries", 0)
run_req = lambda : method_req(url, **kvargs)
r = run_request_with_retry(run_req, expected_status_code, num_retries)
expected_resp = step.get("expected", None)
json_resp = r.json()
if debug:
print(expected_status_code)
print(json_resp)
if expected_resp is not None:
try:
check_result(json_resp, expected_resp, context_path="")
Expand Down Expand Up @@ -353,4 +357,3 @@ def main():
sys.exit(0)
else:
sys.exit(1)

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
method: GET
endpoint: /_resolve/index/gh*
expected:
indices:
- name: gharchive
attributes:
- open
aliases: []
data_streams: []

0 comments on commit 291d582

Please sign in to comment.