From 0a3b290722e147493cf5859a8f6df151ffae9f7a Mon Sep 17 00:00:00 2001 From: Sean Mackrory Date: Wed, 20 Nov 2024 11:58:59 -0700 Subject: [PATCH] ci: perf test results will be stored as CircleCI artifacts only --- performance/daist/daist/models/db.py | 36 ---------- .../daist/daist/rest_api/test_locust.py | 7 -- performance/daist/uts/models/test_db.py | 65 ------------------- 3 files changed, 108 deletions(-) delete mode 100644 performance/daist/uts/models/test_db.py diff --git a/performance/daist/daist/models/db.py b/performance/daist/daist/models/db.py index b860edb18e7..84ac9caee52 100644 --- a/performance/daist/daist/models/db.py +++ b/performance/daist/daist/models/db.py @@ -31,42 +31,6 @@ def get_filename(self, tags: Optional[Iterable[str]] = None, fmt: Format.type_ = Format.TXT) -> Path: return super().get_filename(fmt, tags=tags) - def upload(self): - conn = psycopg2.connect(f'dbname={self.DB_NAME} ' - f'user={environment.perf_result_db_user} ' - f'password={environment.secrets.perf_result_db_pass} ' - f'host={environment.perf_result_db_host}') - - for run_row in self._perf_test_runs_table: - with conn.cursor() as cursor: - query = sql.SQL(f'INSERT INTO {self.Table.PERF_TEST_RUNS} (commit, branch) ' - 'VALUES ({commit}, {branch}) ' - 'RETURNING id;').format( - commit=sql.Literal(run_row.commit), - branch=sql.Literal(run_row.branch)) - cursor.execute(query) - run_id = cursor.fetchone()[0] - - for row in self._perf_tests_table: - query = sql.SQL( - f'INSERT INTO {self.Table.PERF_TESTS} ' - '(test_name, run_id, avg, min, med, max, p90, p95, passes, fails) ' - 'VALUES ({test_name}, {run_id}, {avg}, {min}, {med}, {max}, {p90}, ' - '{p95}, {passes}, {fails});').format( - test_name=sql.Literal(row.test_name), - run_id=sql.Literal(run_id), - avg=sql.Literal(row.avg), - min=sql.Literal(row.min), - med=sql.Literal(row.med), - max=sql.Literal(row.max), - p90=sql.Literal(row.p90), - p95=sql.Literal(row.p95), - passes=sql.Literal(row.passes), - fails=sql.Literal(row.fails), - ) - cursor.execute(query) - conn.commit() - def __str__(self): return '\n'.join([f'{self._perf_test_runs_table.get_qualname()}:', str(self._perf_test_runs_table), diff --git a/performance/daist/daist/rest_api/test_locust.py b/performance/daist/daist/rest_api/test_locust.py index ec6455591a8..f8f17aafa0d 100644 --- a/performance/daist/daist/rest_api/test_locust.py +++ b/performance/daist/daist/rest_api/test_locust.py @@ -83,13 +83,6 @@ def _save_to_results(self, locust_stats: List[StatsEntry], file_meta = FileMeta() file_meta.test_id = self.id() session.result.add_obj(perf_tests_run, perf_tests_run.get_filename(tags=(tag,)), file_meta) - if environment.secrets.perf_result_db_pass is not None: - logger.info(f'Uploading {self.id()} results.') - try: - perf_tests_run.upload() - except Exception as err: - logger.exception(f'Failed to upload {self.id()} results.') - raise err def test(self): self._runner.start(self._USERS, spawn_rate=self._USERS) diff --git a/performance/daist/uts/models/test_db.py b/performance/daist/uts/models/test_db.py deleted file mode 100644 index 743f1a6b0dc..00000000000 --- a/performance/daist/uts/models/test_db.py +++ /dev/null @@ -1,65 +0,0 @@ -import unittest -from pathlib import Path -from unittest import TestCase - -import daist -from daist.models.db import PerfTestRun, PerfTestRunsTable -from daist.models.environment import environment -from daist.models.locust import LocustStatsList - -PATH_TO_SAMPLES = Path(__file__).parent / 'samples' -PATH_TO_SAMPLE_INPUT = (PATH_TO_SAMPLES / - 'LocustStatsList-LocustTest.test_concurrent_read_only_users.pkl') -PATH_TO_REFERENCE_OUTPUT = (PATH_TO_SAMPLES / - 'PerfTestRun-LocustTest.test_concurrent_read_only_users.txt') - - -class TestPerfTestDb(TestCase): - _saved_branch = None - _saved_commit = None - _saved_version = None - - @classmethod - def setUpClass(cls): - super().setUpClass() - cls._saved_branch = environment.git_branch - cls._saved_commit = environment.git_commit - cls._saved_version = daist.__version__ - - environment[environment.Key.GIT_BRANCH] = 'None' - environment[environment.Key.GIT_COMMIT] = 'None' - daist.__version__ = None - - @classmethod - def tearDownClass(cls): - super().tearDownClass() - environment[environment.Key.GIT_BRANCH] = cls._saved_branch - environment[environment.Key.GIT_COMMIT] = cls._saved_commit - daist.__version__ = cls._saved_version - - def test_open(self): - locust_stats = LocustStatsList.open(PATH_TO_SAMPLE_INPUT) - perf_tests_run = PerfTestRun(locust_stats, time=0) - with open(PATH_TO_REFERENCE_OUTPUT, 'r') as inf: - self.assertEqual(inf.read(), str(perf_tests_run)) - - def test_table(self): - exp = """\ -+--------+--------+----------------------+ -| Commit | Branch | Time | -+--------+--------+----------------------+ -| None | None | 1970-01-01T00:00:00Z | -+--------+--------+----------------------+""" - table = PerfTestRunsTable() - table.add_row(time=0) - self.assertEqual(exp, str(table)) - - -@unittest.skipIf(True, 'For development/debugging purposes.') -class TestUpload(TestCase): - _saved_daist_db_pass = None - - def test(self): - locust_stats = LocustStatsList.open(PATH_TO_SAMPLE_INPUT) - run = PerfTestRun(locust_stats, time=0) - run.upload()