From 3075080c894e124892ec6beabf96a0ddb4a3d5a5 Mon Sep 17 00:00:00 2001 From: l0lawrence Date: Thu, 6 Apr 2023 09:04:40 -0700 Subject: [PATCH 01/30] stress updates --- .../azure-servicebus/stress/.helmignore | 6 + .../azure-servicebus/stress/Chart.lock | 4 +- .../azure-servicebus/stress/Chart.yaml | 4 +- .../azure-servicebus/stress/Dockerfile | 3 +- .../charts/stress-test-addons-0.2.0.tgz | Bin 0 -> 7612 bytes .../stress/scenarios-matrix.yaml | 50 ++- .../stress/scripts/dev_requirements.txt | 6 +- .../azure-servicebus/stress/scripts/logger.py | 55 +-- .../stress/scripts/process_monitor.py | 2 +- .../stress/scripts/stress_runner.py | 18 +- .../stress/scripts/stress_test_base.py | 70 +-- .../stress/scripts/test_stress_queues.py | 292 ++++++++----- .../scripts/test_stress_queues_async.py | 411 ++++++++++++++++++ .../stress/templates/testjob.yaml | 141 +++++- .../stress/test-resources.bicep | 120 +++++ 15 files changed, 1000 insertions(+), 182 deletions(-) create mode 100644 sdk/servicebus/azure-servicebus/stress/.helmignore create mode 100644 sdk/servicebus/azure-servicebus/stress/charts/stress-test-addons-0.2.0.tgz create mode 100644 sdk/servicebus/azure-servicebus/stress/scripts/test_stress_queues_async.py create mode 100644 sdk/servicebus/azure-servicebus/stress/test-resources.bicep diff --git a/sdk/servicebus/azure-servicebus/stress/.helmignore b/sdk/servicebus/azure-servicebus/stress/.helmignore new file mode 100644 index 000000000000..61334a0f31ee --- /dev/null +++ b/sdk/servicebus/azure-servicebus/stress/.helmignore @@ -0,0 +1,6 @@ +stress +stress.exe +.env +Dockerfile +*.py +*.txt \ No newline at end of file diff --git a/sdk/servicebus/azure-servicebus/stress/Chart.lock b/sdk/servicebus/azure-servicebus/stress/Chart.lock index f5c554172d82..15552cf4dea9 100644 --- a/sdk/servicebus/azure-servicebus/stress/Chart.lock +++ b/sdk/servicebus/azure-servicebus/stress/Chart.lock @@ -2,5 +2,5 @@ dependencies: - name: stress-test-addons repository: https://stresstestcharts.blob.core.windows.net/helm/ version: 0.2.0 -digest: sha256:59fff3930e78c4ca9f9c0120433c7695d31db63f36ac61d50abcc91b1f1835a0 -generated: "2022-11-19T01:30:02.403917379Z" +digest: sha256:53cbe4c0fed047f6c611523bd34181b21a310e7a3a21cb14f649bb09e4a77648 +generated: "2023-03-14T09:57:20.6731895-07:00" diff --git a/sdk/servicebus/azure-servicebus/stress/Chart.yaml b/sdk/servicebus/azure-servicebus/stress/Chart.yaml index 4f3a42c27ffd..297f89f751d2 100644 --- a/sdk/servicebus/azure-servicebus/stress/Chart.yaml +++ b/sdk/servicebus/azure-servicebus/stress/Chart.yaml @@ -1,5 +1,5 @@ apiVersion: v2 -name: python-servicebus-stress-test +name: py-sb-stress-test description: python service bus stress test. version: 0.1.2 appVersion: v0.2 @@ -9,5 +9,5 @@ annotations: dependencies: - name: stress-test-addons - version: ~0.2.0 + version: 0.2.0 repository: https://stresstestcharts.blob.core.windows.net/helm/ diff --git a/sdk/servicebus/azure-servicebus/stress/Dockerfile b/sdk/servicebus/azure-servicebus/stress/Dockerfile index 61c94647f7ee..ef74c1e9f04c 100644 --- a/sdk/servicebus/azure-servicebus/stress/Dockerfile +++ b/sdk/servicebus/azure-servicebus/stress/Dockerfile @@ -2,10 +2,11 @@ # public OSS users should simply leave this argument blank or ignore its presence entirely ARG REGISTRY="mcr.microsoft.com/mirror/docker/library/" FROM ${REGISTRY}python:3.8-slim-buster +RUN apt-get -y update && apt-get -y install git WORKDIR /app COPY ./scripts /app/stress/scripts WORKDIR /app/stress/scripts -RUN pip3 install -r dev_requirements.txt +RUN pip install -r dev_requirements.txt diff --git a/sdk/servicebus/azure-servicebus/stress/charts/stress-test-addons-0.2.0.tgz b/sdk/servicebus/azure-servicebus/stress/charts/stress-test-addons-0.2.0.tgz new file mode 100644 index 0000000000000000000000000000000000000000..f0d473ee59a269bdaa17b7c7d4e8a088dd05818d GIT binary patch literal 7612 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 literal 0 HcmV?d00001 diff --git a/sdk/servicebus/azure-servicebus/stress/scenarios-matrix.yaml b/sdk/servicebus/azure-servicebus/stress/scenarios-matrix.yaml index 82879e81ed7c..015c143ff022 100644 --- a/sdk/servicebus/azure-servicebus/stress/scenarios-matrix.yaml +++ b/sdk/servicebus/azure-servicebus/stress/scenarios-matrix.yaml @@ -1,7 +1,51 @@ -displayNames: matrix: image: - Dockerfile scenarios: - sbStress: - testTarget: servicebus \ No newline at end of file + # queue: + # testTarget: queue + aqueue: + testTarget: aqueue + # queuepull: + # testTarget: queuepull + aqueuepull: + testTarget: aqueuepull + # batch: + # testTarget: batch + # abatch: + # testTarget: abatch + # queuew: + # testTarget: queuew + aqueuew: + testTarget: aqueuew + # queuepullw: + # testTarget: queuepullw + aqueuepullw: + testTarget: aqueuepullw + # batchw: + # testTarget: batchw + # abatchw: + # testTarget: abatchw + # queueuamqp: + # testTarget: queueuamqp + aqueueuamqp: + testTarget: aqueueuamqp + + # sendreceiveslow: + # testTarget: send_receive_slow + # receivedelete: + # testTarget: receive_delete + # unsettledmessage: + # testTarget: unsettled_message + # largebatch: + # testTarget: large_batch + # pullreceivetimeout: + # testTarget: pull_receive_timeout + # longrenew: + # testTarget: long_renew + # queuepeek: + # testTarget: queue_peek + # queueclosereopen: + # testTarget: queue_close_reopen + # droppedmessages: + # testTarget: dropped_messages \ No newline at end of file diff --git a/sdk/servicebus/azure-servicebus/stress/scripts/dev_requirements.txt b/sdk/servicebus/azure-servicebus/stress/scripts/dev_requirements.txt index d7928a902bf4..a3935756a1ee 100644 --- a/sdk/servicebus/azure-servicebus/stress/scripts/dev_requirements.txt +++ b/sdk/servicebus/azure-servicebus/stress/scripts/dev_requirements.txt @@ -1,6 +1,8 @@ -aiohttp>=3.0; python_version >= '3.5' +aiohttp>=3.0 opencensus-ext-azure psutil pytest -azure-servicebus +git+https://github.com/Azure/azure-sdk-for-python.git@feature/servicebus/pyproto#subdirectory=sdk/servicebus/azure-servicebus&egg=azure-servicebus python-dotenv +websocket-client +uamqp==1.6.3 \ No newline at end of file diff --git a/sdk/servicebus/azure-servicebus/stress/scripts/logger.py b/sdk/servicebus/azure-servicebus/stress/scripts/logger.py index 0875c2e8a7e0..fc0685181d7f 100644 --- a/sdk/servicebus/azure-servicebus/stress/scripts/logger.py +++ b/sdk/servicebus/azure-servicebus/stress/scripts/logger.py @@ -38,11 +38,11 @@ def get_base_logger(log_filename, logger_name, level=logging.INFO, print_console def get_logger(log_filename, logger_name, level=logging.INFO, print_console=False, log_format=None, log_file_max_bytes=20 * 1024 * 1024, log_file_backup_count=3): stress_logger = logging.getLogger(logger_name) - stress_logger.setLevel(level) - eventhub_logger = logging.getLogger("azure.eventhub") - eventhub_logger.setLevel(level) - uamqp_logger = logging.getLogger("uamqp") - uamqp_logger.setLevel(level) + stress_logger.setLevel(logging.WARNING) + eventhub_logger = logging.getLogger("azure.servicebus") + eventhub_logger.setLevel(logging.INFO) + uamqp_logger = logging.getLogger("azure.servicebus._pyamqp.aio.connection") + uamqp_logger.setLevel(logging.DEBUG) formatter = log_format or logging.Formatter('%(asctime)s %(name)-12s %(levelname)-8s %(message)s') if print_console: @@ -56,27 +56,30 @@ def get_logger(log_filename, logger_name, level=logging.INFO, print_console=Fals stress_logger.addHandler(console_handler) if log_filename: - eventhub_file_handler = RotatingFileHandler( - "eventhub_" + log_filename, - maxBytes=log_file_max_bytes, - backupCount=log_file_backup_count - ) - uamqp_file_handler = RotatingFileHandler( - "uamqp_" + log_filename, - maxBytes=log_file_max_bytes, - backupCount=log_file_backup_count - ) - stress_file_handler = RotatingFileHandler( - log_filename, - maxBytes=log_file_max_bytes, - backupCount=log_file_backup_count - ) - eventhub_file_handler.setFormatter(formatter) - uamqp_file_handler.setFormatter(formatter) - stress_file_handler.setFormatter(formatter) - eventhub_logger.addHandler(eventhub_file_handler) - uamqp_logger.addHandler(uamqp_file_handler) - stress_logger.addHandler(stress_file_handler) + try: + eventhub_file_handler = RotatingFileHandler( + log_filename, + maxBytes=log_file_max_bytes, + backupCount=log_file_backup_count + ) + # uamqp_file_handler = RotatingFileHandler( + # "uamqp_" + log_filename, + # maxBytes=log_file_max_bytes, + # backupCount=log_file_backup_count + # ) + stress_file_handler = RotatingFileHandler( + log_filename, + maxBytes=log_file_max_bytes, + backupCount=log_file_backup_count + ) + eventhub_file_handler.setFormatter(formatter) + # uamqp_file_handler.setFormatter(formatter) + stress_file_handler.setFormatter(formatter) + eventhub_logger.addHandler(eventhub_file_handler) + # uamqp_logger.addHandler(uamqp_file_handler) + stress_logger.addHandler(stress_file_handler) + except: + pass return stress_logger diff --git a/sdk/servicebus/azure-servicebus/stress/scripts/process_monitor.py b/sdk/servicebus/azure-servicebus/stress/scripts/process_monitor.py index b59610a4331f..8e8178c5f56b 100644 --- a/sdk/servicebus/azure-servicebus/stress/scripts/process_monitor.py +++ b/sdk/servicebus/azure-servicebus/stress/scripts/process_monitor.py @@ -12,7 +12,7 @@ class ProcessMonitor: - def __init__(self, log_filename, logger_name, log_interval=5.0, print_console=False, + def __init__(self, log_filename, logger_name, log_interval=30.0, print_console=False, process_id=None, **kwargs): """ Process Monitor monitors the CPU usage, memory usage of a specific process. diff --git a/sdk/servicebus/azure-servicebus/stress/scripts/stress_runner.py b/sdk/servicebus/azure-servicebus/stress/scripts/stress_runner.py index c1fe97d8bca1..fac7c5c8ab0e 100644 --- a/sdk/servicebus/azure-servicebus/stress/scripts/stress_runner.py +++ b/sdk/servicebus/azure-servicebus/stress/scripts/stress_runner.py @@ -6,8 +6,10 @@ import os import asyncio +import configparser from argparse import ArgumentParser from datetime import timedelta +from dotenv import load_dotenv from azure.servicebus import ServiceBusClient from azure.servicebus.aio import ServiceBusClient as AsyncServiceBusClient @@ -16,9 +18,7 @@ from app_insights_metric import AzureMonitorMetric from process_monitor import ProcessMonitor -CONNECTION_STR = os.environ['SERVICE_BUS_CONNECTION_STR'] -QUEUE_NAME = os.environ["SERVICE_BUS_QUEUE_NAME"] - +ENV_FILE = os.environ.get("ENV_FILE") def sync_send(client, args): azure_monitor_metric = AzureMonitorMetric("Sync ServiceBus Sender") @@ -53,6 +53,9 @@ async def async_send(client, args): def sync_receive(client, args): + config = configparser.ConfigParser() + config.read("./stress_runner.cfg") + azure_monitor_metric = AzureMonitorMetric("Sync ServiceBus Receiver") process_monitor = ProcessMonitor("monitor_receiver_stress_sync.log", "receiver_stress_sync") stress_test = StressTestRunner( @@ -87,10 +90,14 @@ async def async_receive(client, args): if __name__ == '__main__': + load_dotenv(dotenv_path=ENV_FILE, override=True) parser = ArgumentParser() + parser.add_argument("--conn_str", help="ServiceBus connection string", + default=os.environ.get('SERVICE_BUS_CONNECTION_STR')) + parser.add_argument("--queue_name", help="The queue name.", default=os.environ.get("SERVICE_BUS_QUEUE_NAME")) parser.add_argument("--method", type=str) parser.add_argument("--duration", type=int, default=259200) - parser.add_argument("--logging-enable", action="store_true") + parser.add_argument("--logging_enable", action="store_true") parser.add_argument("--send-batch-size", type=int, default=100) parser.add_argument("--message-size", type=int, default=100) @@ -102,6 +109,9 @@ async def async_receive(client, args): args, _ = parser.parse_known_args() loop = asyncio.get_event_loop() + CONNECTION_STR = args.conn_str + QUEUE_NAME= args.queue_name + if args.method.startswith("sync"): sb_client = ServiceBusClient.from_connection_string(conn_str=CONNECTION_STR) else: diff --git a/sdk/servicebus/azure-servicebus/stress/scripts/stress_test_base.py b/sdk/servicebus/azure-servicebus/stress/scripts/stress_test_base.py index a815659f46e4..bc255fb9025c 100644 --- a/sdk/servicebus/azure-servicebus/stress/scripts/stress_test_base.py +++ b/sdk/servicebus/azure-servicebus/stress/scripts/stress_test_base.py @@ -9,6 +9,7 @@ from datetime import datetime, timedelta import concurrent import sys +import os import asyncio import logging @@ -20,15 +21,16 @@ from azure.servicebus import ServiceBusMessage, ServiceBusMessageBatch from azure.servicebus.exceptions import MessageAlreadySettled - -import logger +from logger import get_logger from app_insights_metric import AbstractMonitorMetric from process_monitor import ProcessMonitor -LOGFILE_NAME = "stress-test.log" +# LOGFILE_NAME = os.environ.get("DEBUG_SHARE") + "/success" +LOGFILE_NAME = None PRINT_CONSOLE = True -_logger = logger.get_base_logger(LOGFILE_NAME, "stress_test", logging.WARN) +# _logger = logger.get_base_logger(LOGFILE_NAME, "stress_test", logging.INFO) +_logger = get_logger(None, "stress_test", level=logging.INFO, print_console=PRINT_CONSOLE) class ReceiveType: @@ -44,11 +46,11 @@ def __init__(self): self.time_elapsed = None self.state_by_sender = {} self.state_by_receiver = {} + self.actual_size = 0 def __repr__(self): return str(vars(self)) - class StressTestRunnerState(object): """Per-runner state, e.g. if you spawn 3 senders each will have this as their state object, which will be coalesced at completion into StressTestResults""" @@ -58,17 +60,19 @@ def __init__(self): self.total_received = 0 self.cpu_percent = None self.memory_bytes = None + self.memory_percent = None self.timestamp = None self.exceptions = [] def __repr__(self): return str(vars(self)) - def populate_process_stats(self): + def populate_process_stats(self, monitor): self.timestamp = datetime.utcnow() try: self.cpu_percent = psutil.cpu_percent() - self.memory_bytes = psutil.virtual_memory().total + self.memory_bytes = psutil.virtual_memory().percent + self.memory_percent = monitor.memory_usage_percent except NameError: return # psutil was not installed, fall back to simply not capturing these stats. @@ -81,15 +85,16 @@ def __init__( self, senders, receivers, + admin_client, duration=timedelta(minutes=15), receive_type=ReceiveType.push, send_batch_size=None, message_size=10, max_wait_time=10, - send_delay=0.01, + send_delay=1.0, receive_delay=0, should_complete_messages=True, - max_message_count=1, + max_message_count=10, send_session_id=None, fail_on_exception=True, azure_monitor_metric=None, @@ -97,6 +102,7 @@ def __init__( ): self.senders = senders self.receivers = receivers + self.admin_client = admin_client self.duration = duration self.receive_type = receive_type self.message_size = message_size @@ -123,7 +129,7 @@ def __init__( self._duration_override = None for arg in sys.argv: - if arg.startswith("--stress_test_duration_seconds="): + if arg.startswith("--duration="): self._duration_override = timedelta(seconds=int(arg.split("=")[1])) self._should_stop = False @@ -161,10 +167,10 @@ def pre_process_message_body(self, payload): """Allows user to transform message payload before sending it.""" return payload - def _schedule_interval_logger(self, end_time, description="", interval_seconds=30): + def _schedule_interval_logger(self, end_time, description="", interval_seconds=5): def _do_interval_logging(): if end_time > datetime.utcnow() and not self._should_stop: - self._state.populate_process_stats() + self._state.populate_process_stats(self.process_monitor) _logger.critical( "{} RECURRENT STATUS: {}".format(description, self._state) ) @@ -194,10 +200,8 @@ def _construct_message(self): def _send(self, sender, end_time): self._schedule_interval_logger(end_time, "Sender " + str(self)) try: - _logger.info("STARTING SENDER") with sender: while end_time > datetime.utcnow() and not self._should_stop: - _logger.info("SENDING") try: message = self._construct_message() if self.send_session_id != None: @@ -213,6 +217,7 @@ def _send(self, sender, end_time): else: self._state.total_sent += 1 # send single message self.on_send(self._state, message, sender) + except Exception as e: _logger.exception("Exception during send: {}".format(e)) self.azure_monitor_metric.record_error(e) @@ -228,11 +233,12 @@ def _send(self, sender, end_time): raise def _receive(self, receiver, end_time): + # _logger = get_logger(LOGFILE_NAME, "stress_test_receive", level=logging.INFO, print_console=PRINT_CONSOLE) self._schedule_interval_logger(end_time, "Receiver " + str(self)) + delivery_ids = [] try: with receiver: while end_time > datetime.utcnow() and not self._should_stop: - _logger.info("RECEIVE LOOP") try: if self.receive_type == ReceiveType.pull: batch = receiver.receive_messages( @@ -240,9 +246,8 @@ def _receive(self, receiver, end_time): max_wait_time=self.max_wait_time, ) elif self.receive_type == ReceiveType.push: - batch = receiver._get_streaming_message_iter( - max_wait_time=self.max_wait_time - ) + receiver.max_wait_time = self.max_wait_time + batch = receiver else: batch = [] @@ -253,6 +258,7 @@ def _receive(self, receiver, end_time): receiver.complete_message(message) except MessageAlreadySettled: # It may have been settled in the plugin callback. pass + self._state.total_received += 1 # TODO: Get EnqueuedTimeUtc out of broker properties and calculate latency. Should properties/app properties be mostly None? if end_time <= datetime.utcnow(): @@ -270,7 +276,7 @@ def _receive(self, receiver, end_time): self.azure_monitor_metric.record_error(e) if self.fail_on_exception: raise - self._state.timestamp = datetime.utcnow() + self._state.timestamp = datetime.utcnow() return self._state except Exception as e: self.azure_monitor_metric.record_error(e) @@ -279,8 +285,12 @@ def _receive(self, receiver, end_time): raise def run(self): + start_time = datetime.utcnow() + if isinstance(self.duration, int): + self.duration = timedelta(seconds=self.duration) end_time = start_time + (self._duration_override or self.duration) + with self.process_monitor: with concurrent.futures.ThreadPoolExecutor(max_workers=4) as proc_pool: _logger.info("STARTING PROC POOL") @@ -301,6 +311,7 @@ def run(self): if each in receivers: result.state_by_receiver[each] = each.result() # TODO: do as_completed in one batch to provide a way to short-circuit on failure. + result.state_by_sender = { s: f.result() for s, f in zip( @@ -313,7 +324,7 @@ def run(self): self.receivers, concurrent.futures.as_completed(receivers) ) } - _logger.info("got receiver results") + _logger.info("Got receiver results") result.total_sent = sum( [r.total_sent for r in result.state_by_sender.values()] ) @@ -331,11 +342,12 @@ def __init__( senders, receivers, duration=timedelta(minutes=15), + admin_client=None, receive_type=ReceiveType.push, send_batch_size=None, message_size=10, max_wait_time=10, - send_delay=0.01, + send_delay=1.00, receive_delay=0, should_complete_messages=True, max_message_count=1, @@ -348,6 +360,7 @@ def __init__( senders, receivers, duration=duration, + admin_client=admin_client, receive_type=receive_type, send_batch_size=send_batch_size, message_size=message_size, @@ -368,7 +381,6 @@ async def _send_async(self, sender, end_time): _logger.info("STARTING SENDER") async with sender: while end_time > datetime.utcnow() and not self._should_stop: - _logger.info("SENDING") try: message = self._construct_message() if self.send_session_id != None: @@ -379,7 +391,10 @@ async def _send_async(self, sender, end_time): self.process_monitor.cpu_usage_percent, self.process_monitor.memory_usage_percent, ) - self._state.total_sent += self.send_batch_size + if self.send_batch_size: + self._state.total_sent += self.send_batch_size + else: + self._state.total_sent += 1 self.on_send(self._state, message, sender) except Exception as e: _logger.exception("Exception during send: {}".format(e)) @@ -396,6 +411,7 @@ async def _send_async(self, sender, end_time): raise async def _receive_handle_message(self, message, receiver, end_time): + # _logger = get_logger(LOGFILE_NAME, "stress_test_receive", level=logging.INFO, print_console=PRINT_CONSOLE) self.on_receive(self._state, message, receiver) try: if self.should_complete_messages: @@ -428,10 +444,8 @@ async def _receive_async(self, receiver, end_time): message, receiver, end_time ) elif self.receive_type == ReceiveType.push: - batch = receiver._get_streaming_message_iter( - max_wait_time=self.max_wait_time - ) - async for message in batch: + receiver.max_wait_time = self.max_wait_time + async for message in receiver: if end_time <= datetime.utcnow(): break await self._receive_handle_message( @@ -454,6 +468,8 @@ async def _receive_async(self, receiver, end_time): async def run_async(self): start_time = datetime.utcnow() + if isinstance(self.duration, int): + self.duration = timedelta(seconds=self.duration) end_time = start_time + (self._duration_override or self.duration) send_tasks = [ asyncio.create_task(self._send_async(sender, end_time)) diff --git a/sdk/servicebus/azure-servicebus/stress/scripts/test_stress_queues.py b/sdk/servicebus/azure-servicebus/stress/scripts/test_stress_queues.py index 838bafbc4625..037049d3c2f2 100644 --- a/sdk/servicebus/azure-servicebus/stress/scripts/test_stress_queues.py +++ b/sdk/servicebus/azure-servicebus/stress/scripts/test_stress_queues.py @@ -1,4 +1,4 @@ -#------------------------------------------------------------------------- +#------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. @@ -9,113 +9,118 @@ import os import pytest from dotenv import load_dotenv -#from argparse import ArgumentParser +from argparse import ArgumentParser -from azure.servicebus import AutoLockRenewer, ServiceBusClient +from azure.servicebus import AutoLockRenewer, ServiceBusClient, TransportType +from azure.servicebus.management import ServiceBusAdministrationClient from azure.servicebus._common.constants import ServiceBusReceiveMode from app_insights_metric import AzureMonitorMetric from stress_test_base import StressTestRunner, ReceiveType ENV_FILE = os.environ.get('ENV_FILE') -load_dotenv(dotenv_path=ENV_FILE, override=True) -LOGGING_ENABLE = False -SERVICE_BUS_CONNECTION_STR = os.environ.get('SERVICE_BUS_CONNECTION_STR') -SERVICEBUS_QUEUE_NAME = os.environ.get('SERVICE_BUS_QUEUE_NAME') -@pytest.mark.liveTest -@pytest.mark.live_test_only -def test_stress_queue_send_and_receive(): +def test_stress_queue_send_and_receive(args): sb_client = ServiceBusClient.from_connection_string( - SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE) + SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) stress_test = StressTestRunner(senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME)], - duration=timedelta(seconds=60), + admin_client = sb_admin_client, + duration=args.duration, azure_monitor_metric=AzureMonitorMetric("test_stress_queue_send_and_receive") ) result = stress_test.run() - assert(result.total_sent > 0) - assert(result.total_received > 0) + print(f"Total send {result.total_sent}") + print(f"Total received {result.total_received}") - -@pytest.mark.liveTest -@pytest.mark.live_test_only -def test_stress_queue_send_and_pull_receive(): +def test_stress_queue_send_and_pull_receive(args): sb_client = ServiceBusClient.from_connection_string( - SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE) + SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) stress_test = StressTestRunner(senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME)], + admin_client = sb_admin_client, receive_type=ReceiveType.pull, - duration=timedelta(seconds=60), + duration=args.duration, azure_monitor_metric=AzureMonitorMetric("test_stress_queue_send_and_pull_receive") ) result = stress_test.run() - assert(result.total_sent > 0) - assert(result.total_received > 0) - + print(f"Total send {result.total_sent}") + print(f"Total received {result.total_received}") -@pytest.mark.liveTest -@pytest.mark.live_test_only -def test_stress_queue_batch_send_and_receive(): +def test_stress_queue_batch_send_and_receive(args): sb_client = ServiceBusClient.from_connection_string( - SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE) + SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) stress_test = StressTestRunner(senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], - receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME)], - duration=timedelta(seconds=60), + receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME, prefetch_count=5)], + admin_client = sb_admin_client, + duration=args.duration, send_batch_size=5, azure_monitor_metric=AzureMonitorMetric("test_stress_queue_batch_send_and_receive") ) result = stress_test.run() - assert(result.total_sent > 0) - assert(result.total_received > 0) + print(f"Total send {result.total_sent}") + print(f"Total received {result.total_received}") + +def test_stress_queue_batch_send_and_receive_u(args): + sb_client = ServiceBusClient.from_connection_string( + SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) + uamqp_sb_client = ServiceBusClient.from_connection_string( + SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE, uamqp_transport=True) + stress_test = StressTestRunner(senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], + receivers = [uamqp_sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME, prefetch_count=5)], + admin_client = sb_admin_client, + duration=args.duration, + send_batch_size=5, + azure_monitor_metric=AzureMonitorMetric("test_stress_queue_batch_send_and_receive") + ) + result = stress_test.run() + print(f"Total send {result.total_sent}") + print(f"Total received {result.total_received}") -@pytest.mark.liveTest -@pytest.mark.live_test_only -def test_stress_queue_slow_send_and_receive(): +def test_stress_queue_slow_send_and_receive(args): sb_client = ServiceBusClient.from_connection_string( - SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE) + SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) stress_test = StressTestRunner(senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME)], - duration=timedelta(seconds=3501*3), - send_delay=3500, + admin_client = sb_admin_client, + # duration=timedelta(seconds=3501*3), + duration=args.duration, + send_delay=(args.duration/3), azure_monitor_metric=AzureMonitorMetric("test_stress_queue_slow_send_and_receive") ) result = stress_test.run() - assert(result.total_sent > 0) - assert(result.total_received > 0) + print(f"Total send {result.total_sent}") + print(f"Total received {result.total_received}") - -@pytest.mark.liveTest -@pytest.mark.live_test_only -def test_stress_queue_receive_and_delete(): +def test_stress_queue_receive_and_delete(args): sb_client = ServiceBusClient.from_connection_string( - SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE) + SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) stress_test = StressTestRunner(senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME, receive_mode=ServiceBusReceiveMode.RECEIVE_AND_DELETE)], + admin_client = sb_admin_client, should_complete_messages = False, - duration=timedelta(seconds=60), + duration=args.duration, azure_monitor_metric=AzureMonitorMetric("test_stress_queue_slow_send_and_receive") ) result = stress_test.run() - assert(result.total_sent > 0) - assert(result.total_received > 0) - + print(f"Total send {result.total_sent}") + print(f"Total received {result.total_received}") -@pytest.mark.liveTest -@pytest.mark.live_test_only -def test_stress_queue_unsettled_messages(): +def test_stress_queue_unsettled_messages(args): sb_client = ServiceBusClient.from_connection_string( - SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE) + SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) stress_test = StressTestRunner(senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME)], - duration = timedelta(seconds=350), + admin_client = sb_admin_client, + # duration = timedelta(seconds=350), + duration=args.duration, should_complete_messages = False, azure_monitor_metric=AzureMonitorMetric("test_stress_queue_unsettled_messages") ) @@ -123,25 +128,23 @@ def test_stress_queue_unsettled_messages(): result = stress_test.run() # This test is prompted by reports of an issue where enough unsettled messages saturate a service-side cache # and prevent further receipt. - assert(result.total_sent > 2500) - assert(result.total_received > 2500) + print(f"Total send {result.total_sent}") + print(f"Total received {result.total_received}") - -@pytest.mark.liveTest -@pytest.mark.live_test_only -def test_stress_queue_receive_large_batch_size(): +def test_stress_queue_receive_large_batch_size(args): sb_client = ServiceBusClient.from_connection_string( - SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE) + SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) stress_test = StressTestRunner(senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME, prefetch_count=50)], - duration = timedelta(seconds=60), + admin_client = sb_admin_client, + duration = args.duration, max_message_count = 50, azure_monitor_metric=AzureMonitorMetric("test_stress_queue_receive_large_batch_size") ) result = stress_test.run() - assert(result.total_sent > 0) - assert(result.total_received > 0) + print(f"Total send {result.total_sent}") + print(f"Total received {result.total_received}") # Cannot be defined at local scope due to pickling into multiproc runner. class ReceiverTimeoutStressTestRunner(StressTestRunner): @@ -151,24 +154,23 @@ def on_send(self, state, sent_message, sender): # To make receive time out, in push mode this delay would trigger receiver reconnection time.sleep(self.max_wait_time + 5) -@pytest.mark.liveTest -@pytest.mark.live_test_only -def test_stress_queue_pull_receive_timeout(): +def test_stress_queue_pull_receive_timeout(args): sb_client = ServiceBusClient.from_connection_string( - SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE) + SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) stress_test = ReceiverTimeoutStressTestRunner( senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME)], + admin_client = sb_admin_client, max_wait_time = 5, receive_type=ReceiveType.pull, - duration=timedelta(seconds=600), + # duration=timedelta(seconds=600), + duration=args.duration, azure_monitor_metric=AzureMonitorMetric("test_stress_queue_pull_receive_timeout") ) result = stress_test.run() - assert(result.total_sent > 0) - assert(result.total_received > 0) - + print(f"Total send {result.total_sent}") + print(f"Total received {result.total_received}") class LongRenewStressTestRunner(StressTestRunner): def on_receive(self, state, received_message, receiver): @@ -177,23 +179,22 @@ def on_receive(self, state, received_message, receiver): renewer.register(receiver, received_message, max_lock_renewal_duration=300) time.sleep(300) -@pytest.mark.liveTest -@pytest.mark.live_test_only -def test_stress_queue_long_renew_send_and_receive(): +def test_stress_queue_long_renew_send_and_receive(args): sb_client = ServiceBusClient.from_connection_string( - SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE) + SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) stress_test = LongRenewStressTestRunner( senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME)], - duration=timedelta(seconds=3000), + admin_client = sb_admin_client, + # duration=timedelta(seconds=3000), + duration=args.duration, send_delay=300, azure_monitor_metric=AzureMonitorMetric("test_stress_queue_long_renew_send_and_receive") ) result = stress_test.run() - assert(result.total_sent > 0) - assert(result.total_received > 0) - + print(f"Total send {result.total_sent}") + print(f"Total received {result.total_received}") class LongSessionRenewStressTestRunner(StressTestRunner): def on_receive(self, state, received_message, receiver): @@ -203,25 +204,25 @@ def on_fail(renewable, error): print("FAILED AUTOLOCKRENEW: " + str(error)) renewer.register(receiver, receiver.session, max_lock_renewal_duration=600, on_lock_renew_failure=on_fail) -@pytest.mark.liveTest -@pytest.mark.live_test_only -def test_stress_queue_long_renew_session_send_and_receive(): +def test_stress_queue_long_renew_session_send_and_receive(args): sb_client = ServiceBusClient.from_connection_string( - SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE) + SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) session_id = 'test_stress_queue_long_renew_send_and_receive' stress_test = LongSessionRenewStressTestRunner( senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME, session_id=session_id)], - duration=timedelta(seconds=3000), + admin_client = sb_admin_client, + # duration=timedelta(seconds=3000), + duration=args.duration, send_delay=300, send_session_id=session_id, azure_monitor_metric=AzureMonitorMetric("test_stress_queue_long_renew_session_send_and_receive") ) result = stress_test.run() - assert(result.total_sent > 0) - assert(result.total_received > 0) + print(f"Total send {result.total_sent}") + print(f"Total received {result.total_received}") class Peekon_receiveStressTestRunner(StressTestRunner): @@ -229,22 +230,23 @@ def on_receive_batch(self, state, received_message, receiver): '''Called on every successful receive''' assert receiver.peek_messages()[0] -@pytest.mark.liveTest -@pytest.mark.live_test_only -def test_stress_queue_peek_messages(): +def test_stress_queue_peek_messages(args): sb_client = ServiceBusClient.from_connection_string( - SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE) + SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) stress_test = Peekon_receiveStressTestRunner( senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME)], - duration = timedelta(seconds=300), + admin_client = sb_admin_client, + # duration = timedelta(seconds=300), + duration=args.duration, receive_delay = 30, receive_type = ReceiveType.none, azure_monitor_metric=AzureMonitorMetric("test_stress_queue_peek_messages") ) result = stress_test.run() - assert(result.total_sent > 0) + print(f"Total send {result.total_sent}") + print(f"Total received {result.total_received}") # TODO: This merits better validation, to be implemented alongside full metric spread. @@ -261,24 +263,23 @@ def on_send(self, state, sent_message, sender): sender.__exit__() sender.__enter__() -@pytest.mark.liveTest -@pytest.mark.live_test_only -@pytest.mark.skip(reason='This test is disabled unless re-openability of handlers is desired and re-enabled') -def test_stress_queue_close_and_reopen(): +def test_stress_queue_close_and_reopen(args): sb_client = ServiceBusClient.from_connection_string( - SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE) + SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) stress_test = RestartHandlerStressTestRunner( senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME)], - duration = timedelta(seconds=300), + admin_client = sb_admin_client, + # duration = timedelta(seconds=300), + duration = args.duration, receive_delay = 30, send_delay = 10, azure_monitor_metric=AzureMonitorMetric("test_stress_queue_close_and_reopen") ) result = stress_test.run() - assert(result.total_sent > 0) - assert(result.total_received > 0) + print(f"Total send {result.total_sent}") + print(f"Total received {result.total_received}") # This test validates that all individual messages are received contiguously over a long time period. # (e.g. not dropped for whatever reason, not sent, or not received) @@ -310,23 +311,96 @@ def pre_process_message_body(self, payload): return str(body) -@pytest.mark.liveTest -@pytest.mark.live_test_only -def test_stress_queue_check_for_dropped_messages(): +def test_stress_queue_check_for_dropped_messages(args): sb_client = ServiceBusClient.from_connection_string( - SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE) + SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) stress_test = DroppedMessageCheckerStressTestRunner( senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME)], + admin_client = sb_admin_client, receive_type=ReceiveType.pull, - duration=timedelta(seconds=3000), + # duration=timedelta(seconds=3000), + duration=args.duration, azure_monitor_metric=AzureMonitorMetric("test_stress_queue_check_for_dropped_messages") ) result = stress_test.run() - assert(result.total_sent > 0) - assert(result.total_received > 0) + print(f"Total send {result.total_sent}") + print(f"Total received {result.total_received}") if __name__ == '__main__': - #parser = ArgumentParser() - pytest.main() + load_dotenv(dotenv_path=ENV_FILE, override=True) + parser = ArgumentParser() + parser.add_argument("--conn_str", help="ServiceBus connection string", + default=os.environ.get('SERVICE_BUS_CONNECTION_STR')) + parser.add_argument("--queue_name", help="The queue name.", default="testQueue") + parser.add_argument("--method", type=str) + parser.add_argument("--duration", type=int, default=259200) + parser.add_argument("--logging_enable", action="store_true") + parser.add_argument("--print_console", action="store_true") + + parser.add_argument("--send-batch-size", type=int, default=100) + parser.add_argument("--message-size", type=int, default=100) + + parser.add_argument("--receive-type", type=str, default="pull") + parser.add_argument("--max_wait_time", type=int, default=10) + parser.add_argument("--max_message_count", type=int, default=1) + parser.add_argument("--uamqp_mode", action="store_true") + parser.add_argument("--transport", action="store_true") + + args, _ = parser.parse_known_args() + + if args.transport: + TRANSPORT_TYPE= TransportType.AmqpOverWebsocket + else: + TRANSPORT_TYPE= TransportType.Amqp + + SERVICE_BUS_CONNECTION_STR = args.conn_str + SERVICEBUS_QUEUE_NAME= args.queue_name + LOGGING_ENABLE = args.logging_enable + + sb_admin_client = ServiceBusAdministrationClient.from_connection_string(SERVICE_BUS_CONNECTION_STR) + + if args.method == "send_receive": + test_stress_queue_send_and_receive(args) + elif args.method == "send_pull_receive": + test_stress_queue_send_and_pull_receive(args) + elif args.method == "send_receive_batch": + test_stress_queue_batch_send_and_receive(args) + elif args.method == "uamqp": + test_stress_queue_batch_send_and_receive_u(args) + elif args.method == "send_receive_slow": + test_stress_queue_slow_send_and_receive(args) + elif args.method == "receive_delete": + test_stress_queue_receive_and_delete(args) + elif args.method == "unsettled_message": + test_stress_queue_unsettled_messages(args) + elif args.method == "large_batch": + test_stress_queue_receive_large_batch_size(args) + elif args.method == "pull_receive_timeout": + test_stress_queue_pull_receive_timeout(args) + elif args.method == "long_renew": + test_stress_queue_long_renew_send_and_receive(args) + elif args.method == "long_renew_session": + test_stress_queue_long_renew_session_send_and_receive(args) + elif args.method == "queue_peek": + test_stress_queue_peek_messages(args) + elif args.method == "queue_close_reopen": + test_stress_queue_close_and_reopen(args) + elif args.method == "dropped_messages": + test_stress_queue_check_for_dropped_messages(args) + else: + test_stress_queue_send_and_receive(args) + test_stress_queue_send_and_pull_receive(args) + test_stress_queue_batch_send_and_receive(args) + test_stress_queue_slow_send_and_receive(args) + test_stress_queue_receive_and_delete(args) + test_stress_queue_unsettled_messages(args) + test_stress_queue_receive_large_batch_size(args) + test_stress_queue_pull_receive_timeout(args) + test_stress_queue_long_renew_send_and_receive(args) + test_stress_queue_long_renew_session_send_and_receive(args) + test_stress_queue_peek_messages(args) + test_stress_queue_close_and_reopen(args) + test_stress_queue_check_for_dropped_messages(args) + diff --git a/sdk/servicebus/azure-servicebus/stress/scripts/test_stress_queues_async.py b/sdk/servicebus/azure-servicebus/stress/scripts/test_stress_queues_async.py new file mode 100644 index 000000000000..d0ca89bd54cb --- /dev/null +++ b/sdk/servicebus/azure-servicebus/stress/scripts/test_stress_queues_async.py @@ -0,0 +1,411 @@ +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- + +from datetime import timedelta +import time +import os +import asyncio +from dotenv import load_dotenv +from argparse import ArgumentParser + +from azure.servicebus import AutoLockRenewer, TransportType +from azure.servicebus.aio import ServiceBusClient +from azure.servicebus.aio.management import ServiceBusAdministrationClient +from azure.servicebus._common.constants import ServiceBusReceiveMode +from app_insights_metric import AzureMonitorMetric + +from stress_test_base import StressTestRunnerAsync, ReceiveType + +ENV_FILE = os.environ.get('ENV_FILE') + + +async def test_stress_queue_send_and_receive(args): + sb_client = ServiceBusClient.from_connection_string( + SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) + stress_test = StressTestRunnerAsync(senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], + receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME)], + admin_client = sb_admin_client, + duration=args.duration, + azure_monitor_metric=AzureMonitorMetric("test_stress_queue_send_and_receive") + ) + + result = await stress_test.run_async() + print(f"Total send {result.total_sent}") + print(f"Total received {result.total_received}") + +async def test_stress_queue_send_and_pull_receive(args): + sb_client = ServiceBusClient.from_connection_string( + SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) + stress_test = StressTestRunnerAsync(senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], + receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME)], + admin_client = sb_admin_client, + receive_type=ReceiveType.pull, + duration=args.duration, + azure_monitor_metric=AzureMonitorMetric("test_stress_queue_send_and_pull_receive") + ) + + result = await stress_test.run_async() + print(f"Total send {result.total_sent}") + print(f"Total received {result.total_received}") + +async def test_stress_queue_batch_send_and_receive_u(args): + sb_client = ServiceBusClient.from_connection_string( + SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) + uamqp_sb_client = ServiceBusClient.from_connection_string( + SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE, uamqp_transport=True) + stress_test = StressTestRunnerAsync(senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], + receivers = [uamqp_sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME, prefetch_count=5)], + admin_client = sb_admin_client, + duration=args.duration, + send_batch_size=5, + azure_monitor_metric=AzureMonitorMetric("test_stress_queue_batch_send_and_receive") + ) + + result = await stress_test.run_async() + print(f"Total send {result.total_sent}") + print(f"Total received {result.total_received}") + +async def test_stress_queue_batch_send_and_receive(args): + sb_client = ServiceBusClient.from_connection_string( + SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) + stress_test = StressTestRunnerAsync(senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], + receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME, prefetch_count=5)], + admin_client = sb_admin_client, + duration=args.duration, + send_batch_size=5, + azure_monitor_metric=AzureMonitorMetric("test_stress_queue_batch_send_and_receive") + ) + + result = await stress_test.run_async() + print(f"Total send {result.total_sent}") + print(f"Total received {result.total_received}") + +async def test_stress_queue_slow_send_and_receive(args): + sb_client = ServiceBusClient.from_connection_string( + SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) + stress_test = StressTestRunnerAsync(senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], + receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME)], + admin_client = sb_admin_client, + # duration=timedelta(seconds=3501*3), + duration=args.duration, + send_delay=(args.duration/3), + azure_monitor_metric=AzureMonitorMetric("test_stress_queue_slow_send_and_receive") + ) + + result = await stress_test.run_async() + print(f"Total send {result.total_sent}") + print(f"Total received {result.total_received}") + +async def test_stress_queue_receive_and_delete(args): + sb_client = ServiceBusClient.from_connection_string( + SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) + stress_test = StressTestRunnerAsync(senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], + receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME, receive_mode=ServiceBusReceiveMode.RECEIVE_AND_DELETE)], + admin_client = sb_admin_client, + should_complete_messages = False, + duration=args.duration, + azure_monitor_metric=AzureMonitorMetric("test_stress_queue_slow_send_and_receive") + ) + + result = await stress_test.run_async() + print(f"Total send {result.total_sent}") + print(f"Total received {result.total_received}") + +async def test_stress_queue_unsettled_messages(args): + sb_client = ServiceBusClient.from_connection_string( + SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) + stress_test = StressTestRunnerAsync(senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], + receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME)], + admin_client = sb_admin_client, + # duration = timedelta(seconds=350), + duration=args.duration, + should_complete_messages = False, + azure_monitor_metric=AzureMonitorMetric("test_stress_queue_unsettled_messages") + ) + + result = await stress_test.run_async() + # This test is prompted by reports of an issue where enough unsettled messages saturate a service-side cache + # and prevent further receipt. + print(f"Total send {result.total_sent}") + print(f"Total received {result.total_received}") + +async def test_stress_queue_receive_large_batch_size(args): + sb_client = ServiceBusClient.from_connection_string( + SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) + stress_test = StressTestRunnerAsync(senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], + receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME, prefetch_count=50)], + admin_client = sb_admin_client, + duration = args.duration, + max_message_count = 50, + azure_monitor_metric=AzureMonitorMetric("test_stress_queue_receive_large_batch_size") + ) + + result = await stress_test.run_async() + print(f"Total send {result.total_sent}") + print(f"Total received {result.total_received}") + +# Cannot be async defined at local scope due to pickling into multiproc runner. +class ReceiverTimeoutStressTestRunner(StressTestRunnerAsync): + def on_send(self, state, sent_message, sender): + '''Called on every successful send''' + if state.total_sent % 10 == 0: + # To make receive time out, in push mode this delay would trigger receiver reconnection + time.sleep(self.max_wait_time + 5) + +async def test_stress_queue_pull_receive_timeout(args): + sb_client = ServiceBusClient.from_connection_string( + SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) + stress_test = ReceiverTimeoutStressTestRunner( + senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], + receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME)], + admin_client = sb_admin_client, + max_wait_time = 5, + receive_type=ReceiveType.pull, + # duration=timedelta(seconds=600), + duration=args.duration, + azure_monitor_metric=AzureMonitorMetric("test_stress_queue_pull_receive_timeout") + ) + + result = await stress_test.run_async() + print(f"Total send {result.total_sent}") + print(f"Total received {result.total_received}") + +class LongRenewStressTestRunner(StressTestRunnerAsync): + def on_receive(self, state, received_message, receiver): + '''Called on every successful receive''' + renewer = AutoLockRenewer() + renewer.register(receiver, received_message, max_lock_renewal_duration=300) + time.sleep(300) + +async def test_stress_queue_long_renew_send_and_receive(args): + sb_client = ServiceBusClient.from_connection_string( + SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) + stress_test = LongRenewStressTestRunner( + senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], + receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME)], + admin_client = sb_admin_client, + # duration=timedelta(seconds=3000), + duration=args.duration, + send_delay=300, + azure_monitor_metric=AzureMonitorMetric("test_stress_queue_long_renew_send_and_receive") + ) + + result = await stress_test.run_async() + print(f"Total send {result.total_sent}") + print(f"Total received {result.total_received}") + +class LongSessionRenewStressTestRunner(StressTestRunnerAsync): + def on_receive(self, state, received_message, receiver): + '''Called on every successful receive''' + renewer = AutoLockRenewer() + def on_fail(renewable, error): + print("FAILED AUTOLOCKRENEW: " + str(error)) + renewer.register(receiver, receiver.session, max_lock_renewal_duration=600, on_lock_renew_failure=on_fail) + +async def test_stress_queue_long_renew_session_send_and_receive(args): + sb_client = ServiceBusClient.from_connection_string( + SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) + session_id = 'test_stress_queue_long_renew_send_and_receive' + + stress_test = LongSessionRenewStressTestRunner( + senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], + receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME, session_id=session_id)], + admin_client = sb_admin_client, + # duration=timedelta(seconds=3000), + duration=args.duration, + send_delay=300, + send_session_id=session_id, + azure_monitor_metric=AzureMonitorMetric("test_stress_queue_long_renew_session_send_and_receive") + ) + + result = await stress_test.run_async() + print(f"Total send {result.total_sent}") + print(f"Total received {result.total_received}") + +class Peekon_receiveStressTestRunner(StressTestRunnerAsync): + def on_receive_batch(self, state, received_message, receiver): + '''Called on every successful receive''' + assert receiver.peek_messages()[0] + +async def test_stress_queue_peek_messages(args): + sb_client = ServiceBusClient.from_connection_string( + SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) + stress_test = Peekon_receiveStressTestRunner( + senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], + receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME)], + admin_client = sb_admin_client, + # duration = timedelta(seconds=300), + duration=args.duration, + receive_delay = 30, + receive_type = ReceiveType.none, + azure_monitor_metric=AzureMonitorMetric("test_stress_queue_peek_messages") + ) + + result = await stress_test.run_async() + print(f"Total send {result.total_sent}") + print(f"Total received {result.total_received}") + # TODO: This merits better validation, to be implemented alongside full metric spread. + + +class RestartHandlerStressTestRunner(StressTestRunnerAsync): + def post_receive(self, state, receiver): + '''Called after completion of every successful receive''' + if state.total_received % 3 == 0: + receiver.__exit__() + receiver.__enter__() + + def on_send(self, state, sent_message, sender): + '''Called after completion of every successful receive''' + if state.total_sent % 3 == 0: + sender.__exit__() + sender.__enter__() + +async def test_stress_queue_close_and_reopen(args): + sb_client = ServiceBusClient.from_connection_string( + SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) + stress_test = RestartHandlerStressTestRunner( + senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], + receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME)], + admin_client = sb_admin_client, + # duration = timedelta(seconds=300), + duration = args.duration, + receive_delay = 30, + send_delay = 10, + azure_monitor_metric=AzureMonitorMetric("test_stress_queue_close_and_reopen") + ) + + result = await stress_test.run_async() + print(f"Total send {result.total_sent}") + print(f"Total received {result.total_received}") + +# This test validates that all individual messages are received contiguously over a long time period. +# (e.g. not dropped for whatever reason, not sent, or not received) +class DroppedMessageCheckerStressTestRunner(StressTestRunnerAsync): + def on_receive(self, state, received_message, receiver): + '''Called on every successful receive''' + last_seen = getattr(state, 'last_seen', -1) + noncontiguous = getattr(state, 'noncontiguous', set()) + body = int(str(received_message)) + if body == last_seen+1: + last_seen += 1 + if noncontiguous: + while (last_seen+1) in noncontiguous: + last_seen += 1 + noncontiguous.remove(last_seen) + else: + noncontiguous.add(body) + state.noncontiguous = noncontiguous + state.last_seen = last_seen + + def pre_process_message_body(self, payload): + '''Called when constructing message body''' + try: + body = self._message_id + except: + _message_id = 0 + body = 0 + _message_id += 1 + + return str(body) + +async def test_stress_queue_check_for_dropped_messages(args): + sb_client = ServiceBusClient.from_connection_string( + SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) + stress_test = DroppedMessageCheckerStressTestRunner( + senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], + receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME)], + admin_client = sb_admin_client, + receive_type=ReceiveType.pull, + # duration=timedelta(seconds=3000), + duration=args.duration, + azure_monitor_metric=AzureMonitorMetric("test_stress_queue_check_for_dropped_messages") + ) + + result = await stress_test.run_async() + print(f"Total send {result.total_sent}") + print(f"Total received {result.total_received}") + +async def run(args): + if args.method == "send_receive": + await test_stress_queue_send_and_receive(args) + elif args.method == "send_pull_receive": + await test_stress_queue_send_and_pull_receive(args) + elif args.method == "send_receive_batch": + await test_stress_queue_batch_send_and_receive(args) + elif args.method == "uamqp": + await test_stress_queue_batch_send_and_receive_u(args) + elif args.method == "send_receive_slow": + await test_stress_queue_slow_send_and_receive(args) + elif args.method == "receive_delete": + await test_stress_queue_receive_and_delete(args) + elif args.method == "unsettled_message": + await test_stress_queue_unsettled_messages(args) + elif args.method == "large_batch": + await test_stress_queue_receive_large_batch_size(args) + elif args.method == "pull_receive_timeout": + await test_stress_queue_pull_receive_timeout(args) + elif args.method == "long_renew": + await test_stress_queue_long_renew_send_and_receive(args) + elif args.method == "long_renew_session": + await test_stress_queue_long_renew_session_send_and_receive(args) + elif args.method == "queue_peek": + await test_stress_queue_peek_messages(args) + elif args.method == "queue_close_reopen": + await test_stress_queue_close_and_reopen(args) + elif args.method == "dropped_messages": + await test_stress_queue_check_for_dropped_messages(args) + else: + await test_stress_queue_send_and_receive(args) + await test_stress_queue_send_and_pull_receive(args) + await test_stress_queue_batch_send_and_receive(args) + await test_stress_queue_slow_send_and_receive(args) + await test_stress_queue_receive_and_delete(args) + await test_stress_queue_unsettled_messages(args) + await test_stress_queue_receive_large_batch_size(args) + await test_stress_queue_pull_receive_timeout(args) + await test_stress_queue_long_renew_send_and_receive(args) + await test_stress_queue_long_renew_session_send_and_receive(args) + await test_stress_queue_peek_messages(args) + await test_stress_queue_close_and_reopen(args) + await test_stress_queue_check_for_dropped_messages(args) + + +if __name__ == '__main__': + load_dotenv(dotenv_path=ENV_FILE, override=True) + parser = ArgumentParser() + parser.add_argument("--conn_str", help="ServiceBus connection string", + default=os.environ.get('SERVICE_BUS_CONNECTION_STR')) + parser.add_argument("--queue_name", help="The queue name.", default='testQueue') + parser.add_argument("--method", type=str) + parser.add_argument("--duration", type=int, default=259200) + parser.add_argument("--logging_enable", action="store_true") + parser.add_argument("--print_console", action="store_true") + + parser.add_argument("--send-batch-size", type=int, default=100) + parser.add_argument("--message-size", type=int, default=100) + + parser.add_argument("--receive-type", type=str, default="pull") + parser.add_argument("--max_wait_time", type=int, default=10) + parser.add_argument("--max_message_count", type=int, default=1) + parser.add_argument("--uamqp_mode", type=bool, default=False) + parser.add_argument("--transport", action="store_true") + + args, _ = parser.parse_known_args() + + if args.transport: + TRANSPORT_TYPE= TransportType.AmqpOverWebsocket + else: + TRANSPORT_TYPE= TransportType.Amqp + + SERVICE_BUS_CONNECTION_STR = args.conn_str + SERVICEBUS_QUEUE_NAME= args.queue_name + LOGGING_ENABLE = args.logging_enable + + sb_admin_client = ServiceBusAdministrationClient.from_connection_string(SERVICE_BUS_CONNECTION_STR) + loop = asyncio.get_event_loop() + loop.run_until_complete(run(args)) + + diff --git a/sdk/servicebus/azure-servicebus/stress/templates/testjob.yaml b/sdk/servicebus/azure-servicebus/stress/templates/testjob.yaml index b673fae60587..78f5fce649d8 100644 --- a/sdk/servicebus/azure-servicebus/stress/templates/testjob.yaml +++ b/sdk/servicebus/azure-servicebus/stress/templates/testjob.yaml @@ -2,9 +2,9 @@ {{- define "stress.python-sb-stress" -}} metadata: labels: - testName: "deploy-python-sb-stress" - testInstance: "servicebus-{{ .Release.Name }}-{{ .Release.Revision }}" - chaos: "true" + testName: "py-sb-stress" + testInstance: "sb-{{ .Release.Name }}-{{ .Release.Revision }}" + chaos: "{{ default false .Stress.chaos }}" spec: containers: - name: python-sb-stress @@ -15,9 +15,140 @@ spec: memory: "2000Mi" cpu: "1" - {{ if eq .Stress.testTarget "sbStress" }} - command: ['bash', '-c', 'python3 test_stress_queues.py'] + {{ if eq .Stress.testTarget "aqueuew" }} + command: ['bash', '-c', 'python test_stress_queues_async.py --method send_receive --duration 300000 --logging-enable --transport'] + {{- end -}} + + # {{ if eq .Stress.testTarget "queuew" }} + # command: ['bash', '-c', 'python test_stress_queues.py --method send_receive --duration 300000 --logging-enable --transport'] + # {{- end -}} + + {{ if eq .Stress.testTarget "aqueuepullw" }} + command: ['bash', '-c', 'python test_stress_queues_async.py --method send_pull_receive --duration 300000 --logging-enable --transport'] + {{- end -}} + + # {{ if eq .Stress.testTarget "queuepullw" }} + # command: ['bash', '-c', 'python test_stress_queues.py --method send_pull_receive --duration 300000 --logging-enable --transport'] + # {{- end -}} + + # {{ if eq .Stress.testTarget "abatchw" }} + # command: ['bash', '-c', 'python test_stress_queues_async.py --method send_receive_batch --duration 300000 --logging-enable --transport'] + # {{- end -}} + + # {{ if eq .Stress.testTarget "batchw" }} + # command: ['bash', '-c', 'python test_stress_queues.py --method send_receive_batch --duration 300000 --logging-enable --transport'] + # {{- end -}} + + {{ if eq .Stress.testTarget "aqueue" }} + command: ['bash', '-c', 'python test_stress_queues_async.py --method send_receive --duration 300000 --logging-enable'] + {{- end -}} + + # {{ if eq .Stress.testTarget "queue" }} + # command: ['bash', '-c', 'python test_stress_queues.py --method send_receive --duration 300000 --logging-enable'] + # {{- end -}} + + {{ if eq .Stress.testTarget "aqueuepull" }} + command: ['bash', '-c', 'python test_stress_queues_async.py --method send_pull_receive --duration 30000 --logging-enable'] + {{- end -}} + + # {{ if eq .Stress.testTarget "queuepull" }} + # command: ['bash', '-c', 'python test_stress_queues.py --method send_pull_receive --duration 300000 --logging-enable'] + # {{- end -}} + + # {{ if eq .Stress.testTarget "abatch" }} + # command: ['bash', '-c', 'python test_stress_queues_async.py --method send_receive_batch --duration 300000 --logging-enable'] + # {{- end -}} + + # {{ if eq .Stress.testTarget "batch" }} + # command: ['bash', '-c', 'python test_stress_queues.py --method send_receive_batch --duration 300000 --logging-enable'] + # {{- end -}} + + # {{ if eq .Stress.testTarget "queueuamqp" }} + # command: ['bash', '-c', 'python test_stress_queues.py --method uamqp --duration 300000 --logging-enable --uamqp_mode'] + # {{- end -}} + + {{ if eq .Stress.testTarget "aqueueuamqp" }} + command: ['bash', '-c', 'python test_stress_queues_async.py --method uamqp --duration 300000 --logging-enable'] + {{- end -}} + + + + + + # {{ if eq .Stress.testTarget "asend_receive_slow" }} + # command: ['bash', '-c', 'python test_stress_queues_async.py --method send_receive_slow --duration 300000 --logging-enable'] + # {{- end -}} + + # {{ if eq .Stress.testTarget "send_receive_slow" }} + # command: ['bash', '-c', 'python test_stress_queues.py --method send_receive_slow --duration 300000 --logging-enable'] + # {{- end -}} + + # {{ if eq .Stress.testTarget "receive_delete" }} + # command: ['bash', '-c', 'python test_stress_queues_async.py --method receive_delete --duration 300000 --logging-enable'] + # {{- end -}} + + # {{ if eq .Stress.testTarget "unsettled_message" }} + # command: ['bash', '-c', 'python test_stress_queues_async.py --method unsettled_message --duration 300000 --logging-enable'] + # {{- end -}} + # {{ if eq .Stress.testTarget "large_batch" }} + # command: ['bash', '-c', 'python test_stress_queues_async.py --method large_batch --duration 300000 --logging-enable'] + # {{- end -}} + # {{ if eq .Stress.testTarget "pull_receive_timeout" }} + # command: ['bash', '-c', 'python test_stress_queues_async.py --method pull_receive_timeout --duration 300000 --logging-enable'] + # {{- end -}} + # {{ if eq .Stress.testTarget "long_renew" }} + # command: ['bash', '-c', 'python test_stress_queues_async.py --method long_renew --duration 300000 --logging-enable'] + # {{- end -}} + # {{ if eq .Stress.testTarget "long_renew_session" }} + # command: ['bash', '-c', 'python test_stress_queues_async.py --method long_renew_session --duration 300000 --logging-enable'] + # {{- end -}} + # {{ if eq .Stress.testTarget "queue_peek" }} + # command: ['bash', '-c', 'python test_stress_queues_async.py --method queue_peek --duration 300000 --logging-enable'] + # {{- end -}} + # {{ if eq .Stress.testTarget "queue_close_reopen" }} + # command: ['bash', '-c', 'python test_stress_queues_async.py --method queue_close_reopen --duration 300000 --logging-enable'] + # {{- end -}} + # {{ if eq .Stress.testTarget "dropped_messages" }} + # command: ['bash', '-c', 'python test_stress_queues_async.py --method dropped_messages --duration 300000 --logging-enable'] + {{- end -}} {{- include "stress-test-addons.container-env" . | nindent 6 }} {{- end -}} + + +{{- include "stress-test-addons.chaos-wrapper.tpl" (list . "stress.network-chaos") -}} +{{- define "stress.network-chaos" -}} +# basically: every 15 minutes do 30s of network loss +kind: Schedule +apiVersion: chaos-mesh.org/v1alpha1 +spec: + selector: + namespaces: + - "{{ .Release.Namespace }}" + labelSelectors: + testInstance: "servicebus-{{ .Release.Name }}-{{ .Release.Revision }}" + chaos: "true" + schedule: "*/5 * * * *" + startingDeadlineSeconds: null + concurrencyPolicy: Allow + historyLimit: 1 + type: NetworkChaos + networkChaos: + selector: + namespaces: + - "{{ .Release.Namespace }}" + labelSelectors: + testInstance: "servicebus-{{ .Release.Name }}-{{ .Release.Revision }}" + chaos: "true" + mode: all + action: loss + duration: 20s + loss: + loss: '100' + correlation: '100' + direction: to + externalTargets: + - {{ .Stress.BaseName }}.servicebus.windows.net +{{- end -}} + diff --git a/sdk/servicebus/azure-servicebus/stress/test-resources.bicep b/sdk/servicebus/azure-servicebus/stress/test-resources.bicep new file mode 100644 index 000000000000..2bc46e309699 --- /dev/null +++ b/sdk/servicebus/azure-servicebus/stress/test-resources.bicep @@ -0,0 +1,120 @@ +@description('The base resource name.') +param baseName string = resourceGroup().name + +@description('The client OID to grant access to test resources.') +param testApplicationOid string + +var apiVersion = '2017-04-01' +var location = resourceGroup().location +var authorizationRuleName_var = '${baseName}/RootManageSharedAccessKey' +var authorizationRuleNameNoManage_var = '${baseName}/NoManage' +var serviceBusDataOwnerRoleId = '/subscriptions/${subscription().subscriptionId}/providers/Microsoft.Authorization/roleDefinitions/090c5cfd-751d-490a-894a-3ce6f1109419' + +var sbPremiumName = 'sb-premium-${baseName}' + +resource servicebus 'Microsoft.ServiceBus/namespaces@2018-01-01-preview' = { + name: baseName + location: location + sku: { + name: 'Standard' + tier: 'Standard' + } + properties: { + zoneRedundant: false + } +} + +resource servicebusPremium 'Microsoft.ServiceBus/namespaces@2018-01-01-preview' = { + name: sbPremiumName + location: location + sku: { + name: 'Premium' + tier: 'Premium' + } +} + + +resource authorizationRuleName 'Microsoft.ServiceBus/namespaces/AuthorizationRules@2015-08-01' = { + name: authorizationRuleName_var + location: location + properties: { + rights: [ + 'Listen' + 'Manage' + 'Send' + ] + } + dependsOn: [ + servicebus + ] +} + +resource authorizationRuleNameNoManage 'Microsoft.ServiceBus/namespaces/AuthorizationRules@2015-08-01' = { + name: authorizationRuleNameNoManage_var + location: location + properties: { + rights: [ + 'Listen' + 'Send' + ] + } + dependsOn: [ + servicebus + ] +} + + + +resource dataOwnerRoleId 'Microsoft.Authorization/roleAssignments@2018-01-01-preview' = { + name: guid('dataOwnerRoleId${baseName}') + properties: { + roleDefinitionId: serviceBusDataOwnerRoleId + principalId: testApplicationOid + } + dependsOn: [ + servicebus + ] +} + +resource testQueue 'Microsoft.ServiceBus/namespaces/queues@2017-04-01' = { + parent: servicebus + name: 'testQueue' + properties: { + lockDuration: 'PT5M' + maxSizeInMegabytes: 1024 + requiresDuplicateDetection: false + requiresSession: false + defaultMessageTimeToLive: 'P10675199DT2H48M5.4775807S' + deadLetteringOnMessageExpiration: false + duplicateDetectionHistoryTimeWindow: 'PT10M' + maxDeliveryCount: 10 + autoDeleteOnIdle: 'P10675199DT2H48M5.4775807S' + enablePartitioning: false + enableExpress: false + } +} + +resource testQueueWithSessions 'Microsoft.ServiceBus/namespaces/queues@2017-04-01' = { + parent: servicebus + name: 'testQueueWithSessions' + properties: { + lockDuration: 'PT5M' + maxSizeInMegabytes: 1024 + requiresDuplicateDetection: false + requiresSession: true + defaultMessageTimeToLive: 'P10675199DT2H48M5.4775807S' + deadLetteringOnMessageExpiration: false + duplicateDetectionHistoryTimeWindow: 'PT10M' + maxDeliveryCount: 10 + autoDeleteOnIdle: 'P10675199DT2H48M5.4775807S' + enablePartitioning: false + enableExpress: false + } +} + +output SERVICEBUS_CONNECTION_STRING string = listKeys(resourceId('Microsoft.ServiceBus/namespaces/authorizationRules', baseName, 'RootManageSharedAccessKey'), apiVersion).primaryConnectionString +output SERVICEBUS_CONNECTION_STRING_NO_MANAGE string = listKeys(resourceId('Microsoft.ServiceBus/namespaces/authorizationRules', baseName, 'NoManage'), apiVersion).primaryConnectionString +output SERVICEBUS_CONNECTION_STRING_PREMIUM string = listKeys(resourceId('Microsoft.ServiceBus/namespaces/authorizationRules', sbPremiumName, 'RootManageSharedAccessKey'), apiVersion).primaryConnectionString +output SERVICEBUS_ENDPOINT string = replace(replace(servicebus.properties.serviceBusEndpoint, ':443/', ''), 'https://', '') +output QUEUE_NAME string = 'testQueue' +output QUEUE_NAME_WITH_SESSIONS string = 'testQueueWithSessions' From f233680accc1effb14a7627c0c4c537e4c3917f2 Mon Sep 17 00:00:00 2001 From: l0lawrence Date: Thu, 6 Apr 2023 10:27:30 -0700 Subject: [PATCH 02/30] changes --- .../stress/scripts/stress_test_base.py | 7 ++++- .../scripts/test_stress_queues_async.py | 28 +++++++++---------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/sdk/servicebus/azure-servicebus/stress/scripts/stress_test_base.py b/sdk/servicebus/azure-servicebus/stress/scripts/stress_test_base.py index bc255fb9025c..0f14990f35b9 100644 --- a/sdk/servicebus/azure-servicebus/stress/scripts/stress_test_base.py +++ b/sdk/servicebus/azure-servicebus/stress/scripts/stress_test_base.py @@ -480,7 +480,12 @@ async def run_async(self): for receiver in self.receivers ] with self.process_monitor: - await asyncio.gather(*send_tasks, *receive_tasks) + # await asyncio.gather(*send_tasks, *receive_tasks) + for task in asyncio.as_completed(send_tasks + receive_tasks): + try: + await task + except Exception as e: + print(e) result = StressTestResults() result.state_by_sender = { s: f.result() for s, f in zip(self.senders, send_tasks) diff --git a/sdk/servicebus/azure-servicebus/stress/scripts/test_stress_queues_async.py b/sdk/servicebus/azure-servicebus/stress/scripts/test_stress_queues_async.py index d0ca89bd54cb..8a8cacf9ce12 100644 --- a/sdk/servicebus/azure-servicebus/stress/scripts/test_stress_queues_async.py +++ b/sdk/servicebus/azure-servicebus/stress/scripts/test_stress_queues_async.py @@ -26,7 +26,7 @@ async def test_stress_queue_send_and_receive(args): sb_client = ServiceBusClient.from_connection_string( SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) stress_test = StressTestRunnerAsync(senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], - receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME)], + receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME, max_wait_time=10)], admin_client = sb_admin_client, duration=args.duration, azure_monitor_metric=AzureMonitorMetric("test_stress_queue_send_and_receive") @@ -40,7 +40,7 @@ async def test_stress_queue_send_and_pull_receive(args): sb_client = ServiceBusClient.from_connection_string( SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) stress_test = StressTestRunnerAsync(senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], - receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME)], + receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME, max_wait_time=10)], admin_client = sb_admin_client, receive_type=ReceiveType.pull, duration=args.duration, @@ -57,7 +57,7 @@ async def test_stress_queue_batch_send_and_receive_u(args): uamqp_sb_client = ServiceBusClient.from_connection_string( SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE, uamqp_transport=True) stress_test = StressTestRunnerAsync(senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], - receivers = [uamqp_sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME, prefetch_count=5)], + receivers = [uamqp_sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME, prefetch_count=5, max_wait_time=10)], admin_client = sb_admin_client, duration=args.duration, send_batch_size=5, @@ -72,7 +72,7 @@ async def test_stress_queue_batch_send_and_receive(args): sb_client = ServiceBusClient.from_connection_string( SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) stress_test = StressTestRunnerAsync(senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], - receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME, prefetch_count=5)], + receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME, prefetch_count=5, max_wait_time=10)], admin_client = sb_admin_client, duration=args.duration, send_batch_size=5, @@ -87,7 +87,7 @@ async def test_stress_queue_slow_send_and_receive(args): sb_client = ServiceBusClient.from_connection_string( SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) stress_test = StressTestRunnerAsync(senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], - receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME)], + receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME, max_wait_time=10)], admin_client = sb_admin_client, # duration=timedelta(seconds=3501*3), duration=args.duration, @@ -103,7 +103,7 @@ async def test_stress_queue_receive_and_delete(args): sb_client = ServiceBusClient.from_connection_string( SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) stress_test = StressTestRunnerAsync(senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], - receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME, receive_mode=ServiceBusReceiveMode.RECEIVE_AND_DELETE)], + receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME, receive_mode=ServiceBusReceiveMode.RECEIVE_AND_DELETE, max_wait_time=10)], admin_client = sb_admin_client, should_complete_messages = False, duration=args.duration, @@ -118,7 +118,7 @@ async def test_stress_queue_unsettled_messages(args): sb_client = ServiceBusClient.from_connection_string( SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) stress_test = StressTestRunnerAsync(senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], - receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME)], + receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME, max_wait_time=10)], admin_client = sb_admin_client, # duration = timedelta(seconds=350), duration=args.duration, @@ -136,7 +136,7 @@ async def test_stress_queue_receive_large_batch_size(args): sb_client = ServiceBusClient.from_connection_string( SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) stress_test = StressTestRunnerAsync(senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], - receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME, prefetch_count=50)], + receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME, prefetch_count=50, max_wait_time=10)], admin_client = sb_admin_client, duration = args.duration, max_message_count = 50, @@ -160,7 +160,7 @@ async def test_stress_queue_pull_receive_timeout(args): SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) stress_test = ReceiverTimeoutStressTestRunner( senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], - receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME)], + receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME, max_wait_time=10)], admin_client = sb_admin_client, max_wait_time = 5, receive_type=ReceiveType.pull, @@ -185,7 +185,7 @@ async def test_stress_queue_long_renew_send_and_receive(args): SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) stress_test = LongRenewStressTestRunner( senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], - receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME)], + receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME, max_wait_time=10)], admin_client = sb_admin_client, # duration=timedelta(seconds=3000), duration=args.duration, @@ -212,7 +212,7 @@ async def test_stress_queue_long_renew_session_send_and_receive(args): stress_test = LongSessionRenewStressTestRunner( senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], - receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME, session_id=session_id)], + receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME, session_id=session_id, max_wait_time=10)], admin_client = sb_admin_client, # duration=timedelta(seconds=3000), duration=args.duration, @@ -235,7 +235,7 @@ async def test_stress_queue_peek_messages(args): SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) stress_test = Peekon_receiveStressTestRunner( senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], - receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME)], + receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME, max_wait_time=10)], admin_client = sb_admin_client, # duration = timedelta(seconds=300), duration=args.duration, @@ -268,7 +268,7 @@ async def test_stress_queue_close_and_reopen(args): SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) stress_test = RestartHandlerStressTestRunner( senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], - receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME)], + receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME, max_wait_time=10)], admin_client = sb_admin_client, # duration = timedelta(seconds=300), duration = args.duration, @@ -316,7 +316,7 @@ async def test_stress_queue_check_for_dropped_messages(args): SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) stress_test = DroppedMessageCheckerStressTestRunner( senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], - receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME)], + receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME, max_wait_time=10)], admin_client = sb_admin_client, receive_type=ReceiveType.pull, # duration=timedelta(seconds=3000), From 99a6b95d9e067817cb6c65458e8a5c1e85d0b812 Mon Sep 17 00:00:00 2001 From: swathipil Date: Thu, 6 Apr 2023 16:12:47 -0700 Subject: [PATCH 03/30] add memray to stress --- .../azure-servicebus/stress/Dockerfile | 6 +- .../stress/scenarios-matrix.yaml | 28 +++-- .../stress/scripts/dev_requirements.txt | 3 +- .../stress/templates/network_loss.yaml | 25 ---- .../stress/templates/testjob.yaml | 113 +----------------- 5 files changed, 24 insertions(+), 151 deletions(-) delete mode 100644 sdk/servicebus/azure-servicebus/stress/templates/network_loss.yaml diff --git a/sdk/servicebus/azure-servicebus/stress/Dockerfile b/sdk/servicebus/azure-servicebus/stress/Dockerfile index ef74c1e9f04c..8df11c085e44 100644 --- a/sdk/servicebus/azure-servicebus/stress/Dockerfile +++ b/sdk/servicebus/azure-servicebus/stress/Dockerfile @@ -7,6 +7,8 @@ RUN apt-get -y update && apt-get -y install git WORKDIR /app COPY ./scripts /app/stress/scripts - +COPY startup.sh /app/stress/scripts WORKDIR /app/stress/scripts -RUN pip install -r dev_requirements.txt + +RUN chmod +x startup.sh +RUN pip3 install -r dev_requirements.txt diff --git a/sdk/servicebus/azure-servicebus/stress/scenarios-matrix.yaml b/sdk/servicebus/azure-servicebus/stress/scenarios-matrix.yaml index 015c143ff022..bd4c4c6dd42f 100644 --- a/sdk/servicebus/azure-servicebus/stress/scenarios-matrix.yaml +++ b/sdk/servicebus/azure-servicebus/stress/scenarios-matrix.yaml @@ -4,33 +4,35 @@ matrix: scenarios: # queue: # testTarget: queue - aqueue: - testTarget: aqueue + #aqueue: + # testTarget: aqueue # queuepull: # testTarget: queuepull - aqueuepull: - testTarget: aqueuepull + #aqueuepull: + # testTarget: aqueuepull + memray: + testTarget: memray + # batch: # testTarget: batch # abatch: # testTarget: abatch # queuew: # testTarget: queuew - aqueuew: - testTarget: aqueuew + #aqueuew: + # testTarget: aqueuew # queuepullw: # testTarget: queuepullw - aqueuepullw: - testTarget: aqueuepullw + #aqueuepullw: + # testTarget: aqueuepullw # batchw: # testTarget: batchw # abatchw: # testTarget: abatchw # queueuamqp: # testTarget: queueuamqp - aqueueuamqp: - testTarget: aqueueuamqp - + #aqueueuamqp: + # testTarget: aqueueuamqp # sendreceiveslow: # testTarget: send_receive_slow # receivedelete: @@ -48,4 +50,6 @@ matrix: # queueclosereopen: # testTarget: queue_close_reopen # droppedmessages: - # testTarget: dropped_messages \ No newline at end of file + # testTarget: dropped_messages + #sbStress: + # testTarget: servicebus diff --git a/sdk/servicebus/azure-servicebus/stress/scripts/dev_requirements.txt b/sdk/servicebus/azure-servicebus/stress/scripts/dev_requirements.txt index a3935756a1ee..230527746377 100644 --- a/sdk/servicebus/azure-servicebus/stress/scripts/dev_requirements.txt +++ b/sdk/servicebus/azure-servicebus/stress/scripts/dev_requirements.txt @@ -5,4 +5,5 @@ pytest git+https://github.com/Azure/azure-sdk-for-python.git@feature/servicebus/pyproto#subdirectory=sdk/servicebus/azure-servicebus&egg=azure-servicebus python-dotenv websocket-client -uamqp==1.6.3 \ No newline at end of file +uamqp==1.6.3 +memray diff --git a/sdk/servicebus/azure-servicebus/stress/templates/network_loss.yaml b/sdk/servicebus/azure-servicebus/stress/templates/network_loss.yaml deleted file mode 100644 index a1e64b80ab9c..000000000000 --- a/sdk/servicebus/azure-servicebus/stress/templates/network_loss.yaml +++ /dev/null @@ -1,25 +0,0 @@ -{{- include "stress-test-addons.chaos-wrapper.tpl" (list . "stress.python-sb-network") -}} -{{- define "stress.python-sb-network" -}} -apiVersion: chaos-mesh.org/v1alpha1 -kind: NetworkChaos -spec: - scheduler: - cron: '@every 30s' - duration: '10s' - action: loss - direction: to - externalTargets: - - '{{ .Stress.ResourceGroupName }}.servicebus.windows.net' - mode: one - selector: - labelSelectors: - testInstance: "servicebus-{{ .Release.Name }}-{{ .Release.Revision }}" - chaos: 'true' - namespaces: - - {{ .Release.Namespace }} - podPhaseSelectors: - - 'Running' - loss: - loss: '100' - correlation: '100' -{{- end -}} \ No newline at end of file diff --git a/sdk/servicebus/azure-servicebus/stress/templates/testjob.yaml b/sdk/servicebus/azure-servicebus/stress/templates/testjob.yaml index 78f5fce649d8..5c956214f5b9 100644 --- a/sdk/servicebus/azure-servicebus/stress/templates/testjob.yaml +++ b/sdk/servicebus/azure-servicebus/stress/templates/testjob.yaml @@ -19,136 +19,27 @@ spec: command: ['bash', '-c', 'python test_stress_queues_async.py --method send_receive --duration 300000 --logging-enable --transport'] {{- end -}} - # {{ if eq .Stress.testTarget "queuew" }} - # command: ['bash', '-c', 'python test_stress_queues.py --method send_receive --duration 300000 --logging-enable --transport'] - # {{- end -}} - {{ if eq .Stress.testTarget "aqueuepullw" }} command: ['bash', '-c', 'python test_stress_queues_async.py --method send_pull_receive --duration 300000 --logging-enable --transport'] {{- end -}} - # {{ if eq .Stress.testTarget "queuepullw" }} - # command: ['bash', '-c', 'python test_stress_queues.py --method send_pull_receive --duration 300000 --logging-enable --transport'] - # {{- end -}} - - # {{ if eq .Stress.testTarget "abatchw" }} - # command: ['bash', '-c', 'python test_stress_queues_async.py --method send_receive_batch --duration 300000 --logging-enable --transport'] - # {{- end -}} - - # {{ if eq .Stress.testTarget "batchw" }} - # command: ['bash', '-c', 'python test_stress_queues.py --method send_receive_batch --duration 300000 --logging-enable --transport'] - # {{- end -}} - {{ if eq .Stress.testTarget "aqueue" }} command: ['bash', '-c', 'python test_stress_queues_async.py --method send_receive --duration 300000 --logging-enable'] {{- end -}} - # {{ if eq .Stress.testTarget "queue" }} - # command: ['bash', '-c', 'python test_stress_queues.py --method send_receive --duration 300000 --logging-enable'] - # {{- end -}} - {{ if eq .Stress.testTarget "aqueuepull" }} command: ['bash', '-c', 'python test_stress_queues_async.py --method send_pull_receive --duration 30000 --logging-enable'] {{- end -}} - # {{ if eq .Stress.testTarget "queuepull" }} - # command: ['bash', '-c', 'python test_stress_queues.py --method send_pull_receive --duration 300000 --logging-enable'] - # {{- end -}} - - # {{ if eq .Stress.testTarget "abatch" }} - # command: ['bash', '-c', 'python test_stress_queues_async.py --method send_receive_batch --duration 300000 --logging-enable'] - # {{- end -}} - - # {{ if eq .Stress.testTarget "batch" }} - # command: ['bash', '-c', 'python test_stress_queues.py --method send_receive_batch --duration 300000 --logging-enable'] - # {{- end -}} - - # {{ if eq .Stress.testTarget "queueuamqp" }} - # command: ['bash', '-c', 'python test_stress_queues.py --method uamqp --duration 300000 --logging-enable --uamqp_mode'] - # {{- end -}} - {{ if eq .Stress.testTarget "aqueueuamqp" }} command: ['bash', '-c', 'python test_stress_queues_async.py --method uamqp --duration 300000 --logging-enable'] {{- end -}} - - - - - # {{ if eq .Stress.testTarget "asend_receive_slow" }} - # command: ['bash', '-c', 'python test_stress_queues_async.py --method send_receive_slow --duration 300000 --logging-enable'] - # {{- end -}} - - # {{ if eq .Stress.testTarget "send_receive_slow" }} - # command: ['bash', '-c', 'python test_stress_queues.py --method send_receive_slow --duration 300000 --logging-enable'] - # {{- end -}} - - # {{ if eq .Stress.testTarget "receive_delete" }} - # command: ['bash', '-c', 'python test_stress_queues_async.py --method receive_delete --duration 300000 --logging-enable'] - # {{- end -}} - - # {{ if eq .Stress.testTarget "unsettled_message" }} - # command: ['bash', '-c', 'python test_stress_queues_async.py --method unsettled_message --duration 300000 --logging-enable'] - # {{- end -}} - # {{ if eq .Stress.testTarget "large_batch" }} - # command: ['bash', '-c', 'python test_stress_queues_async.py --method large_batch --duration 300000 --logging-enable'] - # {{- end -}} - # {{ if eq .Stress.testTarget "pull_receive_timeout" }} - # command: ['bash', '-c', 'python test_stress_queues_async.py --method pull_receive_timeout --duration 300000 --logging-enable'] - # {{- end -}} - # {{ if eq .Stress.testTarget "long_renew" }} - # command: ['bash', '-c', 'python test_stress_queues_async.py --method long_renew --duration 300000 --logging-enable'] - # {{- end -}} - # {{ if eq .Stress.testTarget "long_renew_session" }} - # command: ['bash', '-c', 'python test_stress_queues_async.py --method long_renew_session --duration 300000 --logging-enable'] - # {{- end -}} - # {{ if eq .Stress.testTarget "queue_peek" }} - # command: ['bash', '-c', 'python test_stress_queues_async.py --method queue_peek --duration 300000 --logging-enable'] - # {{- end -}} - # {{ if eq .Stress.testTarget "queue_close_reopen" }} - # command: ['bash', '-c', 'python test_stress_queues_async.py --method queue_close_reopen --duration 300000 --logging-enable'] - # {{- end -}} - # {{ if eq .Stress.testTarget "dropped_messages" }} - # command: ['bash', '-c', 'python test_stress_queues_async.py --method dropped_messages --duration 300000 --logging-enable'] - + {{ if eq .Stress.testTarget "memray" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && memray run --output $DEBUG_SHARE/sb_memray_output.bin test_stress_queues_async.py --method send_pull_receive --duration 30000 --logging-enable'] {{- end -}} {{- include "stress-test-addons.container-env" . | nindent 6 }} {{- end -}} -{{- include "stress-test-addons.chaos-wrapper.tpl" (list . "stress.network-chaos") -}} -{{- define "stress.network-chaos" -}} -# basically: every 15 minutes do 30s of network loss -kind: Schedule -apiVersion: chaos-mesh.org/v1alpha1 -spec: - selector: - namespaces: - - "{{ .Release.Namespace }}" - labelSelectors: - testInstance: "servicebus-{{ .Release.Name }}-{{ .Release.Revision }}" - chaos: "true" - schedule: "*/5 * * * *" - startingDeadlineSeconds: null - concurrencyPolicy: Allow - historyLimit: 1 - type: NetworkChaos - networkChaos: - selector: - namespaces: - - "{{ .Release.Namespace }}" - labelSelectors: - testInstance: "servicebus-{{ .Release.Name }}-{{ .Release.Revision }}" - chaos: "true" - mode: all - action: loss - duration: 20s - loss: - loss: '100' - correlation: '100' - direction: to - externalTargets: - - {{ .Stress.BaseName }}.servicebus.windows.net -{{- end -}} - From a618b3e27ff6e3ff80e70181de9c32532a3f5309 Mon Sep 17 00:00:00 2001 From: swathipil Date: Thu, 6 Apr 2023 16:17:11 -0700 Subject: [PATCH 04/30] undo docker file changes --- sdk/servicebus/azure-servicebus/stress/Dockerfile | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/sdk/servicebus/azure-servicebus/stress/Dockerfile b/sdk/servicebus/azure-servicebus/stress/Dockerfile index 8df11c085e44..e777f3fed449 100644 --- a/sdk/servicebus/azure-servicebus/stress/Dockerfile +++ b/sdk/servicebus/azure-servicebus/stress/Dockerfile @@ -7,8 +7,6 @@ RUN apt-get -y update && apt-get -y install git WORKDIR /app COPY ./scripts /app/stress/scripts -COPY startup.sh /app/stress/scripts -WORKDIR /app/stress/scripts -RUN chmod +x startup.sh -RUN pip3 install -r dev_requirements.txt +WORKDIR /app/stress/scripts +RUN pip install -r dev_requirements.txt \ No newline at end of file From 0aec80f76327de9d4311190e255de4f948a464b6 Mon Sep 17 00:00:00 2001 From: l0lawrence Date: Fri, 7 Apr 2023 13:00:35 -0700 Subject: [PATCH 05/30] add memray chaos --- .../stress/scenarios-matrix.yaml | 63 ++++++++++--------- .../stress/scripts/dev_requirements.txt | 1 - .../stress/scripts/test_stress_queues.py | 1 - .../stress/templates/testjob.yaml | 52 ++++++++++++++- 4 files changed, 84 insertions(+), 33 deletions(-) diff --git a/sdk/servicebus/azure-servicebus/stress/scenarios-matrix.yaml b/sdk/servicebus/azure-servicebus/stress/scenarios-matrix.yaml index bd4c4c6dd42f..1755b3b294c2 100644 --- a/sdk/servicebus/azure-servicebus/stress/scenarios-matrix.yaml +++ b/sdk/servicebus/azure-servicebus/stress/scenarios-matrix.yaml @@ -2,37 +2,42 @@ matrix: image: - Dockerfile scenarios: - # queue: - # testTarget: queue - #aqueue: - # testTarget: aqueue - # queuepull: - # testTarget: queuepull - #aqueuepull: - # testTarget: aqueuepull + queue: + testTarget: queue + aqueue: + testTarget: aqueue + queuepull: + testTarget: queuepull + aqueuepull: + testTarget: aqueuepull + batch: + testTarget: batch + abatch: + testTarget: abatch + queuew: + testTarget: queuew + aqueuew: + testTarget: aqueuew + queuepullw: + testTarget: queuepullw + aqueuepullw: + testTarget: aqueuepullw + batchw: + testTarget: batchw + abatchw: + testTarget: abatchw memray: testTarget: memray - - # batch: - # testTarget: batch - # abatch: - # testTarget: abatch - # queuew: - # testTarget: queuew - #aqueuew: - # testTarget: aqueuew - # queuepullw: - # testTarget: queuepullw - #aqueuepullw: - # testTarget: aqueuepullw - # batchw: - # testTarget: batchw - # abatchw: - # testTarget: abatchw - # queueuamqp: - # testTarget: queueuamqp - #aqueueuamqp: - # testTarget: aqueueuamqp + amemray: + testTarget: amemray + memraychaos: + testTarget: memraychaos + amemraychaos: + testTarget: amemraychaos + queueuamqp: + testTarget: queueuamqp + aqueueuamqp: + testTarget: aqueueuamqp # sendreceiveslow: # testTarget: send_receive_slow # receivedelete: diff --git a/sdk/servicebus/azure-servicebus/stress/scripts/dev_requirements.txt b/sdk/servicebus/azure-servicebus/stress/scripts/dev_requirements.txt index 230527746377..0e6a6fa9cd2b 100644 --- a/sdk/servicebus/azure-servicebus/stress/scripts/dev_requirements.txt +++ b/sdk/servicebus/azure-servicebus/stress/scripts/dev_requirements.txt @@ -1,7 +1,6 @@ aiohttp>=3.0 opencensus-ext-azure psutil -pytest git+https://github.com/Azure/azure-sdk-for-python.git@feature/servicebus/pyproto#subdirectory=sdk/servicebus/azure-servicebus&egg=azure-servicebus python-dotenv websocket-client diff --git a/sdk/servicebus/azure-servicebus/stress/scripts/test_stress_queues.py b/sdk/servicebus/azure-servicebus/stress/scripts/test_stress_queues.py index 037049d3c2f2..965272fbc3d0 100644 --- a/sdk/servicebus/azure-servicebus/stress/scripts/test_stress_queues.py +++ b/sdk/servicebus/azure-servicebus/stress/scripts/test_stress_queues.py @@ -7,7 +7,6 @@ from datetime import timedelta import time import os -import pytest from dotenv import load_dotenv from argparse import ArgumentParser diff --git a/sdk/servicebus/azure-servicebus/stress/templates/testjob.yaml b/sdk/servicebus/azure-servicebus/stress/templates/testjob.yaml index 5c956214f5b9..2de139344f74 100644 --- a/sdk/servicebus/azure-servicebus/stress/templates/testjob.yaml +++ b/sdk/servicebus/azure-servicebus/stress/templates/testjob.yaml @@ -19,24 +19,72 @@ spec: command: ['bash', '-c', 'python test_stress_queues_async.py --method send_receive --duration 300000 --logging-enable --transport'] {{- end -}} + {{ if eq .Stress.testTarget "queuew" }} + command: ['bash', '-c', 'python test_stress_queues.py --method send_receive --duration 300000 --logging-enable --transport'] + {{- end -}} + {{ if eq .Stress.testTarget "aqueuepullw" }} command: ['bash', '-c', 'python test_stress_queues_async.py --method send_pull_receive --duration 300000 --logging-enable --transport'] {{- end -}} + {{ if eq .Stress.testTarget "queuepullw" }} + command: ['bash', '-c', 'python test_stress_queues.py --method send_pull_receive --duration 300000 --logging-enable --transport'] + {{- end -}} + + {{ if eq .Stress.testTarget "abatchw" }} + command: ['bash', '-c', 'python test_stress_queues_async.py --method send_receive_batch --duration 300000 --logging-enable --transport'] + {{- end -}} + + {{ if eq .Stress.testTarget "batchw" }} + command: ['bash', '-c', 'python test_stress_queues.py --method send_receive_batch --duration 300000 --logging-enable --transport'] + {{- end -}} + {{ if eq .Stress.testTarget "aqueue" }} command: ['bash', '-c', 'python test_stress_queues_async.py --method send_receive --duration 300000 --logging-enable'] {{- end -}} + {{ if eq .Stress.testTarget "queue" }} + command: ['bash', '-c', 'python test_stress_queues.py --method send_receive --duration 300000 --logging-enable'] + {{- end -}} + {{ if eq .Stress.testTarget "aqueuepull" }} - command: ['bash', '-c', 'python test_stress_queues_async.py --method send_pull_receive --duration 30000 --logging-enable'] + command: ['bash', '-c', 'python test_stress_queues_async.py --method send_pull_receive --duration 300000 --logging-enable'] + {{- end -}} + + {{ if eq .Stress.testTarget "queuepull" }} + command: ['bash', '-c', 'python test_stress_queues.py --method send_pull_receive --duration 300000 --logging-enable'] + {{- end -}} + + {{ if eq .Stress.testTarget "abatch" }} + command: ['bash', '-c', 'python test_stress_queues_async.py --method send_receive_batch --duration 300000 --logging-enable'] + {{- end -}} + + {{ if eq .Stress.testTarget "batch" }} + command: ['bash', '-c', 'python test_stress_queues.py --method send_receive_batch --duration 300000 --logging-enable'] {{- end -}} {{ if eq .Stress.testTarget "aqueueuamqp" }} command: ['bash', '-c', 'python test_stress_queues_async.py --method uamqp --duration 300000 --logging-enable'] {{- end -}} + {{ if eq .Stress.testTarget "queueuamqp" }} + command: ['bash', '-c', 'python test_stress_queues.py --method uamqp --duration 300000 --logging-enable'] + {{- end -}} + + {{ if eq .Stress.testTarget "amemray" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && memray run --output $DEBUG_SHARE/sb_async_memray_output.bin test_stress_queues_async.py --method send_pull_receive --duration 300000 --logging-enable'] + {{- end -}} + {{ if eq .Stress.testTarget "memray" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && memray run --output $DEBUG_SHARE/sb_memray_output.bin test_stress_queues_async.py --method send_pull_receive --duration 30000 --logging-enable'] + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && memray run --output $DEBUG_SHARE/sb_memray_output.bin test_stress_queues.py --method send_pull_receive --duration 300000 --logging-enable'] + {{- end -}} + + {{ if eq .Stress.testTarget "amemraychaos" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && memray run --output $DEBUG_SHARE/sb_async_memray_chaos_output.bin test_stress_queues_async.py --method send_pull_receive --duration 300000 --logging-enable'] + {{- end -}} + + {{ if eq .Stress.testTarget "memraychaos" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && memray run --output $DEBUG_SHARE/sb_memray_chaos_output.bin test_stress_queues.py --method send_pull_receive --duration 300000 --logging-enable'] {{- end -}} {{- include "stress-test-addons.container-env" . | nindent 6 }} From 0dc5a6e60370da0f51414383a07bb836fd66e9c3 Mon Sep 17 00:00:00 2001 From: l0lawrence Date: Wed, 12 Apr 2023 10:26:59 -0700 Subject: [PATCH 06/30] timeoutError raise --- .../azure/servicebus/_pyamqp/aio/_transport_async.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/_pyamqp/aio/_transport_async.py b/sdk/servicebus/azure-servicebus/azure/servicebus/_pyamqp/aio/_transport_async.py index 4241bd02342c..4350ce57764b 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/_pyamqp/aio/_transport_async.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/_pyamqp/aio/_transport_async.py @@ -83,8 +83,9 @@ async def receive_frame(self, timeout=None, **kwargs): else: decoded = decode_frame(payload) return channel, decoded + except TimeoutError: + raise except ( - TimeoutError, socket.timeout, asyncio.IncompleteReadError, asyncio.TimeoutError, From 787ada7491f979ee9f678d1022656b388c5d15c8 Mon Sep 17 00:00:00 2001 From: l0lawrence Date: Wed, 12 Apr 2023 10:34:22 -0700 Subject: [PATCH 07/30] devred --- .../azure-servicebus/stress/scripts/dev_requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/servicebus/azure-servicebus/stress/scripts/dev_requirements.txt b/sdk/servicebus/azure-servicebus/stress/scripts/dev_requirements.txt index 0e6a6fa9cd2b..7fd730261df2 100644 --- a/sdk/servicebus/azure-servicebus/stress/scripts/dev_requirements.txt +++ b/sdk/servicebus/azure-servicebus/stress/scripts/dev_requirements.txt @@ -1,7 +1,7 @@ aiohttp>=3.0 opencensus-ext-azure psutil -git+https://github.com/Azure/azure-sdk-for-python.git@feature/servicebus/pyproto#subdirectory=sdk/servicebus/azure-servicebus&egg=azure-servicebus +git+https://github.com/l0lawrence/azure-sdk-for-python.git@llaw/servicebus_stress#subdirectory=sdk/servicebus/azure-servicebus&egg=azure-servicebus python-dotenv websocket-client uamqp==1.6.3 From 8b37a1be7140b9832c5362570f9a9c297a42a840 Mon Sep 17 00:00:00 2001 From: l0lawrence Date: Mon, 17 Apr 2023 14:02:08 -0700 Subject: [PATCH 08/30] try log to file --- .../stress/scenarios-matrix.yaml | 8 ++--- .../stress/scripts/dev_requirements.txt | 3 +- .../azure-servicebus/stress/scripts/logger.py | 16 ++++----- .../stress/scripts/stress_test_base.py | 8 ++--- .../stress/templates/testjob.yaml | 36 +++++++++---------- 5 files changed, 35 insertions(+), 36 deletions(-) diff --git a/sdk/servicebus/azure-servicebus/stress/scenarios-matrix.yaml b/sdk/servicebus/azure-servicebus/stress/scenarios-matrix.yaml index 1755b3b294c2..4302d8f8dfcd 100644 --- a/sdk/servicebus/azure-servicebus/stress/scenarios-matrix.yaml +++ b/sdk/servicebus/azure-servicebus/stress/scenarios-matrix.yaml @@ -34,10 +34,10 @@ matrix: testTarget: memraychaos amemraychaos: testTarget: amemraychaos - queueuamqp: - testTarget: queueuamqp - aqueueuamqp: - testTarget: aqueueuamqp + # queueuamqp: + # testTarget: queueuamqp + # aqueueuamqp: + # testTarget: aqueueuamqp # sendreceiveslow: # testTarget: send_receive_slow # receivedelete: diff --git a/sdk/servicebus/azure-servicebus/stress/scripts/dev_requirements.txt b/sdk/servicebus/azure-servicebus/stress/scripts/dev_requirements.txt index 7fd730261df2..7d0035be25a1 100644 --- a/sdk/servicebus/azure-servicebus/stress/scripts/dev_requirements.txt +++ b/sdk/servicebus/azure-servicebus/stress/scripts/dev_requirements.txt @@ -1,8 +1,7 @@ aiohttp>=3.0 opencensus-ext-azure psutil -git+https://github.com/l0lawrence/azure-sdk-for-python.git@llaw/servicebus_stress#subdirectory=sdk/servicebus/azure-servicebus&egg=azure-servicebus +git+https://github.com/kashifkhan/azure-sdk-for-python.git@sb_pyamqp_mem#subdirectory=sdk/servicebus/azure-servicebus&egg=azure-servicebus python-dotenv websocket-client -uamqp==1.6.3 memray diff --git a/sdk/servicebus/azure-servicebus/stress/scripts/logger.py b/sdk/servicebus/azure-servicebus/stress/scripts/logger.py index fc0685181d7f..e93d1423f145 100644 --- a/sdk/servicebus/azure-servicebus/stress/scripts/logger.py +++ b/sdk/servicebus/azure-servicebus/stress/scripts/logger.py @@ -40,7 +40,7 @@ def get_logger(log_filename, logger_name, level=logging.INFO, print_console=Fals stress_logger = logging.getLogger(logger_name) stress_logger.setLevel(logging.WARNING) eventhub_logger = logging.getLogger("azure.servicebus") - eventhub_logger.setLevel(logging.INFO) + eventhub_logger.setLevel(logging.DEBUG) uamqp_logger = logging.getLogger("azure.servicebus._pyamqp.aio.connection") uamqp_logger.setLevel(logging.DEBUG) @@ -62,21 +62,21 @@ def get_logger(log_filename, logger_name, level=logging.INFO, print_console=Fals maxBytes=log_file_max_bytes, backupCount=log_file_backup_count ) - # uamqp_file_handler = RotatingFileHandler( - # "uamqp_" + log_filename, - # maxBytes=log_file_max_bytes, - # backupCount=log_file_backup_count - # ) + uamqp_file_handler = RotatingFileHandler( + "pyamqp_" + log_filename, + maxBytes=log_file_max_bytes, + backupCount=log_file_backup_count + ) stress_file_handler = RotatingFileHandler( log_filename, maxBytes=log_file_max_bytes, backupCount=log_file_backup_count ) eventhub_file_handler.setFormatter(formatter) - # uamqp_file_handler.setFormatter(formatter) + uamqp_file_handler.setFormatter(formatter) stress_file_handler.setFormatter(formatter) eventhub_logger.addHandler(eventhub_file_handler) - # uamqp_logger.addHandler(uamqp_file_handler) + uamqp_logger.addHandler(uamqp_file_handler) stress_logger.addHandler(stress_file_handler) except: pass diff --git a/sdk/servicebus/azure-servicebus/stress/scripts/stress_test_base.py b/sdk/servicebus/azure-servicebus/stress/scripts/stress_test_base.py index 0f14990f35b9..2bba525ad37f 100644 --- a/sdk/servicebus/azure-servicebus/stress/scripts/stress_test_base.py +++ b/sdk/servicebus/azure-servicebus/stress/scripts/stress_test_base.py @@ -25,12 +25,12 @@ from app_insights_metric import AbstractMonitorMetric from process_monitor import ProcessMonitor -# LOGFILE_NAME = os.environ.get("DEBUG_SHARE") + "/success" -LOGFILE_NAME = None +LOGFILE_NAME = os.environ.get("DEBUG_SHARE") +# LOGFILE_NAME = None PRINT_CONSOLE = True -# _logger = logger.get_base_logger(LOGFILE_NAME, "stress_test", logging.INFO) -_logger = get_logger(None, "stress_test", level=logging.INFO, print_console=PRINT_CONSOLE) +_logger = get_logger(LOGFILE_NAME, "stress_test", logging.INFO) +# _logger = get_logger(None, "stress_test", level=logging.INFO, print_console=PRINT_CONSOLE) class ReceiveType: diff --git a/sdk/servicebus/azure-servicebus/stress/templates/testjob.yaml b/sdk/servicebus/azure-servicebus/stress/templates/testjob.yaml index 2de139344f74..9be55ca9ae26 100644 --- a/sdk/servicebus/azure-servicebus/stress/templates/testjob.yaml +++ b/sdk/servicebus/azure-servicebus/stress/templates/testjob.yaml @@ -16,60 +16,60 @@ spec: cpu: "1" {{ if eq .Stress.testTarget "aqueuew" }} - command: ['bash', '-c', 'python test_stress_queues_async.py --method send_receive --duration 300000 --logging-enable --transport'] + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE python test_stress_queues_async.py --method send_receive --duration 300000 --logging-enable --transport'] {{- end -}} {{ if eq .Stress.testTarget "queuew" }} - command: ['bash', '-c', 'python test_stress_queues.py --method send_receive --duration 300000 --logging-enable --transport'] + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE python test_stress_queues.py --method send_receive --duration 300000 --logging-enable --transport'] {{- end -}} {{ if eq .Stress.testTarget "aqueuepullw" }} - command: ['bash', '-c', 'python test_stress_queues_async.py --method send_pull_receive --duration 300000 --logging-enable --transport'] + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE python test_stress_queues_async.py --method send_pull_receive --duration 300000 --logging-enable --transport'] {{- end -}} {{ if eq .Stress.testTarget "queuepullw" }} - command: ['bash', '-c', 'python test_stress_queues.py --method send_pull_receive --duration 300000 --logging-enable --transport'] + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE python test_stress_queues.py --method send_pull_receive --duration 300000 --logging-enable --transport'] {{- end -}} {{ if eq .Stress.testTarget "abatchw" }} - command: ['bash', '-c', 'python test_stress_queues_async.py --method send_receive_batch --duration 300000 --logging-enable --transport'] + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE python test_stress_queues_async.py --method send_receive_batch --duration 300000 --logging-enable --transport'] {{- end -}} {{ if eq .Stress.testTarget "batchw" }} - command: ['bash', '-c', 'python test_stress_queues.py --method send_receive_batch --duration 300000 --logging-enable --transport'] + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE python test_stress_queues.py --method send_receive_batch --duration 300000 --logging-enable --transport'] {{- end -}} {{ if eq .Stress.testTarget "aqueue" }} - command: ['bash', '-c', 'python test_stress_queues_async.py --method send_receive --duration 300000 --logging-enable'] + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE python test_stress_queues_async.py --method send_receive --duration 300000 --logging-enable'] {{- end -}} {{ if eq .Stress.testTarget "queue" }} - command: ['bash', '-c', 'python test_stress_queues.py --method send_receive --duration 300000 --logging-enable'] + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE python test_stress_queues.py --method send_receive --duration 300000 --logging-enable'] {{- end -}} {{ if eq .Stress.testTarget "aqueuepull" }} - command: ['bash', '-c', 'python test_stress_queues_async.py --method send_pull_receive --duration 300000 --logging-enable'] + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE python test_stress_queues_async.py --method send_pull_receive --duration 300000 --logging-enable'] {{- end -}} {{ if eq .Stress.testTarget "queuepull" }} - command: ['bash', '-c', 'python test_stress_queues.py --method send_pull_receive --duration 300000 --logging-enable'] + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE python test_stress_queues.py --method send_pull_receive --duration 300000 --logging-enable'] {{- end -}} {{ if eq .Stress.testTarget "abatch" }} - command: ['bash', '-c', 'python test_stress_queues_async.py --method send_receive_batch --duration 300000 --logging-enable'] + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE python test_stress_queues_async.py --method send_receive_batch --duration 300000 --logging-enable'] {{- end -}} {{ if eq .Stress.testTarget "batch" }} - command: ['bash', '-c', 'python test_stress_queues.py --method send_receive_batch --duration 300000 --logging-enable'] + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE python test_stress_queues.py --method send_receive_batch --duration 300000 --logging-enable'] {{- end -}} - {{ if eq .Stress.testTarget "aqueueuamqp" }} - command: ['bash', '-c', 'python test_stress_queues_async.py --method uamqp --duration 300000 --logging-enable'] - {{- end -}} + # {{ if eq .Stress.testTarget "aqueueuamqp" }} + # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE python test_stress_queues_async.py --method uamqp --duration 300000 --logging-enable'] + # {{- end -}} - {{ if eq .Stress.testTarget "queueuamqp" }} - command: ['bash', '-c', 'python test_stress_queues.py --method uamqp --duration 300000 --logging-enable'] - {{- end -}} + # {{ if eq .Stress.testTarget "queueuamqp" }} + # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE python test_stress_queues.py --method uamqp --duration 300000 --logging-enable'] + # {{- end -}} {{ if eq .Stress.testTarget "amemray" }} command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && memray run --output $DEBUG_SHARE/sb_async_memray_output.bin test_stress_queues_async.py --method send_pull_receive --duration 300000 --logging-enable'] From 5f5369701e1fe52e74c36861fe83b4ca4f13ac19 Mon Sep 17 00:00:00 2001 From: l0lawrence Date: Tue, 18 Apr 2023 10:13:35 -0700 Subject: [PATCH 09/30] test indiv --- .../scripts/test_stress_queues_async.py | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/sdk/servicebus/azure-servicebus/stress/scripts/test_stress_queues_async.py b/sdk/servicebus/azure-servicebus/stress/scripts/test_stress_queues_async.py index 8a8cacf9ce12..6c62321ab06e 100644 --- a/sdk/servicebus/azure-servicebus/stress/scripts/test_stress_queues_async.py +++ b/sdk/servicebus/azure-servicebus/stress/scripts/test_stress_queues_async.py @@ -357,6 +357,48 @@ async def run(args): await test_stress_queue_close_and_reopen(args) elif args.method == "dropped_messages": await test_stress_queue_check_for_dropped_messages(args) + elif args.method == "sender": + sb_client = ServiceBusClient.from_connection_string( + SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) + stress_test = StressTestRunnerAsync(senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], + receivers = [], + admin_client = sb_admin_client, + receive_type=ReceiveType.pull, + duration=args.duration, + azure_monitor_metric=AzureMonitorMetric("test_stress_sender") + ) + + result = await stress_test.run_async() + print(f"Total send {result.total_sent}") + print(f"Total received {result.total_received}") + elif args.method == "receiver": + sb_client = ServiceBusClient.from_connection_string( + SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) + stress_test = StressTestRunnerAsync(senders = [], + receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME, max_wait_time=10)], + admin_client = sb_admin_client, + receive_type=ReceiveType.pull, + duration=args.duration, + azure_monitor_metric=AzureMonitorMetric("test_stress_receiver_messages") + ) + + result = await stress_test.run_async() + print(f"Total send {result.total_sent}") + print(f"Total received {result.total_received}") + elif args.method == "receiveriterator": + sb_client = ServiceBusClient.from_connection_string( + SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) + stress_test = StressTestRunnerAsync(senders = [], + receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME, max_wait_time=10)], + admin_client = sb_admin_client, + receive_type=ReceiveType.push, + duration=args.duration, + azure_monitor_metric=AzureMonitorMetric("test_stress_iterator") + ) + + result = await stress_test.run_async() + print(f"Total send {result.total_sent}") + print(f"Total received {result.total_received}") else: await test_stress_queue_send_and_receive(args) await test_stress_queue_send_and_pull_receive(args) From c4d96ea634ffd15fc4355859c076623708277b5c Mon Sep 17 00:00:00 2001 From: l0lawrence Date: Tue, 18 Apr 2023 10:13:47 -0700 Subject: [PATCH 10/30] test indv --- .../stress/scenarios-matrix.yaml | 66 ++++++------ .../stress/templates/testjob.yaml | 102 ++++++++++-------- 2 files changed, 92 insertions(+), 76 deletions(-) diff --git a/sdk/servicebus/azure-servicebus/stress/scenarios-matrix.yaml b/sdk/servicebus/azure-servicebus/stress/scenarios-matrix.yaml index 4302d8f8dfcd..9486884f83f1 100644 --- a/sdk/servicebus/azure-servicebus/stress/scenarios-matrix.yaml +++ b/sdk/servicebus/azure-servicebus/stress/scenarios-matrix.yaml @@ -2,38 +2,44 @@ matrix: image: - Dockerfile scenarios: - queue: - testTarget: queue - aqueue: - testTarget: aqueue - queuepull: - testTarget: queuepull - aqueuepull: - testTarget: aqueuepull - batch: - testTarget: batch - abatch: - testTarget: abatch - queuew: - testTarget: queuew + # sender: + # testTarget: sender + # receiver: + # testTarget: receiver + # receiveriterator: + # testTarget: receiveriterator + # queue: + # testTarget: queue + # aqueue: + # testTarget: aqueue + # queuepull: + # testTarget: queuepull + # aqueuepull: + # testTarget: aqueuepull + # batch: + # testTarget: batch + # abatch: + # testTarget: abatch + # queuew: + # testTarget: queuew aqueuew: testTarget: aqueuew - queuepullw: - testTarget: queuepullw - aqueuepullw: - testTarget: aqueuepullw - batchw: - testTarget: batchw - abatchw: - testTarget: abatchw - memray: - testTarget: memray - amemray: - testTarget: amemray - memraychaos: - testTarget: memraychaos - amemraychaos: - testTarget: amemraychaos + # queuepullw: + # testTarget: queuepullw + # aqueuepullw: + # testTarget: aqueuepullw + # batchw: + # testTarget: batchw + # abatchw: + # testTarget: abatchw + # memray: + # testTarget: memray + # amemray: + # testTarget: amemray + # memraychaos: + # testTarget: memraychaos + # amemraychaos: + # testTarget: amemraychaos # queueuamqp: # testTarget: queueuamqp # aqueueuamqp: diff --git a/sdk/servicebus/azure-servicebus/stress/templates/testjob.yaml b/sdk/servicebus/azure-servicebus/stress/templates/testjob.yaml index 9be55ca9ae26..b88c983ee63c 100644 --- a/sdk/servicebus/azure-servicebus/stress/templates/testjob.yaml +++ b/sdk/servicebus/azure-servicebus/stress/templates/testjob.yaml @@ -15,53 +15,63 @@ spec: memory: "2000Mi" cpu: "1" + # {{ if eq .Stress.testTarget "sender" }} + # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && memray run --output $DEBUG_SHARE/sender.bin test_stress_queues_async.py --method sender --duration 14400 --logging-enable'] + # {{- end -}} + # {{ if eq .Stress.testTarget "receiver" }} + # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && memray run --output $DEBUG_SHARE/receiver.bin test_stress_queues_async.py --method receiver --duration 14400 --logging-enable'] + # {{- end -}} + # {{ if eq .Stress.testTarget "receiveriterator" }} + # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && memray run --output $DEBUG_SHARE/receiveriterator.bin test_stress_queues_async.py --method receiveriterator --duration 14400 --logging-enable'] + # {{- end -}} + {{ if eq .Stress.testTarget "aqueuew" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE python test_stress_queues_async.py --method send_receive --duration 300000 --logging-enable --transport'] + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python test_stress_queues_async.py --method send_receive --duration 300000 --logging-enable --transport'] {{- end -}} - {{ if eq .Stress.testTarget "queuew" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE python test_stress_queues.py --method send_receive --duration 300000 --logging-enable --transport'] - {{- end -}} + # {{ if eq .Stress.testTarget "queuew" }} + # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues.py --method send_receive --duration 300000 --logging-enable --transport'] + # {{- end -}} - {{ if eq .Stress.testTarget "aqueuepullw" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE python test_stress_queues_async.py --method send_pull_receive --duration 300000 --logging-enable --transport'] - {{- end -}} + # {{ if eq .Stress.testTarget "aqueuepullw" }} + # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues_async.py --method send_pull_receive --duration 300000 --logging-enable --transport'] + # {{- end -}} - {{ if eq .Stress.testTarget "queuepullw" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE python test_stress_queues.py --method send_pull_receive --duration 300000 --logging-enable --transport'] - {{- end -}} + # {{ if eq .Stress.testTarget "queuepullw" }} + # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues.py --method send_pull_receive --duration 300000 --logging-enable --transport'] + # {{- end -}} - {{ if eq .Stress.testTarget "abatchw" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE python test_stress_queues_async.py --method send_receive_batch --duration 300000 --logging-enable --transport'] - {{- end -}} + # {{ if eq .Stress.testTarget "abatchw" }} + # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues_async.py --method send_receive_batch --duration 300000 --logging-enable --transport'] + # {{- end -}} - {{ if eq .Stress.testTarget "batchw" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE python test_stress_queues.py --method send_receive_batch --duration 300000 --logging-enable --transport'] - {{- end -}} + # {{ if eq .Stress.testTarget "batchw" }} + # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues.py --method send_receive_batch --duration 300000 --logging-enable --transport'] + # {{- end -}} - {{ if eq .Stress.testTarget "aqueue" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE python test_stress_queues_async.py --method send_receive --duration 300000 --logging-enable'] - {{- end -}} + # {{ if eq .Stress.testTarget "aqueue" }} + # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues_async.py --method send_receive --duration 300000 --logging-enable'] + # {{- end -}} - {{ if eq .Stress.testTarget "queue" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE python test_stress_queues.py --method send_receive --duration 300000 --logging-enable'] - {{- end -}} + # {{ if eq .Stress.testTarget "queue" }} + # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues.py --method send_receive --duration 300000 --logging-enable'] + # {{- end -}} - {{ if eq .Stress.testTarget "aqueuepull" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE python test_stress_queues_async.py --method send_pull_receive --duration 300000 --logging-enable'] - {{- end -}} + # {{ if eq .Stress.testTarget "aqueuepull" }} + # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues_async.py --method send_pull_receive --duration 300000 --logging-enable'] + # {{- end -}} - {{ if eq .Stress.testTarget "queuepull" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE python test_stress_queues.py --method send_pull_receive --duration 300000 --logging-enable'] - {{- end -}} + # {{ if eq .Stress.testTarget "queuepull" }} + # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues.py --method send_pull_receive --duration 300000 --logging-enable --output $DEBUG_SHARE/output.bin'] + # {{- end -}} - {{ if eq .Stress.testTarget "abatch" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE python test_stress_queues_async.py --method send_receive_batch --duration 300000 --logging-enable'] - {{- end -}} + # {{ if eq .Stress.testTarget "abatch" }} + # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues_async.py --method send_receive_batch --duration 300000 --logging-enable --output $DEBUG_SHARE/output.bin'] + # {{- end -}} - {{ if eq .Stress.testTarget "batch" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE python test_stress_queues.py --method send_receive_batch --duration 300000 --logging-enable'] - {{- end -}} + # {{ if eq .Stress.testTarget "batch" }} + # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues.py --method send_receive_batch --duration 300000 --logging-enable --output $DEBUG_SHARE/output.bin'] + # {{- end -}} # {{ if eq .Stress.testTarget "aqueueuamqp" }} # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE python test_stress_queues_async.py --method uamqp --duration 300000 --logging-enable'] @@ -71,21 +81,21 @@ spec: # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE python test_stress_queues.py --method uamqp --duration 300000 --logging-enable'] # {{- end -}} - {{ if eq .Stress.testTarget "amemray" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && memray run --output $DEBUG_SHARE/sb_async_memray_output.bin test_stress_queues_async.py --method send_pull_receive --duration 300000 --logging-enable'] - {{- end -}} + # {{ if eq .Stress.testTarget "amemray" }} + # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && memray run --output $DEBUG_SHARE/sb_async_memray_output.bin test_stress_queues_async.py --method send_pull_receive --duration 300000 --logging-enable'] + # {{- end -}} - {{ if eq .Stress.testTarget "memray" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && memray run --output $DEBUG_SHARE/sb_memray_output.bin test_stress_queues.py --method send_pull_receive --duration 300000 --logging-enable'] - {{- end -}} + # {{ if eq .Stress.testTarget "memray" }} + # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && memray run --output $DEBUG_SHARE/sb_memray_output.bin test_stress_queues.py --method send_pull_receive --duration 300000 --logging-enable'] + # {{- end -}} - {{ if eq .Stress.testTarget "amemraychaos" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && memray run --output $DEBUG_SHARE/sb_async_memray_chaos_output.bin test_stress_queues_async.py --method send_pull_receive --duration 300000 --logging-enable'] - {{- end -}} + # {{ if eq .Stress.testTarget "amemraychaos" }} + # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && memray run --output $DEBUG_SHARE/sb_async_memray_chaos_output.bin test_stress_queues_async.py --method send_pull_receive --duration 300000 --logging-enable'] + # {{- end -}} - {{ if eq .Stress.testTarget "memraychaos" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && memray run --output $DEBUG_SHARE/sb_memray_chaos_output.bin test_stress_queues.py --method send_pull_receive --duration 300000 --logging-enable'] - {{- end -}} + # {{ if eq .Stress.testTarget "memraychaos" }} + # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && memray run --output $DEBUG_SHARE/sb_memray_chaos_output.bin test_stress_queues.py --method send_pull_receive --duration 300000 --logging-enable'] + # {{- end -}} {{- include "stress-test-addons.container-env" . | nindent 6 }} {{- end -}} From 5d907c575fe9c252c6963a9174cd7efb3b6618f4 Mon Sep 17 00:00:00 2001 From: l0lawrence Date: Tue, 18 Apr 2023 14:33:24 -0700 Subject: [PATCH 11/30] updates --- .../azure-servicebus/stress/scripts/logger.py | 60 ++++--------------- .../stress/scripts/stress_test_base.py | 11 +--- 2 files changed, 13 insertions(+), 58 deletions(-) diff --git a/sdk/servicebus/azure-servicebus/stress/scripts/logger.py b/sdk/servicebus/azure-servicebus/stress/scripts/logger.py index e93d1423f145..c99658328c51 100644 --- a/sdk/servicebus/azure-servicebus/stress/scripts/logger.py +++ b/sdk/servicebus/azure-servicebus/stress/scripts/logger.py @@ -22,64 +22,24 @@ def get_base_logger(log_filename, logger_name, level=logging.INFO, print_console if not logger.handlers: console_handler.setFormatter(formatter) logger.addHandler(console_handler) - - if log_filename: - logger_file_handler = RotatingFileHandler( - log_filename, - maxBytes=log_file_max_bytes, - backupCount=log_file_backup_count - ) - logger_file_handler.setFormatter(formatter) - logger.addHandler(logger_file_handler) - return logger - def get_logger(log_filename, logger_name, level=logging.INFO, print_console=False, log_format=None, log_file_max_bytes=20 * 1024 * 1024, log_file_backup_count=3): stress_logger = logging.getLogger(logger_name) - stress_logger.setLevel(logging.WARNING) - eventhub_logger = logging.getLogger("azure.servicebus") - eventhub_logger.setLevel(logging.DEBUG) - uamqp_logger = logging.getLogger("azure.servicebus._pyamqp.aio.connection") - uamqp_logger.setLevel(logging.DEBUG) + stress_logger.setLevel(logging.DEBUG) + servicebus_logger = logging.getLogger("azure.servicebus") + servicebus_logger.setLevel(logging.DEBUG) + # pyamqp_logger = logging.getLogger("azure.servicebus._pyamqp.aio.connection") + # pyamqp_logger.setLevel(logging.DEBUG) formatter = log_format or logging.Formatter('%(asctime)s %(name)-12s %(levelname)-8s %(message)s') - if print_console: - console_handler = logging.StreamHandler(stream=sys.stdout) - console_handler.setFormatter(formatter) - if not eventhub_logger.handlers: - eventhub_logger.addHandler(console_handler) - if not uamqp_logger.handlers: - uamqp_logger.addHandler(console_handler) - if not stress_logger.handlers: - stress_logger.addHandler(console_handler) - if log_filename: - try: - eventhub_file_handler = RotatingFileHandler( - log_filename, - maxBytes=log_file_max_bytes, - backupCount=log_file_backup_count - ) - uamqp_file_handler = RotatingFileHandler( - "pyamqp_" + log_filename, - maxBytes=log_file_max_bytes, - backupCount=log_file_backup_count - ) - stress_file_handler = RotatingFileHandler( - log_filename, - maxBytes=log_file_max_bytes, - backupCount=log_file_backup_count - ) - eventhub_file_handler.setFormatter(formatter) - uamqp_file_handler.setFormatter(formatter) - stress_file_handler.setFormatter(formatter) - eventhub_logger.addHandler(eventhub_file_handler) - uamqp_logger.addHandler(uamqp_file_handler) - stress_logger.addHandler(stress_file_handler) - except: - pass + console_handler = logging.FileHandler(log_filename) + # console_handler.setFormatter(formatter) + servicebus_logger.addHandler(console_handler) + # pyamqp_logger.addHandler(console_handler) + # stress_logger.addHandler(console_handler) return stress_logger diff --git a/sdk/servicebus/azure-servicebus/stress/scripts/stress_test_base.py b/sdk/servicebus/azure-servicebus/stress/scripts/stress_test_base.py index 2bba525ad37f..f51bf33a6bd3 100644 --- a/sdk/servicebus/azure-servicebus/stress/scripts/stress_test_base.py +++ b/sdk/servicebus/azure-servicebus/stress/scripts/stress_test_base.py @@ -25,12 +25,9 @@ from app_insights_metric import AbstractMonitorMetric from process_monitor import ProcessMonitor -LOGFILE_NAME = os.environ.get("DEBUG_SHARE") -# LOGFILE_NAME = None +LOGFILE_NAME = os.environ.get("DEBUG_SHARE") + "output" PRINT_CONSOLE = True - -_logger = get_logger(LOGFILE_NAME, "stress_test", logging.INFO) -# _logger = get_logger(None, "stress_test", level=logging.INFO, print_console=PRINT_CONSOLE) +_logger = get_logger(LOGFILE_NAME, "stress_test", logging.DEBUG) class ReceiveType: @@ -60,7 +57,6 @@ def __init__(self): self.total_received = 0 self.cpu_percent = None self.memory_bytes = None - self.memory_percent = None self.timestamp = None self.exceptions = [] @@ -72,7 +68,6 @@ def populate_process_stats(self, monitor): try: self.cpu_percent = psutil.cpu_percent() self.memory_bytes = psutil.virtual_memory().percent - self.memory_percent = monitor.memory_usage_percent except NameError: return # psutil was not installed, fall back to simply not capturing these stats. @@ -233,7 +228,7 @@ def _send(self, sender, end_time): raise def _receive(self, receiver, end_time): - # _logger = get_logger(LOGFILE_NAME, "stress_test_receive", level=logging.INFO, print_console=PRINT_CONSOLE) + # _logger = get_logger(LOGFILE_NAME, "stress_test_receive", level=logging.DEBUG, print_console=PRINT_CONSOLE) self._schedule_interval_logger(end_time, "Receiver " + str(self)) delivery_ids = [] try: From 63c0da841627a2d20216354eb3a8d3e801a7b5a8 Mon Sep 17 00:00:00 2001 From: l0lawrence Date: Tue, 18 Apr 2023 19:12:59 -0700 Subject: [PATCH 12/30] tests --- .../stress/scenarios-matrix.yaml | 16 ++++++------- .../azure-servicebus/stress/scripts/logger.py | 23 ++++++++---------- .../stress/scripts/stress_test_base.py | 12 ++++++++-- .../stress/templates/testjob.yaml | 24 +++++++++---------- 4 files changed, 40 insertions(+), 35 deletions(-) diff --git a/sdk/servicebus/azure-servicebus/stress/scenarios-matrix.yaml b/sdk/servicebus/azure-servicebus/stress/scenarios-matrix.yaml index 9486884f83f1..86f870264281 100644 --- a/sdk/servicebus/azure-servicebus/stress/scenarios-matrix.yaml +++ b/sdk/servicebus/azure-servicebus/stress/scenarios-matrix.yaml @@ -2,12 +2,12 @@ matrix: image: - Dockerfile scenarios: - # sender: - # testTarget: sender - # receiver: - # testTarget: receiver - # receiveriterator: - # testTarget: receiveriterator + sender: + testTarget: sender + receiver: + testTarget: receiver + receiveriterator: + testTarget: receiveriterator # queue: # testTarget: queue # aqueue: @@ -22,8 +22,8 @@ matrix: # testTarget: abatch # queuew: # testTarget: queuew - aqueuew: - testTarget: aqueuew + # aqueuew: + # testTarget: aqueuew # queuepullw: # testTarget: queuepullw # aqueuepullw: diff --git a/sdk/servicebus/azure-servicebus/stress/scripts/logger.py b/sdk/servicebus/azure-servicebus/stress/scripts/logger.py index c99658328c51..c59e097744db 100644 --- a/sdk/servicebus/azure-servicebus/stress/scripts/logger.py +++ b/sdk/servicebus/azure-servicebus/stress/scripts/logger.py @@ -14,14 +14,11 @@ def get_base_logger(log_filename, logger_name, level=logging.INFO, print_console=False, log_format=None, log_file_max_bytes=20 * 1024 * 1024, log_file_backup_count=3): logger = logging.getLogger(logger_name) - logger.setLevel(level) + logger.setLevel(logging.DEBUG) formatter = log_format or logging.Formatter('%(asctime)s %(name)-12s %(levelname)-8s %(message)s') - - if print_console: - console_handler = logging.StreamHandler(stream=sys.stdout) - if not logger.handlers: - console_handler.setFormatter(formatter) - logger.addHandler(console_handler) + console_handler = logging.StreamHandler(sys.stdout) + console_handler.setFormatter(formatter) + logger.addHandler(console_handler) return logger def get_logger(log_filename, logger_name, level=logging.INFO, print_console=False, log_format=None, @@ -30,23 +27,23 @@ def get_logger(log_filename, logger_name, level=logging.INFO, print_console=Fals stress_logger.setLevel(logging.DEBUG) servicebus_logger = logging.getLogger("azure.servicebus") servicebus_logger.setLevel(logging.DEBUG) - # pyamqp_logger = logging.getLogger("azure.servicebus._pyamqp.aio.connection") - # pyamqp_logger.setLevel(logging.DEBUG) + pyamqp_logger = logging.getLogger("azure.servicebus._pyamqp") + pyamqp_logger.setLevel(logging.DEBUG) formatter = log_format or logging.Formatter('%(asctime)s %(name)-12s %(levelname)-8s %(message)s') console_handler = logging.FileHandler(log_filename) - # console_handler.setFormatter(formatter) + console_handler.setFormatter(formatter) servicebus_logger.addHandler(console_handler) - # pyamqp_logger.addHandler(console_handler) - # stress_logger.addHandler(console_handler) + pyamqp_logger.addHandler(console_handler) + stress_logger.addHandler(console_handler) return stress_logger def get_azure_logger(logger_name, level=logging.INFO): logger = logging.getLogger("azure_logger_" + logger_name) - logger.setLevel(level) + logger.setLevel(logging.DEBUG) # oc will automatically search for the ENV VAR 'APPLICATIONINSIGHTS_CONNECTION_STRING' logger.addHandler(AzureLogHandler()) return logger diff --git a/sdk/servicebus/azure-servicebus/stress/scripts/stress_test_base.py b/sdk/servicebus/azure-servicebus/stress/scripts/stress_test_base.py index f51bf33a6bd3..449b0d6ab4d4 100644 --- a/sdk/servicebus/azure-servicebus/stress/scripts/stress_test_base.py +++ b/sdk/servicebus/azure-servicebus/stress/scripts/stress_test_base.py @@ -193,14 +193,18 @@ def _construct_message(self): return message def _send(self, sender, end_time): - self._schedule_interval_logger(end_time, "Sender " + str(self)) + # self._schedule_interval_logger(end_time, "Sender " + str(self)) try: + _logger.debug("Starting send loop") + # log sender + _logger.debug("Sender: {}".format(sender)) with sender: while end_time > datetime.utcnow() and not self._should_stop: try: message = self._construct_message() if self.send_session_id != None: message.session_id = self.send_session_id + _logger.debug("Sending message: {}".format(message)) sender.send_messages(message) self.azure_monitor_metric.record_messages_cpu_memory( self.send_batch_size, @@ -229,8 +233,10 @@ def _send(self, sender, end_time): def _receive(self, receiver, end_time): # _logger = get_logger(LOGFILE_NAME, "stress_test_receive", level=logging.DEBUG, print_console=PRINT_CONSOLE) - self._schedule_interval_logger(end_time, "Receiver " + str(self)) + # self._schedule_interval_logger(end_time, "Receiver " + str(self)) delivery_ids = [] + #log receiver + _logger.debug("Receiver: {}".format(receiver)) try: with receiver: while end_time > datetime.utcnow() and not self._should_stop: @@ -247,6 +253,8 @@ def _receive(self, receiver, end_time): batch = [] for message in batch: + # log reciever + _logger.debug("Received message: {}".format(message)) self.on_receive(self._state, message, receiver) try: if self.should_complete_messages: diff --git a/sdk/servicebus/azure-servicebus/stress/templates/testjob.yaml b/sdk/servicebus/azure-servicebus/stress/templates/testjob.yaml index b88c983ee63c..01be6057f633 100644 --- a/sdk/servicebus/azure-servicebus/stress/templates/testjob.yaml +++ b/sdk/servicebus/azure-servicebus/stress/templates/testjob.yaml @@ -15,19 +15,19 @@ spec: memory: "2000Mi" cpu: "1" - # {{ if eq .Stress.testTarget "sender" }} - # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && memray run --output $DEBUG_SHARE/sender.bin test_stress_queues_async.py --method sender --duration 14400 --logging-enable'] - # {{- end -}} - # {{ if eq .Stress.testTarget "receiver" }} - # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && memray run --output $DEBUG_SHARE/receiver.bin test_stress_queues_async.py --method receiver --duration 14400 --logging-enable'] - # {{- end -}} - # {{ if eq .Stress.testTarget "receiveriterator" }} - # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && memray run --output $DEBUG_SHARE/receiveriterator.bin test_stress_queues_async.py --method receiveriterator --duration 14400 --logging-enable'] - # {{- end -}} - - {{ if eq .Stress.testTarget "aqueuew" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python test_stress_queues_async.py --method send_receive --duration 300000 --logging-enable --transport'] + {{ if eq .Stress.testTarget "sender" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python test_stress_queues_async.py --method sender --duration 14400 --logging-enable --transport'] {{- end -}} + {{ if eq .Stress.testTarget "receiver" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python test_stress_queues_async.py --method receiver --duration 14400 --logging-enable --transport'] + {{- end -}} + {{ if eq .Stress.testTarget "receiveriterator" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python test_stress_queues_async.py --method receiveriterator --duration 14400 --logging-enable --transport'] + {{- end -}} + + # {{ if eq .Stress.testTarget "aqueuew" }} + # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python test_stress_queues.py --method send_receive --duration 300000 --logging-enable --transport'] + # {{- end -}} # {{ if eq .Stress.testTarget "queuew" }} # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues.py --method send_receive --duration 300000 --logging-enable --transport'] From fbcac748056d0f925d9685c10b76b17f25d3ba57 Mon Sep 17 00:00:00 2001 From: l0lawrence Date: Wed, 19 Apr 2023 12:32:33 -0700 Subject: [PATCH 13/30] logging_enable --- .../azure-servicebus/stress/scripts/test_stress_queues.py | 2 +- .../azure-servicebus/stress/scripts/test_stress_queues_async.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/servicebus/azure-servicebus/stress/scripts/test_stress_queues.py b/sdk/servicebus/azure-servicebus/stress/scripts/test_stress_queues.py index 965272fbc3d0..1b342f47b8ea 100644 --- a/sdk/servicebus/azure-servicebus/stress/scripts/test_stress_queues.py +++ b/sdk/servicebus/azure-servicebus/stress/scripts/test_stress_queues.py @@ -335,7 +335,7 @@ def test_stress_queue_check_for_dropped_messages(args): parser.add_argument("--queue_name", help="The queue name.", default="testQueue") parser.add_argument("--method", type=str) parser.add_argument("--duration", type=int, default=259200) - parser.add_argument("--logging_enable", action="store_true") + parser.add_argument("--logging-enable", action="store_true") parser.add_argument("--print_console", action="store_true") parser.add_argument("--send-batch-size", type=int, default=100) diff --git a/sdk/servicebus/azure-servicebus/stress/scripts/test_stress_queues_async.py b/sdk/servicebus/azure-servicebus/stress/scripts/test_stress_queues_async.py index 6c62321ab06e..ddf3235f5bdf 100644 --- a/sdk/servicebus/azure-servicebus/stress/scripts/test_stress_queues_async.py +++ b/sdk/servicebus/azure-servicebus/stress/scripts/test_stress_queues_async.py @@ -423,7 +423,7 @@ async def run(args): parser.add_argument("--queue_name", help="The queue name.", default='testQueue') parser.add_argument("--method", type=str) parser.add_argument("--duration", type=int, default=259200) - parser.add_argument("--logging_enable", action="store_true") + parser.add_argument("--logging-enable", action="store_true") parser.add_argument("--print_console", action="store_true") parser.add_argument("--send-batch-size", type=int, default=100) From 7e8b685911b2abf8b22576fc0d88a6ce20790c95 Mon Sep 17 00:00:00 2001 From: l0lawrence Date: Thu, 20 Apr 2023 10:52:38 -0700 Subject: [PATCH 14/30] stress --- .../stress/scenarios-matrix.yaml | 68 +++++------ .../stress/scripts/stress_test_base.py | 6 +- .../stress/scripts/test_stress_queues.py | 19 --- .../scripts/test_stress_queues_async.py | 61 ---------- .../stress/templates/testjob.yaml | 108 +++++++----------- 5 files changed, 69 insertions(+), 193 deletions(-) diff --git a/sdk/servicebus/azure-servicebus/stress/scenarios-matrix.yaml b/sdk/servicebus/azure-servicebus/stress/scenarios-matrix.yaml index 86f870264281..646a35626ec1 100644 --- a/sdk/servicebus/azure-servicebus/stress/scenarios-matrix.yaml +++ b/sdk/servicebus/azure-servicebus/stress/scenarios-matrix.yaml @@ -2,48 +2,32 @@ matrix: image: - Dockerfile scenarios: - sender: - testTarget: sender - receiver: - testTarget: receiver - receiveriterator: - testTarget: receiveriterator - # queue: - # testTarget: queue - # aqueue: - # testTarget: aqueue - # queuepull: - # testTarget: queuepull - # aqueuepull: - # testTarget: aqueuepull - # batch: - # testTarget: batch - # abatch: - # testTarget: abatch - # queuew: - # testTarget: queuew - # aqueuew: - # testTarget: aqueuew - # queuepullw: - # testTarget: queuepullw - # aqueuepullw: - # testTarget: aqueuepullw - # batchw: - # testTarget: batchw - # abatchw: - # testTarget: abatchw - # memray: - # testTarget: memray - # amemray: - # testTarget: amemray - # memraychaos: - # testTarget: memraychaos - # amemraychaos: - # testTarget: amemraychaos - # queueuamqp: - # testTarget: queueuamqp - # aqueueuamqp: - # testTarget: aqueueuamqp + queue: + testTarget: queue + aqueue: + testTarget: aqueue + queuepull: + testTarget: queuepull + aqueuepull: + testTarget: aqueuepull + batch: + testTarget: batch + abatch: + testTarget: abatch + queuew: + testTarget: queuew + aqueuew: + testTarget: aqueuew + queuepullw: + testTarget: queuepullw + aqueuepullw: + testTarget: aqueuepullw + batchw: + testTarget: batchw + abatchw: + testTarget: abatchw + memray: + testTarget: memray # sendreceiveslow: # testTarget: send_receive_slow # receivedelete: diff --git a/sdk/servicebus/azure-servicebus/stress/scripts/stress_test_base.py b/sdk/servicebus/azure-servicebus/stress/scripts/stress_test_base.py index 449b0d6ab4d4..9100fac72ac3 100644 --- a/sdk/servicebus/azure-servicebus/stress/scripts/stress_test_base.py +++ b/sdk/servicebus/azure-servicebus/stress/scripts/stress_test_base.py @@ -232,10 +232,8 @@ def _send(self, sender, end_time): raise def _receive(self, receiver, end_time): - # _logger = get_logger(LOGFILE_NAME, "stress_test_receive", level=logging.DEBUG, print_console=PRINT_CONSOLE) - # self._schedule_interval_logger(end_time, "Receiver " + str(self)) - delivery_ids = [] - #log receiver + self._schedule_interval_logger(end_time, "Receiver " + str(self)) + # log receiver _logger.debug("Receiver: {}".format(receiver)) try: with receiver: diff --git a/sdk/servicebus/azure-servicebus/stress/scripts/test_stress_queues.py b/sdk/servicebus/azure-servicebus/stress/scripts/test_stress_queues.py index 1b342f47b8ea..ee2dab90b9b0 100644 --- a/sdk/servicebus/azure-servicebus/stress/scripts/test_stress_queues.py +++ b/sdk/servicebus/azure-servicebus/stress/scripts/test_stress_queues.py @@ -64,23 +64,6 @@ def test_stress_queue_batch_send_and_receive(args): print(f"Total send {result.total_sent}") print(f"Total received {result.total_received}") -def test_stress_queue_batch_send_and_receive_u(args): - sb_client = ServiceBusClient.from_connection_string( - SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) - uamqp_sb_client = ServiceBusClient.from_connection_string( - SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE, uamqp_transport=True) - stress_test = StressTestRunner(senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], - receivers = [uamqp_sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME, prefetch_count=5)], - admin_client = sb_admin_client, - duration=args.duration, - send_batch_size=5, - azure_monitor_metric=AzureMonitorMetric("test_stress_queue_batch_send_and_receive") - ) - - result = stress_test.run() - print(f"Total send {result.total_sent}") - print(f"Total received {result.total_received}") - def test_stress_queue_slow_send_and_receive(args): sb_client = ServiceBusClient.from_connection_string( SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) @@ -366,8 +349,6 @@ def test_stress_queue_check_for_dropped_messages(args): test_stress_queue_send_and_pull_receive(args) elif args.method == "send_receive_batch": test_stress_queue_batch_send_and_receive(args) - elif args.method == "uamqp": - test_stress_queue_batch_send_and_receive_u(args) elif args.method == "send_receive_slow": test_stress_queue_slow_send_and_receive(args) elif args.method == "receive_delete": diff --git a/sdk/servicebus/azure-servicebus/stress/scripts/test_stress_queues_async.py b/sdk/servicebus/azure-servicebus/stress/scripts/test_stress_queues_async.py index ddf3235f5bdf..42bc8e974fed 100644 --- a/sdk/servicebus/azure-servicebus/stress/scripts/test_stress_queues_async.py +++ b/sdk/servicebus/azure-servicebus/stress/scripts/test_stress_queues_async.py @@ -51,23 +51,6 @@ async def test_stress_queue_send_and_pull_receive(args): print(f"Total send {result.total_sent}") print(f"Total received {result.total_received}") -async def test_stress_queue_batch_send_and_receive_u(args): - sb_client = ServiceBusClient.from_connection_string( - SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) - uamqp_sb_client = ServiceBusClient.from_connection_string( - SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE, uamqp_transport=True) - stress_test = StressTestRunnerAsync(senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], - receivers = [uamqp_sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME, prefetch_count=5, max_wait_time=10)], - admin_client = sb_admin_client, - duration=args.duration, - send_batch_size=5, - azure_monitor_metric=AzureMonitorMetric("test_stress_queue_batch_send_and_receive") - ) - - result = await stress_test.run_async() - print(f"Total send {result.total_sent}") - print(f"Total received {result.total_received}") - async def test_stress_queue_batch_send_and_receive(args): sb_client = ServiceBusClient.from_connection_string( SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) @@ -335,8 +318,6 @@ async def run(args): await test_stress_queue_send_and_pull_receive(args) elif args.method == "send_receive_batch": await test_stress_queue_batch_send_and_receive(args) - elif args.method == "uamqp": - await test_stress_queue_batch_send_and_receive_u(args) elif args.method == "send_receive_slow": await test_stress_queue_slow_send_and_receive(args) elif args.method == "receive_delete": @@ -357,48 +338,6 @@ async def run(args): await test_stress_queue_close_and_reopen(args) elif args.method == "dropped_messages": await test_stress_queue_check_for_dropped_messages(args) - elif args.method == "sender": - sb_client = ServiceBusClient.from_connection_string( - SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) - stress_test = StressTestRunnerAsync(senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], - receivers = [], - admin_client = sb_admin_client, - receive_type=ReceiveType.pull, - duration=args.duration, - azure_monitor_metric=AzureMonitorMetric("test_stress_sender") - ) - - result = await stress_test.run_async() - print(f"Total send {result.total_sent}") - print(f"Total received {result.total_received}") - elif args.method == "receiver": - sb_client = ServiceBusClient.from_connection_string( - SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) - stress_test = StressTestRunnerAsync(senders = [], - receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME, max_wait_time=10)], - admin_client = sb_admin_client, - receive_type=ReceiveType.pull, - duration=args.duration, - azure_monitor_metric=AzureMonitorMetric("test_stress_receiver_messages") - ) - - result = await stress_test.run_async() - print(f"Total send {result.total_sent}") - print(f"Total received {result.total_received}") - elif args.method == "receiveriterator": - sb_client = ServiceBusClient.from_connection_string( - SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) - stress_test = StressTestRunnerAsync(senders = [], - receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME, max_wait_time=10)], - admin_client = sb_admin_client, - receive_type=ReceiveType.push, - duration=args.duration, - azure_monitor_metric=AzureMonitorMetric("test_stress_iterator") - ) - - result = await stress_test.run_async() - print(f"Total send {result.total_sent}") - print(f"Total received {result.total_received}") else: await test_stress_queue_send_and_receive(args) await test_stress_queue_send_and_pull_receive(args) diff --git a/sdk/servicebus/azure-servicebus/stress/templates/testjob.yaml b/sdk/servicebus/azure-servicebus/stress/templates/testjob.yaml index 01be6057f633..afdd4cf59a34 100644 --- a/sdk/servicebus/azure-servicebus/stress/templates/testjob.yaml +++ b/sdk/servicebus/azure-servicebus/stress/templates/testjob.yaml @@ -15,87 +15,61 @@ spec: memory: "2000Mi" cpu: "1" - {{ if eq .Stress.testTarget "sender" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python test_stress_queues_async.py --method sender --duration 14400 --logging-enable --transport'] + {{ if eq .Stress.testTarget "aqueuew" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python test_stress_queues.py --method send_receive --duration 300000 --logging-enable --transport'] {{- end -}} - {{ if eq .Stress.testTarget "receiver" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python test_stress_queues_async.py --method receiver --duration 14400 --logging-enable --transport'] - {{- end -}} - {{ if eq .Stress.testTarget "receiveriterator" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python test_stress_queues_async.py --method receiveriterator --duration 14400 --logging-enable --transport'] - {{- end -}} - - # {{ if eq .Stress.testTarget "aqueuew" }} - # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python test_stress_queues.py --method send_receive --duration 300000 --logging-enable --transport'] - # {{- end -}} - - # {{ if eq .Stress.testTarget "queuew" }} - # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues.py --method send_receive --duration 300000 --logging-enable --transport'] - # {{- end -}} - - # {{ if eq .Stress.testTarget "aqueuepullw" }} - # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues_async.py --method send_pull_receive --duration 300000 --logging-enable --transport'] - # {{- end -}} - # {{ if eq .Stress.testTarget "queuepullw" }} - # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues.py --method send_pull_receive --duration 300000 --logging-enable --transport'] - # {{- end -}} - - # {{ if eq .Stress.testTarget "abatchw" }} - # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues_async.py --method send_receive_batch --duration 300000 --logging-enable --transport'] - # {{- end -}} - - # {{ if eq .Stress.testTarget "batchw" }} - # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues.py --method send_receive_batch --duration 300000 --logging-enable --transport'] - # {{- end -}} + {{ if eq .Stress.testTarget "queuew" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues.py --method send_receive --duration 300000 --logging-enable --transport'] + {{- end -}} - # {{ if eq .Stress.testTarget "aqueue" }} - # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues_async.py --method send_receive --duration 300000 --logging-enable'] - # {{- end -}} + {{ if eq .Stress.testTarget "aqueuepullw" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues_async.py --method send_pull_receive --duration 300000 --logging-enable --transport'] + {{- end -}} - # {{ if eq .Stress.testTarget "queue" }} - # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues.py --method send_receive --duration 300000 --logging-enable'] - # {{- end -}} + {{ if eq .Stress.testTarget "queuepullw" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues.py --method send_pull_receive --duration 300000 --logging-enable --transport'] + {{- end -}} - # {{ if eq .Stress.testTarget "aqueuepull" }} - # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues_async.py --method send_pull_receive --duration 300000 --logging-enable'] - # {{- end -}} + {{ if eq .Stress.testTarget "abatchw" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues_async.py --method send_receive_batch --duration 300000 --logging-enable --transport'] + {{- end -}} - # {{ if eq .Stress.testTarget "queuepull" }} - # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues.py --method send_pull_receive --duration 300000 --logging-enable --output $DEBUG_SHARE/output.bin'] - # {{- end -}} + {{ if eq .Stress.testTarget "batchw" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues.py --method send_receive_batch --duration 300000 --logging-enable --transport'] + {{- end -}} - # {{ if eq .Stress.testTarget "abatch" }} - # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues_async.py --method send_receive_batch --duration 300000 --logging-enable --output $DEBUG_SHARE/output.bin'] - # {{- end -}} + {{ if eq .Stress.testTarget "aqueue" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues_async.py --method send_receive --duration 300000 --logging-enable'] + {{- end -}} - # {{ if eq .Stress.testTarget "batch" }} - # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues.py --method send_receive_batch --duration 300000 --logging-enable --output $DEBUG_SHARE/output.bin'] - # {{- end -}} + {{ if eq .Stress.testTarget "queue" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues.py --method send_receive --duration 300000 --logging-enable'] + {{- end -}} - # {{ if eq .Stress.testTarget "aqueueuamqp" }} - # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE python test_stress_queues_async.py --method uamqp --duration 300000 --logging-enable'] - # {{- end -}} + {{ if eq .Stress.testTarget "aqueuepull" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues_async.py --method send_pull_receive --duration 300000 --logging-enable'] + {{- end -}} - # {{ if eq .Stress.testTarget "queueuamqp" }} - # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE python test_stress_queues.py --method uamqp --duration 300000 --logging-enable'] - # {{- end -}} + {{ if eq .Stress.testTarget "queuepull" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues.py --method send_pull_receive --duration 300000 --logging-enable --output $DEBUG_SHARE/output.bin'] + {{- end -}} - # {{ if eq .Stress.testTarget "amemray" }} - # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && memray run --output $DEBUG_SHARE/sb_async_memray_output.bin test_stress_queues_async.py --method send_pull_receive --duration 300000 --logging-enable'] - # {{- end -}} + {{ if eq .Stress.testTarget "abatch" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues_async.py --method send_receive_batch --duration 300000 --logging-enable --output $DEBUG_SHARE/output.bin'] + {{- end -}} - # {{ if eq .Stress.testTarget "memray" }} - # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && memray run --output $DEBUG_SHARE/sb_memray_output.bin test_stress_queues.py --method send_pull_receive --duration 300000 --logging-enable'] - # {{- end -}} + {{ if eq .Stress.testTarget "batch" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues.py --method send_receive_batch --duration 300000 --logging-enable --output $DEBUG_SHARE/output.bin'] + {{- end -}} - # {{ if eq .Stress.testTarget "amemraychaos" }} - # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && memray run --output $DEBUG_SHARE/sb_async_memray_chaos_output.bin test_stress_queues_async.py --method send_pull_receive --duration 300000 --logging-enable'] - # {{- end -}} + {{ if eq .Stress.testTarget "amemray" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && memray run --output $DEBUG_SHARE/sb_async_memray_output.bin test_stress_queues_async.py --method send_pull_receive --duration 300000 --logging-enable'] + {{- end -}} - # {{ if eq .Stress.testTarget "memraychaos" }} - # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && memray run --output $DEBUG_SHARE/sb_memray_chaos_output.bin test_stress_queues.py --method send_pull_receive --duration 300000 --logging-enable'] - # {{- end -}} + {{ if eq .Stress.testTarget "memray" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && memray run --output $DEBUG_SHARE/sb_memray_output.bin test_stress_queues.py --method send_pull_receive --duration 300000 --logging-enable'] + {{- end -}} {{- include "stress-test-addons.container-env" . | nindent 6 }} {{- end -}} From 186fd5ca5489ba6e41596bba6a6bdcf839c2262d Mon Sep 17 00:00:00 2001 From: l0lawrence Date: Thu, 20 Apr 2023 10:53:33 -0700 Subject: [PATCH 15/30] update --- sdk/servicebus/azure-servicebus/stress/Dockerfile | 2 +- .../azure-servicebus/stress/scripts/dev_requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/servicebus/azure-servicebus/stress/Dockerfile b/sdk/servicebus/azure-servicebus/stress/Dockerfile index e777f3fed449..501383ea4b0b 100644 --- a/sdk/servicebus/azure-servicebus/stress/Dockerfile +++ b/sdk/servicebus/azure-servicebus/stress/Dockerfile @@ -2,7 +2,7 @@ # public OSS users should simply leave this argument blank or ignore its presence entirely ARG REGISTRY="mcr.microsoft.com/mirror/docker/library/" FROM ${REGISTRY}python:3.8-slim-buster -RUN apt-get -y update && apt-get -y install git +# RUN apt-get -y update && apt-get -y install git WORKDIR /app diff --git a/sdk/servicebus/azure-servicebus/stress/scripts/dev_requirements.txt b/sdk/servicebus/azure-servicebus/stress/scripts/dev_requirements.txt index 7d0035be25a1..31431185aeb6 100644 --- a/sdk/servicebus/azure-servicebus/stress/scripts/dev_requirements.txt +++ b/sdk/servicebus/azure-servicebus/stress/scripts/dev_requirements.txt @@ -1,7 +1,7 @@ aiohttp>=3.0 opencensus-ext-azure psutil -git+https://github.com/kashifkhan/azure-sdk-for-python.git@sb_pyamqp_mem#subdirectory=sdk/servicebus/azure-servicebus&egg=azure-servicebus +azure-servicebus==7.10.0b1 python-dotenv websocket-client memray From 0b098014d32cff0402a26c8c317efc76b25e5432 Mon Sep 17 00:00:00 2001 From: l0lawrence Date: Thu, 20 Apr 2023 10:54:32 -0700 Subject: [PATCH 16/30] delete --- .../stress/charts/stress-test-addons-0.2.0.tgz | Bin 7612 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 sdk/servicebus/azure-servicebus/stress/charts/stress-test-addons-0.2.0.tgz diff --git a/sdk/servicebus/azure-servicebus/stress/charts/stress-test-addons-0.2.0.tgz b/sdk/servicebus/azure-servicebus/stress/charts/stress-test-addons-0.2.0.tgz deleted file mode 100644 index f0d473ee59a269bdaa17b7c7d4e8a088dd05818d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 7612 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 From 0d4f713e6e0e9de3491fab9057f52d37cfcd2bbd Mon Sep 17 00:00:00 2001 From: l0lawrence Date: Thu, 20 Apr 2023 10:56:09 -0700 Subject: [PATCH 17/30] remove changes to code --- .../azure/servicebus/_pyamqp/aio/_transport_async.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/_pyamqp/aio/_transport_async.py b/sdk/servicebus/azure-servicebus/azure/servicebus/_pyamqp/aio/_transport_async.py index 4350ce57764b..4241bd02342c 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/_pyamqp/aio/_transport_async.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/_pyamqp/aio/_transport_async.py @@ -83,9 +83,8 @@ async def receive_frame(self, timeout=None, **kwargs): else: decoded = decode_frame(payload) return channel, decoded - except TimeoutError: - raise except ( + TimeoutError, socket.timeout, asyncio.IncompleteReadError, asyncio.TimeoutError, From 725cf1bbacc0aa4d78a1192ba9f44ca8f1a3777f Mon Sep 17 00:00:00 2001 From: l0lawrence Date: Thu, 20 Apr 2023 11:00:37 -0700 Subject: [PATCH 18/30] change level --- .../azure-servicebus/stress/scripts/logger.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/sdk/servicebus/azure-servicebus/stress/scripts/logger.py b/sdk/servicebus/azure-servicebus/stress/scripts/logger.py index c59e097744db..b58e486ee92d 100644 --- a/sdk/servicebus/azure-servicebus/stress/scripts/logger.py +++ b/sdk/servicebus/azure-servicebus/stress/scripts/logger.py @@ -14,21 +14,21 @@ def get_base_logger(log_filename, logger_name, level=logging.INFO, print_console=False, log_format=None, log_file_max_bytes=20 * 1024 * 1024, log_file_backup_count=3): logger = logging.getLogger(logger_name) - logger.setLevel(logging.DEBUG) + logger.setLevel(level) formatter = log_format or logging.Formatter('%(asctime)s %(name)-12s %(levelname)-8s %(message)s') console_handler = logging.StreamHandler(sys.stdout) console_handler.setFormatter(formatter) logger.addHandler(console_handler) return logger -def get_logger(log_filename, logger_name, level=logging.INFO, print_console=False, log_format=None, +def get_logger(log_filename, logger_name, level=logging.DEBUG, print_console=False, log_format=None, log_file_max_bytes=20 * 1024 * 1024, log_file_backup_count=3): stress_logger = logging.getLogger(logger_name) - stress_logger.setLevel(logging.DEBUG) + stress_logger.setLevel(level) servicebus_logger = logging.getLogger("azure.servicebus") - servicebus_logger.setLevel(logging.DEBUG) + servicebus_logger.setLevel(level) pyamqp_logger = logging.getLogger("azure.servicebus._pyamqp") - pyamqp_logger.setLevel(logging.DEBUG) + pyamqp_logger.setLevel(level) formatter = log_format or logging.Formatter('%(asctime)s %(name)-12s %(levelname)-8s %(message)s') @@ -41,9 +41,9 @@ def get_logger(log_filename, logger_name, level=logging.INFO, print_console=Fals return stress_logger -def get_azure_logger(logger_name, level=logging.INFO): +def get_azure_logger(logger_name, level=logging.DEBUG): logger = logging.getLogger("azure_logger_" + logger_name) - logger.setLevel(logging.DEBUG) + logger.setLevel(level) # oc will automatically search for the ENV VAR 'APPLICATIONINSIGHTS_CONNECTION_STRING' logger.addHandler(AzureLogHandler()) return logger From 005ac625b5cbf3611c63cc98f17b7a1f74ebb0d3 Mon Sep 17 00:00:00 2001 From: l0lawrence Date: Thu, 20 Apr 2023 11:05:22 -0700 Subject: [PATCH 19/30] update chart.yaml --- sdk/servicebus/azure-servicebus/stress/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/servicebus/azure-servicebus/stress/Chart.yaml b/sdk/servicebus/azure-servicebus/stress/Chart.yaml index 297f89f751d2..c9401730fb50 100644 --- a/sdk/servicebus/azure-servicebus/stress/Chart.yaml +++ b/sdk/servicebus/azure-servicebus/stress/Chart.yaml @@ -10,4 +10,4 @@ annotations: dependencies: - name: stress-test-addons version: 0.2.0 - repository: https://stresstestcharts.blob.core.windows.net/helm/ + repository: "@stress-test-charts" From 0f0aa793187e9a4fda4fe0b5a14c96d793ed0dd7 Mon Sep 17 00:00:00 2001 From: l0lawrence Date: Fri, 21 Apr 2023 13:41:59 -0700 Subject: [PATCH 20/30] update to local running of indv components --- .../azure-eventhub/stress/Dockerfile38 | 2 +- .../stress/scenarios-matrix.yaml | 56 +++++---- .../stress/scripts/dev_requirement.txt | 2 +- .../azure-eventhub/stress/scripts/logger.py | 48 +------- .../stress/templates/testjob.yaml | 84 +++++++------ .../azure-servicebus/stress/Dockerfile | 2 +- .../stress/scenarios-matrix.yaml | 66 ++++++---- .../stress/scripts/dev_requirements.txt | 3 +- .../azure-servicebus/stress/scripts/logger.py | 6 +- .../stress/scripts/stress_test_base.py | 116 ++++++++++-------- .../stress/scripts/test_stress_queues.py | 70 +++++++++-- .../scripts/test_stress_queues_async.py | 84 +++++++++++-- .../stress/templates/testjob.yaml | 104 +++++++++------- 13 files changed, 389 insertions(+), 254 deletions(-) diff --git a/sdk/eventhub/azure-eventhub/stress/Dockerfile38 b/sdk/eventhub/azure-eventhub/stress/Dockerfile38 index 6ac4055d743c..47e636d92605 100644 --- a/sdk/eventhub/azure-eventhub/stress/Dockerfile38 +++ b/sdk/eventhub/azure-eventhub/stress/Dockerfile38 @@ -2,7 +2,7 @@ # public OSS users should simply leave this argument blank or ignore its presence entirely ARG REGISTRY="mcr.microsoft.com/mirror/docker/library/" FROM ${REGISTRY}python:3.8-slim-buster -# RUN apt-get -y update && apt-get -y install git +RUN apt-get -y update && apt-get -y install git WORKDIR /app diff --git a/sdk/eventhub/azure-eventhub/stress/scenarios-matrix.yaml b/sdk/eventhub/azure-eventhub/stress/scenarios-matrix.yaml index 69b7af99d4b0..9efee6ee3654 100644 --- a/sdk/eventhub/azure-eventhub/stress/scenarios-matrix.yaml +++ b/sdk/eventhub/azure-eventhub/stress/scenarios-matrix.yaml @@ -2,27 +2,35 @@ matrix: image: - Dockerfile38 scenarios: - event-async: - testTarget: event-async - event-sync: - testTarget: event-sync - batch-async: - testTarget: batch-async - batch-sync: - testTarget: batch-sync - bplistsync: - testTarget: bplistsync - bpasync: - testTarget: bpasync - bplistasync: - testTarget: bplistasync - bpsync: - testTarget: bpsync - syncwebsockets: - testTarget: syncwebsockets - asyncwebsockets: - testTarget: asyncwebsockets - sync-batch-web: - testTarget: sync-batch-web - async-batch-web: - testTarget: async-batch-web + send: + testTarget: send + consume: + testTarget: consume + send-async: + testTarget: send-async + consume-async: + testTarget: consume-async + # event-async: + # testTarget: event-async + # event-sync: + # testTarget: event-sync + # batch-async: + # testTarget: batch-async + # batch-sync: + # testTarget: batch-sync + # bplistsync: + # testTarget: bplistsync + # bpasync: + # testTarget: bpasync + # bplistasync: + # testTarget: bplistasync + # bpsync: + # testTarget: bpsync + # syncwebsockets: + # testTarget: syncwebsockets + # asyncwebsockets: + # testTarget: asyncwebsockets + # sync-batch-web: + # testTarget: sync-batch-web + # async-batch-web: + # testTarget: async-batch-web diff --git a/sdk/eventhub/azure-eventhub/stress/scripts/dev_requirement.txt b/sdk/eventhub/azure-eventhub/stress/scripts/dev_requirement.txt index b7ff5a1bb209..35414211f40a 100644 --- a/sdk/eventhub/azure-eventhub/stress/scripts/dev_requirement.txt +++ b/sdk/eventhub/azure-eventhub/stress/scripts/dev_requirement.txt @@ -1,5 +1,5 @@ psutil -azure-eventhub +git+https://github.com/l0lawrence/azure-sdk-for-python.git@sb_to_eh2#subdirectory=sdk/eventhub/azure-eventhub&egg=azure-eventhub azure-eventhub-checkpointstoreblob azure-eventhub-checkpointstoreblob-aio azure-servicebus==7.8.1 diff --git a/sdk/eventhub/azure-eventhub/stress/scripts/logger.py b/sdk/eventhub/azure-eventhub/stress/scripts/logger.py index f8014397569e..164458325bcc 100644 --- a/sdk/eventhub/azure-eventhub/stress/scripts/logger.py +++ b/sdk/eventhub/azure-eventhub/stress/scripts/logger.py @@ -22,19 +22,10 @@ def get_base_logger(log_filename, logger_name, level=logging.INFO, print_console console_handler.setFormatter(formatter) logger.addHandler(console_handler) - if log_filename: - logger_file_handler = RotatingFileHandler( - log_filename, - maxBytes=log_file_max_bytes, - backupCount=log_file_backup_count - ) - logger_file_handler.setFormatter(formatter) - logger.addHandler(logger_file_handler) - return logger -def get_logger(log_filename, logger_name, level=logging.INFO, print_console=False, log_format=None, +def get_logger(log_filename, logger_name, level=logging.DEBUG, print_console=False, log_format=None, log_file_max_bytes=20 * 1024 * 1024, log_file_backup_count=3): stress_logger = logging.getLogger(logger_name) stress_logger.setLevel(level) @@ -44,38 +35,11 @@ def get_logger(log_filename, logger_name, level=logging.INFO, print_console=Fals uamqp_logger.setLevel(level) formatter = log_format or logging.Formatter('%(asctime)s %(name)-12s %(levelname)-8s %(message)s') - if print_console: - console_handler = logging.StreamHandler(stream=sys.stdout) - console_handler.setFormatter(formatter) - if not eventhub_logger.handlers: - eventhub_logger.addHandler(console_handler) - if not uamqp_logger.handlers: - uamqp_logger.addHandler(console_handler) - if not stress_logger.handlers: - stress_logger.addHandler(console_handler) - - if log_filename: - eventhub_file_handler = RotatingFileHandler( - "eventhub_" + log_filename, - maxBytes=log_file_max_bytes, - backupCount=log_file_backup_count - ) - uamqp_file_handler = RotatingFileHandler( - "uamqp_" + log_filename, - maxBytes=log_file_max_bytes, - backupCount=log_file_backup_count - ) - stress_file_handler = RotatingFileHandler( - log_filename, - maxBytes=log_file_max_bytes, - backupCount=log_file_backup_count - ) - eventhub_file_handler.setFormatter(formatter) - uamqp_file_handler.setFormatter(formatter) - stress_file_handler.setFormatter(formatter) - eventhub_logger.addHandler(eventhub_file_handler) - uamqp_logger.addHandler(uamqp_file_handler) - stress_logger.addHandler(stress_file_handler) + console_handler = logging.FileHandler(log_filename) + console_handler.setFormatter(formatter) + eventhub_logger.addHandler(console_handler) + uamqp_logger.addHandler(console_handler) + stress_logger.addHandler(console_handler) return stress_logger diff --git a/sdk/eventhub/azure-eventhub/stress/templates/testjob.yaml b/sdk/eventhub/azure-eventhub/stress/templates/testjob.yaml index c8ee707abeaa..082700dfdc78 100644 --- a/sdk/eventhub/azure-eventhub/stress/templates/testjob.yaml +++ b/sdk/eventhub/azure-eventhub/stress/templates/testjob.yaml @@ -13,54 +13,66 @@ spec: limits: memory: "2000Mi" cpu: "1" - - {{ if eq .Stress.testTarget "event-async" }} - command: ['bash', '-c', 'python azure_eventhub_producer_stress.py -m stress_send_async --duration 259200 & python azure_eventhub_consumer_stress_async.py --duration 259200 '] + {{ if eq .Stress.testTarget "send" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_producer_stress.py -m stress_send_sync --duration 259200 --log_filename $DEBUG_SHARE/output '] {{- end -}} - - {{ if eq .Stress.testTarget "event-sync" }} - command: ['bash', '-c', 'python azure_eventhub_producer_stress.py -m stress_send_sync --duration 259200 & python azure_eventhub_consumer_stress_sync.py --duration 259200 '] + {{ if eq .Stress.testTarget "consume" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_consumer_stress_sync.py --duration 259200 --log_filename $DEBUG_SHARE/output '] + {{- end -}} + {{ if eq .Stress.testTarget "send-async" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_producer_stress.py -m stress_send_async --duration 259200 --log_filename $DEBUG_SHARE/output '] {{- end -}} + {{ if eq .Stress.testTarget "consume-async" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_consumer_stress_async.py --duration 259200 --log_filename $DEBUG_SHARE/output '] + {{- end -}} - {{ if eq .Stress.testTarget "batch-async" }} - command: ['bash', '-c', 'python azure_eventhub_producer_stress.py -m stress_send_list_async --duration 259200 & python azure_eventhub_consumer_stress_async.py --duration 259200 '] - {{- end -}} + # {{ if eq .Stress.testTarget "event-async" }} + # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_producer_stress.py -m stress_send_async --duration 259200 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable & python azure_eventhub_consumer_stress_async.py --duration 259200 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable'] + # {{- end -}} - {{ if eq .Stress.testTarget "batch-sync" }} - command: ['bash', '-c', 'python azure_eventhub_producer_stress.py -m stress_send_list_sync --duration 259200 & python azure_eventhub_consumer_stress_sync.py --duration 259200 '] - {{- end -}} + # {{ if eq .Stress.testTarget "event-sync" }} + # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_producer_stress.py -m stress_send_sync --duration 259200 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable & python azure_eventhub_consumer_stress_sync.py --duration 259200 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable'] + # {{- end -}} - {{ if eq .Stress.testTarget "bplistsync" }} - command: ['bash', '-c', 'python azure_eventhub_producer_stress.py -m stress_send_list_sync --duration 259200 --buffered_mode & python azure_eventhub_consumer_stress_sync.py --duration 259200 '] - {{- end -}} + # {{ if eq .Stress.testTarget "batch-async" }} + # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_producer_stress.py -m stress_send_list_async --duration 259200 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable & python azure_eventhub_consumer_stress_async.py --duration 259200 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable '] + # {{- end -}} - {{ if eq .Stress.testTarget "bpasync" }} - command: ['bash', '-c', 'python azure_eventhub_producer_stress.py -m stress_send_async --duration 259200 --buffered_mode & python azure_eventhub_consumer_stress_async.py --duration 259200'] - {{- end -}} + # {{ if eq .Stress.testTarget "batch-sync" }} + # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_producer_stress.py -m stress_send_list_sync --duration 259200 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable & python azure_eventhub_consumer_stress_sync.py --duration 259200 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable '] + # {{- end -}} - {{ if eq .Stress.testTarget "bplistasync" }} - command: ['bash', '-c', 'python azure_eventhub_producer_stress.py -m stress_send_list_async --duration 259200 --buffered_mode & python azure_eventhub_consumer_stress_async.py --duration 259200 '] - {{- end -}} + # {{ if eq .Stress.testTarget "bplistsync" }} + # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_producer_stress.py -m stress_send_list_sync --duration 259200 --buffered_mode --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable & python azure_eventhub_consumer_stress_sync.py --duration 259200 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable'] + # {{- end -}} - {{ if eq .Stress.testTarget "bpsync" }} - command: ['bash', '-c', 'python azure_eventhub_producer_stress.py -m stress_send_sync --duration 259200 --buffered_mode & python azure_eventhub_consumer_stress_sync.py --duration 259200'] - {{- end -}} + # {{ if eq .Stress.testTarget "bpasync" }} + # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_producer_stress.py -m stress_send_async --duration 259200 --buffered_mode --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable & python azure_eventhub_consumer_stress_async.py --duration 259200 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable'] + # {{- end -}} - {{ if eq .Stress.testTarget "syncwebsockets" }} - command: ['bash', '-c', 'python azure_eventhub_producer_stress.py -m stress_send_sync --duration 259200 --transport_type 1 & python azure_eventhub_consumer_stress_sync.py --duration 259200 --transport_type 1'] - {{- end -}} + # {{ if eq .Stress.testTarget "bplistasync" }} + # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_producer_stress.py -m stress_send_list_async --duration 259200 --buffered_mode --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable & python azure_eventhub_consumer_stress_async.py --duration 259200 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable '] + # {{- end -}} - {{ if eq .Stress.testTarget "asyncwebsockets" }} - command: ['bash', '-c', 'python azure_eventhub_producer_stress.py -m stress_send_async --duration 259200 --transport_type 1 & python azure_eventhub_consumer_stress_async.py --duration 259200 --transport_type 1'] - {{- end -}} + # {{ if eq .Stress.testTarget "bpsync" }} + # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_producer_stress.py -m stress_send_sync --duration 259200 --buffered_mode --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable & python azure_eventhub_consumer_stress_sync.py --duration 259200 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable'] + # {{- end -}} - {{ if eq .Stress.testTarget "sync-batch-web" }} - command: ['bash', '-c', 'python azure_eventhub_producer_stress.py -m stress_send_list_sync --duration 259200 --transport_type 1 & python azure_eventhub_consumer_stress_sync.py --duration 259200 --transport_type 1'] - {{- end -}} + # {{ if eq .Stress.testTarget "syncwebsockets" }} + # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_producer_stress.py -m stress_send_sync --duration 259200 --transport_type 1 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable & python azure_eventhub_consumer_stress_sync.py --duration 259200 --transport_type 1 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable'] + # {{- end -}} - {{ if eq .Stress.testTarget "async-batch-web" }} - command: ['bash', '-c', 'python azure_eventhub_producer_stress.py -m stress_send_list_async --duration 259200 --transport_type 1 & python azure_eventhub_consumer_stress_async.py --duration 259200 --transport_type 1'] - {{- end -}} + # {{ if eq .Stress.testTarget "asyncwebsockets" }} + # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_producer_stress.py -m stress_send_async --duration 259200 --transport_type 1 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable & python azure_eventhub_consumer_stress_async.py --duration 259200 --transport_type 1 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable'] + # {{- end -}} + + # {{ if eq .Stress.testTarget "sync-batch-web" }} + # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_producer_stress.py -m stress_send_list_sync --duration 259200 --transport_type 1 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable & python azure_eventhub_consumer_stress_sync.py --duration 259200 --transport_type 1 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable'] + # {{- end -}} + + # {{ if eq .Stress.testTarget "async-batch-web" }} + # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_producer_stress.py -m stress_send_list_async --duration 259200 --transport_type 1 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable & python azure_eventhub_consumer_stress_async.py --duration 259200 --transport_type 1 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable'] + # {{- end -}} {{- include "stress-test-addons.container-env" . | nindent 6 }} {{- end -}} diff --git a/sdk/servicebus/azure-servicebus/stress/Dockerfile b/sdk/servicebus/azure-servicebus/stress/Dockerfile index 501383ea4b0b..e777f3fed449 100644 --- a/sdk/servicebus/azure-servicebus/stress/Dockerfile +++ b/sdk/servicebus/azure-servicebus/stress/Dockerfile @@ -2,7 +2,7 @@ # public OSS users should simply leave this argument blank or ignore its presence entirely ARG REGISTRY="mcr.microsoft.com/mirror/docker/library/" FROM ${REGISTRY}python:3.8-slim-buster -# RUN apt-get -y update && apt-get -y install git +RUN apt-get -y update && apt-get -y install git WORKDIR /app diff --git a/sdk/servicebus/azure-servicebus/stress/scenarios-matrix.yaml b/sdk/servicebus/azure-servicebus/stress/scenarios-matrix.yaml index 646a35626ec1..39643be8d40a 100644 --- a/sdk/servicebus/azure-servicebus/stress/scenarios-matrix.yaml +++ b/sdk/servicebus/azure-servicebus/stress/scenarios-matrix.yaml @@ -2,32 +2,46 @@ matrix: image: - Dockerfile scenarios: - queue: - testTarget: queue - aqueue: - testTarget: aqueue - queuepull: - testTarget: queuepull - aqueuepull: - testTarget: aqueuepull - batch: - testTarget: batch - abatch: - testTarget: abatch - queuew: - testTarget: queuew - aqueuew: - testTarget: aqueuew - queuepullw: - testTarget: queuepullw - aqueuepullw: - testTarget: aqueuepullw - batchw: - testTarget: batchw - abatchw: - testTarget: abatchw - memray: - testTarget: memray + sender: + testTarget: sender + receiver: + testTarget: receiver + iterator: + testTarget: iterator + senderasync: + testTarget: senderasync + receiverasync: + testTarget: senderasync + iteratorasync: + testTarget: senderasync + iteratorasyncnobatch: + testTarget: iteratorasyncnobatch + # queue: + # testTarget: queue + # aqueue: + # testTarget: aqueue + # queuepull: + # testTarget: queuepull + # aqueuepull: + # testTarget: aqueuepull + # batch: + # testTarget: batch + # abatch: + # testTarget: abatch + # queuew: + # testTarget: queuew + # aqueuew: + # testTarget: aqueuew + # queuepullw: + # testTarget: queuepullw + # aqueuepullw: + # testTarget: aqueuepullw + # batchw: + # testTarget: batchw + # abatchw: + # testTarget: abatchw + # memray: + # testTarget: memray # sendreceiveslow: # testTarget: send_receive_slow # receivedelete: diff --git a/sdk/servicebus/azure-servicebus/stress/scripts/dev_requirements.txt b/sdk/servicebus/azure-servicebus/stress/scripts/dev_requirements.txt index 31431185aeb6..eddc116fe769 100644 --- a/sdk/servicebus/azure-servicebus/stress/scripts/dev_requirements.txt +++ b/sdk/servicebus/azure-servicebus/stress/scripts/dev_requirements.txt @@ -1,7 +1,6 @@ aiohttp>=3.0 opencensus-ext-azure psutil -azure-servicebus==7.10.0b1 python-dotenv websocket-client -memray +git+https://github.com/kashifkhan/azure-sdk-for-python.git@sb_pyamqp_mem#subdirectory=sdk/servicebus/azure-servicebus&egg=azure-servicebus \ No newline at end of file diff --git a/sdk/servicebus/azure-servicebus/stress/scripts/logger.py b/sdk/servicebus/azure-servicebus/stress/scripts/logger.py index b58e486ee92d..3199a5e59afb 100644 --- a/sdk/servicebus/azure-servicebus/stress/scripts/logger.py +++ b/sdk/servicebus/azure-servicebus/stress/scripts/logger.py @@ -11,7 +11,7 @@ from opencensus.ext.azure.log_exporter import AzureLogHandler -def get_base_logger(log_filename, logger_name, level=logging.INFO, print_console=False, log_format=None, +def get_base_logger(log_filename, logger_name, level=logging.ERROR, print_console=False, log_format=None, log_file_max_bytes=20 * 1024 * 1024, log_file_backup_count=3): logger = logging.getLogger(logger_name) logger.setLevel(level) @@ -21,7 +21,7 @@ def get_base_logger(log_filename, logger_name, level=logging.INFO, print_console logger.addHandler(console_handler) return logger -def get_logger(log_filename, logger_name, level=logging.DEBUG, print_console=False, log_format=None, +def get_logger(log_filename, logger_name, level=logging.ERROR, print_console=False, log_format=None, log_file_max_bytes=20 * 1024 * 1024, log_file_backup_count=3): stress_logger = logging.getLogger(logger_name) stress_logger.setLevel(level) @@ -41,7 +41,7 @@ def get_logger(log_filename, logger_name, level=logging.DEBUG, print_console=Fal return stress_logger -def get_azure_logger(logger_name, level=logging.DEBUG): +def get_azure_logger(logger_name, level=logging.ERROR): logger = logging.getLogger("azure_logger_" + logger_name) logger.setLevel(level) # oc will automatically search for the ENV VAR 'APPLICATIONINSIGHTS_CONNECTION_STRING' diff --git a/sdk/servicebus/azure-servicebus/stress/scripts/stress_test_base.py b/sdk/servicebus/azure-servicebus/stress/scripts/stress_test_base.py index 2c27d50c26cf..380fc1fe9546 100644 --- a/sdk/servicebus/azure-servicebus/stress/scripts/stress_test_base.py +++ b/sdk/servicebus/azure-servicebus/stress/scripts/stress_test_base.py @@ -27,7 +27,7 @@ LOGFILE_NAME = os.environ.get("DEBUG_SHARE") + "output" PRINT_CONSOLE = True -_logger = get_logger(LOGFILE_NAME, "stress_test", logging.DEBUG) +_logger = get_logger(LOGFILE_NAME, "stress_test", logging.ERROR) class ReceiveType: @@ -193,7 +193,7 @@ def _construct_message(self): return message def _send(self, sender, end_time): - # self._schedule_interval_logger(end_time, "Sender " + str(self)) + self._schedule_interval_logger(end_time, "Sender " + str(self)) try: _logger.debug("Starting send loop") # log sender @@ -247,8 +247,8 @@ def _receive(self, receiver, end_time): elif self.receive_type == ReceiveType.push: receiver.max_wait_time = self.max_wait_time batch = receiver - else: - batch = [] + # else: + # batch = [] for message in batch: # log reciever @@ -295,15 +295,20 @@ def run(self): with self.process_monitor: with concurrent.futures.ThreadPoolExecutor(max_workers=4) as proc_pool: _logger.info("STARTING PROC POOL") - senders = [ - proc_pool.submit(self._send, sender, end_time) - for sender in self.senders - ] - receivers = [ - proc_pool.submit(self._receive, receiver, end_time) - for receiver in self.receivers - ] - + if self.senders: + senders = [ + proc_pool.submit(self._send, sender, end_time) + for sender in self.senders + ] + else: + senders = [] + if self.receivers: + receivers = [ + proc_pool.submit(self._receive, receiver, end_time) + for receiver in self.receivers + ] + else: + receivers = [] result = StressTestResults() for each in concurrent.futures.as_completed(senders + receivers): _logger.info("SOMETHING FINISHED") @@ -312,26 +317,28 @@ def run(self): if each in receivers: result.state_by_receiver[each] = each.result() # TODO: do as_completed in one batch to provide a way to short-circuit on failure. - - result.state_by_sender = { - s: f.result() - for s, f in zip( - self.senders, concurrent.futures.as_completed(senders) + if self.senders: + result.state_by_sender = { + s: f.result() + for s, f in zip( + self.senders, concurrent.futures.as_completed(senders) + ) + } + _logger.info("Got receiver results") + result.total_sent = sum( + [r.total_sent for r in result.state_by_sender.values()] ) - } - result.state_by_receiver = { - r: f.result() - for r, f in zip( - self.receivers, concurrent.futures.as_completed(receivers) + if self.receivers: + result.state_by_receiver = { + r: f.result() + for r, f in zip( + self.receivers, concurrent.futures.as_completed(receivers) + ) + } + + result.total_received = sum( + [r.total_received for r in result.state_by_receiver.values()] ) - } - _logger.info("Got receiver results") - result.total_sent = sum( - [r.total_sent for r in result.state_by_sender.values()] - ) - result.total_received = sum( - [r.total_received for r in result.state_by_receiver.values()] - ) result.time_elapsed = end_time - start_time _logger.critical("Stress test completed. Results:\n{}".format(result)) return result @@ -377,6 +384,7 @@ def __init__( ) async def _send_async(self, sender, end_time): + _logger.critical("STARTING SENDER") self._schedule_interval_logger(end_time, "Sender " + str(self)) try: _logger.info("STARTING SENDER") @@ -429,6 +437,7 @@ async def _receive_handle_message(self, message, receiver, end_time): ) async def _receive_async(self, receiver, end_time): + _logger.critical("STARTING RECEIVER") self._schedule_interval_logger(end_time, "Receiver " + str(self)) try: async with receiver: @@ -473,14 +482,16 @@ async def run_async(self): if isinstance(self.duration, int): self.duration = timedelta(seconds=self.duration) end_time = start_time + (self._duration_override or self.duration) - send_tasks = [ - asyncio.create_task(self._send_async(sender, end_time)) - for sender in self.senders - ] - receive_tasks = [ - asyncio.create_task(self._receive_async(receiver, end_time)) - for receiver in self.receivers - ] + if self.senders: + send_tasks = [ + asyncio.create_task(self._send_async(sender, end_time)) + for sender in self.senders + ] + if self.receivers: + receive_tasks = [ + asyncio.create_task(self._receive_async(receiver, end_time)) + for receiver in self.receivers + ] with self.process_monitor: # await asyncio.gather(*send_tasks, *receive_tasks) for task in asyncio.as_completed(send_tasks + receive_tasks): @@ -489,19 +500,22 @@ async def run_async(self): except Exception as e: print(e) result = StressTestResults() - result.state_by_sender = { - s: f.result() for s, f in zip(self.senders, send_tasks) - } - result.state_by_receiver = { - r: f.result() for r, f in zip(self.receivers, receive_tasks) - } - _logger.info("got receiver results") - result.total_sent = sum( + if self.senders: + result.state_by_sender = { + s: f.result() for s, f in zip(self.senders, send_tasks) + } + result.total_sent = sum( [r.total_sent for r in result.state_by_sender.values()] - ) - result.total_received = sum( - [r.total_received for r in result.state_by_receiver.values()] - ) + ) + if self.receivers: + result.state_by_receiver = { + r: f.result() for r, f in zip(self.receivers, receive_tasks) + } + _logger.info("got receiver results") + + result.total_received = sum( + [r.total_received for r in result.state_by_receiver.values()] + ) result.time_elapsed = end_time - start_time _logger.critical("Stress test completed. Results:\n{}".format(result)) return result diff --git a/sdk/servicebus/azure-servicebus/stress/scripts/test_stress_queues.py b/sdk/servicebus/azure-servicebus/stress/scripts/test_stress_queues.py index ee2dab90b9b0..ea74c9012f0d 100644 --- a/sdk/servicebus/azure-servicebus/stress/scripts/test_stress_queues.py +++ b/sdk/servicebus/azure-servicebus/stress/scripts/test_stress_queues.py @@ -369,18 +369,62 @@ def test_stress_queue_check_for_dropped_messages(args): test_stress_queue_close_and_reopen(args) elif args.method == "dropped_messages": test_stress_queue_check_for_dropped_messages(args) + elif args.method == "sender": + sb_client = ServiceBusClient.from_connection_string( + SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) + stress_test = StressTestRunner(senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], + receivers = None, + admin_client = sb_admin_client, + duration=args.duration, + send_batch_size=5, + azure_monitor_metric=AzureMonitorMetric("test_stress_queue_batch_send_and_receive") + ) + + result = stress_test.run() + print(f"Total send {result.total_sent}") + print(f"Total received {result.total_received}") + elif args.method == "receiver": + sb_client = ServiceBusClient.from_connection_string( + SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) + stress_test = StressTestRunner(senders = None, + receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME, prefetch_count=5)], + admin_client = sb_admin_client, + duration=args.duration, + receive_type=ReceiveType.pull, + send_batch_size=5, + azure_monitor_metric=AzureMonitorMetric("test_stress_queue_batch_send_and_receive") + ) + + result = stress_test.run() + print(f"Total send {result.total_sent}") + print(f"Total received {result.total_received}") + elif args.method == "iterator": + sb_client = ServiceBusClient.from_connection_string( + SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) + stress_test = StressTestRunner(senders = None, + receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME, prefetch_count=5)], + admin_client = sb_admin_client, + duration=args.duration, + send_batch_size=5, + azure_monitor_metric=AzureMonitorMetric("test_stress_queue_batch_send_and_receive") + ) + + result = stress_test.run() + print(f"Total send {result.total_sent}") + print(f"Total received {result.total_received}") else: - test_stress_queue_send_and_receive(args) - test_stress_queue_send_and_pull_receive(args) - test_stress_queue_batch_send_and_receive(args) - test_stress_queue_slow_send_and_receive(args) - test_stress_queue_receive_and_delete(args) - test_stress_queue_unsettled_messages(args) - test_stress_queue_receive_large_batch_size(args) - test_stress_queue_pull_receive_timeout(args) - test_stress_queue_long_renew_send_and_receive(args) - test_stress_queue_long_renew_session_send_and_receive(args) - test_stress_queue_peek_messages(args) - test_stress_queue_close_and_reopen(args) - test_stress_queue_check_for_dropped_messages(args) + pass + # test_stress_queue_send_and_receive(args) + # test_stress_queue_send_and_pull_receive(args) + # test_stress_queue_batch_send_and_receive(args) + # test_stress_queue_slow_send_and_receive(args) + # test_stress_queue_receive_and_delete(args) + # test_stress_queue_unsettled_messages(args) + # test_stress_queue_receive_large_batch_size(args) + # test_stress_queue_pull_receive_timeout(args) + # test_stress_queue_long_renew_send_and_receive(args) + # test_stress_queue_long_renew_session_send_and_receive(args) + # test_stress_queue_peek_messages(args) + # test_stress_queue_close_and_reopen(args) + # test_stress_queue_check_for_dropped_messages(args) diff --git a/sdk/servicebus/azure-servicebus/stress/scripts/test_stress_queues_async.py b/sdk/servicebus/azure-servicebus/stress/scripts/test_stress_queues_async.py index 42bc8e974fed..a53953cc5f45 100644 --- a/sdk/servicebus/azure-servicebus/stress/scripts/test_stress_queues_async.py +++ b/sdk/servicebus/azure-servicebus/stress/scripts/test_stress_queues_async.py @@ -338,20 +338,78 @@ async def run(args): await test_stress_queue_close_and_reopen(args) elif args.method == "dropped_messages": await test_stress_queue_check_for_dropped_messages(args) + elif args.method == "sender": + sb_client = ServiceBusClient.from_connection_string( + SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) + stress_test = StressTestRunnerAsync(senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], + receivers = None, + admin_client = sb_admin_client, + duration=args.duration, + send_batch_size=5, + azure_monitor_metric=AzureMonitorMetric("test_stress_queue_batch_send_and_receive") + ) + + result = await stress_test.run_async() + print(f"Total send {result.total_sent}") + print(f"Total received {result.total_received}") + elif args.method == "receiver": + sb_client = ServiceBusClient.from_connection_string( + SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) + stress_test = StressTestRunnerAsync(senders = None, + receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME, prefetch_count=5)], + admin_client = sb_admin_client, + duration=args.duration, + receive_type=ReceiveType.pull, + send_batch_size=5, + azure_monitor_metric=AzureMonitorMetric("test_stress_queue_batch_send_and_receive") + ) + + result = await stress_test.run_async() + print(f"Total send {result.total_sent}") + print(f"Total received {result.total_received}") + elif args.method == "iterator": + sb_client = ServiceBusClient.from_connection_string( + SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) + stress_test = StressTestRunnerAsync(senders = None, + receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME, prefetch_count=5)], + admin_client = sb_admin_client, + duration=args.duration, + send_batch_size=5, + azure_monitor_metric=AzureMonitorMetric("test_stress_queue_batch_send_and_receive") + ) + + result = await stress_test.run_async() + print(f"Total send {result.total_sent}") + print(f"Total received {result.total_received}") + elif args.method == "iteratornobatch": + sb_client = ServiceBusClient.from_connection_string( + SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) + stress_test = StressTestRunnerAsync(senders = None, + receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME)], + admin_client = sb_admin_client, + duration=args.duration, + send_batch_size=5, + azure_monitor_metric=AzureMonitorMetric("test_stress_queue_batch_send_and_receive") + ) + + result = await stress_test.run_async() + print(f"Total send {result.total_sent}") + print(f"Total received {result.total_received}") else: - await test_stress_queue_send_and_receive(args) - await test_stress_queue_send_and_pull_receive(args) - await test_stress_queue_batch_send_and_receive(args) - await test_stress_queue_slow_send_and_receive(args) - await test_stress_queue_receive_and_delete(args) - await test_stress_queue_unsettled_messages(args) - await test_stress_queue_receive_large_batch_size(args) - await test_stress_queue_pull_receive_timeout(args) - await test_stress_queue_long_renew_send_and_receive(args) - await test_stress_queue_long_renew_session_send_and_receive(args) - await test_stress_queue_peek_messages(args) - await test_stress_queue_close_and_reopen(args) - await test_stress_queue_check_for_dropped_messages(args) + pass + # await test_stress_queue_send_and_receive(args) + # await test_stress_queue_send_and_pull_receive(args) + # await test_stress_queue_batch_send_and_receive(args) + # await test_stress_queue_slow_send_and_receive(args) + # await test_stress_queue_receive_and_delete(args) + # await test_stress_queue_unsettled_messages(args) + # await test_stress_queue_receive_large_batch_size(args) + # await test_stress_queue_pull_receive_timeout(args) + # await test_stress_queue_long_renew_send_and_receive(args) + # await test_stress_queue_long_renew_session_send_and_receive(args) + # await test_stress_queue_peek_messages(args) + # await test_stress_queue_close_and_reopen(args) + # await test_stress_queue_check_for_dropped_messages(args) if __name__ == '__main__': diff --git a/sdk/servicebus/azure-servicebus/stress/templates/testjob.yaml b/sdk/servicebus/azure-servicebus/stress/templates/testjob.yaml index afdd4cf59a34..bc2988afa373 100644 --- a/sdk/servicebus/azure-servicebus/stress/templates/testjob.yaml +++ b/sdk/servicebus/azure-servicebus/stress/templates/testjob.yaml @@ -15,61 +15,83 @@ spec: memory: "2000Mi" cpu: "1" - {{ if eq .Stress.testTarget "aqueuew" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python test_stress_queues.py --method send_receive --duration 300000 --logging-enable --transport'] + {{ if eq .Stress.testTarget "sender" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python test_stress_queues.py --method sender --duration 300000 --logging-enable'] {{- end -}} - - {{ if eq .Stress.testTarget "queuew" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues.py --method send_receive --duration 300000 --logging-enable --transport'] + {{ if eq .Stress.testTarget "receiver" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python test_stress_queues.py --method receiver --duration 300000 --logging-enable'] {{- end -}} - - {{ if eq .Stress.testTarget "aqueuepullw" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues_async.py --method send_pull_receive --duration 300000 --logging-enable --transport'] + {{ if eq .Stress.testTarget "iterator" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python test_stress_queues.py --method iterator --duration 300000 --logging-enable'] {{- end -}} - - {{ if eq .Stress.testTarget "queuepullw" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues.py --method send_pull_receive --duration 300000 --logging-enable --transport'] + {{ if eq .Stress.testTarget "senderasync" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python test_stress_queues_async.py --method sender --duration 300000 --logging-enable'] {{- end -}} - - {{ if eq .Stress.testTarget "abatchw" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues_async.py --method send_receive_batch --duration 300000 --logging-enable --transport'] + {{ if eq .Stress.testTarget "receiverasync" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python test_stress_queues_async.py --method receiver --duration 300000 --logging-enable'] {{- end -}} - - {{ if eq .Stress.testTarget "batchw" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues.py --method send_receive_batch --duration 300000 --logging-enable --transport'] + {{ if eq .Stress.testTarget "iteratorasync" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python test_stress_queues_async.py --method iterator --duration 300000 --logging-enable'] {{- end -}} - - {{ if eq .Stress.testTarget "aqueue" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues_async.py --method send_receive --duration 300000 --logging-enable'] + {{ if eq .Stress.testTarget "iteratorasyncnobatch" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python test_stress_queues_async.py --method iteratornobatch --duration 300000 --logging-enable'] {{- end -}} - {{ if eq .Stress.testTarget "queue" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues.py --method send_receive --duration 300000 --logging-enable'] - {{- end -}} + # {{ if eq .Stress.testTarget "aqueuew" }} + # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python test_stress_queues.py --method send_receive --duration 300000 --logging-enable --transport'] + # {{- end -}} - {{ if eq .Stress.testTarget "aqueuepull" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues_async.py --method send_pull_receive --duration 300000 --logging-enable'] - {{- end -}} + # {{ if eq .Stress.testTarget "queuew" }} + # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues.py --method send_receive --duration 300000 --logging-enable --transport'] + # {{- end -}} - {{ if eq .Stress.testTarget "queuepull" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues.py --method send_pull_receive --duration 300000 --logging-enable --output $DEBUG_SHARE/output.bin'] - {{- end -}} + # {{ if eq .Stress.testTarget "aqueuepullw" }} + # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues_async.py --method send_pull_receive --duration 300000 --logging-enable --transport'] + # {{- end -}} - {{ if eq .Stress.testTarget "abatch" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues_async.py --method send_receive_batch --duration 300000 --logging-enable --output $DEBUG_SHARE/output.bin'] - {{- end -}} + # {{ if eq .Stress.testTarget "queuepullw" }} + # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues.py --method send_pull_receive --duration 300000 --logging-enable --transport'] + # {{- end -}} - {{ if eq .Stress.testTarget "batch" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues.py --method send_receive_batch --duration 300000 --logging-enable --output $DEBUG_SHARE/output.bin'] - {{- end -}} + # {{ if eq .Stress.testTarget "abatchw" }} + # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues_async.py --method send_receive_batch --duration 300000 --logging-enable --transport'] + # {{- end -}} - {{ if eq .Stress.testTarget "amemray" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && memray run --output $DEBUG_SHARE/sb_async_memray_output.bin test_stress_queues_async.py --method send_pull_receive --duration 300000 --logging-enable'] - {{- end -}} + # {{ if eq .Stress.testTarget "batchw" }} + # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues.py --method send_receive_batch --duration 300000 --logging-enable --transport'] + # {{- end -}} - {{ if eq .Stress.testTarget "memray" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && memray run --output $DEBUG_SHARE/sb_memray_output.bin test_stress_queues.py --method send_pull_receive --duration 300000 --logging-enable'] - {{- end -}} + # {{ if eq .Stress.testTarget "aqueue" }} + # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues_async.py --method send_receive --duration 300000 --logging-enable'] + # {{- end -}} + + # {{ if eq .Stress.testTarget "queue" }} + # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues.py --method send_receive --duration 300000 --logging-enable'] + # {{- end -}} + + # {{ if eq .Stress.testTarget "aqueuepull" }} + # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues_async.py --method send_pull_receive --duration 300000 --logging-enable'] + # {{- end -}} + + # {{ if eq .Stress.testTarget "queuepull" }} + # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues.py --method send_pull_receive --duration 300000 --logging-enable --output $DEBUG_SHARE/output.bin'] + # {{- end -}} + + # {{ if eq .Stress.testTarget "abatch" }} + # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues_async.py --method send_receive_batch --duration 300000 --logging-enable --output $DEBUG_SHARE/output.bin'] + # {{- end -}} + + # {{ if eq .Stress.testTarget "batch" }} + # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues.py --method send_receive_batch --duration 300000 --logging-enable --output $DEBUG_SHARE/output.bin'] + # {{- end -}} + + # {{ if eq .Stress.testTarget "amemray" }} + # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && memray run --output $DEBUG_SHARE/sb_async_memray_output.bin test_stress_queues_async.py --method send_pull_receive --duration 300000 --logging-enable'] + # {{- end -}} + + # {{ if eq .Stress.testTarget "memray" }} + # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && memray run --output $DEBUG_SHARE/sb_memray_output.bin test_stress_queues.py --method send_pull_receive --duration 300000 --logging-enable'] + # {{- end -}} {{- include "stress-test-addons.container-env" . | nindent 6 }} {{- end -}} From 3411957382e6f0f5a154e57af5923bd47b603ba2 Mon Sep 17 00:00:00 2001 From: l0lawrence Date: Fri, 21 Apr 2023 14:28:34 -0700 Subject: [PATCH 21/30] updates --- .../stress/scripts/dev_requirements.txt | 2 ++ .../stress/scripts/stress_test_base.py | 11 +++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/sdk/servicebus/azure-servicebus/stress/scripts/dev_requirements.txt b/sdk/servicebus/azure-servicebus/stress/scripts/dev_requirements.txt index eddc116fe769..c9dfde1be528 100644 --- a/sdk/servicebus/azure-servicebus/stress/scripts/dev_requirements.txt +++ b/sdk/servicebus/azure-servicebus/stress/scripts/dev_requirements.txt @@ -1,6 +1,8 @@ aiohttp>=3.0 opencensus-ext-azure psutil + python-dotenv websocket-client + git+https://github.com/kashifkhan/azure-sdk-for-python.git@sb_pyamqp_mem#subdirectory=sdk/servicebus/azure-servicebus&egg=azure-servicebus \ No newline at end of file diff --git a/sdk/servicebus/azure-servicebus/stress/scripts/stress_test_base.py b/sdk/servicebus/azure-servicebus/stress/scripts/stress_test_base.py index 380fc1fe9546..8a8502421001 100644 --- a/sdk/servicebus/azure-servicebus/stress/scripts/stress_test_base.py +++ b/sdk/servicebus/azure-servicebus/stress/scripts/stress_test_base.py @@ -162,7 +162,7 @@ def pre_process_message_body(self, payload): """Allows user to transform message payload before sending it.""" return payload - def _schedule_interval_logger(self, end_time, description="", interval_seconds=5): + def _schedule_interval_logger(self, end_time, description="", interval_seconds=300): def _do_interval_logging(): if end_time > datetime.utcnow() and not self._should_stop: self._state.populate_process_stats(self.process_monitor) @@ -295,7 +295,7 @@ def run(self): with self.process_monitor: with concurrent.futures.ThreadPoolExecutor(max_workers=4) as proc_pool: _logger.info("STARTING PROC POOL") - if self.senders: + if len(self.senders) !=0: senders = [ proc_pool.submit(self._send, sender, end_time) for sender in self.senders @@ -384,10 +384,9 @@ def __init__( ) async def _send_async(self, sender, end_time): - _logger.critical("STARTING SENDER") self._schedule_interval_logger(end_time, "Sender " + str(self)) try: - _logger.info("STARTING SENDER") + _logger.critical("STARTING SENDER") async with sender: while end_time > datetime.utcnow() and not self._should_stop: try: @@ -420,7 +419,7 @@ async def _send_async(self, sender, end_time): raise async def _receive_handle_message(self, message, receiver, end_time): - # _logger = get_logger(LOGFILE_NAME, "stress_test_receive", level=logging.INFO, print_console=PRINT_CONSOLE) + _logger = get_logger(LOGFILE_NAME, "stress_test_receive", level=logging.ERROR) self.on_receive(self._state, message, receiver) try: if self.should_complete_messages: @@ -437,9 +436,9 @@ async def _receive_handle_message(self, message, receiver, end_time): ) async def _receive_async(self, receiver, end_time): - _logger.critical("STARTING RECEIVER") self._schedule_interval_logger(end_time, "Receiver " + str(self)) try: + _logger.critical("STARTING RECEIVER") async with receiver: while end_time > datetime.utcnow() and not self._should_stop: _logger.info("RECEIVE LOOP") From 6f3d66ab63e5aa78007a0e299b6eca73af82ec47 Mon Sep 17 00:00:00 2001 From: l0lawrence Date: Fri, 21 Apr 2023 14:48:46 -0700 Subject: [PATCH 22/30] remove --- .../azure-servicebus/stress/scripts/stress_test_base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/servicebus/azure-servicebus/stress/scripts/stress_test_base.py b/sdk/servicebus/azure-servicebus/stress/scripts/stress_test_base.py index 8a8502421001..9a96dc896457 100644 --- a/sdk/servicebus/azure-servicebus/stress/scripts/stress_test_base.py +++ b/sdk/servicebus/azure-servicebus/stress/scripts/stress_test_base.py @@ -295,7 +295,7 @@ def run(self): with self.process_monitor: with concurrent.futures.ThreadPoolExecutor(max_workers=4) as proc_pool: _logger.info("STARTING PROC POOL") - if len(self.senders) !=0: + if self.senders: senders = [ proc_pool.submit(self._send, sender, end_time) for sender in self.senders From 69bd14ac995ab54998bebe4c0b66dffd4c76d173 Mon Sep 17 00:00:00 2001 From: l0lawrence Date: Fri, 21 Apr 2023 15:46:08 -0700 Subject: [PATCH 23/30] update --- .../azure-servicebus/stress/scripts/stress_test_base.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sdk/servicebus/azure-servicebus/stress/scripts/stress_test_base.py b/sdk/servicebus/azure-servicebus/stress/scripts/stress_test_base.py index 9a96dc896457..cb9a334fcbee 100644 --- a/sdk/servicebus/azure-servicebus/stress/scripts/stress_test_base.py +++ b/sdk/servicebus/azure-servicebus/stress/scripts/stress_test_base.py @@ -486,11 +486,15 @@ async def run_async(self): asyncio.create_task(self._send_async(sender, end_time)) for sender in self.senders ] + else: + send_tasks = [] if self.receivers: receive_tasks = [ asyncio.create_task(self._receive_async(receiver, end_time)) for receiver in self.receivers ] + else: + receive_tasks = [] with self.process_monitor: # await asyncio.gather(*send_tasks, *receive_tasks) for task in asyncio.as_completed(send_tasks + receive_tasks): From 798aa4dbcc1c6b1b286224a23f53bada03da0164 Mon Sep 17 00:00:00 2001 From: l0lawrence Date: Mon, 24 Apr 2023 09:05:18 -0700 Subject: [PATCH 24/30] update test base --- .../azure-servicebus/stress/scripts/stress_test_base.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sdk/servicebus/azure-servicebus/stress/scripts/stress_test_base.py b/sdk/servicebus/azure-servicebus/stress/scripts/stress_test_base.py index cb9a334fcbee..be29a0f5be4a 100644 --- a/sdk/servicebus/azure-servicebus/stress/scripts/stress_test_base.py +++ b/sdk/servicebus/azure-servicebus/stress/scripts/stress_test_base.py @@ -419,7 +419,7 @@ async def _send_async(self, sender, end_time): raise async def _receive_handle_message(self, message, receiver, end_time): - _logger = get_logger(LOGFILE_NAME, "stress_test_receive", level=logging.ERROR) + # _logger = get_logger(LOGFILE_NAME, "stress_test_receive", level=logging.ERROR) self.on_receive(self._state, message, receiver) try: if self.should_complete_messages: @@ -441,7 +441,6 @@ async def _receive_async(self, receiver, end_time): _logger.critical("STARTING RECEIVER") async with receiver: while end_time > datetime.utcnow() and not self._should_stop: - _logger.info("RECEIVE LOOP") try: if self.receive_type == ReceiveType.pull: batch = await receiver.receive_messages( From eee53e4db7fa3da3802624355d813aee91e65e11 Mon Sep 17 00:00:00 2001 From: l0lawrence Date: Wed, 26 Apr 2023 10:26:55 -0700 Subject: [PATCH 25/30] remove eh changes --- .../azure-eventhub/stress/Dockerfile38 | 2 +- .../stress/scenarios-matrix.yaml | 56 ++++++------- .../azure_eventhub_consumer_stress_async.py | 2 +- .../azure_eventhub_consumer_stress_sync.py | 2 +- .../scripts/azure_eventhub_producer_stress.py | 4 +- .../stress/scripts/dev_requirement.txt | 2 +- .../stress/templates/testjob.yaml | 84 ++++++++----------- 7 files changed, 66 insertions(+), 86 deletions(-) diff --git a/sdk/eventhub/azure-eventhub/stress/Dockerfile38 b/sdk/eventhub/azure-eventhub/stress/Dockerfile38 index 47e636d92605..6ac4055d743c 100644 --- a/sdk/eventhub/azure-eventhub/stress/Dockerfile38 +++ b/sdk/eventhub/azure-eventhub/stress/Dockerfile38 @@ -2,7 +2,7 @@ # public OSS users should simply leave this argument blank or ignore its presence entirely ARG REGISTRY="mcr.microsoft.com/mirror/docker/library/" FROM ${REGISTRY}python:3.8-slim-buster -RUN apt-get -y update && apt-get -y install git +# RUN apt-get -y update && apt-get -y install git WORKDIR /app diff --git a/sdk/eventhub/azure-eventhub/stress/scenarios-matrix.yaml b/sdk/eventhub/azure-eventhub/stress/scenarios-matrix.yaml index 9efee6ee3654..69b7af99d4b0 100644 --- a/sdk/eventhub/azure-eventhub/stress/scenarios-matrix.yaml +++ b/sdk/eventhub/azure-eventhub/stress/scenarios-matrix.yaml @@ -2,35 +2,27 @@ matrix: image: - Dockerfile38 scenarios: - send: - testTarget: send - consume: - testTarget: consume - send-async: - testTarget: send-async - consume-async: - testTarget: consume-async - # event-async: - # testTarget: event-async - # event-sync: - # testTarget: event-sync - # batch-async: - # testTarget: batch-async - # batch-sync: - # testTarget: batch-sync - # bplistsync: - # testTarget: bplistsync - # bpasync: - # testTarget: bpasync - # bplistasync: - # testTarget: bplistasync - # bpsync: - # testTarget: bpsync - # syncwebsockets: - # testTarget: syncwebsockets - # asyncwebsockets: - # testTarget: asyncwebsockets - # sync-batch-web: - # testTarget: sync-batch-web - # async-batch-web: - # testTarget: async-batch-web + event-async: + testTarget: event-async + event-sync: + testTarget: event-sync + batch-async: + testTarget: batch-async + batch-sync: + testTarget: batch-sync + bplistsync: + testTarget: bplistsync + bpasync: + testTarget: bpasync + bplistasync: + testTarget: bplistasync + bpsync: + testTarget: bpsync + syncwebsockets: + testTarget: syncwebsockets + asyncwebsockets: + testTarget: asyncwebsockets + sync-batch-web: + testTarget: sync-batch-web + async-batch-web: + testTarget: async-batch-web diff --git a/sdk/eventhub/azure-eventhub/stress/scripts/azure_eventhub_consumer_stress_async.py b/sdk/eventhub/azure-eventhub/stress/scripts/azure_eventhub_consumer_stress_async.py index a8f8fa3ddca6..e45c1bcd2d87 100644 --- a/sdk/eventhub/azure-eventhub/stress/scripts/azure_eventhub_consumer_stress_async.py +++ b/sdk/eventhub/azure-eventhub/stress/scripts/azure_eventhub_consumer_stress_async.py @@ -92,7 +92,7 @@ def parse_starting_position(args): args = parser.parse_args() starting_position = parse_starting_position(args) -LOGGER = get_logger(args.log_filename, "stress_receive_async", level=logging.INFO, print_console=args.print_console) +LOGGER = get_logger(args.log_filename, "stress_receive_async", level=logging.DEBUG, print_console=args.print_console) LOG_PER_COUNT = args.output_interval start_time = time.perf_counter() diff --git a/sdk/eventhub/azure-eventhub/stress/scripts/azure_eventhub_consumer_stress_sync.py b/sdk/eventhub/azure-eventhub/stress/scripts/azure_eventhub_consumer_stress_sync.py index f77d56b6b689..3159b33f05da 100644 --- a/sdk/eventhub/azure-eventhub/stress/scripts/azure_eventhub_consumer_stress_sync.py +++ b/sdk/eventhub/azure-eventhub/stress/scripts/azure_eventhub_consumer_stress_sync.py @@ -95,7 +95,7 @@ def parse_starting_position(args): LOGGER = get_logger( args.log_filename, "stress_receive_sync", - level=logging.INFO, + level=logging.DEBUG, print_console=print_console ) LOG_PER_COUNT = args.output_interval diff --git a/sdk/eventhub/azure-eventhub/stress/scripts/azure_eventhub_producer_stress.py b/sdk/eventhub/azure-eventhub/stress/scripts/azure_eventhub_producer_stress.py index a89c9d8291f3..27d8c0b0e5f1 100644 --- a/sdk/eventhub/azure-eventhub/stress/scripts/azure_eventhub_producer_stress.py +++ b/sdk/eventhub/azure-eventhub/stress/scripts/azure_eventhub_producer_stress.py @@ -296,7 +296,7 @@ def get_partition_ids(self_inner): method_name = self.args.method logger = get_logger(self.args.log_filename, method_name, - level=logging.INFO, print_console=self.args.print_console) + level=logging.DEBUG, print_console=self.args.print_console) test_method = globals()[method_name] self.running = True @@ -397,7 +397,7 @@ async def get_partition_ids(self_inner): method_name = self.args.method logger = get_logger(self.args.log_filename, method_name, - level=logging.INFO, print_console=self.args.print_console) + level=logging.DEBUG, print_console=self.args.print_console) test_method = globals()[method_name] self.running = True diff --git a/sdk/eventhub/azure-eventhub/stress/scripts/dev_requirement.txt b/sdk/eventhub/azure-eventhub/stress/scripts/dev_requirement.txt index 35414211f40a..b7ff5a1bb209 100644 --- a/sdk/eventhub/azure-eventhub/stress/scripts/dev_requirement.txt +++ b/sdk/eventhub/azure-eventhub/stress/scripts/dev_requirement.txt @@ -1,5 +1,5 @@ psutil -git+https://github.com/l0lawrence/azure-sdk-for-python.git@sb_to_eh2#subdirectory=sdk/eventhub/azure-eventhub&egg=azure-eventhub +azure-eventhub azure-eventhub-checkpointstoreblob azure-eventhub-checkpointstoreblob-aio azure-servicebus==7.8.1 diff --git a/sdk/eventhub/azure-eventhub/stress/templates/testjob.yaml b/sdk/eventhub/azure-eventhub/stress/templates/testjob.yaml index 082700dfdc78..49fb27c78afd 100644 --- a/sdk/eventhub/azure-eventhub/stress/templates/testjob.yaml +++ b/sdk/eventhub/azure-eventhub/stress/templates/testjob.yaml @@ -13,66 +13,54 @@ spec: limits: memory: "2000Mi" cpu: "1" - {{ if eq .Stress.testTarget "send" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_producer_stress.py -m stress_send_sync --duration 259200 --log_filename $DEBUG_SHARE/output '] + + {{ if eq .Stress.testTarget "event-async" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_producer_stress.py -m stress_send_async --duration 259200 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable & python azure_eventhub_consumer_stress_async.py --duration 259200 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable'] {{- end -}} - {{ if eq .Stress.testTarget "consume" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_consumer_stress_sync.py --duration 259200 --log_filename $DEBUG_SHARE/output '] - {{- end -}} - {{ if eq .Stress.testTarget "send-async" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_producer_stress.py -m stress_send_async --duration 259200 --log_filename $DEBUG_SHARE/output '] - {{- end -}} - {{ if eq .Stress.testTarget "consume-async" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_consumer_stress_async.py --duration 259200 --log_filename $DEBUG_SHARE/output '] - {{- end -}} - - # {{ if eq .Stress.testTarget "event-async" }} - # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_producer_stress.py -m stress_send_async --duration 259200 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable & python azure_eventhub_consumer_stress_async.py --duration 259200 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable'] - # {{- end -}} - # {{ if eq .Stress.testTarget "event-sync" }} - # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_producer_stress.py -m stress_send_sync --duration 259200 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable & python azure_eventhub_consumer_stress_sync.py --duration 259200 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable'] - # {{- end -}} + {{ if eq .Stress.testTarget "event-sync" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_producer_stress.py -m stress_send_sync --duration 259200 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable & python azure_eventhub_consumer_stress_sync.py --duration 259200 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable'] + {{- end -}} - # {{ if eq .Stress.testTarget "batch-async" }} - # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_producer_stress.py -m stress_send_list_async --duration 259200 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable & python azure_eventhub_consumer_stress_async.py --duration 259200 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable '] - # {{- end -}} + {{ if eq .Stress.testTarget "batch-async" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_producer_stress.py -m stress_send_list_async --duration 259200 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable & python azure_eventhub_consumer_stress_async.py --duration 259200 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable '] + {{- end -}} - # {{ if eq .Stress.testTarget "batch-sync" }} - # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_producer_stress.py -m stress_send_list_sync --duration 259200 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable & python azure_eventhub_consumer_stress_sync.py --duration 259200 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable '] - # {{- end -}} + {{ if eq .Stress.testTarget "batch-sync" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_producer_stress.py -m stress_send_list_sync --duration 259200 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable & python azure_eventhub_consumer_stress_sync.py --duration 259200 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable '] + {{- end -}} - # {{ if eq .Stress.testTarget "bplistsync" }} - # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_producer_stress.py -m stress_send_list_sync --duration 259200 --buffered_mode --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable & python azure_eventhub_consumer_stress_sync.py --duration 259200 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable'] - # {{- end -}} + {{ if eq .Stress.testTarget "bplistsync" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_producer_stress.py -m stress_send_list_sync --duration 259200 --buffered_mode --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable & python azure_eventhub_consumer_stress_sync.py --duration 259200 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable'] + {{- end -}} - # {{ if eq .Stress.testTarget "bpasync" }} - # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_producer_stress.py -m stress_send_async --duration 259200 --buffered_mode --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable & python azure_eventhub_consumer_stress_async.py --duration 259200 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable'] - # {{- end -}} + {{ if eq .Stress.testTarget "bpasync" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_producer_stress.py -m stress_send_async --duration 259200 --buffered_mode --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable & python azure_eventhub_consumer_stress_async.py --duration 259200 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable'] + {{- end -}} - # {{ if eq .Stress.testTarget "bplistasync" }} - # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_producer_stress.py -m stress_send_list_async --duration 259200 --buffered_mode --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable & python azure_eventhub_consumer_stress_async.py --duration 259200 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable '] - # {{- end -}} + {{ if eq .Stress.testTarget "bplistasync" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_producer_stress.py -m stress_send_list_async --duration 259200 --buffered_mode --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable & python azure_eventhub_consumer_stress_async.py --duration 259200 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable '] + {{- end -}} - # {{ if eq .Stress.testTarget "bpsync" }} - # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_producer_stress.py -m stress_send_sync --duration 259200 --buffered_mode --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable & python azure_eventhub_consumer_stress_sync.py --duration 259200 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable'] - # {{- end -}} + {{ if eq .Stress.testTarget "bpsync" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_producer_stress.py -m stress_send_sync --duration 259200 --buffered_mode --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable & python azure_eventhub_consumer_stress_sync.py --duration 259200 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable'] + {{- end -}} - # {{ if eq .Stress.testTarget "syncwebsockets" }} - # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_producer_stress.py -m stress_send_sync --duration 259200 --transport_type 1 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable & python azure_eventhub_consumer_stress_sync.py --duration 259200 --transport_type 1 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable'] - # {{- end -}} + {{ if eq .Stress.testTarget "syncwebsockets" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_producer_stress.py -m stress_send_sync --duration 259200 --transport_type 1 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable & python azure_eventhub_consumer_stress_sync.py --duration 259200 --transport_type 1 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable'] + {{- end -}} - # {{ if eq .Stress.testTarget "asyncwebsockets" }} - # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_producer_stress.py -m stress_send_async --duration 259200 --transport_type 1 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable & python azure_eventhub_consumer_stress_async.py --duration 259200 --transport_type 1 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable'] - # {{- end -}} + {{ if eq .Stress.testTarget "asyncwebsockets" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_producer_stress.py -m stress_send_async --duration 259200 --transport_type 1 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable & python azure_eventhub_consumer_stress_async.py --duration 259200 --transport_type 1 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable'] + {{- end -}} - # {{ if eq .Stress.testTarget "sync-batch-web" }} - # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_producer_stress.py -m stress_send_list_sync --duration 259200 --transport_type 1 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable & python azure_eventhub_consumer_stress_sync.py --duration 259200 --transport_type 1 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable'] - # {{- end -}} + {{ if eq .Stress.testTarget "sync-batch-web" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_producer_stress.py -m stress_send_list_sync --duration 259200 --transport_type 1 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable & python azure_eventhub_consumer_stress_sync.py --duration 259200 --transport_type 1 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable'] + {{- end -}} - # {{ if eq .Stress.testTarget "async-batch-web" }} - # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_producer_stress.py -m stress_send_list_async --duration 259200 --transport_type 1 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable & python azure_eventhub_consumer_stress_async.py --duration 259200 --transport_type 1 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable'] - # {{- end -}} + {{ if eq .Stress.testTarget "async-batch-web" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_producer_stress.py -m stress_send_list_async --duration 259200 --transport_type 1 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable & python azure_eventhub_consumer_stress_async.py --duration 259200 --transport_type 1 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable'] + {{- end -}} {{- include "stress-test-addons.container-env" . | nindent 6 }} {{- end -}} From faca94f6e88313be6034a698178cf2b2c506aba4 Mon Sep 17 00:00:00 2001 From: l0lawrence Date: Tue, 2 May 2023 09:35:02 -0700 Subject: [PATCH 26/30] logging --- .../azure_eventhub_consumer_stress_async.py | 2 +- .../azure_eventhub_consumer_stress_sync.py | 2 +- .../scripts/azure_eventhub_producer_stress.py | 4 +- .../azure-eventhub/stress/scripts/logger.py | 48 ++++++- .../stress/templates/testjob.yaml | 24 ++-- .../stress/scripts/stress_test_base.py | 5 +- .../stress/scripts/test_stress_queues.py | 120 ++++++---------- .../scripts/test_stress_queues_async.py | 135 ++++++------------ 8 files changed, 146 insertions(+), 194 deletions(-) diff --git a/sdk/eventhub/azure-eventhub/stress/scripts/azure_eventhub_consumer_stress_async.py b/sdk/eventhub/azure-eventhub/stress/scripts/azure_eventhub_consumer_stress_async.py index e45c1bcd2d87..a8f8fa3ddca6 100644 --- a/sdk/eventhub/azure-eventhub/stress/scripts/azure_eventhub_consumer_stress_async.py +++ b/sdk/eventhub/azure-eventhub/stress/scripts/azure_eventhub_consumer_stress_async.py @@ -92,7 +92,7 @@ def parse_starting_position(args): args = parser.parse_args() starting_position = parse_starting_position(args) -LOGGER = get_logger(args.log_filename, "stress_receive_async", level=logging.DEBUG, print_console=args.print_console) +LOGGER = get_logger(args.log_filename, "stress_receive_async", level=logging.INFO, print_console=args.print_console) LOG_PER_COUNT = args.output_interval start_time = time.perf_counter() diff --git a/sdk/eventhub/azure-eventhub/stress/scripts/azure_eventhub_consumer_stress_sync.py b/sdk/eventhub/azure-eventhub/stress/scripts/azure_eventhub_consumer_stress_sync.py index 3159b33f05da..f77d56b6b689 100644 --- a/sdk/eventhub/azure-eventhub/stress/scripts/azure_eventhub_consumer_stress_sync.py +++ b/sdk/eventhub/azure-eventhub/stress/scripts/azure_eventhub_consumer_stress_sync.py @@ -95,7 +95,7 @@ def parse_starting_position(args): LOGGER = get_logger( args.log_filename, "stress_receive_sync", - level=logging.DEBUG, + level=logging.INFO, print_console=print_console ) LOG_PER_COUNT = args.output_interval diff --git a/sdk/eventhub/azure-eventhub/stress/scripts/azure_eventhub_producer_stress.py b/sdk/eventhub/azure-eventhub/stress/scripts/azure_eventhub_producer_stress.py index 27d8c0b0e5f1..a89c9d8291f3 100644 --- a/sdk/eventhub/azure-eventhub/stress/scripts/azure_eventhub_producer_stress.py +++ b/sdk/eventhub/azure-eventhub/stress/scripts/azure_eventhub_producer_stress.py @@ -296,7 +296,7 @@ def get_partition_ids(self_inner): method_name = self.args.method logger = get_logger(self.args.log_filename, method_name, - level=logging.DEBUG, print_console=self.args.print_console) + level=logging.INFO, print_console=self.args.print_console) test_method = globals()[method_name] self.running = True @@ -397,7 +397,7 @@ async def get_partition_ids(self_inner): method_name = self.args.method logger = get_logger(self.args.log_filename, method_name, - level=logging.DEBUG, print_console=self.args.print_console) + level=logging.INFO, print_console=self.args.print_console) test_method = globals()[method_name] self.running = True diff --git a/sdk/eventhub/azure-eventhub/stress/scripts/logger.py b/sdk/eventhub/azure-eventhub/stress/scripts/logger.py index 164458325bcc..f8014397569e 100644 --- a/sdk/eventhub/azure-eventhub/stress/scripts/logger.py +++ b/sdk/eventhub/azure-eventhub/stress/scripts/logger.py @@ -22,10 +22,19 @@ def get_base_logger(log_filename, logger_name, level=logging.INFO, print_console console_handler.setFormatter(formatter) logger.addHandler(console_handler) + if log_filename: + logger_file_handler = RotatingFileHandler( + log_filename, + maxBytes=log_file_max_bytes, + backupCount=log_file_backup_count + ) + logger_file_handler.setFormatter(formatter) + logger.addHandler(logger_file_handler) + return logger -def get_logger(log_filename, logger_name, level=logging.DEBUG, print_console=False, log_format=None, +def get_logger(log_filename, logger_name, level=logging.INFO, print_console=False, log_format=None, log_file_max_bytes=20 * 1024 * 1024, log_file_backup_count=3): stress_logger = logging.getLogger(logger_name) stress_logger.setLevel(level) @@ -35,11 +44,38 @@ def get_logger(log_filename, logger_name, level=logging.DEBUG, print_console=Fal uamqp_logger.setLevel(level) formatter = log_format or logging.Formatter('%(asctime)s %(name)-12s %(levelname)-8s %(message)s') - console_handler = logging.FileHandler(log_filename) - console_handler.setFormatter(formatter) - eventhub_logger.addHandler(console_handler) - uamqp_logger.addHandler(console_handler) - stress_logger.addHandler(console_handler) + if print_console: + console_handler = logging.StreamHandler(stream=sys.stdout) + console_handler.setFormatter(formatter) + if not eventhub_logger.handlers: + eventhub_logger.addHandler(console_handler) + if not uamqp_logger.handlers: + uamqp_logger.addHandler(console_handler) + if not stress_logger.handlers: + stress_logger.addHandler(console_handler) + + if log_filename: + eventhub_file_handler = RotatingFileHandler( + "eventhub_" + log_filename, + maxBytes=log_file_max_bytes, + backupCount=log_file_backup_count + ) + uamqp_file_handler = RotatingFileHandler( + "uamqp_" + log_filename, + maxBytes=log_file_max_bytes, + backupCount=log_file_backup_count + ) + stress_file_handler = RotatingFileHandler( + log_filename, + maxBytes=log_file_max_bytes, + backupCount=log_file_backup_count + ) + eventhub_file_handler.setFormatter(formatter) + uamqp_file_handler.setFormatter(formatter) + stress_file_handler.setFormatter(formatter) + eventhub_logger.addHandler(eventhub_file_handler) + uamqp_logger.addHandler(uamqp_file_handler) + stress_logger.addHandler(stress_file_handler) return stress_logger diff --git a/sdk/eventhub/azure-eventhub/stress/templates/testjob.yaml b/sdk/eventhub/azure-eventhub/stress/templates/testjob.yaml index 49fb27c78afd..c8ee707abeaa 100644 --- a/sdk/eventhub/azure-eventhub/stress/templates/testjob.yaml +++ b/sdk/eventhub/azure-eventhub/stress/templates/testjob.yaml @@ -15,51 +15,51 @@ spec: cpu: "1" {{ if eq .Stress.testTarget "event-async" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_producer_stress.py -m stress_send_async --duration 259200 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable & python azure_eventhub_consumer_stress_async.py --duration 259200 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable'] + command: ['bash', '-c', 'python azure_eventhub_producer_stress.py -m stress_send_async --duration 259200 & python azure_eventhub_consumer_stress_async.py --duration 259200 '] {{- end -}} {{ if eq .Stress.testTarget "event-sync" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_producer_stress.py -m stress_send_sync --duration 259200 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable & python azure_eventhub_consumer_stress_sync.py --duration 259200 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable'] + command: ['bash', '-c', 'python azure_eventhub_producer_stress.py -m stress_send_sync --duration 259200 & python azure_eventhub_consumer_stress_sync.py --duration 259200 '] {{- end -}} {{ if eq .Stress.testTarget "batch-async" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_producer_stress.py -m stress_send_list_async --duration 259200 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable & python azure_eventhub_consumer_stress_async.py --duration 259200 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable '] + command: ['bash', '-c', 'python azure_eventhub_producer_stress.py -m stress_send_list_async --duration 259200 & python azure_eventhub_consumer_stress_async.py --duration 259200 '] {{- end -}} {{ if eq .Stress.testTarget "batch-sync" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_producer_stress.py -m stress_send_list_sync --duration 259200 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable & python azure_eventhub_consumer_stress_sync.py --duration 259200 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable '] + command: ['bash', '-c', 'python azure_eventhub_producer_stress.py -m stress_send_list_sync --duration 259200 & python azure_eventhub_consumer_stress_sync.py --duration 259200 '] {{- end -}} {{ if eq .Stress.testTarget "bplistsync" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_producer_stress.py -m stress_send_list_sync --duration 259200 --buffered_mode --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable & python azure_eventhub_consumer_stress_sync.py --duration 259200 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable'] + command: ['bash', '-c', 'python azure_eventhub_producer_stress.py -m stress_send_list_sync --duration 259200 --buffered_mode & python azure_eventhub_consumer_stress_sync.py --duration 259200 '] {{- end -}} {{ if eq .Stress.testTarget "bpasync" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_producer_stress.py -m stress_send_async --duration 259200 --buffered_mode --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable & python azure_eventhub_consumer_stress_async.py --duration 259200 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable'] + command: ['bash', '-c', 'python azure_eventhub_producer_stress.py -m stress_send_async --duration 259200 --buffered_mode & python azure_eventhub_consumer_stress_async.py --duration 259200'] {{- end -}} {{ if eq .Stress.testTarget "bplistasync" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_producer_stress.py -m stress_send_list_async --duration 259200 --buffered_mode --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable & python azure_eventhub_consumer_stress_async.py --duration 259200 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable '] + command: ['bash', '-c', 'python azure_eventhub_producer_stress.py -m stress_send_list_async --duration 259200 --buffered_mode & python azure_eventhub_consumer_stress_async.py --duration 259200 '] {{- end -}} {{ if eq .Stress.testTarget "bpsync" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_producer_stress.py -m stress_send_sync --duration 259200 --buffered_mode --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable & python azure_eventhub_consumer_stress_sync.py --duration 259200 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable'] + command: ['bash', '-c', 'python azure_eventhub_producer_stress.py -m stress_send_sync --duration 259200 --buffered_mode & python azure_eventhub_consumer_stress_sync.py --duration 259200'] {{- end -}} {{ if eq .Stress.testTarget "syncwebsockets" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_producer_stress.py -m stress_send_sync --duration 259200 --transport_type 1 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable & python azure_eventhub_consumer_stress_sync.py --duration 259200 --transport_type 1 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable'] + command: ['bash', '-c', 'python azure_eventhub_producer_stress.py -m stress_send_sync --duration 259200 --transport_type 1 & python azure_eventhub_consumer_stress_sync.py --duration 259200 --transport_type 1'] {{- end -}} {{ if eq .Stress.testTarget "asyncwebsockets" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_producer_stress.py -m stress_send_async --duration 259200 --transport_type 1 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable & python azure_eventhub_consumer_stress_async.py --duration 259200 --transport_type 1 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable'] + command: ['bash', '-c', 'python azure_eventhub_producer_stress.py -m stress_send_async --duration 259200 --transport_type 1 & python azure_eventhub_consumer_stress_async.py --duration 259200 --transport_type 1'] {{- end -}} {{ if eq .Stress.testTarget "sync-batch-web" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_producer_stress.py -m stress_send_list_sync --duration 259200 --transport_type 1 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable & python azure_eventhub_consumer_stress_sync.py --duration 259200 --transport_type 1 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable'] + command: ['bash', '-c', 'python azure_eventhub_producer_stress.py -m stress_send_list_sync --duration 259200 --transport_type 1 & python azure_eventhub_consumer_stress_sync.py --duration 259200 --transport_type 1'] {{- end -}} {{ if eq .Stress.testTarget "async-batch-web" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python azure_eventhub_producer_stress.py -m stress_send_list_async --duration 259200 --transport_type 1 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable & python azure_eventhub_consumer_stress_async.py --duration 259200 --transport_type 1 --log_filename $DEBUG_SHARE/output --pyamqp_logging_enable'] + command: ['bash', '-c', 'python azure_eventhub_producer_stress.py -m stress_send_list_async --duration 259200 --transport_type 1 & python azure_eventhub_consumer_stress_async.py --duration 259200 --transport_type 1'] {{- end -}} {{- include "stress-test-addons.container-env" . | nindent 6 }} diff --git a/sdk/servicebus/azure-servicebus/stress/scripts/stress_test_base.py b/sdk/servicebus/azure-servicebus/stress/scripts/stress_test_base.py index be29a0f5be4a..43409d1856bf 100644 --- a/sdk/servicebus/azure-servicebus/stress/scripts/stress_test_base.py +++ b/sdk/servicebus/azure-servicebus/stress/scripts/stress_test_base.py @@ -94,6 +94,7 @@ def __init__( fail_on_exception=True, azure_monitor_metric=None, process_monitor=None, + logging_level=logging.ERROR, ): self.senders = senders self.receivers = receivers @@ -112,6 +113,7 @@ def __init__( self.azure_monitor_metric = azure_monitor_metric or AbstractMonitorMetric( "fake_test_name" ) + self.logging_level = logging_level self.process_monitor = process_monitor or ProcessMonitor( "monitor_{}".format(LOGFILE_NAME), "test_stress_queues", @@ -363,6 +365,7 @@ def __init__( fail_on_exception=True, azure_monitor_metric=None, process_monitor=None, + logging_level=logging.ERROR, ): super(StressTestRunnerAsync, self).__init__( senders, @@ -381,6 +384,7 @@ def __init__( fail_on_exception=fail_on_exception, azure_monitor_metric=azure_monitor_metric, process_monitor=process_monitor, + logging_level=logging_level ) async def _send_async(self, sender, end_time): @@ -419,7 +423,6 @@ async def _send_async(self, sender, end_time): raise async def _receive_handle_message(self, message, receiver, end_time): - # _logger = get_logger(LOGFILE_NAME, "stress_test_receive", level=logging.ERROR) self.on_receive(self._state, message, receiver) try: if self.should_complete_messages: diff --git a/sdk/servicebus/azure-servicebus/stress/scripts/test_stress_queues.py b/sdk/servicebus/azure-servicebus/stress/scripts/test_stress_queues.py index ea74c9012f0d..6288696d6cd0 100644 --- a/sdk/servicebus/azure-servicebus/stress/scripts/test_stress_queues.py +++ b/sdk/servicebus/azure-servicebus/stress/scripts/test_stress_queues.py @@ -5,6 +5,7 @@ #-------------------------------------------------------------------------- from datetime import timedelta +import logging import time import os from dotenv import load_dotenv @@ -27,7 +28,8 @@ def test_stress_queue_send_and_receive(args): receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME)], admin_client = sb_admin_client, duration=args.duration, - azure_monitor_metric=AzureMonitorMetric("test_stress_queue_send_and_receive") + azure_monitor_metric=AzureMonitorMetric("test_stress_queue_send_and_receive"), + logging_level=LOGGING_LEVEL ) result = stress_test.run() @@ -42,7 +44,8 @@ def test_stress_queue_send_and_pull_receive(args): admin_client = sb_admin_client, receive_type=ReceiveType.pull, duration=args.duration, - azure_monitor_metric=AzureMonitorMetric("test_stress_queue_send_and_pull_receive") + azure_monitor_metric=AzureMonitorMetric("test_stress_queue_send_and_pull_receive"), + logging_level=LOGGING_LEVEL ) result = stress_test.run() @@ -57,7 +60,8 @@ def test_stress_queue_batch_send_and_receive(args): admin_client = sb_admin_client, duration=args.duration, send_batch_size=5, - azure_monitor_metric=AzureMonitorMetric("test_stress_queue_batch_send_and_receive") + azure_monitor_metric=AzureMonitorMetric("test_stress_queue_batch_send_and_receive"), + logging_level=LOGGING_LEVEL ) result = stress_test.run() @@ -70,10 +74,10 @@ def test_stress_queue_slow_send_and_receive(args): stress_test = StressTestRunner(senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME)], admin_client = sb_admin_client, - # duration=timedelta(seconds=3501*3), duration=args.duration, send_delay=(args.duration/3), - azure_monitor_metric=AzureMonitorMetric("test_stress_queue_slow_send_and_receive") + azure_monitor_metric=AzureMonitorMetric("test_stress_queue_slow_send_and_receive"), + logging_level=LOGGING_LEVEL ) result = stress_test.run() @@ -88,7 +92,8 @@ def test_stress_queue_receive_and_delete(args): admin_client = sb_admin_client, should_complete_messages = False, duration=args.duration, - azure_monitor_metric=AzureMonitorMetric("test_stress_queue_slow_send_and_receive") + azure_monitor_metric=AzureMonitorMetric("test_stress_queue_slow_send_and_receive"), + logging_level=LOGGING_LEVEL ) result = stress_test.run() @@ -101,10 +106,10 @@ def test_stress_queue_unsettled_messages(args): stress_test = StressTestRunner(senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME)], admin_client = sb_admin_client, - # duration = timedelta(seconds=350), duration=args.duration, should_complete_messages = False, - azure_monitor_metric=AzureMonitorMetric("test_stress_queue_unsettled_messages") + azure_monitor_metric=AzureMonitorMetric("test_stress_queue_unsettled_messages"), + logging_level=LOGGING_LEVEL ) result = stress_test.run() @@ -121,7 +126,8 @@ def test_stress_queue_receive_large_batch_size(args): admin_client = sb_admin_client, duration = args.duration, max_message_count = 50, - azure_monitor_metric=AzureMonitorMetric("test_stress_queue_receive_large_batch_size") + azure_monitor_metric=AzureMonitorMetric("test_stress_queue_receive_large_batch_size"), + logging_level=LOGGING_LEVEL ) result = stress_test.run() @@ -145,9 +151,9 @@ def test_stress_queue_pull_receive_timeout(args): admin_client = sb_admin_client, max_wait_time = 5, receive_type=ReceiveType.pull, - # duration=timedelta(seconds=600), duration=args.duration, - azure_monitor_metric=AzureMonitorMetric("test_stress_queue_pull_receive_timeout") + azure_monitor_metric=AzureMonitorMetric("test_stress_queue_pull_receive_timeout"), + logging_level=LOGGING_LEVEL ) result = stress_test.run() @@ -168,10 +174,10 @@ def test_stress_queue_long_renew_send_and_receive(args): senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME)], admin_client = sb_admin_client, - # duration=timedelta(seconds=3000), duration=args.duration, send_delay=300, - azure_monitor_metric=AzureMonitorMetric("test_stress_queue_long_renew_send_and_receive") + azure_monitor_metric=AzureMonitorMetric("test_stress_queue_long_renew_send_and_receive"), + logging_level=LOGGING_LEVEL ) result = stress_test.run() @@ -195,11 +201,11 @@ def test_stress_queue_long_renew_session_send_and_receive(args): senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME, session_id=session_id)], admin_client = sb_admin_client, - # duration=timedelta(seconds=3000), duration=args.duration, send_delay=300, send_session_id=session_id, - azure_monitor_metric=AzureMonitorMetric("test_stress_queue_long_renew_session_send_and_receive") + azure_monitor_metric=AzureMonitorMetric("test_stress_queue_long_renew_session_send_and_receive"), + logging_level=LOGGING_LEVEL ) result = stress_test.run() @@ -219,11 +225,11 @@ def test_stress_queue_peek_messages(args): senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME)], admin_client = sb_admin_client, - # duration = timedelta(seconds=300), duration=args.duration, receive_delay = 30, receive_type = ReceiveType.none, - azure_monitor_metric=AzureMonitorMetric("test_stress_queue_peek_messages") + azure_monitor_metric=AzureMonitorMetric("test_stress_queue_peek_messages"), + logging_level=LOGGING_LEVEL ) result = stress_test.run() @@ -252,11 +258,11 @@ def test_stress_queue_close_and_reopen(args): senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME)], admin_client = sb_admin_client, - # duration = timedelta(seconds=300), duration = args.duration, receive_delay = 30, send_delay = 10, - azure_monitor_metric=AzureMonitorMetric("test_stress_queue_close_and_reopen") + azure_monitor_metric=AzureMonitorMetric("test_stress_queue_close_and_reopen"), + logging_level=LOGGING_LEVEL ) result = stress_test.run() @@ -301,9 +307,9 @@ def test_stress_queue_check_for_dropped_messages(args): receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME)], admin_client = sb_admin_client, receive_type=ReceiveType.pull, - # duration=timedelta(seconds=3000), duration=args.duration, - azure_monitor_metric=AzureMonitorMetric("test_stress_queue_check_for_dropped_messages") + azure_monitor_metric=AzureMonitorMetric("test_stress_queue_check_for_dropped_messages"), + logging_level=LOGGING_LEVEL ) result = stress_test.run() @@ -329,6 +335,7 @@ def test_stress_queue_check_for_dropped_messages(args): parser.add_argument("--max_message_count", type=int, default=1) parser.add_argument("--uamqp_mode", action="store_true") parser.add_argument("--transport", action="store_true") + parser.add_argument("--debug_level", help="Flag for setting a debug level, can be Info, Debug, Warning, Error or Critical", type=str, default="Error") args, _ = parser.parse_known_args() @@ -340,6 +347,7 @@ def test_stress_queue_check_for_dropped_messages(args): SERVICE_BUS_CONNECTION_STR = args.conn_str SERVICEBUS_QUEUE_NAME= args.queue_name LOGGING_ENABLE = args.logging_enable + LOGGING_LEVEL = getattr(logging, args.debug_level.upper(), None) sb_admin_client = ServiceBusAdministrationClient.from_connection_string(SERVICE_BUS_CONNECTION_STR) @@ -369,62 +377,18 @@ def test_stress_queue_check_for_dropped_messages(args): test_stress_queue_close_and_reopen(args) elif args.method == "dropped_messages": test_stress_queue_check_for_dropped_messages(args) - elif args.method == "sender": - sb_client = ServiceBusClient.from_connection_string( - SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) - stress_test = StressTestRunner(senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], - receivers = None, - admin_client = sb_admin_client, - duration=args.duration, - send_batch_size=5, - azure_monitor_metric=AzureMonitorMetric("test_stress_queue_batch_send_and_receive") - ) - - result = stress_test.run() - print(f"Total send {result.total_sent}") - print(f"Total received {result.total_received}") - elif args.method == "receiver": - sb_client = ServiceBusClient.from_connection_string( - SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) - stress_test = StressTestRunner(senders = None, - receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME, prefetch_count=5)], - admin_client = sb_admin_client, - duration=args.duration, - receive_type=ReceiveType.pull, - send_batch_size=5, - azure_monitor_metric=AzureMonitorMetric("test_stress_queue_batch_send_and_receive") - ) - - result = stress_test.run() - print(f"Total send {result.total_sent}") - print(f"Total received {result.total_received}") - elif args.method == "iterator": - sb_client = ServiceBusClient.from_connection_string( - SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) - stress_test = StressTestRunner(senders = None, - receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME, prefetch_count=5)], - admin_client = sb_admin_client, - duration=args.duration, - send_batch_size=5, - azure_monitor_metric=AzureMonitorMetric("test_stress_queue_batch_send_and_receive") - ) - - result = stress_test.run() - print(f"Total send {result.total_sent}") - print(f"Total received {result.total_received}") else: - pass - # test_stress_queue_send_and_receive(args) - # test_stress_queue_send_and_pull_receive(args) - # test_stress_queue_batch_send_and_receive(args) - # test_stress_queue_slow_send_and_receive(args) - # test_stress_queue_receive_and_delete(args) - # test_stress_queue_unsettled_messages(args) - # test_stress_queue_receive_large_batch_size(args) - # test_stress_queue_pull_receive_timeout(args) - # test_stress_queue_long_renew_send_and_receive(args) - # test_stress_queue_long_renew_session_send_and_receive(args) - # test_stress_queue_peek_messages(args) - # test_stress_queue_close_and_reopen(args) - # test_stress_queue_check_for_dropped_messages(args) + test_stress_queue_send_and_receive(args) + test_stress_queue_send_and_pull_receive(args) + test_stress_queue_batch_send_and_receive(args) + test_stress_queue_slow_send_and_receive(args) + test_stress_queue_receive_and_delete(args) + test_stress_queue_unsettled_messages(args) + test_stress_queue_receive_large_batch_size(args) + test_stress_queue_pull_receive_timeout(args) + test_stress_queue_long_renew_send_and_receive(args) + test_stress_queue_long_renew_session_send_and_receive(args) + test_stress_queue_peek_messages(args) + test_stress_queue_close_and_reopen(args) + test_stress_queue_check_for_dropped_messages(args) diff --git a/sdk/servicebus/azure-servicebus/stress/scripts/test_stress_queues_async.py b/sdk/servicebus/azure-servicebus/stress/scripts/test_stress_queues_async.py index a53953cc5f45..eb9f05765cf2 100644 --- a/sdk/servicebus/azure-servicebus/stress/scripts/test_stress_queues_async.py +++ b/sdk/servicebus/azure-servicebus/stress/scripts/test_stress_queues_async.py @@ -5,6 +5,7 @@ #-------------------------------------------------------------------------- from datetime import timedelta +import logging import time import os import asyncio @@ -29,7 +30,8 @@ async def test_stress_queue_send_and_receive(args): receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME, max_wait_time=10)], admin_client = sb_admin_client, duration=args.duration, - azure_monitor_metric=AzureMonitorMetric("test_stress_queue_send_and_receive") + azure_monitor_metric=AzureMonitorMetric("test_stress_queue_send_and_receive"), + logging_level=LOGGING_LEVEL ) result = await stress_test.run_async() @@ -44,7 +46,8 @@ async def test_stress_queue_send_and_pull_receive(args): admin_client = sb_admin_client, receive_type=ReceiveType.pull, duration=args.duration, - azure_monitor_metric=AzureMonitorMetric("test_stress_queue_send_and_pull_receive") + azure_monitor_metric=AzureMonitorMetric("test_stress_queue_send_and_pull_receive"), + logging_level=LOGGING_LEVEL ) result = await stress_test.run_async() @@ -59,7 +62,8 @@ async def test_stress_queue_batch_send_and_receive(args): admin_client = sb_admin_client, duration=args.duration, send_batch_size=5, - azure_monitor_metric=AzureMonitorMetric("test_stress_queue_batch_send_and_receive") + azure_monitor_metric=AzureMonitorMetric("test_stress_queue_batch_send_and_receive"), + logging_level=LOGGING_LEVEL ) result = await stress_test.run_async() @@ -72,10 +76,10 @@ async def test_stress_queue_slow_send_and_receive(args): stress_test = StressTestRunnerAsync(senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME, max_wait_time=10)], admin_client = sb_admin_client, - # duration=timedelta(seconds=3501*3), duration=args.duration, send_delay=(args.duration/3), - azure_monitor_metric=AzureMonitorMetric("test_stress_queue_slow_send_and_receive") + azure_monitor_metric=AzureMonitorMetric("test_stress_queue_slow_send_and_receive"), + logging_level=LOGGING_LEVEL ) result = await stress_test.run_async() @@ -90,7 +94,8 @@ async def test_stress_queue_receive_and_delete(args): admin_client = sb_admin_client, should_complete_messages = False, duration=args.duration, - azure_monitor_metric=AzureMonitorMetric("test_stress_queue_slow_send_and_receive") + azure_monitor_metric=AzureMonitorMetric("test_stress_queue_slow_send_and_receive"), + logging_level=LOGGING_LEVEL ) result = await stress_test.run_async() @@ -103,10 +108,10 @@ async def test_stress_queue_unsettled_messages(args): stress_test = StressTestRunnerAsync(senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME, max_wait_time=10)], admin_client = sb_admin_client, - # duration = timedelta(seconds=350), duration=args.duration, should_complete_messages = False, - azure_monitor_metric=AzureMonitorMetric("test_stress_queue_unsettled_messages") + azure_monitor_metric=AzureMonitorMetric("test_stress_queue_unsettled_messages"), + logging_level=LOGGING_LEVEL ) result = await stress_test.run_async() @@ -123,7 +128,8 @@ async def test_stress_queue_receive_large_batch_size(args): admin_client = sb_admin_client, duration = args.duration, max_message_count = 50, - azure_monitor_metric=AzureMonitorMetric("test_stress_queue_receive_large_batch_size") + azure_monitor_metric=AzureMonitorMetric("test_stress_queue_receive_large_batch_size"), + logging_level=LOGGING_LEVEL ) result = await stress_test.run_async() @@ -147,9 +153,9 @@ async def test_stress_queue_pull_receive_timeout(args): admin_client = sb_admin_client, max_wait_time = 5, receive_type=ReceiveType.pull, - # duration=timedelta(seconds=600), duration=args.duration, - azure_monitor_metric=AzureMonitorMetric("test_stress_queue_pull_receive_timeout") + azure_monitor_metric=AzureMonitorMetric("test_stress_queue_pull_receive_timeout"), + logging_level=LOGGING_LEVEL ) result = await stress_test.run_async() @@ -170,10 +176,10 @@ async def test_stress_queue_long_renew_send_and_receive(args): senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME, max_wait_time=10)], admin_client = sb_admin_client, - # duration=timedelta(seconds=3000), duration=args.duration, send_delay=300, - azure_monitor_metric=AzureMonitorMetric("test_stress_queue_long_renew_send_and_receive") + azure_monitor_metric=AzureMonitorMetric("test_stress_queue_long_renew_send_and_receive"), + logging_level=LOGGING_LEVEL ) result = await stress_test.run_async() @@ -197,11 +203,11 @@ async def test_stress_queue_long_renew_session_send_and_receive(args): senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME, session_id=session_id, max_wait_time=10)], admin_client = sb_admin_client, - # duration=timedelta(seconds=3000), duration=args.duration, send_delay=300, send_session_id=session_id, - azure_monitor_metric=AzureMonitorMetric("test_stress_queue_long_renew_session_send_and_receive") + azure_monitor_metric=AzureMonitorMetric("test_stress_queue_long_renew_session_send_and_receive"), + logging_level=LOGGING_LEVEL ) result = await stress_test.run_async() @@ -220,11 +226,11 @@ async def test_stress_queue_peek_messages(args): senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME, max_wait_time=10)], admin_client = sb_admin_client, - # duration = timedelta(seconds=300), duration=args.duration, receive_delay = 30, receive_type = ReceiveType.none, - azure_monitor_metric=AzureMonitorMetric("test_stress_queue_peek_messages") + azure_monitor_metric=AzureMonitorMetric("test_stress_queue_peek_messages"), + logging_level=LOGGING_LEVEL ) result = await stress_test.run_async() @@ -253,11 +259,11 @@ async def test_stress_queue_close_and_reopen(args): senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME, max_wait_time=10)], admin_client = sb_admin_client, - # duration = timedelta(seconds=300), duration = args.duration, receive_delay = 30, send_delay = 10, - azure_monitor_metric=AzureMonitorMetric("test_stress_queue_close_and_reopen") + azure_monitor_metric=AzureMonitorMetric("test_stress_queue_close_and_reopen"), + logging_level=LOGGING_LEVEL ) result = await stress_test.run_async() @@ -302,9 +308,9 @@ async def test_stress_queue_check_for_dropped_messages(args): receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME, max_wait_time=10)], admin_client = sb_admin_client, receive_type=ReceiveType.pull, - # duration=timedelta(seconds=3000), duration=args.duration, - azure_monitor_metric=AzureMonitorMetric("test_stress_queue_check_for_dropped_messages") + azure_monitor_metric=AzureMonitorMetric("test_stress_queue_check_for_dropped_messages"), + logging_level=LOGGING_LEVEL ) result = await stress_test.run_async() @@ -338,78 +344,20 @@ async def run(args): await test_stress_queue_close_and_reopen(args) elif args.method == "dropped_messages": await test_stress_queue_check_for_dropped_messages(args) - elif args.method == "sender": - sb_client = ServiceBusClient.from_connection_string( - SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) - stress_test = StressTestRunnerAsync(senders = [sb_client.get_queue_sender(SERVICEBUS_QUEUE_NAME)], - receivers = None, - admin_client = sb_admin_client, - duration=args.duration, - send_batch_size=5, - azure_monitor_metric=AzureMonitorMetric("test_stress_queue_batch_send_and_receive") - ) - - result = await stress_test.run_async() - print(f"Total send {result.total_sent}") - print(f"Total received {result.total_received}") - elif args.method == "receiver": - sb_client = ServiceBusClient.from_connection_string( - SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) - stress_test = StressTestRunnerAsync(senders = None, - receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME, prefetch_count=5)], - admin_client = sb_admin_client, - duration=args.duration, - receive_type=ReceiveType.pull, - send_batch_size=5, - azure_monitor_metric=AzureMonitorMetric("test_stress_queue_batch_send_and_receive") - ) - - result = await stress_test.run_async() - print(f"Total send {result.total_sent}") - print(f"Total received {result.total_received}") - elif args.method == "iterator": - sb_client = ServiceBusClient.from_connection_string( - SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) - stress_test = StressTestRunnerAsync(senders = None, - receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME, prefetch_count=5)], - admin_client = sb_admin_client, - duration=args.duration, - send_batch_size=5, - azure_monitor_metric=AzureMonitorMetric("test_stress_queue_batch_send_and_receive") - ) - - result = await stress_test.run_async() - print(f"Total send {result.total_sent}") - print(f"Total received {result.total_received}") - elif args.method == "iteratornobatch": - sb_client = ServiceBusClient.from_connection_string( - SERVICE_BUS_CONNECTION_STR, logging_enable=LOGGING_ENABLE, transport_type=TRANSPORT_TYPE) - stress_test = StressTestRunnerAsync(senders = None, - receivers = [sb_client.get_queue_receiver(SERVICEBUS_QUEUE_NAME)], - admin_client = sb_admin_client, - duration=args.duration, - send_batch_size=5, - azure_monitor_metric=AzureMonitorMetric("test_stress_queue_batch_send_and_receive") - ) - - result = await stress_test.run_async() - print(f"Total send {result.total_sent}") - print(f"Total received {result.total_received}") else: - pass - # await test_stress_queue_send_and_receive(args) - # await test_stress_queue_send_and_pull_receive(args) - # await test_stress_queue_batch_send_and_receive(args) - # await test_stress_queue_slow_send_and_receive(args) - # await test_stress_queue_receive_and_delete(args) - # await test_stress_queue_unsettled_messages(args) - # await test_stress_queue_receive_large_batch_size(args) - # await test_stress_queue_pull_receive_timeout(args) - # await test_stress_queue_long_renew_send_and_receive(args) - # await test_stress_queue_long_renew_session_send_and_receive(args) - # await test_stress_queue_peek_messages(args) - # await test_stress_queue_close_and_reopen(args) - # await test_stress_queue_check_for_dropped_messages(args) + await test_stress_queue_send_and_receive(args) + await test_stress_queue_send_and_pull_receive(args) + await test_stress_queue_batch_send_and_receive(args) + await test_stress_queue_slow_send_and_receive(args) + await test_stress_queue_receive_and_delete(args) + await test_stress_queue_unsettled_messages(args) + await test_stress_queue_receive_large_batch_size(args) + await test_stress_queue_pull_receive_timeout(args) + await test_stress_queue_long_renew_send_and_receive(args) + await test_stress_queue_long_renew_session_send_and_receive(args) + await test_stress_queue_peek_messages(args) + await test_stress_queue_close_and_reopen(args) + await test_stress_queue_check_for_dropped_messages(args) if __name__ == '__main__': @@ -431,7 +379,7 @@ async def run(args): parser.add_argument("--max_message_count", type=int, default=1) parser.add_argument("--uamqp_mode", type=bool, default=False) parser.add_argument("--transport", action="store_true") - + parser.add_argument("--debug_level", help="Flag for setting a debug level, can be Info, Debug, Warning, Error or Critical", type=str, default="Error") args, _ = parser.parse_known_args() if args.transport: @@ -442,6 +390,7 @@ async def run(args): SERVICE_BUS_CONNECTION_STR = args.conn_str SERVICEBUS_QUEUE_NAME= args.queue_name LOGGING_ENABLE = args.logging_enable + LOGGING_LEVEL = getattr(logging, args.debug_level.upper(), None) sb_admin_client = ServiceBusAdministrationClient.from_connection_string(SERVICE_BUS_CONNECTION_STR) loop = asyncio.get_event_loop() From e4c77020febd115ea3a795d0f1d1a8cca61c5d19 Mon Sep 17 00:00:00 2001 From: l0lawrence Date: Tue, 2 May 2023 09:38:09 -0700 Subject: [PATCH 27/30] update jpb --- .../stress/scripts/dev_requirements.txt | 6 +- .../stress/templates/testjob.yaml | 104 +++++++----------- 2 files changed, 43 insertions(+), 67 deletions(-) diff --git a/sdk/servicebus/azure-servicebus/stress/scripts/dev_requirements.txt b/sdk/servicebus/azure-servicebus/stress/scripts/dev_requirements.txt index c9dfde1be528..dc6a5d000de9 100644 --- a/sdk/servicebus/azure-servicebus/stress/scripts/dev_requirements.txt +++ b/sdk/servicebus/azure-servicebus/stress/scripts/dev_requirements.txt @@ -1,8 +1,6 @@ aiohttp>=3.0 opencensus-ext-azure psutil - +azure-servicebus python-dotenv -websocket-client - -git+https://github.com/kashifkhan/azure-sdk-for-python.git@sb_pyamqp_mem#subdirectory=sdk/servicebus/azure-servicebus&egg=azure-servicebus \ No newline at end of file +websocket-client \ No newline at end of file diff --git a/sdk/servicebus/azure-servicebus/stress/templates/testjob.yaml b/sdk/servicebus/azure-servicebus/stress/templates/testjob.yaml index bc2988afa373..9d46259360de 100644 --- a/sdk/servicebus/azure-servicebus/stress/templates/testjob.yaml +++ b/sdk/servicebus/azure-servicebus/stress/templates/testjob.yaml @@ -15,83 +15,61 @@ spec: memory: "2000Mi" cpu: "1" - {{ if eq .Stress.testTarget "sender" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python test_stress_queues.py --method sender --duration 300000 --logging-enable'] + {{ if eq .Stress.testTarget "aqueuew" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python test_stress_queues.py --method send_receive --duration 300000 --logging-enable --transport'] {{- end -}} - {{ if eq .Stress.testTarget "receiver" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python test_stress_queues.py --method receiver --duration 300000 --logging-enable'] - {{- end -}} - {{ if eq .Stress.testTarget "iterator" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python test_stress_queues.py --method iterator --duration 300000 --logging-enable'] - {{- end -}} - {{ if eq .Stress.testTarget "senderasync" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python test_stress_queues_async.py --method sender --duration 300000 --logging-enable'] - {{- end -}} - {{ if eq .Stress.testTarget "receiverasync" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python test_stress_queues_async.py --method receiver --duration 300000 --logging-enable'] - {{- end -}} - {{ if eq .Stress.testTarget "iteratorasync" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python test_stress_queues_async.py --method iterator --duration 300000 --logging-enable'] - {{- end -}} - {{ if eq .Stress.testTarget "iteratorasyncnobatch" }} - command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python test_stress_queues_async.py --method iteratornobatch --duration 300000 --logging-enable'] - {{- end -}} - - # {{ if eq .Stress.testTarget "aqueuew" }} - # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python test_stress_queues.py --method send_receive --duration 300000 --logging-enable --transport'] - # {{- end -}} - # {{ if eq .Stress.testTarget "queuew" }} - # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues.py --method send_receive --duration 300000 --logging-enable --transport'] - # {{- end -}} + {{ if eq .Stress.testTarget "queuew" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output && python test_stress_queues.py --method send_receive --duration 300000 --logging-enable --transport'] + {{- end -}} - # {{ if eq .Stress.testTarget "aqueuepullw" }} - # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues_async.py --method send_pull_receive --duration 300000 --logging-enable --transport'] - # {{- end -}} + {{ if eq .Stress.testTarget "aqueuepullw" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output.bin && python test_stress_queues_async.py --method send_pull_receive --duration 300000 --logging-enable --transport'] + {{- end -}} - # {{ if eq .Stress.testTarget "queuepullw" }} - # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues.py --method send_pull_receive --duration 300000 --logging-enable --transport'] - # {{- end -}} + {{ if eq .Stress.testTarget "queuepullw" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output.bin && python test_stress_queues.py --method send_pull_receive --duration 300000 --logging-enable --transport'] + {{- end -}} - # {{ if eq .Stress.testTarget "abatchw" }} - # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues_async.py --method send_receive_batch --duration 300000 --logging-enable --transport'] - # {{- end -}} + {{ if eq .Stress.testTarget "abatchw" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output.bin && python test_stress_queues_async.py --method send_receive_batch --duration 300000 --logging-enable --transport'] + {{- end -}} - # {{ if eq .Stress.testTarget "batchw" }} - # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues.py --method send_receive_batch --duration 300000 --logging-enable --transport'] - # {{- end -}} + {{ if eq .Stress.testTarget "batchw" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output.bin && python test_stress_queues.py --method send_receive_batch --duration 300000 --logging-enable --transport'] + {{- end -}} - # {{ if eq .Stress.testTarget "aqueue" }} - # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues_async.py --method send_receive --duration 300000 --logging-enable'] - # {{- end -}} + {{ if eq .Stress.testTarget "aqueue" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output.bin && python test_stress_queues_async.py --method send_receive --duration 300000 --logging-enable'] + {{- end -}} - # {{ if eq .Stress.testTarget "queue" }} - # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues.py --method send_receive --duration 300000 --logging-enable'] - # {{- end -}} + {{ if eq .Stress.testTarget "queue" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output.bin && python test_stress_queues.py --method send_receive --duration 300000 --logging-enable'] + {{- end -}} - # {{ if eq .Stress.testTarget "aqueuepull" }} - # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues_async.py --method send_pull_receive --duration 300000 --logging-enable'] - # {{- end -}} + {{ if eq .Stress.testTarget "aqueuepull" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output.bin && python test_stress_queues_async.py --method send_pull_receive --duration 300000 --logging-enable'] + {{- end -}} - # {{ if eq .Stress.testTarget "queuepull" }} - # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues.py --method send_pull_receive --duration 300000 --logging-enable --output $DEBUG_SHARE/output.bin'] - # {{- end -}} + {{ if eq .Stress.testTarget "queuepull" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output.bin && python test_stress_queues.py --method send_pull_receive --duration 300000 --logging-enable --output $DEBUG_SHARE/output.bin'] + {{- end -}} - # {{ if eq .Stress.testTarget "abatch" }} - # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues_async.py --method send_receive_batch --duration 300000 --logging-enable --output $DEBUG_SHARE/output.bin'] - # {{- end -}} + {{ if eq .Stress.testTarget "abatch" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output.bin && python test_stress_queues_async.py --method send_receive_batch --duration 300000 --logging-enable --output $DEBUG_SHARE/output.bin'] + {{- end -}} - # {{ if eq .Stress.testTarget "batch" }} - # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat $DEBUG_SHARE/output.bin && python test_stress_queues.py --method send_receive_batch --duration 300000 --logging-enable --output $DEBUG_SHARE/output.bin'] - # {{- end -}} + {{ if eq .Stress.testTarget "batch" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && cat > $DEBUG_SHARE/output.bin && python test_stress_queues.py --method send_receive_batch --duration 300000 --logging-enable --output $DEBUG_SHARE/output.bin'] + {{- end -}} - # {{ if eq .Stress.testTarget "amemray" }} - # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && memray run --output $DEBUG_SHARE/sb_async_memray_output.bin test_stress_queues_async.py --method send_pull_receive --duration 300000 --logging-enable'] - # {{- end -}} + {{ if eq .Stress.testTarget "amemray" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && memray run --output $DEBUG_SHARE/sb_async_memray_output.bin test_stress_queues_async.py --method send_pull_receive --duration 300000 --logging-enable'] + {{- end -}} - # {{ if eq .Stress.testTarget "memray" }} - # command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && memray run --output $DEBUG_SHARE/sb_memray_output.bin test_stress_queues.py --method send_pull_receive --duration 300000 --logging-enable'] - # {{- end -}} + {{ if eq .Stress.testTarget "memray" }} + command: ['bash', '-c', 'mkdir -p $DEBUG_SHARE && memray run --output $DEBUG_SHARE/sb_memray_output.bin test_stress_queues.py --method send_pull_receive --duration 300000 --logging-enable'] + {{- end -}} {{- include "stress-test-addons.container-env" . | nindent 6 }} {{- end -}} From c451a61e95918b95d7eeb1c4b86229651b30314e Mon Sep 17 00:00:00 2001 From: l0lawrence Date: Tue, 2 May 2023 09:39:06 -0700 Subject: [PATCH 28/30] update docker --- sdk/servicebus/azure-servicebus/stress/Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sdk/servicebus/azure-servicebus/stress/Dockerfile b/sdk/servicebus/azure-servicebus/stress/Dockerfile index e777f3fed449..96439c796da8 100644 --- a/sdk/servicebus/azure-servicebus/stress/Dockerfile +++ b/sdk/servicebus/azure-servicebus/stress/Dockerfile @@ -2,7 +2,8 @@ # public OSS users should simply leave this argument blank or ignore its presence entirely ARG REGISTRY="mcr.microsoft.com/mirror/docker/library/" FROM ${REGISTRY}python:3.8-slim-buster -RUN apt-get -y update && apt-get -y install git +# Install if running off git branch +# RUN apt-get -y update && apt-get -y install git WORKDIR /app From d147240ea5d5abaa6ea30145fe24d850d822bfcd Mon Sep 17 00:00:00 2001 From: l0lawrence Date: Tue, 2 May 2023 09:40:00 -0700 Subject: [PATCH 29/30] update scenarios --- .../stress/scenarios-matrix.yaml | 88 ++++++------------- 1 file changed, 28 insertions(+), 60 deletions(-) diff --git a/sdk/servicebus/azure-servicebus/stress/scenarios-matrix.yaml b/sdk/servicebus/azure-servicebus/stress/scenarios-matrix.yaml index 39643be8d40a..04b654df2476 100644 --- a/sdk/servicebus/azure-servicebus/stress/scenarios-matrix.yaml +++ b/sdk/servicebus/azure-servicebus/stress/scenarios-matrix.yaml @@ -2,63 +2,31 @@ matrix: image: - Dockerfile scenarios: - sender: - testTarget: sender - receiver: - testTarget: receiver - iterator: - testTarget: iterator - senderasync: - testTarget: senderasync - receiverasync: - testTarget: senderasync - iteratorasync: - testTarget: senderasync - iteratorasyncnobatch: - testTarget: iteratorasyncnobatch - # queue: - # testTarget: queue - # aqueue: - # testTarget: aqueue - # queuepull: - # testTarget: queuepull - # aqueuepull: - # testTarget: aqueuepull - # batch: - # testTarget: batch - # abatch: - # testTarget: abatch - # queuew: - # testTarget: queuew - # aqueuew: - # testTarget: aqueuew - # queuepullw: - # testTarget: queuepullw - # aqueuepullw: - # testTarget: aqueuepullw - # batchw: - # testTarget: batchw - # abatchw: - # testTarget: abatchw - # memray: - # testTarget: memray - # sendreceiveslow: - # testTarget: send_receive_slow - # receivedelete: - # testTarget: receive_delete - # unsettledmessage: - # testTarget: unsettled_message - # largebatch: - # testTarget: large_batch - # pullreceivetimeout: - # testTarget: pull_receive_timeout - # longrenew: - # testTarget: long_renew - # queuepeek: - # testTarget: queue_peek - # queueclosereopen: - # testTarget: queue_close_reopen - # droppedmessages: - # testTarget: dropped_messages - #sbStress: - # testTarget: servicebus + queue: + testTarget: queue + aqueue: + testTarget: aqueue + queuepull: + testTarget: queuepull + aqueuepull: + testTarget: aqueuepull + batch: + testTarget: batch + abatch: + testTarget: abatch + queuew: + testTarget: queuew + aqueuew: + testTarget: aqueuew + queuepullw: + testTarget: queuepullw + aqueuepullw: + testTarget: aqueuepullw + batchw: + testTarget: batchw + abatchw: + testTarget: abatchw + memray: + testTarget: memray + amemray: + testTarget: amemray From a52b8440fde207e5706ffc74826321ce957ffe17 Mon Sep 17 00:00:00 2001 From: l0lawrence Date: Tue, 2 May 2023 09:44:12 -0700 Subject: [PATCH 30/30] logging --- .../azure-servicebus/stress/scripts/stress_test_base.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/sdk/servicebus/azure-servicebus/stress/scripts/stress_test_base.py b/sdk/servicebus/azure-servicebus/stress/scripts/stress_test_base.py index 43409d1856bf..67c016c9bfb3 100644 --- a/sdk/servicebus/azure-servicebus/stress/scripts/stress_test_base.py +++ b/sdk/servicebus/azure-servicebus/stress/scripts/stress_test_base.py @@ -390,7 +390,6 @@ def __init__( async def _send_async(self, sender, end_time): self._schedule_interval_logger(end_time, "Sender " + str(self)) try: - _logger.critical("STARTING SENDER") async with sender: while end_time > datetime.utcnow() and not self._should_stop: try: @@ -441,7 +440,6 @@ async def _receive_handle_message(self, message, receiver, end_time): async def _receive_async(self, receiver, end_time): self._schedule_interval_logger(end_time, "Receiver " + str(self)) try: - _logger.critical("STARTING RECEIVER") async with receiver: while end_time > datetime.utcnow() and not self._should_stop: try: