Skip to content

Commit

Permalink
improvement(perf-simple-query): send results to argus
Browse files Browse the repository at this point in the history
Sending perf-simple-query results to Argus.

refs: scylladb/qa-tasks#1244
  • Loading branch information
soyacz authored and fruch committed Aug 28, 2024
1 parent 145a4d6 commit dcd890a
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
12 changes: 10 additions & 2 deletions microbenchmarking_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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", [])
)
26 changes: 26 additions & 0 deletions sdcm/argus_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
4 changes: 3 additions & 1 deletion sdcm/utils/microbenchmarking/perf_simple_query_reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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

0 comments on commit dcd890a

Please sign in to comment.