Skip to content

Commit

Permalink
[EventHubs] Fix bug in sending stress test code and update default st…
Browse files Browse the repository at this point in the history
…ress test settings (Azure#19429)

The issues were found when running stress test with chaos-mesh: Azure#19241.

After fixing the test code, send could ignore error and recover properly.
also updated the default settings for stress test config.
  • Loading branch information
yunhaoling authored and rakshith91 committed Jul 16, 2021
1 parent 390da8e commit 1d356fd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ def handle_exception(error, ignore_send_failure, stress_logger, azure_monitor_me


def stress_send_sync(producer: EventHubProducerClient, args, stress_logger, azure_monitor_metric):
batch = producer.create_batch(partition_id=args.send_partition_id, partition_key=args.send_partition_key)
try:
batch = producer.create_batch(partition_id=args.send_partition_id, partition_key=args.send_partition_key)
while True:
event_data = EventData(body=b"D" * args.payload)
batch.add(event_data)
Expand All @@ -41,6 +41,8 @@ def stress_send_sync(producer: EventHubProducerClient, args, stress_logger, azur
producer.send_batch(batch)
except EventHubError as e:
return handle_exception(e, args.ignore_send_failure, stress_logger, azure_monitor_metric)
except EventHubError as e:
return handle_exception(e, args.ignore_send_failure, stress_logger, azure_monitor_metric)
return len(batch)


Expand All @@ -57,8 +59,8 @@ def stress_send_list_sync(producer: EventHubProducerClient, args, stress_logger,


async def stress_send_async(producer: EventHubProducerClientAsync, args, stress_logger, azure_monitor_metric):
batch = await producer.create_batch()
try:
batch = await producer.create_batch(partition_id=args.send_partition_id, partition_key=args.send_partition_key)
while True:
event_data = EventData(body=b"D" * args.payload)
batch.add(event_data)
Expand All @@ -67,6 +69,8 @@ async def stress_send_async(producer: EventHubProducerClientAsync, args, stress_
await producer.send_batch(batch)
except EventHubError as e:
return handle_exception(e, args.ignore_send_failure, stress_logger, azure_monitor_metric)
except EventHubError as e:
return handle_exception(e, args.ignore_send_failure, stress_logger, azure_monitor_metric)
return len(batch)


Expand Down Expand Up @@ -275,7 +279,7 @@ def run_test_method(self, test_method, worker, logger, process_monitor):
logger.info("keyboard interrupted")
self.stop()
except Exception as e:
logger.exception("%r failed:", type(worker), e)
logger.exception("%r failed: %r", type(worker), e)
self.stop()
logger.info("%r has finished testing", test_method)

Expand Down Expand Up @@ -373,7 +377,7 @@ async def run_test_method_async(self, test_method, worker, logger, process_monit
logger.info("keyboard interrupted")
self.stop()
except Exception as e:
logger.exception("%r failed: ", type(worker), e)
logger.exception("%r failed: %r", type(worker), e)
self.stop()
logger.info("%r has finished testing", test_method)

Expand Down
6 changes: 3 additions & 3 deletions sdk/eventhub/azure-eventhub/stress/stress_runner.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ auth_timeout=60
# log output per output_interval messages
output_interval=1000
# By default every stress test will create a new eventhub, if set to no, the specific eventhub name should be provided
create_new_eventhub=yes
create_new_eventhub=no
partition_cnt_to_create=32
message_retention_in_days=7
run_generated_commands=yes
Expand Down Expand Up @@ -57,7 +57,7 @@ transport_type=0
retry_total=5
retry_backoff_factor=0.8
retry_backoff_max=180
ignore_send_failure=False
ignore_send_failure=True


[RUN_METHODS]
Expand All @@ -71,7 +71,7 @@ receive_async=no
receive_with_checkpointstore_sync=no
# receive alone require manual eventhub connection string input -- the eventhub and blob resource must exist
receive_with_checkpointstore_async=no
send_and_receive_sync=no
send_and_receive_sync=yes
send_and_receive_async=yes
send_and_receive_with_checkpointstore_sync=no
send_and_receive_with_checkpointstore_async=no
Expand Down

0 comments on commit 1d356fd

Please sign in to comment.