diff --git a/.github/workflows/unit_test.yml b/.github/workflows/unit_test.yml index 574dddf..75cf786 100644 --- a/.github/workflows/unit_test.yml +++ b/.github/workflows/unit_test.yml @@ -1,6 +1,6 @@ name: Run pytest on Pull Request -on: [push,pull_request] +on: [push] jobs: test: diff --git a/fmatch/matcher.py b/fmatch/matcher.py index 69814a5..84cb069 100644 --- a/fmatch/matcher.py +++ b/fmatch/matcher.py @@ -195,14 +195,14 @@ def burner_results(self, uuid, uuids, index): runs = [item['_source'] for item in result["hits"]["hits"]] return runs - def burner_cpu_results(self, uuids, namespace, index): - """ kube burner CPU aggregated results for a namespace + def burner_metric_query(self, uuids, namespace, index, metricName): + """ burner_metric_query will query for specific metricName data. + Args: - uuids (_type_): _description_ - namespace (_type_): _description_ - index (_type_): _description_ - Returns: - _type_: _description_ + uuids (list): List of uuids + namespace (str): namespace we are interested in + index (str): ES/OS Index to query from + metricName (str): metricName defined in kube-burner metrics """ ids = "\" OR uuid: \"".join(uuids) query = { @@ -239,7 +239,7 @@ def burner_cpu_results(self, uuids, namespace, index): "query_string": { "query": ( f'( uuid: \"{ids}\" )' - f' AND metricName: "containerCPU"' + f' AND metricName: {metricName}' f' AND labels.namespace.keyword: {namespace}' ) } @@ -252,6 +252,28 @@ def burner_cpu_results(self, uuids, namespace, index): data = self.parse_burner_cpu_results(runs) return data + def burner_cpu_results(self, uuids, namespace, index): + """ kube burner CPU aggregated results for a namespace + Args: + uuids (_type_): _description_ + namespace (_type_): _description_ + index (_type_): _description_ + Returns: + _type_: _description_ + """ + return self.burner_metric_query(uuids, namespace, index, "containerCPU") + + def burner_mem_results(self, uuids, namespace, index): + """ kube burner memory aggregated results for a namespace + Args: + uuids (_type_): _description_ + namespace (_type_): _description_ + index (_type_): _description_ + Returns: + _type_: _description_ + """ + return self.burner_metric_query(uuids, namespace, index, "containerMemory") + def parse_burner_cpu_results(self, data: dict): """ parse out CPU data from kube-burner query Args: diff --git a/fmatch/test_fmatch.py b/fmatch/test_fmatch.py index f181959..07f6682 100644 --- a/fmatch/test_fmatch.py +++ b/fmatch/test_fmatch.py @@ -37,6 +37,8 @@ ids, "openshift-ovn-kubernetes", "ripsaw-kube-burner*") etcd_cpu = match.burner_cpu_results( ids, "openshift-etcd", "ripsaw-kube-burner*") +ovn_mem = match.burner_mem_results( + ids, "openshift-ovn-kubernetes", "ripsaw-kube-burner*") podl_df = match.convert_to_df( podl, columns=['uuid', 'timestamp', 'quantileName', 'P99'])