Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

string and not list bug fix #19

Merged
merged 1 commit into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions fmatch/matcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,10 @@ def get_uuid_by_metadata(self, meta, index=None):
must=[
Q(
"match", **{field: str(value)}
) # if isinstance(value, str) else Q('terms', **{field: value})
) if isinstance(value, str) else Q('match', **{field: value})
for field, value in meta.items()
if field not in "ocpVersion benchmark"
]
+ ([Q("match", **{"benchmark.keyword": meta["benchmark"]})]
if "benchmark" in meta else []),
if field not in "ocpVersion"
],
filter=[
Q("wildcard", ocpVersion=f"{version}*"),
Q("match", jobStatus="success"),
Expand Down Expand Up @@ -155,10 +153,10 @@ def getResults(self, uuid: str, uuids: list, index_str: str, metrics: dict):
metric_queries = []
not_queries = [
~Q("match", **{not_item_key: not_item_value})
for not_item_key, not_item_value in metrics["not"].items()
for not_item_key, not_item_value in metrics.get("not",{}).items()
]
metric_queries = [
Q("match", **{metric_key: f'"{metric_value}"'})
Q("match", **{metric_key: metric_value})
for metric_key, metric_value in metrics.items()
if metric_key not in ["name", "metric_of_interest", "not"]
]
Expand Down Expand Up @@ -194,7 +192,7 @@ def get_agg_metric_query(self, uuids, index, metrics):
for not_item_key, not_item_value in not_item.items()
]
metric_queries = [
Q("match", **{metric_key: f'"{metric_value}"'})
Q("match", **{metric_key: metric_value})
for metric_key, metric_value in metrics.items()
if metric_key not in ["name", "metric_of_interest", "not", "agg"]
]
Expand Down
4 changes: 2 additions & 2 deletions fmatch/test_fmatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
meta["jobStatus"] = "success"
meta["ocpVersion"] = "4.15"
meta["networkType"] = "OVNKubernetes"
meta["benchmark"] = "cluster-density-v2"
meta["benchmark.keyword"] = "cluster-density-v2"
# meta['encrypted'] = "true"
# meta['ipsec'] = "false"
# meta['fips'] = "false"
Expand All @@ -44,7 +44,7 @@
kapi_metrics = {
"name": "apiserverCPU",
"metricName": "containerCPU",
"labels.namespace": "openshift-kube-apiserver",
"labels.namespace.keyword": "openshift-kube-apiserver",
"metric_of_interest": "value",
"agg": {"value": "cpu", "agg_type": "avg"},
}
Expand Down
Loading