Skip to content

Commit

Permalink
Minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
rdettai committed Apr 3, 2024
1 parent f102222 commit 75c7bd8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
17 changes: 12 additions & 5 deletions distribution/lambda/cdk/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ def test_mock_data_endpoints():
app.MOCK_DATA_STACK_NAME, mock_data_stack.API_GATEWAY_EXPORT_NAME
)

def req(method, path, body=None):
def req(method, path, body=None, expected_status=200):
conn = http.client.HTTPSConnection(urlparse(apigw_url).netloc)
conn.request(
method,
Expand All @@ -426,12 +426,12 @@ def req(method, path, body=None):
)
response = conn.getresponse()
print(f"{method} {path}")
if response.status != 200:
print(f"[{response.status}] => {response.read().decode()}")
headers = {k: v for (k, v) in response.getheaders()}
body = _decompress_if_gzip(response.read(), headers)
if response.status != expected_status:
print(f"[{response.status}] => {body}")
exit(1)
else:
headers = {k: v for (k, v) in response.getheaders()}
body = _decompress_if_gzip(response.read(), headers)
print(f"[{response.status}] => {json.dumps(json.loads(body))[0:100]}")

req("GET", f"/api/v1/{mock_sales_index_id}/search?query=animal")
Expand All @@ -447,3 +447,10 @@ def req(method, path, body=None):
'{"query":{"bool":{"must":[{"range":{"quantity":{"gt":5}}}]}},"size":10}',
)
req("GET", f"/api/v1/_elastic/{mock_sales_index_id}/_field_caps?fields=quantity")
# expected errors
req(
"GET",
f"/api/v1/_elastic/{mock_sales_index_id}/_search?query=animal",
expected_status=400,
)
req("GET", f"/api/v1/_elastic/_search?q=animal", expected_status=501)
1 change: 0 additions & 1 deletion distribution/lambda/cdk/stacks/examples/mock_data_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ def __init__(
search_resource = api.root.add_resource("v1").add_resource("{proxy+}")
search_resource.add_method("POST", searcher_integration, api_key_required=True)
search_resource.add_method("GET", searcher_integration, api_key_required=True)
search_resource.add_method("PUT", searcher_integration, api_key_required=True)
# Change the deployment id (api-deployment-x) each time the API changes,
# otherwise changes are not deployed.
api_deployment = aws_apigateway.Deployment(self, "api-deployment-1", api=api)
Expand Down
4 changes: 1 addition & 3 deletions quickwit/quickwit-lambda/src/searcher/warp_lambda.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,7 @@ where
v.insert(content_len.into());
}

parts.uri = warp::hyper::Uri::from_str(uri.as_str())
.map_err(|e| e)
.unwrap();
parts.uri = warp::hyper::Uri::from_str(uri.as_str()).unwrap();
let warp_request = WarpRequest::from_parts(parts, body);

// Call warp service with warp request, save future
Expand Down

0 comments on commit 75c7bd8

Please sign in to comment.