tests: авточистка очередей до и после прогона (мусор не копится)
This commit is contained in:
@@ -324,6 +324,26 @@ def worker(wid):
|
|||||||
time.sleep(random.uniform(0.01, 0.05))
|
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():
|
def progress_printer():
|
||||||
while not stop.is_set():
|
while not stop.is_set():
|
||||||
stop.wait(30)
|
stop.wait(30)
|
||||||
@@ -341,6 +361,9 @@ def main():
|
|||||||
print("Нужны AWS_ACCESS_KEY_ID и AWS_SECRET_ACCESS_KEY")
|
print("Нужны AWS_ACCESS_KEY_ID и AWS_SECRET_ACCESS_KEY")
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
# Чистим стартовый мусор прошлых прогонов.
|
||||||
|
cleanup_all_queues(make_client())
|
||||||
|
|
||||||
threads = [threading.Thread(target=worker, args=(i,), daemon=True) for i in range(WORKERS)]
|
threads = [threading.Thread(target=worker, args=(i,), daemon=True) for i in range(WORKERS)]
|
||||||
hthread = threading.Thread(target=health_monitor, daemon=True)
|
hthread = threading.Thread(target=health_monitor, daemon=True)
|
||||||
pthread = threading.Thread(target=progress_printer, daemon=True)
|
pthread = threading.Thread(target=progress_printer, daemon=True)
|
||||||
@@ -354,6 +377,9 @@ def main():
|
|||||||
for t in threads:
|
for t in threads:
|
||||||
t.join(timeout=30)
|
t.join(timeout=30)
|
||||||
|
|
||||||
|
# Чистим остатки: очереди от циклов, упавших на сбоях.
|
||||||
|
cleanup_all_queues(make_client())
|
||||||
|
|
||||||
el = int(time.time() - start_ts)
|
el = int(time.time() - start_ts)
|
||||||
with stats_lock:
|
with stats_lock:
|
||||||
s = dict(stats)
|
s = dict(stats)
|
||||||
|
|||||||
Reference in New Issue
Block a user