diff --git a/tests/load_test.py b/tests/load_test.py index 66f16a3..4027b15 100644 --- a/tests/load_test.py +++ b/tests/load_test.py @@ -324,6 +324,26 @@ def worker(wid): time.sleep(random.uniform(0.01, 0.05)) +def cleanup_all_queues(sqs): + """Удаляет ВСЕ очереди тенанта. + Вызывается ПЕРЕД прогоном (стартовый мусор прошлых прогонов) и ПОСЛЕ + (остатки от циклов, упавших на сбое — без этого копятся очереди и + тест упирается в лимит MaxQueues тенанта).""" + try: + urls = sqs.list_queues().get("QueueUrls", []) + except Exception: + urls = [] + deleted = 0 + for u in urls: + try: + sqs.delete_queue(QueueUrl=u) + deleted += 1 + except Exception: + pass + if deleted: + print(f"cleanup: удалено очередей {deleted}", flush=True) + + def progress_printer(): while not stop.is_set(): stop.wait(30) @@ -341,6 +361,9 @@ def main(): print("Нужны AWS_ACCESS_KEY_ID и AWS_SECRET_ACCESS_KEY") return 1 + # Чистим стартовый мусор прошлых прогонов. + cleanup_all_queues(make_client()) + threads = [threading.Thread(target=worker, args=(i,), daemon=True) for i in range(WORKERS)] hthread = threading.Thread(target=health_monitor, daemon=True) pthread = threading.Thread(target=progress_printer, daemon=True) @@ -354,6 +377,9 @@ def main(): for t in threads: t.join(timeout=30) + # Чистим остатки: очереди от циклов, упавших на сбоях. + cleanup_all_queues(make_client()) + el = int(time.time() - start_ts) with stats_lock: s = dict(stats)