From c7f7f753a2f344aa0ce626632e6a8afea9d4696c Mon Sep 17 00:00:00 2001 From: Vladimir Filonov Date: Thu, 14 Nov 2024 15:22:58 +0400 Subject: [PATCH] Fix creation of lastalerts in setup_stress_alerts_no_elastic --- tests/conftest.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 134db6a0f..bc603b3e4 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -334,6 +334,7 @@ def is_elastic_responsive(host, port, user, password): basic_auth=(user, password), ) info = elastic_client._client.info() + print("Elastic still up now") return True if info else False except Exception: print("Elastic still not up") @@ -550,7 +551,16 @@ def _setup_stress_alerts_no_elastic(num_alerts): last_alerts = [] for alert in alerts: - set_last_alert(SINGLE_TENANT_UUID, alert, db_session) + last_alerts.append( + LastAlert( + tenant_id=SINGLE_TENANT_UUID, + fingerprint=alert.fingerprint, + timestamp=alert.timestamp, + alert_id=alert.id, + ) + ) + db_session.add_all(last_alerts) + db_session.commit() return alerts @@ -564,8 +574,10 @@ def setup_stress_alerts( num_alerts = request.param.get( "num_alerts", 1000 ) # Default to 1000 alerts if not specified - + start_time = time.time() alerts = setup_stress_alerts_no_elastic(num_alerts) + print(f"time taken to setup {num_alerts} alerts with db: ", time.time() - start_time) + # add all to elasticsearch alerts_dto = convert_db_alerts_to_dto_alerts(alerts) elastic_client.index_alerts(alerts_dto)