Skip to content

Commit

Permalink
[ServiceBus][Perf] Fix perf tests (#30004)
Browse files Browse the repository at this point in the history
Some async tests were trying to use an synchronous receiver/sender.
This fixes that so that the tests can run.

Signed-off-by: Paul Van Eck <[email protected]>
  • Loading branch information
pvaneck authored Apr 21, 2023
1 parent fbe7a0e commit 328a3df
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ def run_batch_sync(self) -> int:
)
else:
self.sender.send_messages(ServiceBusMessage(self.data))

return self.args.batch_size

async def run_batch_async(self) -> int:
if self.args.batch_size > 1:
await self.sender.send_messages(
await self.async_sender.send_messages(
[ServiceBusMessage(self.data) for _ in range(self.args.batch_size)]
)
else:
await self.sender.send_messages(ServiceBusMessage(self.data))
return self.args.batch_size
await self.async_sender.send_messages(ServiceBusMessage(self.data))

return self.args.batch_size
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from ._test_base import _TopicTest
from ._test_base import _SendTopicTest

from azure_devtools.perfstress_tests import get_random_bytes

from azure.servicebus import ServiceBusMessage

class SendTopicMessageTest(_TopicTest):
class SendTopicMessageTest(_SendTopicTest):
def __init__(self, arguments) -> None:
super().__init__(arguments)
self.data = get_random_bytes(self.args.message_size)
Expand All @@ -21,15 +21,15 @@ def run_batch_sync(self) -> int:
)
else:
self.sender.send_messages(ServiceBusMessage(self.data))

return self.args.batch_size

async def run_batch_async(self) -> int:
if self.args.batch_size > 1:
await self.sender.send_messages(
await self.async_sender.send_messages(
[ServiceBusMessage(self.data) for _ in range(self.args.batch_size)]
)
else:
await self.sender.send_messages(ServiceBusMessage(self.data))
return self.args.batch_size
await self.async_sender.send_messages(ServiceBusMessage(self.data))

return self.args.batch_size

0 comments on commit 328a3df

Please sign in to comment.