From dcd890ab951e8d173d6d63169ad5b1d8b974ae76 Mon Sep 17 00:00:00 2001 From: Lukasz Sojka Date: Tue, 27 Aug 2024 09:53:47 +0200 Subject: [PATCH] improvement(perf-simple-query): send results to argus Sending perf-simple-query results to Argus. refs: https://github.com/scylladb/qa-tasks/issues/1244 --- microbenchmarking_test.py | 12 +++++++-- sdcm/argus_results.py | 26 +++++++++++++++++++ .../perf_simple_query_reporter.py | 4 ++- 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/microbenchmarking_test.py b/microbenchmarking_test.py index c7ff512056..8ff586d1aa 100644 --- a/microbenchmarking_test.py +++ b/microbenchmarking_test.py @@ -11,6 +11,8 @@ # # Copyright (c) 2023 ScyllaDB import json + +from sdcm.argus_results import send_perf_simple_query_result_to_argus from sdcm.tester import ClusterTester, teardown_on_exception, log_run_info from sdcm.utils.microbenchmarking.perf_simple_query_reporter import PerfSimpleQueryAnalyzer @@ -28,12 +30,18 @@ def test_perf_simple_query(self): result = self.db_cluster.nodes[0].remoter.run( "scylla perf-simple-query --json-result=perf-simple-query-result.txt --smp 1 -m 1G") if result.ok: + regression_report = {} output = self.db_cluster.nodes[0].remoter.run("cat perf-simple-query-result.txt").stdout + results = json.loads(output) self.create_test_stats( - specific_tested_stats={"perf_simple_query_result": json.loads(output)}, + specific_tested_stats={"perf_simple_query_result": results}, doc_id_with_timestamp=True) if self.create_stats: is_gce = self.params.get('cluster_backend') == 'gce' - PerfSimpleQueryAnalyzer(self._test_index, self._es_doc_type).check_regression( + regression_report = PerfSimpleQueryAnalyzer(self._test_index, self._es_doc_type).check_regression( self._test_id, is_gce=is_gce, extra_jobs_to_compare=self.params.get('perf_extra_jobs_to_compare')) + send_perf_simple_query_result_to_argus(self.test_config.argus_client(), + results, + regression_report.get("scylla_date_results_table", []) + ) diff --git a/sdcm/argus_results.py b/sdcm/argus_results.py index 2d67b27702..cb3c2db2a4 100644 --- a/sdcm/argus_results.py +++ b/sdcm/argus_results.py @@ -10,6 +10,7 @@ # See LICENSE for more details. # # Copyright (c) 2024 ScyllaDB +import json from argus.client import ArgusClient from argus.client.generic_result import GenericResultTable, ColumnMetadata, ResultType, Status @@ -114,3 +115,28 @@ def send_result_to_argus(argus_client: ArgusClient, workload: str, name: str, de result_table.add_result(column=f"{interval}ms", row=f"Cycle #{cycle}", value=value, status=Status.PASS) argus_client.submit_results(result_table) + + +def send_perf_simple_query_result_to_argus(argus_client: ArgusClient, result: dict, previous_results: list = None): + stats = result["stats"] + workload = result["test_properties"]["type"] + parameters = result["parameters"] + + class PerfSimpleQueryResult(GenericResultTable): + class Meta: + name = f"{workload} - Perf Simple Query" + description = json.dumps(parameters) + Columns = [ColumnMetadata(name=param, unit="", type=ResultType.FLOAT) for param in stats.keys()] + + def _get_status_based_on_previous_results(metric: str): + if previous_results is None: + return Status.PASS + if all((result.get(f"is_{metric}_within_limits", True) for result in previous_results)): + return Status.PASS + else: + return Status.ERROR + + result_table = PerfSimpleQueryResult() + for key, value in stats.items(): + result_table.add_result(column=key, row="#1", value=value, status=_get_status_based_on_previous_results(key)) + argus_client.submit_results(result_table) diff --git a/sdcm/utils/microbenchmarking/perf_simple_query_reporter.py b/sdcm/utils/microbenchmarking/perf_simple_query_reporter.py index 9cfd4975d0..8c22ed1cd9 100644 --- a/sdcm/utils/microbenchmarking/perf_simple_query_reporter.py +++ b/sdcm/utils/microbenchmarking/perf_simple_query_reporter.py @@ -47,7 +47,8 @@ def get_sorted_results_as_list(results): keys.sort(reverse=True) return [results[key] for key in keys] - def check_regression(self, test_id, mad_deviation_limit=0.02, regression_limit=0.05, is_gce=False, extra_jobs_to_compare=None): # pylint: disable=too-many-locals,too-many-statements # noqa: PLR0914 + def check_regression(self, test_id, mad_deviation_limit=0.02, regression_limit=0.05, is_gce=False, extra_jobs_to_compare=None # pylint: disable=too-many-locals,too-many-statements # noqa: PLR0914 + ) -> dict: doc = self.get_test_by_id(test_id) if not doc: self.log.error('Cannot find test by id: {}!'.format(test_id)) @@ -150,3 +151,4 @@ def make_table_line_for_render(data): file_path = os.path.join(TestConfig.logdir(), 'email_data.json') with open(file_path, 'w', encoding="utf-8") as file: json.dump(for_render, file) + return for_render