Skip to content
Snippets Groups Projects
Commit 1435b658 authored by Sören Henning's avatar Sören Henning
Browse files

Fix passing metadata

parent 5499c7d5
No related branches found
No related tags found
1 merge request!242Draft: Feature/346 use strimzi kafka
Pipeline #6022 passed
...@@ -57,15 +57,14 @@ def check_result(result, operator: str, threshold): ...@@ -57,15 +57,14 @@ def check_result(result, operator: str, threshold):
@app.post("/",response_model=bool) @app.post("/",response_model=bool)
async def check_slo(request: Request): async def check_slo(request: Request):
data = json.loads(await request.body()) data = json.loads(await request.body())
logger.info('Received request with metadata: %s', data['metadata'])
warmup = int(data['metadata']['warmup']) warmup = int(data['metadata']['warmup'])
query_aggregation = get_aggr_func(data['metadata']['queryAggregation']) query_aggregation = get_aggr_func(data['metadata']['queryAggregation'])
rep_aggregation = get_aggr_func(data['metadata']['repetitionAggregation']) rep_aggregation = get_aggr_func(data['metadata']['repetitionAggregation'])
operator = data['metadata']['operator'] operator = data['metadata']['operator']
threshold = int(data['metadata']['threshold']) threshold = int(data['metadata']['threshold'])
for r in data["results"]:
aggr_query(r[0]["values"], warmup, query_aggregation)
query_results = [aggr_query(r[0]["values"], warmup, query_aggregation) for r in data["results"]] query_results = [aggr_query(r[0]["values"], warmup, query_aggregation) for r in data["results"]]
result = pd.DataFrame(query_results).aggregate(rep_aggregation).at[0] result = pd.DataFrame(query_results).aggregate(rep_aggregation).at[0]
return check_result(result, operator, threshold) return check_result(result, operator, threshold)
......
...@@ -50,12 +50,11 @@ class SloCheckerFactory { ...@@ -50,12 +50,11 @@ class SloCheckerFactory {
// TODO validate property contents // TODO validate property contents
metadata = mapOf( metadata = mapOf(
"warmup" to (properties["warmup"]?.toInt() ?: throw IllegalArgumentException("warmup expected")), "warmup" to (properties["warmup"]?.toInt() ?: throw IllegalArgumentException("warmup expected")),
"queryAggregation" to (properties["warmup"]?.toInt() "queryAggregation" to (properties["queryAggregation"]
?: throw IllegalArgumentException("queryAggregation expected")), ?: throw IllegalArgumentException("queryAggregation expected")),
"repetitionAggregation" to (properties["warmup"]?.toInt() "repetitionAggregation" to (properties["repetitionAggregation"]
?: throw IllegalArgumentException("repetitionAggregation expected")), ?: throw IllegalArgumentException("repetitionAggregation expected")),
"operator" to (properties["warmup"]?.toInt() "operator" to (properties["operator"] ?: throw IllegalArgumentException("operator expected")),
?: throw IllegalArgumentException("operator expected")),
"threshold" to (properties["threshold"]?.toInt() "threshold" to (properties["threshold"]?.toInt()
?: throw IllegalArgumentException("threshold expected")) ?: throw IllegalArgumentException("threshold expected"))
) )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment