Stress test: ability to use multiple dsns (projects)

This commit is contained in:
Klaas van Schelven
2024-06-27 09:52:10 +02:00
parent e9ed7835c1
commit c5df10e9cf
2 changed files with 8 additions and 4 deletions

View File

@@ -204,6 +204,7 @@ def evict_for_max_events(project, timestamp, stored_event_count=None, include_ne
if max_total_irrelevance < -1: # < -1: as in `evict_for_irrelevance`
if not include_never_evict:
# everything that remains is 'never_evict'. 'never say never' and evict those as a last measure
return evict_for_max_events(project, timestamp, stored_event_count - evicted, True)
raise Exception("No more effective eviction possible but target not reached") # "should not happen"

View File

@@ -1,3 +1,4 @@
import random
import io
import uuid
import brotli
@@ -19,7 +20,7 @@ class Command(BaseCommand):
parser.add_argument("--threads", type=int, default=1)
parser.add_argument("--requests", type=int, default=1)
parser.add_argument("--dsn")
parser.add_argument("--dsn", nargs="+", action="extend")
parser.add_argument("--fresh-id", action="store_true")
parser.add_argument("--fresh-timestamp", action="store_true")
parser.add_argument("--compress", action="store", choices=["gzip", "deflate", "br"], default=None)
@@ -35,7 +36,7 @@ class Command(BaseCommand):
# usually not what we want to do our stress-tests for. (if this assumption is still true later in 2024, we can
# just remove the non-envelope mode support completely.)
assert use_envelope, "Only envelope mode is supported"
dsn = options['dsn']
dsns = options['dsn']
json_filename = options["filename"]
with open(json_filename) as f:
@@ -56,7 +57,7 @@ class Command(BaseCommand):
t0 = time.time()
for i in range(options["threads"]):
t = threading.Thread(target=self.loop_send_to_server, args=(
dsn, options, use_envelope, compress, prepared_data[i], timings[i]))
dsns, options, use_envelope, compress, prepared_data[i], timings[i]))
t.start()
print("waiting for threads to finish")
@@ -107,8 +108,10 @@ class Command(BaseCommand):
return compressed_data
@staticmethod
def loop_send_to_server(dsn, options, use_envelope, compress, compressed_datas, timings):
def loop_send_to_server(dsns, options, use_envelope, compress, compressed_datas, timings):
for compressed_data in compressed_datas.values():
dsn = random.choice(dsns)
t0 = time.time()
Command.send_to_server(dsn, options, use_envelope, compress, compressed_data)
taken = time.time() - t0