diff --git a/sdk/eventhub/azure-eventhub/CHANGELOG.md b/sdk/eventhub/azure-eventhub/CHANGELOG.md index f91722a13585..c756e771869b 100644 --- a/sdk/eventhub/azure-eventhub/CHANGELOG.md +++ b/sdk/eventhub/azure-eventhub/CHANGELOG.md @@ -3,12 +3,7 @@ ## 5.12.2 (2024-10-02) ### Bugs Fixed - -- Fixed a bug where creating the SSL context in the async clients was making a blocking call outside of the constructor.([#37246](https://github.com/Azure/azure-sdk-for-python/issues/37246)) - -### Other Changes - -- Implemented backpressure for async consumer to address a memory leak issue. ([#36398](https://github.com/Azure/azure-sdk-for-python/issues/36398)) +- Implemented backpressure for async consumer to address a memory leak issue. ([#36398](https://github.com/Azure/azure-sdk-for-python/issues/36398)) ## 5.12.1 (2024-06-11) diff --git a/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/aio/_transport_async.py b/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/aio/_transport_async.py index 81c0f2eb9535..8bdbf9fa4b5e 100644 --- a/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/aio/_transport_async.py +++ b/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/aio/_transport_async.py @@ -262,21 +262,23 @@ def __init__( self.sslopts = ssl_opts self.network_trace_params = kwargs.get('network_trace_params') self._use_tls = use_tls - try: - self.sslopts = self._build_ssl_opts(self.sslopts) - except FileNotFoundError as exc: - # FileNotFoundError does not have missing filename info, so adding it below. - # Assuming that this must be ca_certs, since this is the only file path that - # users can pass in (`connection_verify` in the EH/SB clients) through sslopts above. - # For uamqp exception parity. - exc.filename = self.sslopts - raise exc async def connect(self): try: # are we already connected? if self.connected: return + try: + # Building ssl opts here instead of constructor, so that invalid cert error is raised + # when client is connecting, rather then during creation. For uamqp exception parity. + self.sslopts = self._build_ssl_opts(self.sslopts) + except FileNotFoundError as exc: + # FileNotFoundError does not have missing filename info, so adding it below. + # Assuming that this must be ca_certs, since this is the only file path that + # users can pass in (`connection_verify` in the EH/SB clients) through sslopts above. + # For uamqp exception parity. Remove later when resolving issue #27128. + exc.filename = self.sslopts + raise exc self.reader, self.writer = await asyncio.open_connection( host=self.host, port=self.port, diff --git a/sdk/eventhub/azure-eventhub/tests/livetest/asynctests/test_negative_async.py b/sdk/eventhub/azure-eventhub/tests/livetest/asynctests/test_negative_async.py index 8092742e9405..18c488972b26 100644 --- a/sdk/eventhub/azure-eventhub/tests/livetest/asynctests/test_negative_async.py +++ b/sdk/eventhub/azure-eventhub/tests/livetest/asynctests/test_negative_async.py @@ -503,10 +503,11 @@ async def on_error(partition_context, error): fully_qualified_namespace=live_eventhub["hostname"], eventhub_name=live_eventhub["event_hub"], credential=azure_credential, - connection_verify="fakecert.pem", + connection_verify="cacert.pem", uamqp_transport=uamqp_transport, ) + # TODO: this seems like a bug from uamqp, should be ConnectError? async with producer_client: with pytest.raises(EventHubError): await producer_client.create_batch(partition_id="0") diff --git a/sdk/eventhub/azure-eventhub/tests/livetest/synctests/test_negative.py b/sdk/eventhub/azure-eventhub/tests/livetest/synctests/test_negative.py index ac9de8e1ca57..7c6512a76aa7 100644 --- a/sdk/eventhub/azure-eventhub/tests/livetest/synctests/test_negative.py +++ b/sdk/eventhub/azure-eventhub/tests/livetest/synctests/test_negative.py @@ -444,10 +444,11 @@ def on_error(partition_context, error): fully_qualified_namespace=live_eventhub["hostname"], eventhub_name=live_eventhub["event_hub"], credential=azure_credential, - connection_verify="fakecert.pem", + connection_verify="cacert.pem", uamqp_transport=uamqp_transport, ) + # TODO: this seems like a bug from uamqp, should be ConnectError? with producer_client: with pytest.raises(EventHubError): producer_client.create_batch(partition_id="0") diff --git a/sdk/servicebus/azure-servicebus/CHANGELOG.md b/sdk/servicebus/azure-servicebus/CHANGELOG.md index 8b2aa828e8e1..6bbb7a341554 100644 --- a/sdk/servicebus/azure-servicebus/CHANGELOG.md +++ b/sdk/servicebus/azure-servicebus/CHANGELOG.md @@ -8,8 +8,6 @@ ### Bugs Fixed -- Fixed a bug where creating the SSL context in the async clients was making a blocking call outside of the constructor.([#37246](https://github.com/Azure/azure-sdk-for-python/issues/37246)) - ### Other Changes ## 7.12.3 (2024-09-19) 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 81c0f2eb9535..8bdbf9fa4b5e 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 @@ -262,21 +262,23 @@ def __init__( self.sslopts = ssl_opts self.network_trace_params = kwargs.get('network_trace_params') self._use_tls = use_tls - try: - self.sslopts = self._build_ssl_opts(self.sslopts) - except FileNotFoundError as exc: - # FileNotFoundError does not have missing filename info, so adding it below. - # Assuming that this must be ca_certs, since this is the only file path that - # users can pass in (`connection_verify` in the EH/SB clients) through sslopts above. - # For uamqp exception parity. - exc.filename = self.sslopts - raise exc async def connect(self): try: # are we already connected? if self.connected: return + try: + # Building ssl opts here instead of constructor, so that invalid cert error is raised + # when client is connecting, rather then during creation. For uamqp exception parity. + self.sslopts = self._build_ssl_opts(self.sslopts) + except FileNotFoundError as exc: + # FileNotFoundError does not have missing filename info, so adding it below. + # Assuming that this must be ca_certs, since this is the only file path that + # users can pass in (`connection_verify` in the EH/SB clients) through sslopts above. + # For uamqp exception parity. Remove later when resolving issue #27128. + exc.filename = self.sslopts + raise exc self.reader, self.writer = await asyncio.open_connection( host=self.host, port=self.port, diff --git a/sdk/servicebus/azure-servicebus/tests/async_tests/test_sb_client_async.py b/sdk/servicebus/azure-servicebus/tests/async_tests/test_sb_client_async.py index ed69a9e621e9..d0cd520748fa 100644 --- a/sdk/servicebus/azure-servicebus/tests/async_tests/test_sb_client_async.py +++ b/sdk/servicebus/azure-servicebus/tests/async_tests/test_sb_client_async.py @@ -672,9 +672,8 @@ async def test_custom_endpoint_connection_verify_exception_async(self, # invalid cert file to connection_verify should fail client = ServiceBusClient(hostname, credential, connection_verify="fakecertfile.pem", uamqp_transport=uamqp_transport) async with client: - sender = client.get_queue_sender(servicebus_queue.name) with pytest.raises(ServiceBusError): - async with sender: + async with client.get_queue_sender(servicebus_queue.name) as sender: await sender.send_messages(ServiceBusMessage("foo")) # Skipping on OSX uamqp - it's raising an Authentication/TimeoutError diff --git a/sdk/servicebus/azure-servicebus/tests/test_sb_client.py b/sdk/servicebus/azure-servicebus/tests/test_sb_client.py index 056002eeac7c..bbdf1c534ff4 100644 --- a/sdk/servicebus/azure-servicebus/tests/test_sb_client.py +++ b/sdk/servicebus/azure-servicebus/tests/test_sb_client.py @@ -700,9 +700,8 @@ def test_custom_endpoint_connection_verify_exception(self, # invalid cert file to connection_verify should fail client = ServiceBusClient(hostname, credential, connection_verify="fakecertfile.pem", uamqp_transport=uamqp_transport) with client: - sender = client.get_queue_sender(servicebus_queue.name) with pytest.raises(ServiceBusError): - with sender: + with client.get_queue_sender(servicebus_queue.name) as sender: sender.send_messages(ServiceBusMessage("foo")) # Skipping on OSX uamqp - it's raising an Authentication/TimeoutError