Skip to content

Commit

Permalink
string and not list bug fix (#19)
Browse files Browse the repository at this point in the history
Signed-off-by: Shashank Reddy Boyapally <sboyapal@redhat.com>
  • Loading branch information
shashank-boyapally authored Feb 19, 2024
1 parent ff516c7 commit 0e6f6e7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
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

0 comments on commit 0e6f6e7

Please sign in to comment.