From 8a3e77e4b3feca9544eea5bb85a446e3b32be176 Mon Sep 17 00:00:00 2001 From: shiyingchen Date: Mon, 27 Apr 2026 11:29:26 +0800 Subject: [PATCH 01/20] fix live test Co-authored-by: Copilot --- .../dev_requirements.txt | 2 +- .../tests/conftest.py | 6 +- ...subClientAutoConnecttest_auto_connect.json | 51 +++++++ ...toConnectAsynctest_auto_connect_async.json | 49 +++++++ ...test_disable_recovery_and_autoconnect.json | 28 ++++ ...ery_and_autoconnect_send_concurrently.json | 28 ++++ ...isable_recovery_and_autoconnect_async.json | 27 ++++ ...d_autoconnect_send_concurrently_async.json | 27 ++++ ...tWebpubsubClientRecoverytest_recovery.json | 28 ++++ ...lientRecoveryAsynctest_recovery_async.json | 27 ++++ ...endConcurrentlytest_send_concurrently.json | 28 ++++ ...ntlyAsynctest_send_concurrently_async.json | 27 ++++ ...subClientSmoketest_call_back_deadlock.json | 28 ++++ ...pubsubClientSmoketest_context_manager.json | 28 ++++ ...ubsubClientSmoketest_duplicated_start.json | 28 ++++ ...pubsubClientSmoketest_duplicated_stop.json | 28 ++++ ...yTestWebpubsubClientSmoketest_on_stop.json | 51 +++++++ ...bsubClientSmoketest_open_client_error.json | 4 + ...WebpubsubClientSmoketest_rejoin_group.json | 97 +++++++++++++ ...stWebpubsubClientSmoketest_send_event.json | 28 ++++ ...okeAsynctest_call_back_deadlock_async.json | 27 ++++ ...tSmokeAsynctest_context_manager_async.json | 27 ++++ ...SmokeAsynctest_duplicated_start_async.json | 27 ++++ ...tSmokeAsynctest_duplicated_stop_async.json | 27 ++++ ...subClientSmokeAsynctest_on_stop_async.json | 49 +++++++ ...mokeAsynctest_open_client_error_async.json | 4 + ...ientSmokeAsynctest_rejoin_group_async.json | 93 +++++++++++++ ...ClientSmokeAsynctest_send_event_async.json | 27 ++++ .../tests/test_auto_connect.py | 4 +- .../tests/test_auto_connect_async.py | 4 +- .../tests/test_no_recovery_no_connect.py | 8 +- .../test_no_recovery_no_connect_async.py | 8 +- .../tests/test_recovery.py | 4 +- .../tests/test_recovery_async.py | 4 +- .../tests/test_send_concurrently.py | 4 +- .../tests/test_send_concurrently_async.py | 4 +- .../tests/test_smoke.py | 39 +++--- .../tests/test_smoke_async.py | 40 +++--- .../tests/testcase.py | 12 +- .../tests/testcase_async.py | 12 +- .../tests/test_generated_api_coverage.py | 128 +++++++++--------- .../test_generated_api_coverage_async.py | 128 +++++++++--------- .../tests/test_list_connections.py | 4 +- .../tests/test_list_connections_async.py | 4 +- .../tests/test_live_api_coverage.py | 7 +- .../tests/test_live_api_coverage_async.py | 16 ++- .../tests/test_reverse_proxy.py | 4 +- .../tests/test_reverse_proxy_async.py | 4 +- .../tests/test_smoke.py | 28 ++-- .../tests/test_smoke_async.py | 28 ++-- .../tests/testcase.py | 4 +- .../tests/testcase_async.py | 2 - sdk/webpubsub/test-resources.bicep | 73 ++++++++++ sdk/webpubsub/tests.yml | 4 - 54 files changed, 1229 insertions(+), 249 deletions(-) create mode 100644 sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_auto_connect.pyTestWebpubsubClientAutoConnecttest_auto_connect.json create mode 100644 sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_auto_connect_async.pyTestWebpubsubClientAutoConnectAsynctest_auto_connect_async.json create mode 100644 sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_no_recovery_no_connect.pyTestWebpubsubClientNoRecoveryNoReconnecttest_disable_recovery_and_autoconnect.json create mode 100644 sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_no_recovery_no_connect.pyTestWebpubsubClientNoRecoveryNoReconnecttest_disable_recovery_and_autoconnect_send_concurrently.json create mode 100644 sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_no_recovery_no_connect_async.pyTestWebpubsubClientNoRecoveryNoReconnectAsynctest_disable_recovery_and_autoconnect_async.json create mode 100644 sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_no_recovery_no_connect_async.pyTestWebpubsubClientNoRecoveryNoReconnectAsynctest_disable_recovery_and_autoconnect_send_concurrently_async.json create mode 100644 sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_recovery.pyTestWebpubsubClientRecoverytest_recovery.json create mode 100644 sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_recovery_async.pyTestWebpubsubClientRecoveryAsynctest_recovery_async.json create mode 100644 sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_send_concurrently.pyTestWebpubsubClientSendConcurrentlytest_send_concurrently.json create mode 100644 sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_send_concurrently_async.pyTestWebpubsubClientSendConcurrentlyAsynctest_send_concurrently_async.json create mode 100644 sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_call_back_deadlock.json create mode 100644 sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_context_manager.json create mode 100644 sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_duplicated_start.json create mode 100644 sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_duplicated_stop.json create mode 100644 sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_on_stop.json create mode 100644 sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_open_client_error.json create mode 100644 sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_rejoin_group.json create mode 100644 sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_send_event.json create mode 100644 sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_call_back_deadlock_async.json create mode 100644 sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_context_manager_async.json create mode 100644 sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_duplicated_start_async.json create mode 100644 sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_duplicated_stop_async.json create mode 100644 sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_on_stop_async.json create mode 100644 sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_open_client_error_async.json create mode 100644 sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_rejoin_group_async.json create mode 100644 sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_send_event_async.json create mode 100644 sdk/webpubsub/test-resources.bicep diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/dev_requirements.txt b/sdk/webpubsub/azure-messaging-webpubsubclient/dev_requirements.txt index 4c9ec1f26d4f..65083eeb5eab 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/dev_requirements.txt +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/dev_requirements.txt @@ -1,6 +1,6 @@ -e ../../../eng/tools/azure-sdk-tools ../../core/azure-core ../../identity/azure-identity -azure-messaging-webpubsubservice==1.1.0b1 +../azure-messaging-webpubsubservice psutil aiohttp>=3.9.3 diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/conftest.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/conftest.py index 9cc88c245ac6..c0351cc98007 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/conftest.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/conftest.py @@ -32,8 +32,8 @@ @pytest.fixture(scope="session", autouse=True) def add_sanitizers(test_proxy): - connection_string = os.environ.get("WEBPUBSUBCLIENT_CONNECTION_STRING", "WEBPUBSUBCLIENT_CONNECTION_STRING") + endpoint = os.environ.get("WEBPUBSUBCLIENT_ENDPOINT", "WEBPUBSUBCLIENT_ENDPOINT") add_general_regex_sanitizer( - regex=connection_string, - value="Endpoint=https://myservice.webpubsub.azure.com;AccessKey=aaaaaaaaaaaaa;Version=1.0;", + regex=endpoint, + value="https://myservice.webpubsub.azure.com", ) diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_auto_connect.pyTestWebpubsubClientAutoConnecttest_auto_connect.json b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_auto_connect.pyTestWebpubsubClientAutoConnecttest_auto_connect.json new file mode 100644 index 000000000000..1998bb8828f0 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_auto_connect.pyTestWebpubsubClientAutoConnecttest_auto_connect.json @@ -0,0 +1,51 @@ +{ + "Entries": [ + { + "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&clientType=Default", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "*/*", + "Connection": "keep-alive", + "Content-Length": "0", + "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", + "Connection": "keep-alive", + "Content-Type": "application/json; charset=utf-8", + "Date": "Mon, 27 Apr 2026 03:23:18 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked" + }, + "ResponseBody": { + "token": "Sanitized" + } + }, + { + "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&clientType=Default", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "*/*", + "Connection": "keep-alive", + "Content-Length": "0", + "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", + "Connection": "keep-alive", + "Content-Type": "application/json; charset=utf-8", + "Date": "Mon, 27 Apr 2026 03:23:20 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked" + }, + "ResponseBody": { + "token": "Sanitized" + } + } + ], + "Variables": {} +} diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_auto_connect_async.pyTestWebpubsubClientAutoConnectAsynctest_auto_connect_async.json b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_auto_connect_async.pyTestWebpubsubClientAutoConnectAsynctest_auto_connect_async.json new file mode 100644 index 000000000000..ee663358d3a1 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_auto_connect_async.pyTestWebpubsubClientAutoConnectAsynctest_auto_connect_async.json @@ -0,0 +1,49 @@ +{ + "Entries": [ + { + "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&minutesToExpire=60&clientType=Default", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "*/*", + "Content-Length": "0", + "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", + "Connection": "keep-alive", + "Content-Type": "application/json; charset=utf-8", + "Date": "Mon, 27 Apr 2026 03:23:25 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked" + }, + "ResponseBody": { + "token": "Sanitized" + } + }, + { + "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&minutesToExpire=60&clientType=Default", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "*/*", + "Content-Length": "0", + "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", + "Connection": "keep-alive", + "Content-Type": "application/json; charset=utf-8", + "Date": "Mon, 27 Apr 2026 03:23:28 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked" + }, + "ResponseBody": { + "token": "Sanitized" + } + } + ], + "Variables": {} +} diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_no_recovery_no_connect.pyTestWebpubsubClientNoRecoveryNoReconnecttest_disable_recovery_and_autoconnect.json b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_no_recovery_no_connect.pyTestWebpubsubClientNoRecoveryNoReconnecttest_disable_recovery_and_autoconnect.json new file mode 100644 index 000000000000..29e8a895cc22 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_no_recovery_no_connect.pyTestWebpubsubClientNoRecoveryNoReconnecttest_disable_recovery_and_autoconnect.json @@ -0,0 +1,28 @@ +{ + "Entries": [ + { + "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&clientType=Default", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "*/*", + "Connection": "keep-alive", + "Content-Length": "0", + "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", + "Connection": "keep-alive", + "Content-Type": "application/json; charset=utf-8", + "Date": "Mon, 27 Apr 2026 03:23:32 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked" + }, + "ResponseBody": { + "token": "Sanitized" + } + } + ], + "Variables": {} +} diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_no_recovery_no_connect.pyTestWebpubsubClientNoRecoveryNoReconnecttest_disable_recovery_and_autoconnect_send_concurrently.json b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_no_recovery_no_connect.pyTestWebpubsubClientNoRecoveryNoReconnecttest_disable_recovery_and_autoconnect_send_concurrently.json new file mode 100644 index 000000000000..b5de50a0e4ae --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_no_recovery_no_connect.pyTestWebpubsubClientNoRecoveryNoReconnecttest_disable_recovery_and_autoconnect_send_concurrently.json @@ -0,0 +1,28 @@ +{ + "Entries": [ + { + "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&clientType=Default", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "*/*", + "Connection": "keep-alive", + "Content-Length": "0", + "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", + "Connection": "keep-alive", + "Content-Type": "application/json; charset=utf-8", + "Date": "Mon, 27 Apr 2026 03:23:42 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked" + }, + "ResponseBody": { + "token": "Sanitized" + } + } + ], + "Variables": {} +} diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_no_recovery_no_connect_async.pyTestWebpubsubClientNoRecoveryNoReconnectAsynctest_disable_recovery_and_autoconnect_async.json b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_no_recovery_no_connect_async.pyTestWebpubsubClientNoRecoveryNoReconnectAsynctest_disable_recovery_and_autoconnect_async.json new file mode 100644 index 000000000000..3c64183c683f --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_no_recovery_no_connect_async.pyTestWebpubsubClientNoRecoveryNoReconnectAsynctest_disable_recovery_and_autoconnect_async.json @@ -0,0 +1,27 @@ +{ + "Entries": [ + { + "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&minutesToExpire=60&clientType=Default", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "*/*", + "Content-Length": "0", + "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", + "Connection": "keep-alive", + "Content-Type": "application/json; charset=utf-8", + "Date": "Mon, 27 Apr 2026 03:23:50 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked" + }, + "ResponseBody": { + "token": "Sanitized" + } + } + ], + "Variables": {} +} diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_no_recovery_no_connect_async.pyTestWebpubsubClientNoRecoveryNoReconnectAsynctest_disable_recovery_and_autoconnect_send_concurrently_async.json b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_no_recovery_no_connect_async.pyTestWebpubsubClientNoRecoveryNoReconnectAsynctest_disable_recovery_and_autoconnect_send_concurrently_async.json new file mode 100644 index 000000000000..171b351dad53 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_no_recovery_no_connect_async.pyTestWebpubsubClientNoRecoveryNoReconnectAsynctest_disable_recovery_and_autoconnect_send_concurrently_async.json @@ -0,0 +1,27 @@ +{ + "Entries": [ + { + "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&minutesToExpire=60&clientType=Default", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "*/*", + "Content-Length": "0", + "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", + "Connection": "keep-alive", + "Content-Type": "application/json; charset=utf-8", + "Date": "Mon, 27 Apr 2026 03:23:59 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked" + }, + "ResponseBody": { + "token": "Sanitized" + } + } + ], + "Variables": {} +} diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_recovery.pyTestWebpubsubClientRecoverytest_recovery.json b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_recovery.pyTestWebpubsubClientRecoverytest_recovery.json new file mode 100644 index 000000000000..afed6a67f487 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_recovery.pyTestWebpubsubClientRecoverytest_recovery.json @@ -0,0 +1,28 @@ +{ + "Entries": [ + { + "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&clientType=Default", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "*/*", + "Connection": "keep-alive", + "Content-Length": "0", + "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", + "Connection": "keep-alive", + "Content-Type": "application/json; charset=utf-8", + "Date": "Mon, 27 Apr 2026 03:24:08 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked" + }, + "ResponseBody": { + "token": "Sanitized" + } + } + ], + "Variables": {} +} diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_recovery_async.pyTestWebpubsubClientRecoveryAsynctest_recovery_async.json b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_recovery_async.pyTestWebpubsubClientRecoveryAsynctest_recovery_async.json new file mode 100644 index 000000000000..ed97d6e9fa00 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_recovery_async.pyTestWebpubsubClientRecoveryAsynctest_recovery_async.json @@ -0,0 +1,27 @@ +{ + "Entries": [ + { + "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&minutesToExpire=60&clientType=Default", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "*/*", + "Content-Length": "0", + "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", + "Connection": "keep-alive", + "Content-Type": "application/json; charset=utf-8", + "Date": "Mon, 27 Apr 2026 03:24:13 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked" + }, + "ResponseBody": { + "token": "Sanitized" + } + } + ], + "Variables": {} +} diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_send_concurrently.pyTestWebpubsubClientSendConcurrentlytest_send_concurrently.json b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_send_concurrently.pyTestWebpubsubClientSendConcurrentlytest_send_concurrently.json new file mode 100644 index 000000000000..dd809f746d73 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_send_concurrently.pyTestWebpubsubClientSendConcurrentlytest_send_concurrently.json @@ -0,0 +1,28 @@ +{ + "Entries": [ + { + "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&clientType=Default", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "*/*", + "Connection": "keep-alive", + "Content-Length": "0", + "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", + "Connection": "keep-alive", + "Content-Type": "application/json; charset=utf-8", + "Date": "Mon, 27 Apr 2026 03:24:20 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked" + }, + "ResponseBody": { + "token": "Sanitized" + } + } + ], + "Variables": {} +} diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_send_concurrently_async.pyTestWebpubsubClientSendConcurrentlyAsynctest_send_concurrently_async.json b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_send_concurrently_async.pyTestWebpubsubClientSendConcurrentlyAsynctest_send_concurrently_async.json new file mode 100644 index 000000000000..51b80fbff55d --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_send_concurrently_async.pyTestWebpubsubClientSendConcurrentlyAsynctest_send_concurrently_async.json @@ -0,0 +1,27 @@ +{ + "Entries": [ + { + "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&minutesToExpire=60&clientType=Default", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "*/*", + "Content-Length": "0", + "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", + "Connection": "keep-alive", + "Content-Type": "application/json; charset=utf-8", + "Date": "Mon, 27 Apr 2026 03:24:24 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked" + }, + "ResponseBody": { + "token": "Sanitized" + } + } + ], + "Variables": {} +} diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_call_back_deadlock.json b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_call_back_deadlock.json new file mode 100644 index 000000000000..e4a81703fe1a --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_call_back_deadlock.json @@ -0,0 +1,28 @@ +{ + "Entries": [ + { + "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&clientType=Default", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "*/*", + "Connection": "keep-alive", + "Content-Length": "0", + "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", + "Connection": "keep-alive", + "Content-Type": "application/json; charset=utf-8", + "Date": "Mon, 27 Apr 2026 03:24:27 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked" + }, + "ResponseBody": { + "token": "Sanitized" + } + } + ], + "Variables": {} +} diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_context_manager.json b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_context_manager.json new file mode 100644 index 000000000000..f45b37814fd4 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_context_manager.json @@ -0,0 +1,28 @@ +{ + "Entries": [ + { + "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&clientType=Default", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "*/*", + "Connection": "keep-alive", + "Content-Length": "0", + "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", + "Connection": "keep-alive", + "Content-Type": "application/json; charset=utf-8", + "Date": "Mon, 27 Apr 2026 03:24:32 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked" + }, + "ResponseBody": { + "token": "Sanitized" + } + } + ], + "Variables": {} +} diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_duplicated_start.json b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_duplicated_start.json new file mode 100644 index 000000000000..1403eb15ae33 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_duplicated_start.json @@ -0,0 +1,28 @@ +{ + "Entries": [ + { + "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&clientType=Default", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "*/*", + "Connection": "keep-alive", + "Content-Length": "0", + "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", + "Connection": "keep-alive", + "Content-Type": "application/json; charset=utf-8", + "Date": "Mon, 27 Apr 2026 03:24:47 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked" + }, + "ResponseBody": { + "token": "Sanitized" + } + } + ], + "Variables": {} +} diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_duplicated_stop.json b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_duplicated_stop.json new file mode 100644 index 000000000000..e7f9152f4289 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_duplicated_stop.json @@ -0,0 +1,28 @@ +{ + "Entries": [ + { + "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&clientType=Default", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "*/*", + "Connection": "keep-alive", + "Content-Length": "0", + "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", + "Connection": "keep-alive", + "Content-Type": "application/json; charset=utf-8", + "Date": "Mon, 27 Apr 2026 03:24:49 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked" + }, + "ResponseBody": { + "token": "Sanitized" + } + } + ], + "Variables": {} +} diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_on_stop.json b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_on_stop.json new file mode 100644 index 000000000000..f467f72a2a15 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_on_stop.json @@ -0,0 +1,51 @@ +{ + "Entries": [ + { + "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&clientType=Default", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "*/*", + "Connection": "keep-alive", + "Content-Length": "0", + "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", + "Connection": "keep-alive", + "Content-Type": "application/json; charset=utf-8", + "Date": "Mon, 27 Apr 2026 03:24:37 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked" + }, + "ResponseBody": { + "token": "Sanitized" + } + }, + { + "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&clientType=Default", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "*/*", + "Connection": "keep-alive", + "Content-Length": "0", + "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", + "Connection": "keep-alive", + "Content-Type": "application/json; charset=utf-8", + "Date": "Mon, 27 Apr 2026 03:24:39 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked" + }, + "ResponseBody": { + "token": "Sanitized" + } + } + ], + "Variables": {} +} diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_open_client_error.json b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_open_client_error.json new file mode 100644 index 000000000000..f721723386d8 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_open_client_error.json @@ -0,0 +1,4 @@ +{ + "Entries": [], + "Variables": {} +} diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_rejoin_group.json b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_rejoin_group.json new file mode 100644 index 000000000000..6cdf87cce795 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_rejoin_group.json @@ -0,0 +1,97 @@ +{ + "Entries": [ + { + "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&clientType=Default", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "*/*", + "Connection": "keep-alive", + "Content-Length": "0", + "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", + "Connection": "keep-alive", + "Content-Type": "application/json; charset=utf-8", + "Date": "Mon, 27 Apr 2026 03:24:55 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked" + }, + "ResponseBody": { + "token": "Sanitized" + } + }, + { + "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&clientType=Default", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "*/*", + "Connection": "keep-alive", + "Content-Length": "0", + "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", + "Connection": "keep-alive", + "Content-Type": "application/json; charset=utf-8", + "Date": "Mon, 27 Apr 2026 03:24:57 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked" + }, + "ResponseBody": { + "token": "Sanitized" + } + }, + { + "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&clientType=Default", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "*/*", + "Connection": "keep-alive", + "Content-Length": "0", + "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", + "Connection": "keep-alive", + "Content-Type": "application/json; charset=utf-8", + "Date": "Mon, 27 Apr 2026 03:25:02 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked" + }, + "ResponseBody": { + "token": "Sanitized" + } + }, + { + "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&clientType=Default", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "*/*", + "Connection": "keep-alive", + "Content-Length": "0", + "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", + "Connection": "keep-alive", + "Content-Type": "application/json; charset=utf-8", + "Date": "Mon, 27 Apr 2026 03:25:04 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked" + }, + "ResponseBody": { + "token": "Sanitized" + } + } + ], + "Variables": {} +} diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_send_event.json b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_send_event.json new file mode 100644 index 000000000000..4971971560df --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_send_event.json @@ -0,0 +1,28 @@ +{ + "Entries": [ + { + "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&clientType=Default", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "*/*", + "Connection": "keep-alive", + "Content-Length": "0", + "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", + "Connection": "keep-alive", + "Content-Type": "application/json; charset=utf-8", + "Date": "Mon, 27 Apr 2026 03:24:52 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked" + }, + "ResponseBody": { + "token": "Sanitized" + } + } + ], + "Variables": {} +} diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_call_back_deadlock_async.json b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_call_back_deadlock_async.json new file mode 100644 index 000000000000..a838a53ccafe --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_call_back_deadlock_async.json @@ -0,0 +1,27 @@ +{ + "Entries": [ + { + "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&minutesToExpire=60&clientType=Default", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "*/*", + "Content-Length": "0", + "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", + "Connection": "keep-alive", + "Content-Type": "application/json; charset=utf-8", + "Date": "Mon, 27 Apr 2026 03:25:09 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked" + }, + "ResponseBody": { + "token": "Sanitized" + } + } + ], + "Variables": {} +} diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_context_manager_async.json b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_context_manager_async.json new file mode 100644 index 000000000000..759b35a4fa30 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_context_manager_async.json @@ -0,0 +1,27 @@ +{ + "Entries": [ + { + "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&minutesToExpire=60&clientType=Default", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "*/*", + "Content-Length": "0", + "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", + "Connection": "keep-alive", + "Content-Type": "application/json; charset=utf-8", + "Date": "Mon, 27 Apr 2026 03:25:14 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked" + }, + "ResponseBody": { + "token": "Sanitized" + } + } + ], + "Variables": {} +} diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_duplicated_start_async.json b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_duplicated_start_async.json new file mode 100644 index 000000000000..6e8bb4168128 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_duplicated_start_async.json @@ -0,0 +1,27 @@ +{ + "Entries": [ + { + "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&minutesToExpire=60&clientType=Default", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "*/*", + "Content-Length": "0", + "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", + "Connection": "keep-alive", + "Content-Type": "application/json; charset=utf-8", + "Date": "Mon, 27 Apr 2026 03:25:29 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked" + }, + "ResponseBody": { + "token": "Sanitized" + } + } + ], + "Variables": {} +} diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_duplicated_stop_async.json b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_duplicated_stop_async.json new file mode 100644 index 000000000000..f6fd3dfa655c --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_duplicated_stop_async.json @@ -0,0 +1,27 @@ +{ + "Entries": [ + { + "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&minutesToExpire=60&clientType=Default", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "*/*", + "Content-Length": "0", + "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", + "Connection": "keep-alive", + "Content-Type": "application/json; charset=utf-8", + "Date": "Mon, 27 Apr 2026 03:25:32 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked" + }, + "ResponseBody": { + "token": "Sanitized" + } + } + ], + "Variables": {} +} diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_on_stop_async.json b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_on_stop_async.json new file mode 100644 index 000000000000..4d873e38e8f4 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_on_stop_async.json @@ -0,0 +1,49 @@ +{ + "Entries": [ + { + "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&minutesToExpire=60&clientType=Default", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "*/*", + "Content-Length": "0", + "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", + "Connection": "keep-alive", + "Content-Type": "application/json; charset=utf-8", + "Date": "Mon, 27 Apr 2026 03:25:19 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked" + }, + "ResponseBody": { + "token": "Sanitized" + } + }, + { + "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&minutesToExpire=60&clientType=Default", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "*/*", + "Content-Length": "0", + "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", + "Connection": "keep-alive", + "Content-Type": "application/json; charset=utf-8", + "Date": "Mon, 27 Apr 2026 03:25:22 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked" + }, + "ResponseBody": { + "token": "Sanitized" + } + } + ], + "Variables": {} +} diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_open_client_error_async.json b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_open_client_error_async.json new file mode 100644 index 000000000000..f721723386d8 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_open_client_error_async.json @@ -0,0 +1,4 @@ +{ + "Entries": [], + "Variables": {} +} diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_rejoin_group_async.json b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_rejoin_group_async.json new file mode 100644 index 000000000000..c2cdaeeb0a95 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_rejoin_group_async.json @@ -0,0 +1,93 @@ +{ + "Entries": [ + { + "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&minutesToExpire=60&clientType=Default", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "*/*", + "Content-Length": "0", + "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", + "Connection": "keep-alive", + "Content-Type": "application/json; charset=utf-8", + "Date": "Mon, 27 Apr 2026 03:25:39 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked" + }, + "ResponseBody": { + "token": "Sanitized" + } + }, + { + "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&minutesToExpire=60&clientType=Default", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "*/*", + "Content-Length": "0", + "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", + "Connection": "keep-alive", + "Content-Type": "application/json; charset=utf-8", + "Date": "Mon, 27 Apr 2026 03:25:42 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked" + }, + "ResponseBody": { + "token": "Sanitized" + } + }, + { + "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&minutesToExpire=60&clientType=Default", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "*/*", + "Content-Length": "0", + "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", + "Connection": "keep-alive", + "Content-Type": "application/json; charset=utf-8", + "Date": "Mon, 27 Apr 2026 03:25:47 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked" + }, + "ResponseBody": { + "token": "Sanitized" + } + }, + { + "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&minutesToExpire=60&clientType=Default", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "*/*", + "Content-Length": "0", + "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", + "Connection": "keep-alive", + "Content-Type": "application/json; charset=utf-8", + "Date": "Mon, 27 Apr 2026 03:25:50 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked" + }, + "ResponseBody": { + "token": "Sanitized" + } + } + ], + "Variables": {} +} diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_send_event_async.json b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_send_event_async.json new file mode 100644 index 000000000000..718ed736c773 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_send_event_async.json @@ -0,0 +1,27 @@ +{ + "Entries": [ + { + "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&minutesToExpire=60&clientType=Default", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "*/*", + "Content-Length": "0", + "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", + "Connection": "keep-alive", + "Content-Type": "application/json; charset=utf-8", + "Date": "Mon, 27 Apr 2026 03:25:36 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked" + }, + "ResponseBody": { + "token": "Sanitized" + } + } + ], + "Variables": {} +} diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_auto_connect.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_auto_connect.py index 180e011e8280..a095cfc85e23 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_auto_connect.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_auto_connect.py @@ -16,9 +16,9 @@ class TestWebpubsubClientAutoConnect(WebpubsubClientTest): # auto_connect will be triggered if connection is dropped by accident and we disable recovery @WebpubsubClientPowerShellPreparer() @recorded_by_proxy - def test_auto_connect(self, webpubsubclient_connection_string): + def test_auto_connect(self, webpubsubclient_endpoint): client = self.create_client( - connection_string=webpubsubclient_connection_string, + endpoint=webpubsubclient_endpoint, protocol_type=WebPubSubProtocolType.JSON, message_retry_total=10, reconnect_retry_total=10, diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_auto_connect_async.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_auto_connect_async.py index 2b43c979289e..d107f7a57abd 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_auto_connect_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_auto_connect_async.py @@ -16,9 +16,9 @@ class TestWebpubsubClientAutoConnectAsync(WebpubsubClientTestAsync): # auto_connect will be triggered if connection is dropped by accident and we disable recovery @WebpubsubClientPowerShellPreparer() @recorded_by_proxy_async - async def test_auto_connect_async(self, webpubsubclient_connection_string): + async def test_auto_connect_async(self, webpubsubclient_endpoint): client = await self.create_client( - connection_string=webpubsubclient_connection_string, + endpoint=webpubsubclient_endpoint, protocol_type=WebPubSubProtocolType.JSON, message_retry_total=10, reconnect_retry_total=10, diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_no_recovery_no_connect.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_no_recovery_no_connect.py index 2f5614277ee2..06e1e3ebe124 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_no_recovery_no_connect.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_no_recovery_no_connect.py @@ -25,9 +25,9 @@ class TestWebpubsubClientNoRecoveryNoReconnect(WebpubsubClientTest): # disable recovery and auto reconnect @WebpubsubClientPowerShellPreparer() @recorded_by_proxy - def test_disable_recovery_and_autoconnect(self, webpubsubclient_connection_string): + def test_disable_recovery_and_autoconnect(self, webpubsubclient_endpoint): client = self.create_client( - connection_string=webpubsubclient_connection_string, + endpoint=webpubsubclient_endpoint, reconnect_retry_total=0, protocol_type=WebPubSubProtocolType.JSON, ) @@ -47,10 +47,10 @@ def test_disable_recovery_and_autoconnect(self, webpubsubclient_connection_strin @WebpubsubClientPowerShellPreparer() @recorded_by_proxy def test_disable_recovery_and_autoconnect_send_concurrently( - self, webpubsubclient_connection_string + self, webpubsubclient_endpoint ): client = self.create_client( - connection_string=webpubsubclient_connection_string, + endpoint=webpubsubclient_endpoint, reconnect_retry_total=0, message_retry_total=3, protocol_type=WebPubSubProtocolType.JSON, diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_no_recovery_no_connect_async.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_no_recovery_no_connect_async.py index 4175598fa2ae..fcca6fd7d6ca 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_no_recovery_no_connect_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_no_recovery_no_connect_async.py @@ -20,9 +20,9 @@ class TestWebpubsubClientNoRecoveryNoReconnectAsync(WebpubsubClientTestAsync): # disable recovery and auto reconnect @WebpubsubClientPowerShellPreparer() @recorded_by_proxy_async - async def test_disable_recovery_and_autoconnect_async(self, webpubsubclient_connection_string): + async def test_disable_recovery_and_autoconnect_async(self, webpubsubclient_endpoint): client = await self.create_client( - connection_string=webpubsubclient_connection_string, + endpoint=webpubsubclient_endpoint, reconnect_retry_total=0, protocol_type=WebPubSubProtocolType.JSON, ) @@ -42,10 +42,10 @@ async def test_disable_recovery_and_autoconnect_async(self, webpubsubclient_conn @WebpubsubClientPowerShellPreparer() @recorded_by_proxy_async async def test_disable_recovery_and_autoconnect_send_concurrently_async( - self, webpubsubclient_connection_string + self, webpubsubclient_endpoint ): client = await self.create_client( - connection_string=webpubsubclient_connection_string, + endpoint=webpubsubclient_endpoint, reconnect_retry_total=0, message_retry_total=3, protocol_type=WebPubSubProtocolType.JSON, diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_recovery.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_recovery.py index f6abea8cecf9..472f1c674ad4 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_recovery.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_recovery.py @@ -15,8 +15,8 @@ class TestWebpubsubClientRecovery(WebpubsubClientTest): # recovery will be triggered if connection is dropped by accident @WebpubsubClientPowerShellPreparer() @recorded_by_proxy - def test_recovery(self, webpubsubclient_connection_string): - client = self.create_client(connection_string=webpubsubclient_connection_string, message_retry_total=10) + def test_recovery(self, webpubsubclient_endpoint): + client = self.create_client(endpoint=webpubsubclient_endpoint, message_retry_total=10) name = "test_recovery" with client: time.sleep(0.001) # wait for connection_id to be updated diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_recovery_async.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_recovery_async.py index 591096e09e6c..b3b172b092ba 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_recovery_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_recovery_async.py @@ -16,8 +16,8 @@ class TestWebpubsubClientRecoveryAsync(WebpubsubClientTestAsync): # recovery will be triggered if connection is dropped by accident @WebpubsubClientPowerShellPreparer() @recorded_by_proxy_async - async def test_recovery_async(self, webpubsubclient_connection_string): - client = await self.create_client(connection_string=webpubsubclient_connection_string, message_retry_total=10) + async def test_recovery_async(self, webpubsubclient_endpoint): + client = await self.create_client(endpoint=webpubsubclient_endpoint, message_retry_total=10) name = "test_recovery_async" async with client: await asyncio.sleep(0.001) # wait for connection_id to be updated diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_send_concurrently.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_send_concurrently.py index f4f3ea9ad0df..681d191d473e 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_send_concurrently.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_send_concurrently.py @@ -13,8 +13,8 @@ class TestWebpubsubClientSendConcurrently(WebpubsubClientTest): @WebpubsubClientPowerShellPreparer() @recorded_by_proxy - def test_send_concurrently(self, webpubsubclient_connection_string): - client = self.create_client(connection_string=webpubsubclient_connection_string) + def test_send_concurrently(self, webpubsubclient_endpoint): + client = self.create_client(endpoint=webpubsubclient_endpoint) with client: group_name = "test_send_concurrently" client.join_group(group_name) diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_send_concurrently_async.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_send_concurrently_async.py index 905ac3df8b4d..ac439ded053d 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_send_concurrently_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_send_concurrently_async.py @@ -15,8 +15,8 @@ class TestWebpubsubClientSendConcurrentlyAsync(WebpubsubClientTestAsync): @WebpubsubClientPowerShellPreparer() @recorded_by_proxy_async - async def test_send_concurrently_async(self, webpubsubclient_connection_string): - client = await self.create_client(connection_string=webpubsubclient_connection_string) + async def test_send_concurrently_async(self, webpubsubclient_endpoint): + client = await self.create_client(endpoint=webpubsubclient_endpoint) async with client: group_name = "test_send_concurrently_async" await client.join_group(group_name) diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke.py index 94effcff964f..3c6cb0a3efc1 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke.py @@ -14,6 +14,7 @@ on_group_message, TEST_RESULT, ) +from azure.messaging.webpubsubclient import WebPubSubClient, WebPubSubClientCredential from azure.messaging.webpubsubclient.models import ( OnGroupDataMessageArgs, OpenClientError, @@ -25,8 +26,8 @@ class TestWebpubsubClientSmoke(WebpubsubClientTest): @WebpubsubClientPowerShellPreparer() @recorded_by_proxy - def test_call_back_deadlock(self, webpubsubclient_connection_string): - client = self.create_client(connection_string=webpubsubclient_connection_string) + def test_call_back_deadlock(self, webpubsubclient_endpoint): + client = self.create_client(endpoint=webpubsubclient_endpoint) group_name = "test_call_back_deadlock" def on_group_message(msg: OnGroupDataMessageArgs): @@ -43,8 +44,8 @@ def on_group_message(msg: OnGroupDataMessageArgs): @WebpubsubClientPowerShellPreparer() @recorded_by_proxy - def test_context_manager(self, webpubsubclient_connection_string): - client = self.create_client(connection_string=webpubsubclient_connection_string) + def test_context_manager(self, webpubsubclient_endpoint): + client = self.create_client(endpoint=webpubsubclient_endpoint) with client: group_name = "test_context_manager" client.join_group(group_name) @@ -55,8 +56,8 @@ def test_context_manager(self, webpubsubclient_connection_string): # test on_stop @WebpubsubClientPowerShellPreparer() @recorded_by_proxy - def test_on_stop(self, webpubsubclient_connection_string): - client = self.create_client(connection_string=webpubsubclient_connection_string) + def test_on_stop(self, webpubsubclient_endpoint): + client = self.create_client(endpoint=webpubsubclient_endpoint) def on_stop(): client.open() @@ -67,19 +68,19 @@ def on_stop(): time.sleep(0.1) assert client.is_connected() client.close() - time.sleep(1.0) + time.sleep(3.0) assert client.is_connected() # remove stopped event and close again client.unsubscribe("stopped", on_stop) client.close() - time.sleep(1.0) + time.sleep(3.0) assert not client.is_connected() @WebpubsubClientPowerShellPreparer() @recorded_by_proxy - def test_duplicated_start(self, webpubsubclient_connection_string): - client = self.create_client(connection_string=webpubsubclient_connection_string) + def test_duplicated_start(self, webpubsubclient_endpoint): + client = self.create_client(endpoint=webpubsubclient_endpoint) with pytest.raises(OpenClientError): with client: client.open() @@ -87,16 +88,16 @@ def test_duplicated_start(self, webpubsubclient_connection_string): @WebpubsubClientPowerShellPreparer() @recorded_by_proxy - def test_duplicated_stop(self, webpubsubclient_connection_string): - client = self.create_client(connection_string=webpubsubclient_connection_string) + def test_duplicated_stop(self, webpubsubclient_endpoint): + client = self.create_client(endpoint=webpubsubclient_endpoint) with client: client.close() assert not client.is_connected() @WebpubsubClientPowerShellPreparer() @recorded_by_proxy - def test_send_event(self, webpubsubclient_connection_string): - client = self.create_client(connection_string=webpubsubclient_connection_string, message_retry_total=0) + def test_send_event(self, webpubsubclient_endpoint): + client = self.create_client(endpoint=webpubsubclient_endpoint, message_retry_total=0) with client: # please register event handler in azure portal before run this test try: @@ -106,10 +107,10 @@ def test_send_event(self, webpubsubclient_connection_string): @WebpubsubClientPowerShellPreparer() @recorded_by_proxy - def test_rejoin_group(self, webpubsubclient_connection_string): + def test_rejoin_group(self, webpubsubclient_endpoint): def _test(enable_auto_rejoin, test_group_name, assert_func): client = self.create_client( - connection_string=webpubsubclient_connection_string, + endpoint=webpubsubclient_endpoint, auto_rejoin_groups=enable_auto_rejoin, ) group_name = test_group_name @@ -137,8 +138,10 @@ def _test(enable_auto_rejoin, test_group_name, assert_func): @WebpubsubClientPowerShellPreparer() @recorded_by_proxy def test_open_client_error(self): - client = self.create_client( - connection_string="Endpoint=https://myservice.webpubsub.azure.com;AccessKey=aaaaaaaaaaaaa;Version=1.0;", + client = WebPubSubClient( + credential=WebPubSubClientCredential( + lambda: "wss://myservice.webpubsub.azure.com/client/hubs/Hub" + ), ) start_time = time.time() with pytest.raises(OpenClientError) as err: diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke_async.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke_async.py index cea2929c9fe7..3cc4d86e8afa 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke_async.py @@ -14,6 +14,7 @@ on_group_message, TEST_RESULT_ASYNC, ) +from azure.messaging.webpubsubclient.aio import WebPubSubClient as AsyncWebPubSubClient, WebPubSubClientCredential as AsyncWebPubSubClientCredential from azure.messaging.webpubsubclient.models import ( OnGroupDataMessageArgs, OpenClientError, @@ -25,8 +26,8 @@ class TestWebpubsubClientSmokeAsync(WebpubsubClientTestAsync): @WebpubsubClientPowerShellPreparer() @recorded_by_proxy_async - async def test_call_back_deadlock_async(self, webpubsubclient_connection_string): - client = await self.create_client(connection_string=webpubsubclient_connection_string) + async def test_call_back_deadlock_async(self, webpubsubclient_endpoint): + client = await self.create_client(endpoint=webpubsubclient_endpoint) group_name = "test_call_back_deadlock_async" async def on_group_message(msg: OnGroupDataMessageArgs): @@ -43,8 +44,8 @@ async def on_group_message(msg: OnGroupDataMessageArgs): @WebpubsubClientPowerShellPreparer() @recorded_by_proxy_async - async def test_context_manager_async(self, webpubsubclient_connection_string): - client = await self.create_client(connection_string=webpubsubclient_connection_string) + async def test_context_manager_async(self, webpubsubclient_endpoint): + client = await self.create_client(endpoint=webpubsubclient_endpoint) async with client: group_name = "test_context_manager_async" await client.join_group(group_name) @@ -55,8 +56,8 @@ async def test_context_manager_async(self, webpubsubclient_connection_string): # test on_stop @WebpubsubClientPowerShellPreparer() @recorded_by_proxy_async - async def test_on_stop_async(self, webpubsubclient_connection_string): - client = await self.create_client(connection_string=webpubsubclient_connection_string) + async def test_on_stop_async(self, webpubsubclient_endpoint): + client = await self.create_client(endpoint=webpubsubclient_endpoint) async def on_stop(): await client.open() @@ -67,19 +68,19 @@ async def on_stop(): await asyncio.sleep(0.1) assert client.is_connected() await client.close() - await asyncio.sleep(1.0) + await asyncio.sleep(3.0) assert client.is_connected() # remove stopped event and close again await client.unsubscribe("stopped", on_stop) await client.close() - await asyncio.sleep(1.0) + await asyncio.sleep(3.0) assert not client.is_connected() @WebpubsubClientPowerShellPreparer() @recorded_by_proxy_async - async def test_duplicated_start_async(self, webpubsubclient_connection_string): - client = await self.create_client(connection_string=webpubsubclient_connection_string) + async def test_duplicated_start_async(self, webpubsubclient_endpoint): + client = await self.create_client(endpoint=webpubsubclient_endpoint) with pytest.raises(OpenClientError): async with client: await client.open() @@ -87,16 +88,16 @@ async def test_duplicated_start_async(self, webpubsubclient_connection_string): @WebpubsubClientPowerShellPreparer() @recorded_by_proxy_async - async def test_duplicated_stop_async(self, webpubsubclient_connection_string): - client = await self.create_client(connection_string=webpubsubclient_connection_string) + async def test_duplicated_stop_async(self, webpubsubclient_endpoint): + client = await self.create_client(endpoint=webpubsubclient_endpoint) async with client: await client.close() assert not client.is_connected() @WebpubsubClientPowerShellPreparer() @recorded_by_proxy_async - async def test_send_event_async(self, webpubsubclient_connection_string): - client = await self.create_client(connection_string=webpubsubclient_connection_string, message_retry_total=0) + async def test_send_event_async(self, webpubsubclient_endpoint): + client = await self.create_client(endpoint=webpubsubclient_endpoint, message_retry_total=0) async with client: # please register event handler in azure portal before run this test try: @@ -106,10 +107,10 @@ async def test_send_event_async(self, webpubsubclient_connection_string): @WebpubsubClientPowerShellPreparer() @recorded_by_proxy_async - async def test_rejoin_group_async(self, webpubsubclient_connection_string): + async def test_rejoin_group_async(self, webpubsubclient_endpoint): async def _test(enable_auto_rejoin, test_group_name, assert_func): client = await self.create_client( - connection_string=webpubsubclient_connection_string, + endpoint=webpubsubclient_endpoint, auto_rejoin_groups=enable_auto_rejoin, ) group_name = test_group_name @@ -137,8 +138,11 @@ async def _test(enable_auto_rejoin, test_group_name, assert_func): @WebpubsubClientPowerShellPreparer() @recorded_by_proxy_async async def test_open_client_error_async(self): - client = await self.create_client( - connection_string="Endpoint=https://myservice.webpubsub.azure.com;AccessKey=aaaaaaaaaaaaa;Version=1.0;", + async def _fake_url_provider(): + return "wss://myservice.webpubsub.azure.com/client/hubs/Hub" + + client = AsyncWebPubSubClient( + credential=AsyncWebPubSubClientCredential(_fake_url_provider), ) start_time = time.time() with pytest.raises(OpenClientError) as err: diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/testcase.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/testcase.py index 77f69f2e6d24..75f5289b3f10 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/testcase.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/testcase.py @@ -16,12 +16,18 @@ class WebpubsubClientTest(AzureRecordedTestCase): def create_client( self, - connection_string, + endpoint, hub: str = "Hub", roles: List[str] = ["webpubsub.joinLeaveGroup", "webpubsub.sendToGroup"], **kwargs, ): - service_client = WebPubSubServiceClient.from_connection_string(connection_string, hub) + credential = self.get_credential(WebPubSubServiceClient) + service_client = self.create_client_from_credential( + WebPubSubServiceClient, + credential=credential, + endpoint=endpoint, + hub=hub, + ) return WebPubSubClient( credential=WebPubSubClientCredential(lambda: service_client.get_client_access_token(roles=roles)["url"]), **kwargs, @@ -31,7 +37,7 @@ def create_client( WebpubsubClientPowerShellPreparer = functools.partial( PowerShellPreparer, "webpubsubclient", - webpubsubclient_connection_string="Endpoint=https://myservice.webpubsub.azure.com;AccessKey=aaaaaaaaaaaaa;Version=1.0;", + webpubsubclient_endpoint="https://myservice.webpubsub.azure.com", ) TEST_RESULT = set() diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/testcase_async.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/testcase_async.py index c9836ccc2f5a..9f6d368f5a70 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/testcase_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/testcase_async.py @@ -14,14 +14,20 @@ class WebpubsubClientTestAsync(AzureRecordedTestCase): async def create_client( self, - connection_string, + endpoint, hub: str = "Hub", roles: List[str] = ["webpubsub.joinLeaveGroup", "webpubsub.sendToGroup"], **kwargs, ): - service_client = WebPubSubServiceClient.from_connection_string(connection_string, hub) + credential = self.get_credential(WebPubSubServiceClient, is_async=True) async def client_access_url_provider(): - return (await service_client.get_client_access_token(roles=roles))["url"] + async with self.create_client_from_credential( + WebPubSubServiceClient, + credential=credential, + endpoint=endpoint, + hub=hub, + ) as service_client: + return (await service_client.get_client_access_token(roles=roles))["url"] return WebPubSubClient( credential=WebPubSubClientCredential(client_access_url_provider), **kwargs, diff --git a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_generated_api_coverage.py b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_generated_api_coverage.py index ad56d2c4b68b..184a1134584f 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_generated_api_coverage.py +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_generated_api_coverage.py @@ -20,8 +20,8 @@ class TestGeneratedApiCoverage(WebpubsubTest): @WebpubsubPowerShellPreparer() @recorded_by_proxy - def test_get_service_status(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + def test_get_service_status(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") assert client.get_service_status() @WebpubsubPowerShellPreparer() @@ -39,28 +39,28 @@ def test_generate_client_token(self, webpubsub_endpoint, **kwargs): @WebpubsubPowerShellPreparer() @recorded_by_proxy - def test_close_all_connections(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + def test_close_all_connections(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") client.close_all_connections(excluded=["fake-conn-1", "fake-conn-2"], reason="test") @WebpubsubPowerShellPreparer() @recorded_by_proxy - def test_add_connections_to_groups(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + def test_add_connections_to_groups(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") client.add_connections_to_groups(groups_to_add={"filter": "userId eq 'nobody'", "groups": ["group1", "group2"]}) @WebpubsubPowerShellPreparer() @recorded_by_proxy - def test_remove_connections_from_groups(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + def test_remove_connections_from_groups(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") client.remove_connections_from_groups( groups_to_remove={"filter": "userId eq 'nobody'", "groups": ["group1", "group2"]} ) @WebpubsubPowerShellPreparer() @recorded_by_proxy - def test_send_to_all_json(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + def test_send_to_all_json(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") client.send_to_all( message={"hello": "world"}, content_type="application/json", @@ -70,20 +70,20 @@ def test_send_to_all_json(self, webpubsub_connection_string): @WebpubsubPowerShellPreparer() @recorded_by_proxy - def test_send_to_all_text(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + def test_send_to_all_text(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") client.send_to_all(message="hello", content_type="text/plain") @WebpubsubPowerShellPreparer() @recorded_by_proxy - def test_send_to_all_binary(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + def test_send_to_all_binary(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") client.send_to_all(message=b"hello", content_type="application/octet-stream") @WebpubsubPowerShellPreparer() @recorded_by_proxy - def test_send_to_group_json(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + def test_send_to_group_json(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") client.send_to_group( group="group1", message={"hello": "world"}, @@ -94,20 +94,20 @@ def test_send_to_group_json(self, webpubsub_connection_string): @WebpubsubPowerShellPreparer() @recorded_by_proxy - def test_send_to_group_text(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + def test_send_to_group_text(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") client.send_to_group(group="group1", message="hello", content_type="text/plain") @WebpubsubPowerShellPreparer() @recorded_by_proxy - def test_send_to_group_binary(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + def test_send_to_group_binary(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") client.send_to_group(group="group1", message=b"hello", content_type="application/octet-stream") @WebpubsubPowerShellPreparer() @recorded_by_proxy - def test_send_to_user_json(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + def test_send_to_user_json(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") client.send_to_user( user_id="user1", message={"hello": "world"}, @@ -117,20 +117,20 @@ def test_send_to_user_json(self, webpubsub_connection_string): @WebpubsubPowerShellPreparer() @recorded_by_proxy - def test_send_to_user_text(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + def test_send_to_user_text(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") client.send_to_user(user_id="user1", message="hello", content_type="text/plain") @WebpubsubPowerShellPreparer() @recorded_by_proxy - def test_send_to_user_binary(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + def test_send_to_user_binary(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") client.send_to_user(user_id="user1", message=b"hello", content_type="application/octet-stream") @WebpubsubPowerShellPreparer() @recorded_by_proxy - def test_send_to_connection_with_fake_connection_id(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + def test_send_to_connection_with_fake_connection_id(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") client.send_to_connection( connection_id="fake-connection-id", message={"hello": "world"}, @@ -139,117 +139,117 @@ def test_send_to_connection_with_fake_connection_id(self, webpubsub_connection_s @WebpubsubPowerShellPreparer() @recorded_by_proxy - def test_close_connection_with_fake_connection_id(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + def test_close_connection_with_fake_connection_id(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") client.close_connection(connection_id="fake-connection-id", reason="test") @WebpubsubPowerShellPreparer() @recorded_by_proxy - def test_add_connection_to_group_not_found(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + def test_add_connection_to_group_not_found(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") with pytest.raises(ResourceNotFoundError): client.add_connection_to_group(group="group1", connection_id="fake-connection-id") @WebpubsubPowerShellPreparer() @recorded_by_proxy - def test_grant_permission_not_found(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + def test_grant_permission_not_found(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") with pytest.raises(ResourceNotFoundError): client.grant_permission(permission="sendToGroup", connection_id="fake-connection-id", target_name="group1") @WebpubsubPowerShellPreparer() @recorded_by_proxy - def test_revoke_permission_with_fake_connection_id(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + def test_revoke_permission_with_fake_connection_id(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") client.revoke_permission(permission="sendToGroup", connection_id="fake-connection-id", target_name="group1") @WebpubsubPowerShellPreparer() @recorded_by_proxy - def test_add_user_to_group_not_found(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + def test_add_user_to_group_not_found(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") with pytest.raises(ResourceNotFoundError): client.add_user_to_group(group="group1", user_id="fake-user") @WebpubsubPowerShellPreparer() @recorded_by_proxy - def test_connection_exists(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + def test_connection_exists(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") assert not client.connection_exists(connection_id="fake-connection-id") @WebpubsubPowerShellPreparer() @recorded_by_proxy - def test_user_exists(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + def test_user_exists(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") assert not client.user_exists(user_id="fake-user") @WebpubsubPowerShellPreparer() @recorded_by_proxy - def test_group_exists(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + def test_group_exists(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") assert not client.group_exists(group="fake-group") @WebpubsubPowerShellPreparer() @recorded_by_proxy - def test_check_permission(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + def test_check_permission(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") assert not client.check_permission( permission="sendToGroup", connection_id="fake-connection-id", target_name="group1" ) @WebpubsubPowerShellPreparer() @recorded_by_proxy - def test_has_permission(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + def test_has_permission(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") assert not client.has_permission( permission="sendToGroup", connection_id="fake-connection-id", target_name="group1" ) @WebpubsubPowerShellPreparer() @recorded_by_proxy - def test_remove_connection_from_all_groups(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + def test_remove_connection_from_all_groups(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") client.remove_connection_from_all_groups(connection_id="fake-connection-id") @WebpubsubPowerShellPreparer() @recorded_by_proxy - def test_remove_user_from_all_groups(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + def test_remove_user_from_all_groups(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") client.remove_user_from_all_groups(user_id="fake-user") @WebpubsubPowerShellPreparer() @recorded_by_proxy - def test_close_group_connections(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + def test_close_group_connections(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") client.close_group_connections(group="group1", excluded=["fake-conn-1", "fake-conn-2"], reason="test") @WebpubsubPowerShellPreparer() @recorded_by_proxy - def test_close_user_connections(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + def test_close_user_connections(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") client.close_user_connections(user_id="user1", excluded=["fake-conn-1", "fake-conn-2"], reason="test") @WebpubsubPowerShellPreparer() @recorded_by_proxy - def test_remove_user_from_group(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + def test_remove_user_from_group(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") client.remove_user_from_group(group="group1", user_id="fake-user") @WebpubsubPowerShellPreparer() @recorded_by_proxy - def test_list_connections_in_group(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + def test_list_connections_in_group(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") result = list(client.list_connections_in_group(group="group1", top=10)) assert isinstance(result, list) @WebpubsubPowerShellPreparer() @recorded_by_proxy - def test_list_connections(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + def test_list_connections(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") result = list(client.list_connections(group="group1", top=10)) assert isinstance(result, list) @WebpubsubPowerShellPreparer() @recorded_by_proxy - def test_remove_connection_from_group(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + def test_remove_connection_from_group(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") client.remove_connection_from_group(group="group1", connection_id="fake-connection-id") diff --git a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_generated_api_coverage_async.py b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_generated_api_coverage_async.py index d9f24744d820..a41138d65efc 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_generated_api_coverage_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_generated_api_coverage_async.py @@ -21,8 +21,8 @@ class TestGeneratedApiCoverageAsync(WebpubsubAsyncTest): @WebpubsubPowerShellPreparer() @recorded_by_proxy_async - async def test_get_service_status(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + async def test_get_service_status(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") assert await client.get_service_status() @WebpubsubPowerShellPreparer() @@ -40,30 +40,30 @@ async def test_generate_client_token(self, webpubsub_endpoint, **kwargs): @WebpubsubPowerShellPreparer() @recorded_by_proxy_async - async def test_close_all_connections(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + async def test_close_all_connections(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") await client.close_all_connections(excluded=["fake-conn-1", "fake-conn-2"], reason="test") @WebpubsubPowerShellPreparer() @recorded_by_proxy_async - async def test_add_connections_to_groups(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + async def test_add_connections_to_groups(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") await client.add_connections_to_groups( groups_to_add={"filter": "userId eq 'nobody'", "groups": ["group1", "group2"]} ) @WebpubsubPowerShellPreparer() @recorded_by_proxy_async - async def test_remove_connections_from_groups(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + async def test_remove_connections_from_groups(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") await client.remove_connections_from_groups( groups_to_remove={"filter": "userId eq 'nobody'", "groups": ["group1", "group2"]} ) @WebpubsubPowerShellPreparer() @recorded_by_proxy_async - async def test_send_to_all_json(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + async def test_send_to_all_json(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") await client.send_to_all( message={"hello": "world"}, content_type="application/json", @@ -73,20 +73,20 @@ async def test_send_to_all_json(self, webpubsub_connection_string): @WebpubsubPowerShellPreparer() @recorded_by_proxy_async - async def test_send_to_all_text(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + async def test_send_to_all_text(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") await client.send_to_all(message="hello", content_type="text/plain") @WebpubsubPowerShellPreparer() @recorded_by_proxy_async - async def test_send_to_all_binary(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + async def test_send_to_all_binary(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") await client.send_to_all(message=b"hello", content_type="application/octet-stream") @WebpubsubPowerShellPreparer() @recorded_by_proxy_async - async def test_send_to_group_json(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + async def test_send_to_group_json(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") await client.send_to_group( group="group1", message={"hello": "world"}, @@ -97,20 +97,20 @@ async def test_send_to_group_json(self, webpubsub_connection_string): @WebpubsubPowerShellPreparer() @recorded_by_proxy_async - async def test_send_to_group_text(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + async def test_send_to_group_text(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") await client.send_to_group(group="group1", message="hello", content_type="text/plain") @WebpubsubPowerShellPreparer() @recorded_by_proxy_async - async def test_send_to_group_binary(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + async def test_send_to_group_binary(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") await client.send_to_group(group="group1", message=b"hello", content_type="application/octet-stream") @WebpubsubPowerShellPreparer() @recorded_by_proxy_async - async def test_send_to_user_json(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + async def test_send_to_user_json(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") await client.send_to_user( user_id="user1", message={"hello": "world"}, @@ -120,20 +120,20 @@ async def test_send_to_user_json(self, webpubsub_connection_string): @WebpubsubPowerShellPreparer() @recorded_by_proxy_async - async def test_send_to_user_text(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + async def test_send_to_user_text(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") await client.send_to_user(user_id="user1", message="hello", content_type="text/plain") @WebpubsubPowerShellPreparer() @recorded_by_proxy_async - async def test_send_to_user_binary(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + async def test_send_to_user_binary(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") await client.send_to_user(user_id="user1", message=b"hello", content_type="application/octet-stream") @WebpubsubPowerShellPreparer() @recorded_by_proxy_async - async def test_send_to_connection_with_fake_connection_id(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + async def test_send_to_connection_with_fake_connection_id(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") await client.send_to_connection( connection_id="fake-connection-id", message={"hello": "world"}, @@ -142,21 +142,21 @@ async def test_send_to_connection_with_fake_connection_id(self, webpubsub_connec @WebpubsubPowerShellPreparer() @recorded_by_proxy_async - async def test_close_connection_with_fake_connection_id(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + async def test_close_connection_with_fake_connection_id(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") await client.close_connection(connection_id="fake-connection-id", reason="test") @WebpubsubPowerShellPreparer() @recorded_by_proxy_async - async def test_add_connection_to_group_not_found(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + async def test_add_connection_to_group_not_found(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") with pytest.raises(ResourceNotFoundError): await client.add_connection_to_group(group="group1", connection_id="fake-connection-id") @WebpubsubPowerShellPreparer() @recorded_by_proxy_async - async def test_grant_permission_not_found(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + async def test_grant_permission_not_found(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") with pytest.raises(ResourceNotFoundError): await client.grant_permission( permission="sendToGroup", connection_id="fake-connection-id", target_name="group1" @@ -164,99 +164,99 @@ async def test_grant_permission_not_found(self, webpubsub_connection_string): @WebpubsubPowerShellPreparer() @recorded_by_proxy_async - async def test_revoke_permission_with_fake_connection_id(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + async def test_revoke_permission_with_fake_connection_id(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") await client.revoke_permission( permission="sendToGroup", connection_id="fake-connection-id", target_name="group1" ) @WebpubsubPowerShellPreparer() @recorded_by_proxy_async - async def test_add_user_to_group_not_found(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + async def test_add_user_to_group_not_found(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") with pytest.raises(ResourceNotFoundError): await client.add_user_to_group(group="group1", user_id="fake-user") @WebpubsubPowerShellPreparer() @recorded_by_proxy_async - async def test_connection_exists(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + async def test_connection_exists(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") assert not await client.connection_exists(connection_id="fake-connection-id") @WebpubsubPowerShellPreparer() @recorded_by_proxy_async - async def test_user_exists(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + async def test_user_exists(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") assert not await client.user_exists(user_id="fake-user") @WebpubsubPowerShellPreparer() @recorded_by_proxy_async - async def test_group_exists(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + async def test_group_exists(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") assert not await client.group_exists(group="fake-group") @WebpubsubPowerShellPreparer() @recorded_by_proxy_async - async def test_check_permission(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + async def test_check_permission(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") assert not await client.check_permission( permission="sendToGroup", connection_id="fake-connection-id", target_name="group1" ) @WebpubsubPowerShellPreparer() @recorded_by_proxy_async - async def test_has_permission(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + async def test_has_permission(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") assert not await client.has_permission( permission="sendToGroup", connection_id="fake-connection-id", target_name="group1" ) @WebpubsubPowerShellPreparer() @recorded_by_proxy_async - async def test_remove_connection_from_all_groups(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + async def test_remove_connection_from_all_groups(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") await client.remove_connection_from_all_groups(connection_id="fake-connection-id") @WebpubsubPowerShellPreparer() @recorded_by_proxy_async - async def test_remove_user_from_all_groups(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + async def test_remove_user_from_all_groups(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") await client.remove_user_from_all_groups(user_id="fake-user") @WebpubsubPowerShellPreparer() @recorded_by_proxy_async - async def test_close_group_connections(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + async def test_close_group_connections(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") await client.close_group_connections(group="group1", excluded=["fake-conn-1", "fake-conn-2"], reason="test") @WebpubsubPowerShellPreparer() @recorded_by_proxy_async - async def test_close_user_connections(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + async def test_close_user_connections(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") await client.close_user_connections(user_id="user1", excluded=["fake-conn-1", "fake-conn-2"], reason="test") @WebpubsubPowerShellPreparer() @recorded_by_proxy_async - async def test_remove_user_from_group(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + async def test_remove_user_from_group(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") await client.remove_user_from_group(group="group1", user_id="fake-user") @WebpubsubPowerShellPreparer() @recorded_by_proxy_async - async def test_list_connections_in_group(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + async def test_list_connections_in_group(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") result = [member async for member in client.list_connections_in_group(group="group1", top=10)] assert isinstance(result, list) @WebpubsubPowerShellPreparer() @recorded_by_proxy_async - async def test_list_connections(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + async def test_list_connections(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") result = [member async for member in client.list_connections(group="group1", top=10)] assert isinstance(result, list) @WebpubsubPowerShellPreparer() @recorded_by_proxy_async - async def test_remove_connection_from_group(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="apicoverage") + async def test_remove_connection_from_group(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="apicoverage") await client.remove_connection_from_group(group="group1", connection_id="fake-connection-id") diff --git a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_list_connections.py b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_list_connections.py index 64b28c84df4d..88e295fab768 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_list_connections.py +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_list_connections.py @@ -22,7 +22,7 @@ def test_list_connections(self, **kwargs): asyncio.run(self._test_list_connections_impl(**kwargs)) async def _test_list_connections_impl(self, **kwargs): - webpubsub_connection_string = kwargs.get("webpubsub_connection_string") + webpubsub_endpoint = kwargs.get("webpubsub_endpoint") # Test cases with different pagination scenarios test_cases = [ {"total_connection_count": 6, "max_count_to_list": 6, "expected_total_count": 6, "expected_page_count": 1}, @@ -37,7 +37,7 @@ async def _test_list_connections_impl(self, **kwargs): ] for test_case in test_cases: - client = self.create_client(connection_string=webpubsub_connection_string, hub="test_list_connections") + client = self.create_client(endpoint=webpubsub_endpoint, hub="test_list_connections") group_name = "group1" ws_clients = [] diff --git a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_list_connections_async.py b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_list_connections_async.py index b36442647607..57746aee8062 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_list_connections_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_list_connections_async.py @@ -17,7 +17,7 @@ class TestListConnectionsAsync(WebpubsubAsyncTest): @WebpubsubPowerShellPreparer() @recorded_by_proxy_async async def test_list_connections(self, **kwargs): - webpubsub_connection_string = kwargs.get("webpubsub_connection_string") + webpubsub_endpoint = kwargs.get("webpubsub_endpoint") # Test cases with different pagination scenarios test_cases = [ {"total_connection_count": 6, "max_count_to_list": 6, "expected_total_count": 6, "expected_page_count": 1}, @@ -32,7 +32,7 @@ async def test_list_connections(self, **kwargs): ] for test_case in test_cases: - client = self.create_client(connection_string=webpubsub_connection_string, hub="test_list_connections") + client = self.create_client(endpoint=webpubsub_endpoint, hub="test_list_connections") async with client: group_name = "group1" ws_clients = [] diff --git a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_live_api_coverage.py b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_live_api_coverage.py index 2540e9a29658..10992f5fcaff 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_live_api_coverage.py +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_live_api_coverage.py @@ -27,11 +27,11 @@ def _find_connection_id(self, client, group_name, user_id): @WebpubsubPowerShellPreparer() @recorded_by_proxy - def test_live_api_coverage_all_apis_and_parameters(self, webpubsub_endpoint, webpubsub_connection_string): + def test_live_api_coverage_all_apis_and_parameters(self, webpubsub_endpoint, webpubsub_socketio_endpoint): if not getattr(self, "is_live", False): pytest.skip("Live WebSocket coverage test is skipped in playback mode") - client = self.create_client(connection_string=webpubsub_connection_string, hub="hub") + client = self.create_client(endpoint=webpubsub_endpoint, hub="hub") aad_client = self.create_client(endpoint=webpubsub_endpoint, hub="hub") user_id = "live-user-1" @@ -55,7 +55,8 @@ def test_live_api_coverage_all_apis_and_parameters(self, webpubsub_endpoint, web assert "webpubsub.joinLeaveGroup" in decoded["role"] assert group_1 in decoded["webpubsub.group"] - socketio_token = client.get_client_access_token(user_id=user_id, groups=[group_1], client_protocol="SocketIO") + socketio_client = self.create_client(endpoint=webpubsub_socketio_endpoint, hub="hub") + socketio_token = socketio_client.get_client_access_token(user_id=user_id, groups=[group_1], client_protocol="SocketIO") assert socketio_token["token"] generated_token = aad_client.generate_client_token( diff --git a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_live_api_coverage_async.py b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_live_api_coverage_async.py index 978de6645cd6..ca6657f346f5 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_live_api_coverage_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_live_api_coverage_async.py @@ -30,12 +30,12 @@ async def _find_connection_id(self, client, group_name, user_id): @WebpubsubPowerShellPreparer() @recorded_by_proxy_async async def test_live_api_coverage_all_apis_and_parameters_async( - self, webpubsub_endpoint, webpubsub_connection_string + self, webpubsub_endpoint, webpubsub_socketio_endpoint ): if not getattr(self, "is_live", False): pytest.skip("Live WebSocket coverage test is skipped in playback mode") - client = self.create_client(connection_string=webpubsub_connection_string, hub="hub") + client = self.create_client(endpoint=webpubsub_endpoint, hub="hub") aad_client = self.create_client(endpoint=webpubsub_endpoint, hub="hub") user_id = "live-user-1" @@ -60,11 +60,13 @@ async def test_live_api_coverage_all_apis_and_parameters_async( assert "webpubsub.joinLeaveGroup" in decoded["role"] assert group_1 in decoded["webpubsub.group"] - socketio_token = await client.get_client_access_token( - user_id=user_id, - groups=[group_1], - client_protocol="SocketIO", - ) + socketio_client = self.create_client(endpoint=webpubsub_socketio_endpoint, hub="hub") + async with socketio_client: + socketio_token = await socketio_client.get_client_access_token( + user_id=user_id, + groups=[group_1], + client_protocol="SocketIO", + ) assert socketio_token["token"] generated_token = await aad_client.generate_client_token( diff --git a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_reverse_proxy.py b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_reverse_proxy.py index e373804ba7a3..f68d9a89faad 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_reverse_proxy.py +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_reverse_proxy.py @@ -53,9 +53,9 @@ def _callback(pipeline_request): @WebpubsubPowerShellPreparer() @recorded_by_proxy - def test_reverse_proxy_call(self, webpubsub_connection_string, webpubsub_reverse_proxy_endpoint): + def test_reverse_proxy_call(self, webpubsub_endpoint, webpubsub_reverse_proxy_endpoint): client = self.create_client( - connection_string=webpubsub_connection_string, + endpoint=webpubsub_endpoint, hub="hub", logging_enable=True, reverse_proxy_endpoint=webpubsub_reverse_proxy_endpoint, diff --git a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_reverse_proxy_async.py b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_reverse_proxy_async.py index 7ef02f256ecc..b65c6791b97f 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_reverse_proxy_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_reverse_proxy_async.py @@ -59,9 +59,9 @@ def _callback(pipeline_request): @pytest.mark.asyncio @WebpubsubPowerShellPreparer() @recorded_by_proxy_async - async def test_reverse_proxy_call(self, webpubsub_connection_string, webpubsub_reverse_proxy_endpoint): + async def test_reverse_proxy_call(self, webpubsub_endpoint, webpubsub_reverse_proxy_endpoint): client = self.create_client( - connection_string=webpubsub_connection_string, + endpoint=webpubsub_endpoint, hub="hub", logging_enable=True, reverse_proxy_endpoint=webpubsub_reverse_proxy_endpoint, diff --git a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_smoke.py b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_smoke.py index e876bb201947..6230c603d1b1 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_smoke.py +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_smoke.py @@ -70,43 +70,43 @@ def test_get_client_access_token(self, webpubsub_endpoint): @WebpubsubPowerShellPreparer() @recorded_by_proxy - def test_hello_world_with_connection_string(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="hub") + def test_hello_world_with_connection_string(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="hub") client.send_to_all(message="Hello, World!", content_type="text/plain") @WebpubsubPowerShellPreparer() @recorded_by_proxy - def test_hello_world_with_connection_string_json(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="hub") + def test_hello_world_with_connection_string_json(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="hub") client.send_to_all(message={"hello": "world!"}) @WebpubsubPowerShellPreparer() @recorded_by_proxy - def test_hello_world_with_connection_string_binary(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="hub") + def test_hello_world_with_connection_string_binary(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="hub") client.send_to_all(message=b"Hello, World!", content_type="application/octet-stream") @WebpubsubPowerShellPreparer() @recorded_by_proxy - def test_no_users_groups(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="hub") + def test_no_users_groups(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="hub") assert not client.user_exists(user_id="fake user") assert not client.group_exists(group="fake group") @WebpubsubPowerShellPreparer() @recorded_by_proxy - def test_remove_connection_from_all_groups(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="hub") + def test_remove_connection_from_all_groups(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="hub") client.remove_connection_from_all_groups(connection_id="fake connection id") @WebpubsubPowerShellPreparer() @recorded_by_proxy - def test_send_with_filter(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="hub") + def test_send_with_filter(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="hub") client.send_to_all(message={"hello": "world!"}, filter="userId ne 'user1'", content_type="text/plain") @WebpubsubPowerShellPreparer() @recorded_by_proxy - def test_get_client_access_key_with_groups(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="hub") + def test_get_client_access_key_with_groups(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="hub") client.get_client_access_token(user_id="user1", groups=["groups1"]) diff --git a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_smoke_async.py b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_smoke_async.py index 84e70c05a288..d89b59acc0e9 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_smoke_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_smoke_async.py @@ -38,43 +38,43 @@ async def test_get_client_access_token(self, webpubsub_endpoint): @WebpubsubPowerShellPreparer() @recorded_by_proxy_async - async def test_hello_world_with_connection_string(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="hub") + async def test_hello_world_with_connection_string(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="hub") await client.send_to_all(message="Hello, World!", content_type="text/plain") @WebpubsubPowerShellPreparer() @recorded_by_proxy_async - async def test_hello_world_with_connection_string_json(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="hub") + async def test_hello_world_with_connection_string_json(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="hub") await client.send_to_all(message={"hello": "world!"}) @WebpubsubPowerShellPreparer() @recorded_by_proxy_async - async def test_hello_world_with_connection_string_binary(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="hub") + async def test_hello_world_with_connection_string_binary(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="hub") await client.send_to_all(message=b"Hello, World!", content_type="application/octet-stream") @WebpubsubPowerShellPreparer() @recorded_by_proxy_async - async def test_no_users_groups(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="hub") + async def test_no_users_groups(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="hub") assert not await client.user_exists(user_id="fake user") assert not await client.group_exists(group="fake group") @WebpubsubPowerShellPreparer() @recorded_by_proxy_async - async def test_remove_connection_from_all_groups(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="hub") + async def test_remove_connection_from_all_groups(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="hub") await client.remove_connection_from_all_groups(connection_id="fake connection id") @WebpubsubPowerShellPreparer() @recorded_by_proxy_async - async def test_send_with_filter(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="hub") + async def test_send_with_filter(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="hub") await client.send_to_all(message={"hello": "world!"}, filter="userId ne 'user1'", content_type="text/plain") @WebpubsubPowerShellPreparer() @recorded_by_proxy_async - async def test_get_client_access_key_with_groups(self, webpubsub_connection_string): - client = self.create_client(connection_string=webpubsub_connection_string, hub="hub") + async def test_get_client_access_key_with_groups(self, webpubsub_endpoint): + client = self.create_client(endpoint=webpubsub_endpoint, hub="hub") await client.get_client_access_token(user_id="user1", groups=["groups1"]) diff --git a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/testcase.py b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/testcase.py index 4a319cf1dbd8..a21176bd3770 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/testcase.py +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/testcase.py @@ -11,8 +11,6 @@ class WebpubsubTest(AzureRecordedTestCase): def create_client(self, endpoint=None, hub=None, reverse_proxy_endpoint=None, **kwargs): - if kwargs.get("connection_string"): - return WebPubSubServiceClient.from_connection_string(kwargs.pop("connection_string"), hub, **kwargs) credential = self.get_credential(WebPubSubServiceClient) return self.create_client_from_credential( WebPubSubServiceClient, @@ -28,5 +26,5 @@ def create_client(self, endpoint=None, hub=None, reverse_proxy_endpoint=None, ** "webpubsub", webpubsub_endpoint="https://myservice.webpubsub.azure.com", webpubsub_reverse_proxy_endpoint="https://myservice.webpubsub.azure.com", - webpubsub_connection_string="Endpoint=https://myservice.webpubsub.azure.com;AccessKey=aaaaaaaaaaaaa;Version=1.0;", + webpubsub_socketio_endpoint="https://myservice-socketio.webpubsub.azure.com", ) diff --git a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/testcase_async.py b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/testcase_async.py index 538211460604..6d65abb16482 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/testcase_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/testcase_async.py @@ -10,8 +10,6 @@ class WebpubsubAsyncTest(AzureRecordedTestCase): def create_client(self, endpoint=None, hub=None, reverse_proxy_endpoint=None, **kwargs): - if kwargs.get("connection_string"): - return WebPubSubServiceClient.from_connection_string(kwargs.pop("connection_string"), hub, **kwargs) credential = self.get_credential(WebPubSubServiceClient, is_async=True) return self.create_client_from_credential( WebPubSubServiceClient, diff --git a/sdk/webpubsub/test-resources.bicep b/sdk/webpubsub/test-resources.bicep new file mode 100644 index 000000000000..b4665536fcbe --- /dev/null +++ b/sdk/webpubsub/test-resources.bicep @@ -0,0 +1,73 @@ +param baseName string = resourceGroup().name +param testApplicationOid string +param location string = resourceGroup().location +param supportsSafeSecretStandard bool = false + +var webpubsubName = 'e2e-${baseName}' +var socketioName = 'e2e-socketio-${baseName}' +// Web PubSub Service Owner +var ownerRoleId = '12cf5a90-567b-43ae-8102-96cf46c7d9b4' + +resource webPubSubSocketIO 'Microsoft.SignalRService/webPubSub@2024-10-01-preview' = { + name: socketioName + location: location + kind: 'SocketIO' + sku: { + name: 'Standard_S1' + tier: 'Standard' + capacity: 1 + } + properties: { + tls: { + clientCertEnabled: false + } + disableLocalAuth: supportsSafeSecretStandard + } +} + +resource webPubSub 'Microsoft.SignalRService/webPubSub@2024-10-01-preview' = { + name: webpubsubName + location: location + kind: 'WebPubSub' + sku: { + name: 'Standard_S1' + tier: 'Standard' + capacity: 1 + } + properties: { + tls: { + clientCertEnabled: false + } + networkACLs: { + defaultAction: 'Deny' + publicNetwork: { + allow: ['ServerConnection', 'ClientConnection', 'RESTAPI', 'Trace'] + } + privateEndpoints: [] + } + disableLocalAuth: supportsSafeSecretStandard + } +} + +resource ownerRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = { + name: guid('ownerRoleId', webPubSub.id) + properties: { + roleDefinitionId: resourceId('Microsoft.Authorization/roleDefinitions', ownerRoleId) + principalId: testApplicationOid + } +} + +resource socketIOOwnerRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = { + name: guid('ownerRoleId', webPubSubSocketIO.id) + properties: { + roleDefinitionId: resourceId('Microsoft.Authorization/roleDefinitions', ownerRoleId) + principalId: testApplicationOid + } +} + +output AZURE_SUBSCRIPTION_ID string = subscription().subscriptionId +output AZURE_RESOURCE_GROUP string = resourceGroup().name +output WEBPUBSUB_ENDPOINT string = 'https://${webPubSub.properties.hostName}' +output WEBPUBSUB_REVERSE_PROXY_ENDPOINT string = 'https://${webPubSub.properties.hostName}' +output WEBPUBSUBCLIENT_ENDPOINT string = 'https://${webPubSub.properties.hostName}' +output WEBPUBSUB_SOCKETIO_ENDPOINT string = 'https://${webPubSubSocketIO.properties.hostName}' diff --git a/sdk/webpubsub/tests.yml b/sdk/webpubsub/tests.yml index e0c2f37352d1..7a03ef94410d 100644 --- a/sdk/webpubsub/tests.yml +++ b/sdk/webpubsub/tests.yml @@ -8,8 +8,4 @@ extends: MatrixReplace: - TestSamples=.*/true EnvVars: - WEBPUBSUB_REVERSE_PROXY_ENDPOINT: $(webpubsub-reverse-proxy-endpoint) - WEBPUBSUB_ENDPOINT: $(webpubsub-endpoint) - WEBPUBSUB_CONNECTION_STRING: $(webpubsub-connection-string) - TEST_MODE: "RunLiveNoRecord" # use when allowing preparers to create the rgs for you AZURE_TEST_RUN_LIVE: "true" # use when utilizing the New-TestResources Script From c7c9793665da50eaf3e91912bf1cf76b32c51da9 Mon Sep 17 00:00:00 2001 From: shiyingchen Date: Mon, 27 Apr 2026 11:58:51 +0800 Subject: [PATCH 02/20] update bicep Co-authored-by: Copilot --- sdk/webpubsub/test-resources.bicep | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sdk/webpubsub/test-resources.bicep b/sdk/webpubsub/test-resources.bicep index b4665536fcbe..c3eaa9f6665a 100644 --- a/sdk/webpubsub/test-resources.bicep +++ b/sdk/webpubsub/test-resources.bicep @@ -50,7 +50,8 @@ resource webPubSub 'Microsoft.SignalRService/webPubSub@2024-10-01-preview' = { } resource ownerRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = { - name: guid('ownerRoleId', webPubSub.id) + name: guid('ownerRoleId', webPubSub.id, testApplicationOid) + scope: webPubSub properties: { roleDefinitionId: resourceId('Microsoft.Authorization/roleDefinitions', ownerRoleId) principalId: testApplicationOid @@ -58,7 +59,8 @@ resource ownerRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01 } resource socketIOOwnerRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = { - name: guid('ownerRoleId', webPubSubSocketIO.id) + name: guid('ownerRoleId', webPubSubSocketIO.id, testApplicationOid) + scope: webPubSubSocketIO properties: { roleDefinitionId: resourceId('Microsoft.Authorization/roleDefinitions', ownerRoleId) principalId: testApplicationOid From c58cdc8e1091865c78ef9b2533d5035b67a1b12f Mon Sep 17 00:00:00 2001 From: shiyingchen Date: Mon, 27 Apr 2026 13:24:17 +0800 Subject: [PATCH 03/20] fix ci Co-authored-by: Copilot --- .../tests/test_auto_connect.py | 2 +- .../tests/test_auto_connect_async.py | 2 +- .../azure-messaging-webpubsubclient/tests/test_recovery.py | 2 +- .../tests/test_recovery_async.py | 2 +- sdk/webpubsub/azure-mgmt-webpubsub/dev_requirements.txt | 1 + sdk/webpubsub/test-resources.bicep | 7 ------- 6 files changed, 5 insertions(+), 11 deletions(-) diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_auto_connect.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_auto_connect.py index a095cfc85e23..6371f200b429 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_auto_connect.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_auto_connect.py @@ -27,7 +27,7 @@ def test_auto_connect(self, webpubsubclient_endpoint): ) name = "test_auto_connect" with client: - time.sleep(0.001) # wait for connection_id to be updated + time.sleep(1) # wait for connection_id to be updated conn_id0 = client._connection_id group_name = name client.subscribe("group-message", on_group_message) diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_auto_connect_async.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_auto_connect_async.py index d107f7a57abd..c92fd7aecccf 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_auto_connect_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_auto_connect_async.py @@ -27,7 +27,7 @@ async def test_auto_connect_async(self, webpubsubclient_endpoint): ) name = "test_auto_connect_async" async with client: - await asyncio.sleep(0.001) # wait for connection_id to be updated + await asyncio.sleep(1) # wait for connection_id to be updated conn_id0 = client._connection_id group_name = name await client.subscribe("group-message", on_group_message) diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_recovery.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_recovery.py index 472f1c674ad4..f8c023dba3a6 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_recovery.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_recovery.py @@ -19,7 +19,7 @@ def test_recovery(self, webpubsubclient_endpoint): client = self.create_client(endpoint=webpubsubclient_endpoint, message_retry_total=10) name = "test_recovery" with client: - time.sleep(0.001) # wait for connection_id to be updated + time.sleep(1) # wait for connection_id to be updated conn_id0 = client._connection_id group_name = name client.subscribe("group-message", on_group_message) diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_recovery_async.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_recovery_async.py index b3b172b092ba..4f2957b9c363 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_recovery_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_recovery_async.py @@ -20,7 +20,7 @@ async def test_recovery_async(self, webpubsubclient_endpoint): client = await self.create_client(endpoint=webpubsubclient_endpoint, message_retry_total=10) name = "test_recovery_async" async with client: - await asyncio.sleep(0.001) # wait for connection_id to be updated + await asyncio.sleep(1) # wait for connection_id to be updated conn_id0 = client._connection_id group_name = name await client.subscribe("group-message", on_group_message) diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/dev_requirements.txt b/sdk/webpubsub/azure-mgmt-webpubsub/dev_requirements.txt index 21cc05c69feb..a248c967d56c 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/dev_requirements.txt +++ b/sdk/webpubsub/azure-mgmt-webpubsub/dev_requirements.txt @@ -1,3 +1,4 @@ -e ../../../eng/tools/azure-sdk-tools ../../identity/azure-identity +../../resources/azure-mgmt-resource aiohttp \ No newline at end of file diff --git a/sdk/webpubsub/test-resources.bicep b/sdk/webpubsub/test-resources.bicep index c3eaa9f6665a..abcc8c7762d5 100644 --- a/sdk/webpubsub/test-resources.bicep +++ b/sdk/webpubsub/test-resources.bicep @@ -38,13 +38,6 @@ resource webPubSub 'Microsoft.SignalRService/webPubSub@2024-10-01-preview' = { tls: { clientCertEnabled: false } - networkACLs: { - defaultAction: 'Deny' - publicNetwork: { - allow: ['ServerConnection', 'ClientConnection', 'RESTAPI', 'Trace'] - } - privateEndpoints: [] - } disableLocalAuth: supportsSafeSecretStandard } } From c0075d2e9d3f6a3b8991e3650b871a729e9c6c28 Mon Sep 17 00:00:00 2001 From: shiyingchen Date: Mon, 27 Apr 2026 14:42:26 +0800 Subject: [PATCH 04/20] fix race condition Co-authored-by: Copilot --- .../tests/test_send_concurrently.py | 2 ++ .../azure-messaging-webpubsubclient/tests/test_smoke.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_send_concurrently.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_send_concurrently.py index 681d191d473e..7da9ac9a6537 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_send_concurrently.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_send_concurrently.py @@ -4,6 +4,7 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # ------------------------------------------------------------------------- +import time import pytest from devtools_testutils import recorded_by_proxy from testcase import WebpubsubClientTest, WebpubsubClientPowerShellPreparer, SafeThread @@ -18,6 +19,7 @@ def test_send_concurrently(self, webpubsubclient_endpoint): with client: group_name = "test_send_concurrently" client.join_group(group_name) + time.sleep(1) # wait for connection to stabilize before concurrent sends def send(idx): client.send_to_group(group_name, f"hello_{idx}", "text") diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke.py index 3c6cb0a3efc1..2a7efd738867 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke.py @@ -119,7 +119,7 @@ def _test(enable_auto_rejoin, test_group_name, assert_func): client.join_group(group_name) with client: - time.sleep(1) # make sure rejoin group is called + time.sleep(3) # make sure rejoin group is called client.send_to_group(group_name, group_name, "text") time.sleep(1) # wait for on_group_message to be called assert assert_func(test_group_name) From 526ef440127713368d7ad5381e58ae68ffb8a46f Mon Sep 17 00:00:00 2001 From: shiyingchen Date: Mon, 27 Apr 2026 15:19:06 +0800 Subject: [PATCH 05/20] add retry for timing-sensitive tests Co-authored-by: Copilot --- .../tests/test_auto_connect.py | 12 +++++++-- .../tests/test_auto_connect_async.py | 12 +++++++-- .../tests/test_recovery.py | 6 ++++- .../tests/test_recovery_async.py | 6 ++++- .../tests/test_smoke.py | 27 ++++++++++++++++--- .../tests/test_smoke_async.py | 19 ++++++++++--- 6 files changed, 69 insertions(+), 13 deletions(-) diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_auto_connect.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_auto_connect.py index 6371f200b429..f3996fcc18d8 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_auto_connect.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_auto_connect.py @@ -27,13 +27,21 @@ def test_auto_connect(self, webpubsubclient_endpoint): ) name = "test_auto_connect" with client: - time.sleep(1) # wait for connection_id to be updated + # wait for connection_id to be updated + for _ in range(30): + if client._connection_id is not None: + break + time.sleep(1) conn_id0 = client._connection_id group_name = name client.subscribe("group-message", on_group_message) client.join_group(group_name) client._ws.sock.close(1001) # close the connection to trigger auto connect - time.sleep(3) # wait for reconnect + # wait for reconnect + for _ in range(30): + if client.is_connected() and client._connection_id != conn_id0: + break + time.sleep(1) client.send_to_group(group_name, name, "text") time.sleep(1) # wait for on_group_message to be called conn_id1 = client._connection_id diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_auto_connect_async.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_auto_connect_async.py index c92fd7aecccf..1606d0283346 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_auto_connect_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_auto_connect_async.py @@ -27,7 +27,11 @@ async def test_auto_connect_async(self, webpubsubclient_endpoint): ) name = "test_auto_connect_async" async with client: - await asyncio.sleep(1) # wait for connection_id to be updated + # wait for connection_id to be updated + for _ in range(30): + if client._connection_id is not None: + break + await asyncio.sleep(1) conn_id0 = client._connection_id group_name = name await client.subscribe("group-message", on_group_message) @@ -35,7 +39,11 @@ async def test_auto_connect_async(self, webpubsubclient_endpoint): await client._ws.sock.close( code=1001 ) # close the connection to trigger auto connect - await asyncio.sleep(3) # wait for reconnect + # wait for reconnect + for _ in range(30): + if client.is_connected() and client._connection_id != conn_id0: + break + await asyncio.sleep(1) await client.send_to_group(group_name, name, "text") await asyncio.sleep(1) # wait for on_group_message to be called conn_id1 = client._connection_id diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_recovery.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_recovery.py index f8c023dba3a6..2ae733c26eaf 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_recovery.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_recovery.py @@ -19,7 +19,11 @@ def test_recovery(self, webpubsubclient_endpoint): client = self.create_client(endpoint=webpubsubclient_endpoint, message_retry_total=10) name = "test_recovery" with client: - time.sleep(1) # wait for connection_id to be updated + # wait for connection_id to be updated + for _ in range(30): + if client._connection_id is not None: + break + time.sleep(1) conn_id0 = client._connection_id group_name = name client.subscribe("group-message", on_group_message) diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_recovery_async.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_recovery_async.py index 4f2957b9c363..b858a77ff141 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_recovery_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_recovery_async.py @@ -20,7 +20,11 @@ async def test_recovery_async(self, webpubsubclient_endpoint): client = await self.create_client(endpoint=webpubsubclient_endpoint, message_retry_total=10) name = "test_recovery_async" async with client: - await asyncio.sleep(1) # wait for connection_id to be updated + # wait for connection_id to be updated + for _ in range(30): + if client._connection_id is not None: + break + await asyncio.sleep(1) conn_id0 = client._connection_id group_name = name await client.subscribe("group-message", on_group_message) diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke.py index 2a7efd738867..26a240dab55d 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke.py @@ -68,13 +68,21 @@ def on_stop(): time.sleep(0.1) assert client.is_connected() client.close() - time.sleep(3.0) + # wait for on_stop callback to reconnect + for _ in range(30): + if client.is_connected(): + break + time.sleep(1) assert client.is_connected() # remove stopped event and close again client.unsubscribe("stopped", on_stop) client.close() - time.sleep(3.0) + # wait for disconnect to finalize + for _ in range(30): + if not client.is_connected(): + break + time.sleep(1) assert not client.is_connected() @WebpubsubClientPowerShellPreparer() @@ -112,6 +120,7 @@ def _test(enable_auto_rejoin, test_group_name, assert_func): client = self.create_client( endpoint=webpubsubclient_endpoint, auto_rejoin_groups=enable_auto_rejoin, + message_retry_total=10, ) group_name = test_group_name client.subscribe("group-message", on_group_message) @@ -119,8 +128,18 @@ def _test(enable_auto_rejoin, test_group_name, assert_func): client.join_group(group_name) with client: - time.sleep(3) # make sure rejoin group is called - client.send_to_group(group_name, group_name, "text") + # retry send until connection is ready (open() runs in background thread) + for attempt in range(30): + try: + if not client.is_connected(): + time.sleep(1) + continue + client.send_to_group(group_name, group_name, "text") + break + except SendMessageError: + time.sleep(1) + else: + raise RuntimeError("Failed to send after 30 attempts") time.sleep(1) # wait for on_group_message to be called assert assert_func(test_group_name) diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke_async.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke_async.py index 3cc4d86e8afa..e955fb6d5be6 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke_async.py @@ -68,13 +68,21 @@ async def on_stop(): await asyncio.sleep(0.1) assert client.is_connected() await client.close() - await asyncio.sleep(3.0) + # wait for on_stop callback to reconnect + for _ in range(30): + if client.is_connected(): + break + await asyncio.sleep(1) assert client.is_connected() # remove stopped event and close again await client.unsubscribe("stopped", on_stop) await client.close() - await asyncio.sleep(3.0) + # wait for disconnect to finalize + for _ in range(30): + if not client.is_connected(): + break + await asyncio.sleep(1) assert not client.is_connected() @WebpubsubClientPowerShellPreparer() @@ -119,7 +127,12 @@ async def _test(enable_auto_rejoin, test_group_name, assert_func): await client.join_group(group_name) async with client: - await asyncio.sleep(1) # make sure rejoin group is called + # wait for connection and auto-rejoin to complete + for _ in range(30): + if client.is_connected(): + break + await asyncio.sleep(1) + await asyncio.sleep(2) # extra time for auto-rejoin await client.send_to_group(group_name, group_name, "text") await asyncio.sleep(1) # wait for on_group_message to be called assert assert_func(test_group_name) From 644acfa1d2af0a448b9074f78a35a6ea7518a5b2 Mon Sep 17 00:00:00 2001 From: shiyingchen Date: Mon, 27 Apr 2026 15:57:18 +0800 Subject: [PATCH 06/20] fix samples Co-authored-by: Copilot --- .../samples/hello_world.py | 5 +++-- .../samples/hello_world_async.py | 6 ++++-- .../samples/hello_world_exceptions.py | 5 +++-- .../samples/send_compare_between_async_sync.py | 11 +++++++---- .../tests/test_smoke.py | 11 +++++------ .../samples/get_client_access_token.py | 18 +++++------------- .../samples/get_client_access_token_async.py | 17 +++++------------ .../samples/integration_sample.py | 15 ++++++++------- .../samples/send_messages_connection_string.py | 9 +++++---- ...nd_messages_connection_string_apim_proxy.py | 11 ++++++----- 10 files changed, 51 insertions(+), 57 deletions(-) diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/samples/hello_world.py b/sdk/webpubsub/azure-messaging-webpubsubclient/samples/hello_world.py index 371c77b21091..249c9ef8e53e 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/samples/hello_world.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/samples/hello_world.py @@ -6,6 +6,7 @@ import os from azure.messaging.webpubsubclient import WebPubSubClient, WebPubSubClientCredential from azure.messaging.webpubsubservice import WebPubSubServiceClient +from azure.identity import DefaultAzureCredential from azure.messaging.webpubsubclient.models import ( OnConnectedArgs, OnGroupDataMessageArgs, @@ -37,8 +38,8 @@ def on_group_message(msg: OnGroupDataMessageArgs): def main(): - service_client = WebPubSubServiceClient.from_connection_string( # type: ignore - connection_string=os.getenv("WEBPUBSUB_CONNECTION_STRING", ""), hub="hub" + service_client = WebPubSubServiceClient( + endpoint=os.getenv("WEBPUBSUB_ENDPOINT", ""), hub="hub", credential=DefaultAzureCredential() ) client = WebPubSubClient( credential=WebPubSubClientCredential( diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/samples/hello_world_async.py b/sdk/webpubsub/azure-messaging-webpubsubclient/samples/hello_world_async.py index 77ee5c11d275..900a8e49d1c9 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/samples/hello_world_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/samples/hello_world_async.py @@ -7,6 +7,7 @@ import asyncio from azure.messaging.webpubsubclient.aio import WebPubSubClient, WebPubSubClientCredential from azure.messaging.webpubsubservice.aio import WebPubSubServiceClient +from azure.identity.aio import DefaultAzureCredential from azure.messaging.webpubsubclient.models import ( OnConnectedArgs, OnGroupDataMessageArgs, @@ -38,8 +39,9 @@ async def on_group_message(msg: OnGroupDataMessageArgs): async def main(): - service_client = WebPubSubServiceClient.from_connection_string( # type: ignore - connection_string=os.getenv("WEBPUBSUB_CONNECTION_STRING", ""), hub="hub" + credential = DefaultAzureCredential() + service_client = WebPubSubServiceClient( + endpoint=os.getenv("WEBPUBSUB_ENDPOINT", ""), hub="hub", credential=credential ) async def client_access_url_provider(): return (await service_client.get_client_access_token( diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/samples/hello_world_exceptions.py b/sdk/webpubsub/azure-messaging-webpubsubclient/samples/hello_world_exceptions.py index b9ca3cf3d648..778640e45b83 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/samples/hello_world_exceptions.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/samples/hello_world_exceptions.py @@ -7,6 +7,7 @@ import logging from azure.messaging.webpubsubclient import WebPubSubClient, WebPubSubClientCredential from azure.messaging.webpubsubservice import WebPubSubServiceClient +from azure.identity import DefaultAzureCredential from azure.messaging.webpubsubclient.models import OpenClientError, SendMessageError from dotenv import load_dotenv @@ -17,8 +18,8 @@ # The following code is to show how to handle exceptions in WebPubSubClient, and it # may not run directly def main(): - service_client = WebPubSubServiceClient.from_connection_string( # type: ignore - connection_string=os.getenv("WEBPUBSUB_CONNECTION_STRING", ""), hub="hub" + service_client = WebPubSubServiceClient( + endpoint=os.getenv("WEBPUBSUB_ENDPOINT", ""), hub="hub", credential=DefaultAzureCredential() ) client = WebPubSubClient( credential=WebPubSubClientCredential( diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/samples/send_compare_between_async_sync.py b/sdk/webpubsub/azure-messaging-webpubsubclient/samples/send_compare_between_async_sync.py index b8a2dd32f043..7493a936719b 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/samples/send_compare_between_async_sync.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/samples/send_compare_between_async_sync.py @@ -13,6 +13,8 @@ from azure.messaging.webpubsubclient import WebPubSubClient as Client from azure.messaging.webpubsubclient import WebPubSubClientCredential from azure.messaging.webpubsubclient.models import WebPubSubDataType +from azure.identity import DefaultAzureCredential +from azure.identity.aio import DefaultAzureCredential as AsyncDefaultAzureCredential from dotenv import load_dotenv load_dotenv() @@ -23,16 +25,17 @@ def client_access_url_provider(): - service_client = WebPubSubServiceClient.from_connection_string( # type: ignore - connection_string=os.getenv("WEBPUBSUB_CONNECTION_STRING", ""), hub="hub" + service_client = WebPubSubServiceClient( + endpoint=os.getenv("WEBPUBSUB_ENDPOINT", ""), hub="hub", credential=DefaultAzureCredential() ) return service_client.get_client_access_token( roles=["webpubsub.joinLeaveGroup", "webpubsub.sendToGroup"] )["url"] async def client_access_url_provider_async(): - service_client_async = WebPubSubServiceClientAsync.from_connection_string( # type: ignore - connection_string=os.getenv("WEBPUBSUB_CONNECTION_STRING", ""), hub="hub" + credential = AsyncDefaultAzureCredential() + service_client_async = WebPubSubServiceClientAsync( + endpoint=os.getenv("WEBPUBSUB_ENDPOINT", ""), hub="hub", credential=credential ) return (await service_client_async.get_client_access_token( roles=["webpubsub.joinLeaveGroup", "webpubsub.sendToGroup"] diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke.py index 26a240dab55d..5e5c6e1852ad 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke.py @@ -140,14 +140,13 @@ def _test(enable_auto_rejoin, test_group_name, assert_func): time.sleep(1) else: raise RuntimeError("Failed to send after 30 attempts") - time.sleep(1) # wait for on_group_message to be called - assert assert_func(test_group_name) - - _test( - enable_auto_rejoin=True, + # wait for on_group_message callback to fire + for _ in range(10): + if assert_func(test_group_name): + break + time.sleep(1) test_group_name="test_rejoin_group", assert_func=lambda x: x in TEST_RESULT, - ) _test( enable_auto_rejoin=False, test_group_name="test_disable_rejoin_group", diff --git a/sdk/webpubsub/azure-messaging-webpubsubservice/samples/get_client_access_token.py b/sdk/webpubsub/azure-messaging-webpubsubservice/samples/get_client_access_token.py index a90cdd1b954c..f190afa72bcd 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubservice/samples/get_client_access_token.py +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/samples/get_client_access_token.py @@ -35,26 +35,18 @@ LOG = logging.getLogger() # Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables: -# AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET, WEBPUBSUB_ENDPOINT, WEBPUBSUB_CONNECTION_STRING +# AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET, WEBPUBSUB_ENDPOINT try: endpoint = os.environ["WEBPUBSUB_ENDPOINT"] - connection_string = os.environ["WEBPUBSUB_CONNECTION_STRING"] except KeyError: LOG.error( - "Missing environment variable 'WEBPUBSUB_ENDPOINT' or 'WEBPUBSUB_CONNECTION_STRING' - please set if before running the example" + "Missing environment variable 'WEBPUBSUB_ENDPOINT' - please set if before running the example" ) exit() # Build a client through AAD -client_aad = WebPubSubServiceClient(endpoint=endpoint, hub="hub", credential=DefaultAzureCredential()) +client = WebPubSubServiceClient(endpoint=endpoint, hub="hub", credential=DefaultAzureCredential()) # Build authentication token -token_aad = client_aad.get_client_access_token() -print("token by AAD: {}".format(token_aad)) - -# Build a client through connection string -client_key = WebPubSubServiceClient.from_connection_string(connection_string, hub="hub") - -# Build authentication token -token_key = client_key.get_client_access_token() -print("token by access key: {}".format(token_key)) +token = client.get_client_access_token() +print("token by AAD: {}".format(token)) diff --git a/sdk/webpubsub/azure-messaging-webpubsubservice/samples/get_client_access_token_async.py b/sdk/webpubsub/azure-messaging-webpubsubservice/samples/get_client_access_token_async.py index 0d032ea1f3df..ca9b07d7102c 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubservice/samples/get_client_access_token_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/samples/get_client_access_token_async.py @@ -38,28 +38,21 @@ async def main(): # Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables: - # AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET, WEBPUBSUB_ENDPOINT, WEBPUBSUB_CONNECTION_STRING + # AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET, WEBPUBSUB_ENDPOINT try: endpoint = os.environ["WEBPUBSUB_ENDPOINT"] - connection_string = os.environ["WEBPUBSUB_CONNECTION_STRING"] except KeyError: LOG.error( - "Missing environment variable 'WEBPUBSUB_ENDPOINT' or 'WEBPUBSUB_CONNECTION_STRING' - please set if before running the example" + "Missing environment variable 'WEBPUBSUB_ENDPOINT' - please set if before running the example" ) exit() # Build a client through AAD(async) async with DefaultAzureCredential() as credential: - async with WebPubSubServiceClientAsync(endpoint=endpoint, hub="hub", credential=credential) as client_aad_async: + async with WebPubSubServiceClientAsync(endpoint=endpoint, hub="hub", credential=credential) as client: # Build authentication token(async) - token_aad_async = await client_aad_async.get_client_access_token() - print("token by AAD(async): {}".format(token_aad_async)) - - # Build a client through connection string(async) - async with WebPubSubServiceClientAsync.from_connection_string(connection_string, hub="hub") as client_key_async: - # Build authentication token(async) - token_key_async = await client_key_async.get_client_access_token() - print("token by access key(async): {}".format(token_key_async)) + token = await client.get_client_access_token() + print("token by AAD(async): {}".format(token)) if __name__ == "__main__": diff --git a/sdk/webpubsub/azure-messaging-webpubsubservice/samples/integration_sample.py b/sdk/webpubsub/azure-messaging-webpubsubservice/samples/integration_sample.py index 44c1d80bfaa7..89c021b36dea 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubservice/samples/integration_sample.py +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/samples/integration_sample.py @@ -12,6 +12,7 @@ from websocket import WebSocketApp from typing import List, Optional from azure.messaging.webpubsubservice import WebPubSubServiceClient +from azure.identity import DefaultAzureCredential logging.basicConfig(level=logging.DEBUG) LOG = logging.getLogger() @@ -62,10 +63,10 @@ def client_number(self): return len(self.clients) -def test_overall_integration(webpubsub_connection_string: str): - # build a service client from the connection string. - service = WebPubSubServiceClient.from_connection_string( - webpubsub_connection_string, hub="hub", logging_enable=False +def test_overall_integration(endpoint: str): + # build a service client through AAD. + service = WebPubSubServiceClient( + endpoint=endpoint, hub="hub", credential=DefaultAzureCredential(), logging_enable=False ) # build multiple websocket clients connected to the Web PubSub service @@ -114,11 +115,11 @@ def test_overall_integration(webpubsub_connection_string: str): if __name__ == "__main__": try: - connection_string = os.environ["WEBPUBSUB_CONNECTION_STRING"] + endpoint = os.environ["WEBPUBSUB_ENDPOINT"] except KeyError: LOG.error( - "Missing environment variable 'WEBPUBSUB_CONNECTION_STRING' - please set if before running the example" + "Missing environment variable 'WEBPUBSUB_ENDPOINT' - please set if before running the example" ) exit() - test_overall_integration(connection_string) + test_overall_integration(endpoint) diff --git a/sdk/webpubsub/azure-messaging-webpubsubservice/samples/send_messages_connection_string.py b/sdk/webpubsub/azure-messaging-webpubsubservice/samples/send_messages_connection_string.py index 69a2ca9a4bd8..f43cffdd1f5a 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubservice/samples/send_messages_connection_string.py +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/samples/send_messages_connection_string.py @@ -29,20 +29,21 @@ import os from azure.messaging.webpubsubservice import WebPubSubServiceClient +from azure.identity import DefaultAzureCredential from azure.core.exceptions import HttpResponseError logging.basicConfig(level=logging.DEBUG) LOG = logging.getLogger() try: - connection_string = os.environ["WEBPUBSUB_CONNECTION_STRING"] + endpoint = os.environ["WEBPUBSUB_ENDPOINT"] except KeyError: - LOG.error("Missing environment variable 'WEBPUBSUB_CONNECTION_STRING' - please set if before running the example") + LOG.error("Missing environment variable 'WEBPUBSUB_ENDPOINT' - please set if before running the example") exit() -# Build a client from the connection string. And for this example, we have enabled debug +# Build a client through AAD. And for this example, we have enabled debug # tracing. For production code, this should be turned off. -client = WebPubSubServiceClient.from_connection_string(connection_string, hub="hub", logging_enable=True) +client = WebPubSubServiceClient(endpoint=endpoint, hub="hub", credential=DefaultAzureCredential(), logging_enable=True) try: # Raise an exception if the service rejected the call diff --git a/sdk/webpubsub/azure-messaging-webpubsubservice/samples/send_messages_connection_string_apim_proxy.py b/sdk/webpubsub/azure-messaging-webpubsubservice/samples/send_messages_connection_string_apim_proxy.py index f8aaaf4e84ac..0850c67f1a6a 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubservice/samples/send_messages_connection_string_apim_proxy.py +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/samples/send_messages_connection_string_apim_proxy.py @@ -30,25 +30,26 @@ import os from azure.messaging.webpubsubservice import WebPubSubServiceClient +from azure.identity import DefaultAzureCredential from azure.core.exceptions import HttpResponseError logging.basicConfig(level=logging.DEBUG) LOG = logging.getLogger() try: - connection_string = os.environ["WEBPUBSUB_CONNECTION_STRING"] + endpoint = os.environ["WEBPUBSUB_ENDPOINT"] reverse_proxy_endpoint = os.environ["WEBPUBSUB_REVERSE_PROXY_ENDPOINT"] except KeyError: LOG.error( - "Missing environment variable 'WEBPUBSUB_CONNECTION_STRING' or 'WEBPUBSUB_REVERSE_PROXY_ENDPOINT' - please set if before running the example" + "Missing environment variable 'WEBPUBSUB_ENDPOINT' or 'WEBPUBSUB_REVERSE_PROXY_ENDPOINT' - please set if before running the example" ) exit() -# Build a client from the connection string. And for this example, we have enabled debug +# Build a client through AAD. And for this example, we have enabled debug # tracing. For production code, this should be turned off. # If you want to know more about the effect of `reverse_proxy_endpoint`, please reference: https://github.com/Azure/azure-webpubsub/issues/194 -client = WebPubSubServiceClient.from_connection_string( - connection_string, hub="hub", logging_enable=True, reverse_proxy_endpoint=reverse_proxy_endpoint +client = WebPubSubServiceClient( + endpoint=endpoint, hub="hub", credential=DefaultAzureCredential(), logging_enable=True, reverse_proxy_endpoint=reverse_proxy_endpoint ) try: From 97b036c4d26810319fd4fe2fc1a1f4ed04e1a23a Mon Sep 17 00:00:00 2001 From: shiyingchen Date: Mon, 27 Apr 2026 16:46:31 +0800 Subject: [PATCH 07/20] skip integration_sample and add timeout Co-authored-by: Copilot --- eng/tools/azure-sdk-tools/azpysdk/samples.py | 3 +++ .../tests/test_live_api_coverage.py | 10 +++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/eng/tools/azure-sdk-tools/azpysdk/samples.py b/eng/tools/azure-sdk-tools/azpysdk/samples.py index 0ebf1f056725..a7f7b83e229e 100644 --- a/eng/tools/azure-sdk-tools/azpysdk/samples.py +++ b/eng/tools/azure-sdk-tools/azpysdk/samples.py @@ -158,6 +158,9 @@ "blob_samples_container_access_policy_async.py", "blob_samples_client_side_encryption_keyvault.py", ], + "azure-messaging-webpubsubservice": [ + "integration_sample.py", + ], } diff --git a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_live_api_coverage.py b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_live_api_coverage.py index 10992f5fcaff..303d3aef1387 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_live_api_coverage.py +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_live_api_coverage.py @@ -70,7 +70,7 @@ def test_live_api_coverage_all_apis_and_parameters(self, webpubsub_endpoint, web ws = None try: - ws = ws_connect(access_token["url"]) + ws = ws_connect(access_token["url"], open_timeout=30) assert client.get_service_status() @@ -165,28 +165,28 @@ def test_live_api_coverage_all_apis_and_parameters(self, webpubsub_endpoint, web # close_group_connections (connection auto-joins group_1 via token) ws.close() - ws = ws_connect(access_token["url"]) + ws = ws_connect(access_token["url"], open_timeout=30) conn = self._find_connection_id(client, group_1, user_id) assert conn is not None client.close_group_connections(group=group_1, reason="live-coverage") assert not client.connection_exists(connection_id=conn) # close_user_connections - ws = ws_connect(access_token["url"]) + ws = ws_connect(access_token["url"], open_timeout=30) conn = self._find_connection_id(client, group_1, user_id) assert conn is not None client.close_user_connections(user_id=user_id, reason="live-coverage") assert not client.connection_exists(connection_id=conn) # close_connection - ws = ws_connect(access_token["url"]) + ws = ws_connect(access_token["url"], open_timeout=30) conn = self._find_connection_id(client, group_1, user_id) assert conn is not None client.close_connection(connection_id=conn, reason="live-coverage") assert not client.connection_exists(connection_id=conn) # close_all_connections - ws = ws_connect(access_token["url"]) + ws = ws_connect(access_token["url"], open_timeout=30) conn = self._find_connection_id(client, group_1, user_id) assert conn is not None client.close_all_connections(reason="live-coverage") From 31846d0b1244c2d7db99033f402aeaba7b780a76 Mon Sep 17 00:00:00 2001 From: shiyingchen Date: Mon, 27 Apr 2026 16:50:07 +0800 Subject: [PATCH 08/20] add retry for auto_connect Co-authored-by: Copilot --- .../tests/test_auto_connect.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_auto_connect.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_auto_connect.py index f3996fcc18d8..aab466dd4226 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_auto_connect.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_auto_connect.py @@ -42,8 +42,12 @@ def test_auto_connect(self, webpubsubclient_endpoint): if client.is_connected() and client._connection_id != conn_id0: break time.sleep(1) - client.send_to_group(group_name, name, "text") - time.sleep(1) # wait for on_group_message to be called + # retry send_to_group to allow async group rejoin to complete + for _ in range(10): + client.send_to_group(group_name, name, "text") + time.sleep(1) + if name in TEST_RESULT: + break conn_id1 = client._connection_id assert conn_id0 is not None assert conn_id1 is not None From 641272b7f2237f298132875a0816701e60320f8f Mon Sep 17 00:00:00 2001 From: shiyingchen Date: Tue, 28 Apr 2026 13:55:10 +0800 Subject: [PATCH 09/20] fix ci timing issue Co-authored-by: Copilot --- .../tests/test_auto_connect_async.py | 6 +++++- .../tests/test_no_recovery_no_connect.py | 2 +- .../tests/test_no_recovery_no_connect_async.py | 2 +- .../tests/test_recovery.py | 6 +++++- .../tests/test_recovery_async.py | 6 +++++- .../tests/test_send_concurrently.py | 6 +++++- .../tests/test_smoke.py | 10 ++++++++-- .../tests/test_smoke_async.py | 16 +++++++++++++--- .../tests/test_list_connections.py | 2 ++ .../tests/test_list_connections_async.py | 1 + .../tests/test_live_api_coverage.py | 18 +++++++++++++++++- .../tests/test_live_api_coverage_async.py | 18 +++++++++++++++++- 12 files changed, 80 insertions(+), 13 deletions(-) diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_auto_connect_async.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_auto_connect_async.py index 1606d0283346..494556044bc8 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_auto_connect_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_auto_connect_async.py @@ -45,7 +45,11 @@ async def test_auto_connect_async(self, webpubsubclient_endpoint): break await asyncio.sleep(1) await client.send_to_group(group_name, name, "text") - await asyncio.sleep(1) # wait for on_group_message to be called + # wait for on_group_message callback to fire + for _ in range(10): + if name in TEST_RESULT_ASYNC: + break + await asyncio.sleep(1) conn_id1 = client._connection_id assert conn_id0 is not None assert conn_id1 is not None diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_no_recovery_no_connect.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_no_recovery_no_connect.py index 06e1e3ebe124..40d1e960e7fb 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_no_recovery_no_connect.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_no_recovery_no_connect.py @@ -39,7 +39,7 @@ def test_disable_recovery_and_autoconnect(self, webpubsubclient_endpoint): client._ws.sock.close(1001) # close connection with pytest.raises(SendMessageError): client.send_to_group(group_name, name, "text") - time.sleep(1) # wait for on_group_message to be called + time.sleep(3) # wait to confirm message was NOT received assert name not in TEST_RESULT diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_no_recovery_no_connect_async.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_no_recovery_no_connect_async.py index fcca6fd7d6ca..99e4516d0cff 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_no_recovery_no_connect_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_no_recovery_no_connect_async.py @@ -34,7 +34,7 @@ async def test_disable_recovery_and_autoconnect_async(self, webpubsubclient_endp await client._ws.session.close() # close connection with pytest.raises(SendMessageError): await client.send_to_group(group_name, name, "text") - await asyncio.sleep(1) # wait for on_group_message to be called + await asyncio.sleep(3) # wait to confirm message was NOT received assert name not in TEST_RESULT_ASYNC diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_recovery.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_recovery.py index 2ae733c26eaf..6be5546b4207 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_recovery.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_recovery.py @@ -31,7 +31,11 @@ def test_recovery(self, webpubsubclient_endpoint): client._ws.sock.close(1001) # close connection to trigger recovery client.send_to_group(group_name, name, "text") conn_id1 = client._connection_id - time.sleep(1) # wait for on_group_message to be called + # wait for on_group_message callback to fire + for _ in range(10): + if name in TEST_RESULT: + break + time.sleep(1) assert name in TEST_RESULT assert conn_id0 is not None diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_recovery_async.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_recovery_async.py index b858a77ff141..2092d6cdc6b3 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_recovery_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_recovery_async.py @@ -32,7 +32,11 @@ async def test_recovery_async(self, webpubsubclient_endpoint): await client._ws.session.close() # close connection to trigger recovery await client.send_to_group(group_name, name, "text") conn_id1 = client._connection_id - await asyncio.sleep(1) # wait for on_group_message to be called + # wait for on_group_message callback to fire + for _ in range(10): + if name in TEST_RESULT_ASYNC: + break + await asyncio.sleep(1) assert name in TEST_RESULT_ASYNC assert conn_id0 is not None diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_send_concurrently.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_send_concurrently.py index 7da9ac9a6537..a09039d50ed5 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_send_concurrently.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_send_concurrently.py @@ -19,7 +19,11 @@ def test_send_concurrently(self, webpubsubclient_endpoint): with client: group_name = "test_send_concurrently" client.join_group(group_name) - time.sleep(1) # wait for connection to stabilize before concurrent sends + # wait for connection to stabilize before concurrent sends + for _ in range(30): + if client.is_connected(): + break + time.sleep(1) def send(idx): client.send_to_group(group_name, f"hello_{idx}", "text") diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke.py index 5e5c6e1852ad..614d46561adf 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke.py @@ -50,7 +50,10 @@ def test_context_manager(self, webpubsubclient_endpoint): group_name = "test_context_manager" client.join_group(group_name) client.send_to_group(group_name, "test_context_manager", "text") - time.sleep(2.0) + for _ in range(30): + if client._sequence_id.sequence_id > 0: + break + time.sleep(1) assert client._sequence_id.sequence_id > 0 # test on_stop @@ -65,7 +68,10 @@ def on_stop(): with client: # open client again after close client.subscribe("stopped", on_stop) - time.sleep(0.1) + for _ in range(30): + if client.is_connected(): + break + time.sleep(1) assert client.is_connected() client.close() # wait for on_stop callback to reconnect diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke_async.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke_async.py index e955fb6d5be6..090f68d36c7c 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke_async.py @@ -50,7 +50,10 @@ async def test_context_manager_async(self, webpubsubclient_endpoint): group_name = "test_context_manager_async" await client.join_group(group_name) await client.send_to_group(group_name, "test_context_manager", "text") - await asyncio.sleep(2.0) + for _ in range(30): + if client._sequence_id.sequence_id > 0: + break + await asyncio.sleep(1) assert client._sequence_id.sequence_id > 0 # test on_stop @@ -65,7 +68,10 @@ async def on_stop(): async with client: # open client again after close await client.subscribe("stopped", on_stop) - await asyncio.sleep(0.1) + for _ in range(30): + if client.is_connected(): + break + await asyncio.sleep(1) assert client.is_connected() await client.close() # wait for on_stop callback to reconnect @@ -134,7 +140,11 @@ async def _test(enable_auto_rejoin, test_group_name, assert_func): await asyncio.sleep(1) await asyncio.sleep(2) # extra time for auto-rejoin await client.send_to_group(group_name, group_name, "text") - await asyncio.sleep(1) # wait for on_group_message to be called + # wait for on_group_message callback to fire + for _ in range(10): + if assert_func(test_group_name): + break + await asyncio.sleep(1) assert assert_func(test_group_name) await _test( diff --git a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_list_connections.py b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_list_connections.py index 88e295fab768..f900f2d4eabf 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_list_connections.py +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_list_connections.py @@ -5,6 +5,7 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # ------------------------------------------------------------------------- +import asyncio from websockets import connect as ws_connect from testcase import WebpubsubTest, WebpubsubPowerShellPreparer from devtools_testutils import recorded_by_proxy, set_custom_default_matcher @@ -50,6 +51,7 @@ async def _test_list_connections_impl(self, **kwargs): for _ in range(test_case["total_connection_count"]): ws = await ws_connect(client_url) ws_clients.append(ws) + await asyncio.sleep(3) # wait for server to register connections # List connections with pagination actual_page_count = 0 diff --git a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_list_connections_async.py b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_list_connections_async.py index 57746aee8062..0f222e67547a 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_list_connections_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_list_connections_async.py @@ -46,6 +46,7 @@ async def test_list_connections(self, **kwargs): for _ in range(test_case["total_connection_count"]): ws = await ws_connect(client_url) ws_clients.append(ws) + await asyncio.sleep(3) # wait for server to register connections # List connections with pagination actual_page_count = 0 diff --git a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_live_api_coverage.py b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_live_api_coverage.py index 303d3aef1387..297dd68ec847 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_live_api_coverage.py +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_live_api_coverage.py @@ -17,7 +17,7 @@ @pytest.mark.live_test_only class TestLiveApiCoverage(WebpubsubTest): def _find_connection_id(self, client, group_name, user_id): - for _ in range(10): + for _ in range(30): members = list(client.list_connections(group=group_name, top=20)) for member in members: if member.user_id == user_id and member.connection_id: @@ -169,6 +169,10 @@ def test_live_api_coverage_all_apis_and_parameters(self, webpubsub_endpoint, web conn = self._find_connection_id(client, group_1, user_id) assert conn is not None client.close_group_connections(group=group_1, reason="live-coverage") + for _ in range(30): + if not client.connection_exists(connection_id=conn): + break + time.sleep(1) assert not client.connection_exists(connection_id=conn) # close_user_connections @@ -176,6 +180,10 @@ def test_live_api_coverage_all_apis_and_parameters(self, webpubsub_endpoint, web conn = self._find_connection_id(client, group_1, user_id) assert conn is not None client.close_user_connections(user_id=user_id, reason="live-coverage") + for _ in range(30): + if not client.connection_exists(connection_id=conn): + break + time.sleep(1) assert not client.connection_exists(connection_id=conn) # close_connection @@ -183,6 +191,10 @@ def test_live_api_coverage_all_apis_and_parameters(self, webpubsub_endpoint, web conn = self._find_connection_id(client, group_1, user_id) assert conn is not None client.close_connection(connection_id=conn, reason="live-coverage") + for _ in range(30): + if not client.connection_exists(connection_id=conn): + break + time.sleep(1) assert not client.connection_exists(connection_id=conn) # close_all_connections @@ -190,6 +202,10 @@ def test_live_api_coverage_all_apis_and_parameters(self, webpubsub_endpoint, web conn = self._find_connection_id(client, group_1, user_id) assert conn is not None client.close_all_connections(reason="live-coverage") + for _ in range(30): + if not client.connection_exists(connection_id=conn): + break + time.sleep(1) assert not client.connection_exists(connection_id=conn) ws = None diff --git a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_live_api_coverage_async.py b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_live_api_coverage_async.py index ca6657f346f5..99f1a3474fe7 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_live_api_coverage_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_live_api_coverage_async.py @@ -19,7 +19,7 @@ @pytest.mark.asyncio class TestLiveApiCoverageAsync(WebpubsubAsyncTest): async def _find_connection_id(self, client, group_name, user_id): - for _ in range(10): + for _ in range(30): members = [member async for member in client.list_connections(group=group_name, top=20)] for member in members: if member.user_id == user_id and member.connection_id: @@ -199,6 +199,10 @@ async def test_live_api_coverage_all_apis_and_parameters_async( conn = await self._find_connection_id(client, group_1, user_id) assert conn is not None await client.close_group_connections(group=group_1, reason="live-coverage") + for _ in range(30): + if not await client.connection_exists(connection_id=conn): + break + await asyncio.sleep(1) assert not await client.connection_exists(connection_id=conn) # close_user_connections @@ -206,6 +210,10 @@ async def test_live_api_coverage_all_apis_and_parameters_async( conn = await self._find_connection_id(client, group_1, user_id) assert conn is not None await client.close_user_connections(user_id=user_id, reason="live-coverage") + for _ in range(30): + if not await client.connection_exists(connection_id=conn): + break + await asyncio.sleep(1) assert not await client.connection_exists(connection_id=conn) # close_connection @@ -213,6 +221,10 @@ async def test_live_api_coverage_all_apis_and_parameters_async( conn = await self._find_connection_id(client, group_1, user_id) assert conn is not None await client.close_connection(connection_id=conn, reason="live-coverage") + for _ in range(30): + if not await client.connection_exists(connection_id=conn): + break + await asyncio.sleep(1) assert not await client.connection_exists(connection_id=conn) # close_all_connections @@ -220,6 +232,10 @@ async def test_live_api_coverage_all_apis_and_parameters_async( conn = await self._find_connection_id(client, group_1, user_id) assert conn is not None await client.close_all_connections(reason="live-coverage") + for _ in range(30): + if not await client.connection_exists(connection_id=conn): + break + await asyncio.sleep(1) assert not await client.connection_exists(connection_id=conn) ws = None From 0f9641b721f8606402f7ecc608fe8ef9ba3e69b1 Mon Sep 17 00:00:00 2001 From: shiyingchen Date: Tue, 28 Apr 2026 15:11:40 +0800 Subject: [PATCH 10/20] fix race condition Co-authored-by: Copilot --- ...subClientAutoConnecttest_auto_connect.json | 51 ---------- ...toConnectAsynctest_auto_connect_async.json | 49 ---------- ...test_disable_recovery_and_autoconnect.json | 28 ------ ...ery_and_autoconnect_send_concurrently.json | 28 ------ ...isable_recovery_and_autoconnect_async.json | 27 ------ ...d_autoconnect_send_concurrently_async.json | 27 ------ ...tWebpubsubClientRecoverytest_recovery.json | 28 ------ ...lientRecoveryAsynctest_recovery_async.json | 27 ------ ...endConcurrentlytest_send_concurrently.json | 28 ------ ...ntlyAsynctest_send_concurrently_async.json | 27 ------ ...subClientSmoketest_call_back_deadlock.json | 28 ------ ...pubsubClientSmoketest_context_manager.json | 28 ------ ...ubsubClientSmoketest_duplicated_start.json | 28 ------ ...pubsubClientSmoketest_duplicated_stop.json | 28 ------ ...yTestWebpubsubClientSmoketest_on_stop.json | 51 ---------- ...bsubClientSmoketest_open_client_error.json | 4 - ...WebpubsubClientSmoketest_rejoin_group.json | 97 ------------------- ...stWebpubsubClientSmoketest_send_event.json | 28 ------ ...okeAsynctest_call_back_deadlock_async.json | 27 ------ ...tSmokeAsynctest_context_manager_async.json | 27 ------ ...SmokeAsynctest_duplicated_start_async.json | 27 ------ ...tSmokeAsynctest_duplicated_stop_async.json | 27 ------ ...subClientSmokeAsynctest_on_stop_async.json | 49 ---------- ...mokeAsynctest_open_client_error_async.json | 4 - ...ientSmokeAsynctest_rejoin_group_async.json | 93 ------------------ ...ClientSmokeAsynctest_send_event_async.json | 27 ------ .../tests/test_no_recovery_no_connect.py | 5 + .../test_no_recovery_no_connect_async.py | 5 + .../tests/test_list_connections_async.py | 1 + .../tests/test_live_api_coverage.py | 4 + .../tests/test_live_api_coverage_async.py | 12 ++- 31 files changed, 23 insertions(+), 897 deletions(-) delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_auto_connect.pyTestWebpubsubClientAutoConnecttest_auto_connect.json delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_auto_connect_async.pyTestWebpubsubClientAutoConnectAsynctest_auto_connect_async.json delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_no_recovery_no_connect.pyTestWebpubsubClientNoRecoveryNoReconnecttest_disable_recovery_and_autoconnect.json delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_no_recovery_no_connect.pyTestWebpubsubClientNoRecoveryNoReconnecttest_disable_recovery_and_autoconnect_send_concurrently.json delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_no_recovery_no_connect_async.pyTestWebpubsubClientNoRecoveryNoReconnectAsynctest_disable_recovery_and_autoconnect_async.json delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_no_recovery_no_connect_async.pyTestWebpubsubClientNoRecoveryNoReconnectAsynctest_disable_recovery_and_autoconnect_send_concurrently_async.json delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_recovery.pyTestWebpubsubClientRecoverytest_recovery.json delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_recovery_async.pyTestWebpubsubClientRecoveryAsynctest_recovery_async.json delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_send_concurrently.pyTestWebpubsubClientSendConcurrentlytest_send_concurrently.json delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_send_concurrently_async.pyTestWebpubsubClientSendConcurrentlyAsynctest_send_concurrently_async.json delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_call_back_deadlock.json delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_context_manager.json delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_duplicated_start.json delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_duplicated_stop.json delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_on_stop.json delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_open_client_error.json delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_rejoin_group.json delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_send_event.json delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_call_back_deadlock_async.json delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_context_manager_async.json delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_duplicated_start_async.json delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_duplicated_stop_async.json delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_on_stop_async.json delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_open_client_error_async.json delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_rejoin_group_async.json delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_send_event_async.json diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_auto_connect.pyTestWebpubsubClientAutoConnecttest_auto_connect.json b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_auto_connect.pyTestWebpubsubClientAutoConnecttest_auto_connect.json deleted file mode 100644 index 1998bb8828f0..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_auto_connect.pyTestWebpubsubClientAutoConnecttest_auto_connect.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "Entries": [ - { - "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&clientType=Default", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "*/*", - "Connection": "keep-alive", - "Content-Length": "0", - "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" - }, - "RequestBody": null, - "StatusCode": 200, - "ResponseHeaders": { - "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", - "Connection": "keep-alive", - "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 27 Apr 2026 03:23:18 GMT", - "Strict-Transport-Security": "max-age=31536000; includeSubDomains", - "Transfer-Encoding": "chunked" - }, - "ResponseBody": { - "token": "Sanitized" - } - }, - { - "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&clientType=Default", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "*/*", - "Connection": "keep-alive", - "Content-Length": "0", - "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" - }, - "RequestBody": null, - "StatusCode": 200, - "ResponseHeaders": { - "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", - "Connection": "keep-alive", - "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 27 Apr 2026 03:23:20 GMT", - "Strict-Transport-Security": "max-age=31536000; includeSubDomains", - "Transfer-Encoding": "chunked" - }, - "ResponseBody": { - "token": "Sanitized" - } - } - ], - "Variables": {} -} diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_auto_connect_async.pyTestWebpubsubClientAutoConnectAsynctest_auto_connect_async.json b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_auto_connect_async.pyTestWebpubsubClientAutoConnectAsynctest_auto_connect_async.json deleted file mode 100644 index ee663358d3a1..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_auto_connect_async.pyTestWebpubsubClientAutoConnectAsynctest_auto_connect_async.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "Entries": [ - { - "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&minutesToExpire=60&clientType=Default", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "*/*", - "Content-Length": "0", - "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" - }, - "RequestBody": null, - "StatusCode": 200, - "ResponseHeaders": { - "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", - "Connection": "keep-alive", - "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 27 Apr 2026 03:23:25 GMT", - "Strict-Transport-Security": "max-age=31536000; includeSubDomains", - "Transfer-Encoding": "chunked" - }, - "ResponseBody": { - "token": "Sanitized" - } - }, - { - "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&minutesToExpire=60&clientType=Default", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "*/*", - "Content-Length": "0", - "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" - }, - "RequestBody": null, - "StatusCode": 200, - "ResponseHeaders": { - "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", - "Connection": "keep-alive", - "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 27 Apr 2026 03:23:28 GMT", - "Strict-Transport-Security": "max-age=31536000; includeSubDomains", - "Transfer-Encoding": "chunked" - }, - "ResponseBody": { - "token": "Sanitized" - } - } - ], - "Variables": {} -} diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_no_recovery_no_connect.pyTestWebpubsubClientNoRecoveryNoReconnecttest_disable_recovery_and_autoconnect.json b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_no_recovery_no_connect.pyTestWebpubsubClientNoRecoveryNoReconnecttest_disable_recovery_and_autoconnect.json deleted file mode 100644 index 29e8a895cc22..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_no_recovery_no_connect.pyTestWebpubsubClientNoRecoveryNoReconnecttest_disable_recovery_and_autoconnect.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "Entries": [ - { - "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&clientType=Default", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "*/*", - "Connection": "keep-alive", - "Content-Length": "0", - "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" - }, - "RequestBody": null, - "StatusCode": 200, - "ResponseHeaders": { - "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", - "Connection": "keep-alive", - "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 27 Apr 2026 03:23:32 GMT", - "Strict-Transport-Security": "max-age=31536000; includeSubDomains", - "Transfer-Encoding": "chunked" - }, - "ResponseBody": { - "token": "Sanitized" - } - } - ], - "Variables": {} -} diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_no_recovery_no_connect.pyTestWebpubsubClientNoRecoveryNoReconnecttest_disable_recovery_and_autoconnect_send_concurrently.json b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_no_recovery_no_connect.pyTestWebpubsubClientNoRecoveryNoReconnecttest_disable_recovery_and_autoconnect_send_concurrently.json deleted file mode 100644 index b5de50a0e4ae..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_no_recovery_no_connect.pyTestWebpubsubClientNoRecoveryNoReconnecttest_disable_recovery_and_autoconnect_send_concurrently.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "Entries": [ - { - "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&clientType=Default", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "*/*", - "Connection": "keep-alive", - "Content-Length": "0", - "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" - }, - "RequestBody": null, - "StatusCode": 200, - "ResponseHeaders": { - "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", - "Connection": "keep-alive", - "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 27 Apr 2026 03:23:42 GMT", - "Strict-Transport-Security": "max-age=31536000; includeSubDomains", - "Transfer-Encoding": "chunked" - }, - "ResponseBody": { - "token": "Sanitized" - } - } - ], - "Variables": {} -} diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_no_recovery_no_connect_async.pyTestWebpubsubClientNoRecoveryNoReconnectAsynctest_disable_recovery_and_autoconnect_async.json b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_no_recovery_no_connect_async.pyTestWebpubsubClientNoRecoveryNoReconnectAsynctest_disable_recovery_and_autoconnect_async.json deleted file mode 100644 index 3c64183c683f..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_no_recovery_no_connect_async.pyTestWebpubsubClientNoRecoveryNoReconnectAsynctest_disable_recovery_and_autoconnect_async.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "Entries": [ - { - "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&minutesToExpire=60&clientType=Default", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "*/*", - "Content-Length": "0", - "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" - }, - "RequestBody": null, - "StatusCode": 200, - "ResponseHeaders": { - "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", - "Connection": "keep-alive", - "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 27 Apr 2026 03:23:50 GMT", - "Strict-Transport-Security": "max-age=31536000; includeSubDomains", - "Transfer-Encoding": "chunked" - }, - "ResponseBody": { - "token": "Sanitized" - } - } - ], - "Variables": {} -} diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_no_recovery_no_connect_async.pyTestWebpubsubClientNoRecoveryNoReconnectAsynctest_disable_recovery_and_autoconnect_send_concurrently_async.json b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_no_recovery_no_connect_async.pyTestWebpubsubClientNoRecoveryNoReconnectAsynctest_disable_recovery_and_autoconnect_send_concurrently_async.json deleted file mode 100644 index 171b351dad53..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_no_recovery_no_connect_async.pyTestWebpubsubClientNoRecoveryNoReconnectAsynctest_disable_recovery_and_autoconnect_send_concurrently_async.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "Entries": [ - { - "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&minutesToExpire=60&clientType=Default", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "*/*", - "Content-Length": "0", - "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" - }, - "RequestBody": null, - "StatusCode": 200, - "ResponseHeaders": { - "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", - "Connection": "keep-alive", - "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 27 Apr 2026 03:23:59 GMT", - "Strict-Transport-Security": "max-age=31536000; includeSubDomains", - "Transfer-Encoding": "chunked" - }, - "ResponseBody": { - "token": "Sanitized" - } - } - ], - "Variables": {} -} diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_recovery.pyTestWebpubsubClientRecoverytest_recovery.json b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_recovery.pyTestWebpubsubClientRecoverytest_recovery.json deleted file mode 100644 index afed6a67f487..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_recovery.pyTestWebpubsubClientRecoverytest_recovery.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "Entries": [ - { - "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&clientType=Default", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "*/*", - "Connection": "keep-alive", - "Content-Length": "0", - "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" - }, - "RequestBody": null, - "StatusCode": 200, - "ResponseHeaders": { - "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", - "Connection": "keep-alive", - "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 27 Apr 2026 03:24:08 GMT", - "Strict-Transport-Security": "max-age=31536000; includeSubDomains", - "Transfer-Encoding": "chunked" - }, - "ResponseBody": { - "token": "Sanitized" - } - } - ], - "Variables": {} -} diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_recovery_async.pyTestWebpubsubClientRecoveryAsynctest_recovery_async.json b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_recovery_async.pyTestWebpubsubClientRecoveryAsynctest_recovery_async.json deleted file mode 100644 index ed97d6e9fa00..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_recovery_async.pyTestWebpubsubClientRecoveryAsynctest_recovery_async.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "Entries": [ - { - "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&minutesToExpire=60&clientType=Default", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "*/*", - "Content-Length": "0", - "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" - }, - "RequestBody": null, - "StatusCode": 200, - "ResponseHeaders": { - "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", - "Connection": "keep-alive", - "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 27 Apr 2026 03:24:13 GMT", - "Strict-Transport-Security": "max-age=31536000; includeSubDomains", - "Transfer-Encoding": "chunked" - }, - "ResponseBody": { - "token": "Sanitized" - } - } - ], - "Variables": {} -} diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_send_concurrently.pyTestWebpubsubClientSendConcurrentlytest_send_concurrently.json b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_send_concurrently.pyTestWebpubsubClientSendConcurrentlytest_send_concurrently.json deleted file mode 100644 index dd809f746d73..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_send_concurrently.pyTestWebpubsubClientSendConcurrentlytest_send_concurrently.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "Entries": [ - { - "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&clientType=Default", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "*/*", - "Connection": "keep-alive", - "Content-Length": "0", - "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" - }, - "RequestBody": null, - "StatusCode": 200, - "ResponseHeaders": { - "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", - "Connection": "keep-alive", - "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 27 Apr 2026 03:24:20 GMT", - "Strict-Transport-Security": "max-age=31536000; includeSubDomains", - "Transfer-Encoding": "chunked" - }, - "ResponseBody": { - "token": "Sanitized" - } - } - ], - "Variables": {} -} diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_send_concurrently_async.pyTestWebpubsubClientSendConcurrentlyAsynctest_send_concurrently_async.json b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_send_concurrently_async.pyTestWebpubsubClientSendConcurrentlyAsynctest_send_concurrently_async.json deleted file mode 100644 index 51b80fbff55d..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_send_concurrently_async.pyTestWebpubsubClientSendConcurrentlyAsynctest_send_concurrently_async.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "Entries": [ - { - "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&minutesToExpire=60&clientType=Default", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "*/*", - "Content-Length": "0", - "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" - }, - "RequestBody": null, - "StatusCode": 200, - "ResponseHeaders": { - "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", - "Connection": "keep-alive", - "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 27 Apr 2026 03:24:24 GMT", - "Strict-Transport-Security": "max-age=31536000; includeSubDomains", - "Transfer-Encoding": "chunked" - }, - "ResponseBody": { - "token": "Sanitized" - } - } - ], - "Variables": {} -} diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_call_back_deadlock.json b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_call_back_deadlock.json deleted file mode 100644 index e4a81703fe1a..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_call_back_deadlock.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "Entries": [ - { - "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&clientType=Default", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "*/*", - "Connection": "keep-alive", - "Content-Length": "0", - "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" - }, - "RequestBody": null, - "StatusCode": 200, - "ResponseHeaders": { - "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", - "Connection": "keep-alive", - "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 27 Apr 2026 03:24:27 GMT", - "Strict-Transport-Security": "max-age=31536000; includeSubDomains", - "Transfer-Encoding": "chunked" - }, - "ResponseBody": { - "token": "Sanitized" - } - } - ], - "Variables": {} -} diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_context_manager.json b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_context_manager.json deleted file mode 100644 index f45b37814fd4..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_context_manager.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "Entries": [ - { - "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&clientType=Default", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "*/*", - "Connection": "keep-alive", - "Content-Length": "0", - "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" - }, - "RequestBody": null, - "StatusCode": 200, - "ResponseHeaders": { - "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", - "Connection": "keep-alive", - "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 27 Apr 2026 03:24:32 GMT", - "Strict-Transport-Security": "max-age=31536000; includeSubDomains", - "Transfer-Encoding": "chunked" - }, - "ResponseBody": { - "token": "Sanitized" - } - } - ], - "Variables": {} -} diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_duplicated_start.json b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_duplicated_start.json deleted file mode 100644 index 1403eb15ae33..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_duplicated_start.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "Entries": [ - { - "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&clientType=Default", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "*/*", - "Connection": "keep-alive", - "Content-Length": "0", - "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" - }, - "RequestBody": null, - "StatusCode": 200, - "ResponseHeaders": { - "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", - "Connection": "keep-alive", - "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 27 Apr 2026 03:24:47 GMT", - "Strict-Transport-Security": "max-age=31536000; includeSubDomains", - "Transfer-Encoding": "chunked" - }, - "ResponseBody": { - "token": "Sanitized" - } - } - ], - "Variables": {} -} diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_duplicated_stop.json b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_duplicated_stop.json deleted file mode 100644 index e7f9152f4289..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_duplicated_stop.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "Entries": [ - { - "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&clientType=Default", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "*/*", - "Connection": "keep-alive", - "Content-Length": "0", - "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" - }, - "RequestBody": null, - "StatusCode": 200, - "ResponseHeaders": { - "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", - "Connection": "keep-alive", - "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 27 Apr 2026 03:24:49 GMT", - "Strict-Transport-Security": "max-age=31536000; includeSubDomains", - "Transfer-Encoding": "chunked" - }, - "ResponseBody": { - "token": "Sanitized" - } - } - ], - "Variables": {} -} diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_on_stop.json b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_on_stop.json deleted file mode 100644 index f467f72a2a15..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_on_stop.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "Entries": [ - { - "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&clientType=Default", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "*/*", - "Connection": "keep-alive", - "Content-Length": "0", - "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" - }, - "RequestBody": null, - "StatusCode": 200, - "ResponseHeaders": { - "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", - "Connection": "keep-alive", - "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 27 Apr 2026 03:24:37 GMT", - "Strict-Transport-Security": "max-age=31536000; includeSubDomains", - "Transfer-Encoding": "chunked" - }, - "ResponseBody": { - "token": "Sanitized" - } - }, - { - "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&clientType=Default", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "*/*", - "Connection": "keep-alive", - "Content-Length": "0", - "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" - }, - "RequestBody": null, - "StatusCode": 200, - "ResponseHeaders": { - "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", - "Connection": "keep-alive", - "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 27 Apr 2026 03:24:39 GMT", - "Strict-Transport-Security": "max-age=31536000; includeSubDomains", - "Transfer-Encoding": "chunked" - }, - "ResponseBody": { - "token": "Sanitized" - } - } - ], - "Variables": {} -} diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_open_client_error.json b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_open_client_error.json deleted file mode 100644 index f721723386d8..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_open_client_error.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "Entries": [], - "Variables": {} -} diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_rejoin_group.json b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_rejoin_group.json deleted file mode 100644 index 6cdf87cce795..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_rejoin_group.json +++ /dev/null @@ -1,97 +0,0 @@ -{ - "Entries": [ - { - "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&clientType=Default", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "*/*", - "Connection": "keep-alive", - "Content-Length": "0", - "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" - }, - "RequestBody": null, - "StatusCode": 200, - "ResponseHeaders": { - "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", - "Connection": "keep-alive", - "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 27 Apr 2026 03:24:55 GMT", - "Strict-Transport-Security": "max-age=31536000; includeSubDomains", - "Transfer-Encoding": "chunked" - }, - "ResponseBody": { - "token": "Sanitized" - } - }, - { - "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&clientType=Default", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "*/*", - "Connection": "keep-alive", - "Content-Length": "0", - "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" - }, - "RequestBody": null, - "StatusCode": 200, - "ResponseHeaders": { - "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", - "Connection": "keep-alive", - "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 27 Apr 2026 03:24:57 GMT", - "Strict-Transport-Security": "max-age=31536000; includeSubDomains", - "Transfer-Encoding": "chunked" - }, - "ResponseBody": { - "token": "Sanitized" - } - }, - { - "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&clientType=Default", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "*/*", - "Connection": "keep-alive", - "Content-Length": "0", - "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" - }, - "RequestBody": null, - "StatusCode": 200, - "ResponseHeaders": { - "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", - "Connection": "keep-alive", - "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 27 Apr 2026 03:25:02 GMT", - "Strict-Transport-Security": "max-age=31536000; includeSubDomains", - "Transfer-Encoding": "chunked" - }, - "ResponseBody": { - "token": "Sanitized" - } - }, - { - "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&clientType=Default", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "*/*", - "Connection": "keep-alive", - "Content-Length": "0", - "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" - }, - "RequestBody": null, - "StatusCode": 200, - "ResponseHeaders": { - "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", - "Connection": "keep-alive", - "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 27 Apr 2026 03:25:04 GMT", - "Strict-Transport-Security": "max-age=31536000; includeSubDomains", - "Transfer-Encoding": "chunked" - }, - "ResponseBody": { - "token": "Sanitized" - } - } - ], - "Variables": {} -} diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_send_event.json b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_send_event.json deleted file mode 100644 index 4971971560df..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke.pyTestWebpubsubClientSmoketest_send_event.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "Entries": [ - { - "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&clientType=Default", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "*/*", - "Connection": "keep-alive", - "Content-Length": "0", - "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" - }, - "RequestBody": null, - "StatusCode": 200, - "ResponseHeaders": { - "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", - "Connection": "keep-alive", - "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 27 Apr 2026 03:24:52 GMT", - "Strict-Transport-Security": "max-age=31536000; includeSubDomains", - "Transfer-Encoding": "chunked" - }, - "ResponseBody": { - "token": "Sanitized" - } - } - ], - "Variables": {} -} diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_call_back_deadlock_async.json b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_call_back_deadlock_async.json deleted file mode 100644 index a838a53ccafe..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_call_back_deadlock_async.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "Entries": [ - { - "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&minutesToExpire=60&clientType=Default", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "*/*", - "Content-Length": "0", - "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" - }, - "RequestBody": null, - "StatusCode": 200, - "ResponseHeaders": { - "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", - "Connection": "keep-alive", - "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 27 Apr 2026 03:25:09 GMT", - "Strict-Transport-Security": "max-age=31536000; includeSubDomains", - "Transfer-Encoding": "chunked" - }, - "ResponseBody": { - "token": "Sanitized" - } - } - ], - "Variables": {} -} diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_context_manager_async.json b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_context_manager_async.json deleted file mode 100644 index 759b35a4fa30..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_context_manager_async.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "Entries": [ - { - "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&minutesToExpire=60&clientType=Default", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "*/*", - "Content-Length": "0", - "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" - }, - "RequestBody": null, - "StatusCode": 200, - "ResponseHeaders": { - "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", - "Connection": "keep-alive", - "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 27 Apr 2026 03:25:14 GMT", - "Strict-Transport-Security": "max-age=31536000; includeSubDomains", - "Transfer-Encoding": "chunked" - }, - "ResponseBody": { - "token": "Sanitized" - } - } - ], - "Variables": {} -} diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_duplicated_start_async.json b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_duplicated_start_async.json deleted file mode 100644 index 6e8bb4168128..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_duplicated_start_async.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "Entries": [ - { - "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&minutesToExpire=60&clientType=Default", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "*/*", - "Content-Length": "0", - "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" - }, - "RequestBody": null, - "StatusCode": 200, - "ResponseHeaders": { - "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", - "Connection": "keep-alive", - "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 27 Apr 2026 03:25:29 GMT", - "Strict-Transport-Security": "max-age=31536000; includeSubDomains", - "Transfer-Encoding": "chunked" - }, - "ResponseBody": { - "token": "Sanitized" - } - } - ], - "Variables": {} -} diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_duplicated_stop_async.json b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_duplicated_stop_async.json deleted file mode 100644 index f6fd3dfa655c..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_duplicated_stop_async.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "Entries": [ - { - "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&minutesToExpire=60&clientType=Default", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "*/*", - "Content-Length": "0", - "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" - }, - "RequestBody": null, - "StatusCode": 200, - "ResponseHeaders": { - "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", - "Connection": "keep-alive", - "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 27 Apr 2026 03:25:32 GMT", - "Strict-Transport-Security": "max-age=31536000; includeSubDomains", - "Transfer-Encoding": "chunked" - }, - "ResponseBody": { - "token": "Sanitized" - } - } - ], - "Variables": {} -} diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_on_stop_async.json b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_on_stop_async.json deleted file mode 100644 index 4d873e38e8f4..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_on_stop_async.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "Entries": [ - { - "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&minutesToExpire=60&clientType=Default", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "*/*", - "Content-Length": "0", - "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" - }, - "RequestBody": null, - "StatusCode": 200, - "ResponseHeaders": { - "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", - "Connection": "keep-alive", - "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 27 Apr 2026 03:25:19 GMT", - "Strict-Transport-Security": "max-age=31536000; includeSubDomains", - "Transfer-Encoding": "chunked" - }, - "ResponseBody": { - "token": "Sanitized" - } - }, - { - "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&minutesToExpire=60&clientType=Default", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "*/*", - "Content-Length": "0", - "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" - }, - "RequestBody": null, - "StatusCode": 200, - "ResponseHeaders": { - "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", - "Connection": "keep-alive", - "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 27 Apr 2026 03:25:22 GMT", - "Strict-Transport-Security": "max-age=31536000; includeSubDomains", - "Transfer-Encoding": "chunked" - }, - "ResponseBody": { - "token": "Sanitized" - } - } - ], - "Variables": {} -} diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_open_client_error_async.json b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_open_client_error_async.json deleted file mode 100644 index f721723386d8..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_open_client_error_async.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "Entries": [], - "Variables": {} -} diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_rejoin_group_async.json b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_rejoin_group_async.json deleted file mode 100644 index c2cdaeeb0a95..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_rejoin_group_async.json +++ /dev/null @@ -1,93 +0,0 @@ -{ - "Entries": [ - { - "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&minutesToExpire=60&clientType=Default", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "*/*", - "Content-Length": "0", - "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" - }, - "RequestBody": null, - "StatusCode": 200, - "ResponseHeaders": { - "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", - "Connection": "keep-alive", - "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 27 Apr 2026 03:25:39 GMT", - "Strict-Transport-Security": "max-age=31536000; includeSubDomains", - "Transfer-Encoding": "chunked" - }, - "ResponseBody": { - "token": "Sanitized" - } - }, - { - "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&minutesToExpire=60&clientType=Default", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "*/*", - "Content-Length": "0", - "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" - }, - "RequestBody": null, - "StatusCode": 200, - "ResponseHeaders": { - "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", - "Connection": "keep-alive", - "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 27 Apr 2026 03:25:42 GMT", - "Strict-Transport-Security": "max-age=31536000; includeSubDomains", - "Transfer-Encoding": "chunked" - }, - "ResponseBody": { - "token": "Sanitized" - } - }, - { - "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&minutesToExpire=60&clientType=Default", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "*/*", - "Content-Length": "0", - "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" - }, - "RequestBody": null, - "StatusCode": 200, - "ResponseHeaders": { - "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", - "Connection": "keep-alive", - "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 27 Apr 2026 03:25:47 GMT", - "Strict-Transport-Security": "max-age=31536000; includeSubDomains", - "Transfer-Encoding": "chunked" - }, - "ResponseBody": { - "token": "Sanitized" - } - }, - { - "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&minutesToExpire=60&clientType=Default", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "*/*", - "Content-Length": "0", - "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" - }, - "RequestBody": null, - "StatusCode": 200, - "ResponseHeaders": { - "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", - "Connection": "keep-alive", - "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 27 Apr 2026 03:25:50 GMT", - "Strict-Transport-Security": "max-age=31536000; includeSubDomains", - "Transfer-Encoding": "chunked" - }, - "ResponseBody": { - "token": "Sanitized" - } - } - ], - "Variables": {} -} diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_send_event_async.json b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_send_event_async.json deleted file mode 100644 index 718ed736c773..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/recordings/test_smoke_async.pyTestWebpubsubClientSmokeAsynctest_send_event_async.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "Entries": [ - { - "RequestUri": "https://Sanitized.webpubsub.azure.com/api/hubs/Hub/:generateToken?api-version=2024-12-01&role=webpubsub.joinLeaveGroup&role=webpubsub.sendToGroup&minutesToExpire=60&clientType=Default", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "*/*", - "Content-Length": "0", - "User-Agent": "azsdk-python-messaging-webpubsubservice/1.3.0 Python/3.14.4 (Windows-11-10.0.26200-SP0)" - }, - "RequestBody": null, - "StatusCode": 200, - "ResponseHeaders": { - "api-supported-versions": "2021-10-01, 2022-11-01, 2023-07-01, 2024-01-01, 2024-12-01", - "Connection": "keep-alive", - "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 27 Apr 2026 03:25:36 GMT", - "Strict-Transport-Security": "max-age=31536000; includeSubDomains", - "Transfer-Encoding": "chunked" - }, - "ResponseBody": { - "token": "Sanitized" - } - } - ], - "Variables": {} -} diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_no_recovery_no_connect.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_no_recovery_no_connect.py index 40d1e960e7fb..a8425074ce28 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_no_recovery_no_connect.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_no_recovery_no_connect.py @@ -37,6 +37,11 @@ def test_disable_recovery_and_autoconnect(self, webpubsubclient_endpoint): client.subscribe("group-message", on_group_message) client.join_group(group_name) client._ws.sock.close(1001) # close connection + # wait for client to detect disconnection so send raises SendMessageError + for _ in range(30): + if not client.is_connected(): + break + time.sleep(1) with pytest.raises(SendMessageError): client.send_to_group(group_name, name, "text") time.sleep(3) # wait to confirm message was NOT received diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_no_recovery_no_connect_async.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_no_recovery_no_connect_async.py index 99e4516d0cff..70055eb43201 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_no_recovery_no_connect_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_no_recovery_no_connect_async.py @@ -32,6 +32,11 @@ async def test_disable_recovery_and_autoconnect_async(self, webpubsubclient_endp await client.subscribe("group-message", on_group_message) await client.join_group(group_name) await client._ws.session.close() # close connection + # wait for client to detect disconnection so send raises SendMessageError + for _ in range(30): + if not client.is_connected(): + break + await asyncio.sleep(1) with pytest.raises(SendMessageError): await client.send_to_group(group_name, name, "text") await asyncio.sleep(3) # wait to confirm message was NOT received diff --git a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_list_connections_async.py b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_list_connections_async.py index 0f222e67547a..19358346116a 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_list_connections_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_list_connections_async.py @@ -4,6 +4,7 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # ------------------------------------------------------------------------- +import asyncio import pytest from websockets import connect as ws_connect from testcase import WebpubsubPowerShellPreparer diff --git a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_live_api_coverage.py b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_live_api_coverage.py index 297dd68ec847..e55c212b7de5 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_live_api_coverage.py +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_live_api_coverage.py @@ -165,6 +165,7 @@ def test_live_api_coverage_all_apis_and_parameters(self, webpubsub_endpoint, web # close_group_connections (connection auto-joins group_1 via token) ws.close() + time.sleep(2) # wait for server to finish cleaning up before reconnecting ws = ws_connect(access_token["url"], open_timeout=30) conn = self._find_connection_id(client, group_1, user_id) assert conn is not None @@ -176,6 +177,7 @@ def test_live_api_coverage_all_apis_and_parameters(self, webpubsub_endpoint, web assert not client.connection_exists(connection_id=conn) # close_user_connections + time.sleep(2) ws = ws_connect(access_token["url"], open_timeout=30) conn = self._find_connection_id(client, group_1, user_id) assert conn is not None @@ -187,6 +189,7 @@ def test_live_api_coverage_all_apis_and_parameters(self, webpubsub_endpoint, web assert not client.connection_exists(connection_id=conn) # close_connection + time.sleep(2) ws = ws_connect(access_token["url"], open_timeout=30) conn = self._find_connection_id(client, group_1, user_id) assert conn is not None @@ -198,6 +201,7 @@ def test_live_api_coverage_all_apis_and_parameters(self, webpubsub_endpoint, web assert not client.connection_exists(connection_id=conn) # close_all_connections + time.sleep(2) ws = ws_connect(access_token["url"], open_timeout=30) conn = self._find_connection_id(client, group_1, user_id) assert conn is not None diff --git a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_live_api_coverage_async.py b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_live_api_coverage_async.py index 99f1a3474fe7..9c0c77e28b96 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_live_api_coverage_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_live_api_coverage_async.py @@ -195,7 +195,8 @@ async def test_live_api_coverage_all_apis_and_parameters_async( # close_group_connections (connection auto-joins group_1 via token) await ws.close() - ws = await ws_connect(access_token["url"]) + await asyncio.sleep(2) # wait for server to finish cleaning up before reconnecting + ws = await ws_connect(access_token["url"], open_timeout=30) conn = await self._find_connection_id(client, group_1, user_id) assert conn is not None await client.close_group_connections(group=group_1, reason="live-coverage") @@ -206,7 +207,8 @@ async def test_live_api_coverage_all_apis_and_parameters_async( assert not await client.connection_exists(connection_id=conn) # close_user_connections - ws = await ws_connect(access_token["url"]) + await asyncio.sleep(2) + ws = await ws_connect(access_token["url"], open_timeout=30) conn = await self._find_connection_id(client, group_1, user_id) assert conn is not None await client.close_user_connections(user_id=user_id, reason="live-coverage") @@ -217,7 +219,8 @@ async def test_live_api_coverage_all_apis_and_parameters_async( assert not await client.connection_exists(connection_id=conn) # close_connection - ws = await ws_connect(access_token["url"]) + await asyncio.sleep(2) + ws = await ws_connect(access_token["url"], open_timeout=30) conn = await self._find_connection_id(client, group_1, user_id) assert conn is not None await client.close_connection(connection_id=conn, reason="live-coverage") @@ -228,7 +231,8 @@ async def test_live_api_coverage_all_apis_and_parameters_async( assert not await client.connection_exists(connection_id=conn) # close_all_connections - ws = await ws_connect(access_token["url"]) + await asyncio.sleep(2) + ws = await ws_connect(access_token["url"], open_timeout=30) conn = await self._find_connection_id(client, group_1, user_id) assert conn is not None await client.close_all_connections(reason="live-coverage") From ae7e3bdb907d8f81421e89e48082e358b4d41e05 Mon Sep 17 00:00:00 2001 From: shiyingchen Date: Tue, 28 Apr 2026 15:50:08 +0800 Subject: [PATCH 11/20] fix timing issue Co-authored-by: Copilot --- .../tests/test_smoke.py | 10 ++++++++-- .../tests/test_smoke_async.py | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke.py index 614d46561adf..61407b14e38b 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke.py @@ -61,9 +61,14 @@ def test_context_manager(self, webpubsubclient_endpoint): @recorded_by_proxy def test_on_stop(self, webpubsubclient_endpoint): client = self.create_client(endpoint=webpubsubclient_endpoint) + reopen_error = None def on_stop(): - client.open() + nonlocal reopen_error + try: + client.open() + except Exception as e: + reopen_error = e with client: # open client again after close @@ -75,10 +80,11 @@ def on_stop(): assert client.is_connected() client.close() # wait for on_stop callback to reconnect - for _ in range(30): + for _ in range(60): if client.is_connected(): break time.sleep(1) + assert reopen_error is None, f"on_stop callback failed: {reopen_error}" assert client.is_connected() # remove stopped event and close again diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke_async.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke_async.py index 090f68d36c7c..aa2116bdc874 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke_async.py @@ -61,9 +61,14 @@ async def test_context_manager_async(self, webpubsubclient_endpoint): @recorded_by_proxy_async async def test_on_stop_async(self, webpubsubclient_endpoint): client = await self.create_client(endpoint=webpubsubclient_endpoint) + reopen_error = None async def on_stop(): - await client.open() + nonlocal reopen_error + try: + await client.open() + except Exception as e: + reopen_error = e async with client: # open client again after close @@ -75,10 +80,11 @@ async def on_stop(): assert client.is_connected() await client.close() # wait for on_stop callback to reconnect - for _ in range(30): + for _ in range(60): if client.is_connected(): break await asyncio.sleep(1) + assert reopen_error is None, f"on_stop callback failed: {reopen_error}" assert client.is_connected() # remove stopped event and close again From 658de4f02c8a128708411a328f9d395ec3e526bf Mon Sep 17 00:00:00 2001 From: shiyingchen Date: Tue, 28 Apr 2026 17:27:18 +0800 Subject: [PATCH 12/20] update tests Co-authored-by: Copilot --- .../tests/test_smoke.py | 12 ++++++----- .../tests/test_smoke_async.py | 10 +++++----- .../tests/test_live_api_coverage.py | 20 +++++++++++++++---- .../tests/test_live_api_coverage_async.py | 20 +++++++++++++++---- 4 files changed, 44 insertions(+), 18 deletions(-) diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke.py index 61407b14e38b..db547309c644 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke.py @@ -6,6 +6,7 @@ # ------------------------------------------------------------------------- from typing import List, Any import time +import threading import pytest from devtools_testutils import recorded_by_proxy from testcase import ( @@ -62,6 +63,7 @@ def test_context_manager(self, webpubsubclient_endpoint): def test_on_stop(self, webpubsubclient_endpoint): client = self.create_client(endpoint=webpubsubclient_endpoint) reopen_error = None + reopen_complete = threading.Event() def on_stop(): nonlocal reopen_error @@ -69,6 +71,8 @@ def on_stop(): client.open() except Exception as e: reopen_error = e + finally: + reopen_complete.set() with client: # open client again after close @@ -79,11 +83,9 @@ def on_stop(): time.sleep(1) assert client.is_connected() client.close() - # wait for on_stop callback to reconnect - for _ in range(60): - if client.is_connected(): - break - time.sleep(1) + # wait for on_stop callback to finish reopening + if not reopen_complete.wait(timeout=60): + pytest.fail("on_stop callback failed to complete within 60 seconds") assert reopen_error is None, f"on_stop callback failed: {reopen_error}" assert client.is_connected() diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke_async.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke_async.py index aa2116bdc874..f206d0459372 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke_async.py @@ -62,6 +62,7 @@ async def test_context_manager_async(self, webpubsubclient_endpoint): async def test_on_stop_async(self, webpubsubclient_endpoint): client = await self.create_client(endpoint=webpubsubclient_endpoint) reopen_error = None + reopen_complete = asyncio.Event() async def on_stop(): nonlocal reopen_error @@ -69,6 +70,8 @@ async def on_stop(): await client.open() except Exception as e: reopen_error = e + finally: + reopen_complete.set() async with client: # open client again after close @@ -79,11 +82,8 @@ async def on_stop(): await asyncio.sleep(1) assert client.is_connected() await client.close() - # wait for on_stop callback to reconnect - for _ in range(60): - if client.is_connected(): - break - await asyncio.sleep(1) + # wait for on_stop callback to finish reopening + await asyncio.wait_for(reopen_complete.wait(), timeout=60) assert reopen_error is None, f"on_stop callback failed: {reopen_error}" assert client.is_connected() diff --git a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_live_api_coverage.py b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_live_api_coverage.py index e55c212b7de5..61ae8c78401e 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_live_api_coverage.py +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_live_api_coverage.py @@ -25,6 +25,18 @@ def _find_connection_id(self, client, group_name, user_id): time.sleep(1) return None + def _wait_for_server_cleanup(self, delay_seconds=2): + """ + Wait for server-side cleanup after closing a connection. + + The server needs time to process the disconnection before accepting new connections. + This is a pragmatic wait since we don't have a direct signal for when cleanup completes. + + Args: + delay_seconds: Time to wait in seconds (default 2 seconds for server cleanup) + """ + time.sleep(delay_seconds) + @WebpubsubPowerShellPreparer() @recorded_by_proxy def test_live_api_coverage_all_apis_and_parameters(self, webpubsub_endpoint, webpubsub_socketio_endpoint): @@ -165,7 +177,7 @@ def test_live_api_coverage_all_apis_and_parameters(self, webpubsub_endpoint, web # close_group_connections (connection auto-joins group_1 via token) ws.close() - time.sleep(2) # wait for server to finish cleaning up before reconnecting + self._wait_for_server_cleanup() ws = ws_connect(access_token["url"], open_timeout=30) conn = self._find_connection_id(client, group_1, user_id) assert conn is not None @@ -177,7 +189,7 @@ def test_live_api_coverage_all_apis_and_parameters(self, webpubsub_endpoint, web assert not client.connection_exists(connection_id=conn) # close_user_connections - time.sleep(2) + self._wait_for_server_cleanup() ws = ws_connect(access_token["url"], open_timeout=30) conn = self._find_connection_id(client, group_1, user_id) assert conn is not None @@ -189,7 +201,7 @@ def test_live_api_coverage_all_apis_and_parameters(self, webpubsub_endpoint, web assert not client.connection_exists(connection_id=conn) # close_connection - time.sleep(2) + self._wait_for_server_cleanup() ws = ws_connect(access_token["url"], open_timeout=30) conn = self._find_connection_id(client, group_1, user_id) assert conn is not None @@ -201,7 +213,7 @@ def test_live_api_coverage_all_apis_and_parameters(self, webpubsub_endpoint, web assert not client.connection_exists(connection_id=conn) # close_all_connections - time.sleep(2) + self._wait_for_server_cleanup() ws = ws_connect(access_token["url"], open_timeout=30) conn = self._find_connection_id(client, group_1, user_id) assert conn is not None diff --git a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_live_api_coverage_async.py b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_live_api_coverage_async.py index 9c0c77e28b96..a429317c1c3a 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_live_api_coverage_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_live_api_coverage_async.py @@ -27,6 +27,18 @@ async def _find_connection_id(self, client, group_name, user_id): await asyncio.sleep(1) return None + async def _wait_for_server_cleanup(self, delay_seconds=2): + """ + Wait for server-side cleanup after closing a connection. + + The server needs time to process the disconnection before accepting new connections. + This is a pragmatic wait since we don't have a direct signal for when cleanup completes. + + Args: + delay_seconds: Time to wait in seconds (default 2 seconds for server cleanup) + """ + await asyncio.sleep(delay_seconds) + @WebpubsubPowerShellPreparer() @recorded_by_proxy_async async def test_live_api_coverage_all_apis_and_parameters_async( @@ -195,7 +207,7 @@ async def test_live_api_coverage_all_apis_and_parameters_async( # close_group_connections (connection auto-joins group_1 via token) await ws.close() - await asyncio.sleep(2) # wait for server to finish cleaning up before reconnecting + await self._wait_for_server_cleanup() ws = await ws_connect(access_token["url"], open_timeout=30) conn = await self._find_connection_id(client, group_1, user_id) assert conn is not None @@ -207,7 +219,7 @@ async def test_live_api_coverage_all_apis_and_parameters_async( assert not await client.connection_exists(connection_id=conn) # close_user_connections - await asyncio.sleep(2) + await self._wait_for_server_cleanup() ws = await ws_connect(access_token["url"], open_timeout=30) conn = await self._find_connection_id(client, group_1, user_id) assert conn is not None @@ -219,7 +231,7 @@ async def test_live_api_coverage_all_apis_and_parameters_async( assert not await client.connection_exists(connection_id=conn) # close_connection - await asyncio.sleep(2) + await self._wait_for_server_cleanup() ws = await ws_connect(access_token["url"], open_timeout=30) conn = await self._find_connection_id(client, group_1, user_id) assert conn is not None @@ -231,7 +243,7 @@ async def test_live_api_coverage_all_apis_and_parameters_async( assert not await client.connection_exists(connection_id=conn) # close_all_connections - await asyncio.sleep(2) + await self._wait_for_server_cleanup() ws = await ws_connect(access_token["url"], open_timeout=30) conn = await self._find_connection_id(client, group_1, user_id) assert conn is not None From 917aa1037c7dc2d1a6cf4aa24af56302e131775a Mon Sep 17 00:00:00 2001 From: shiyingchen Date: Tue, 28 Apr 2026 18:02:36 +0800 Subject: [PATCH 13/20] retry Co-authored-by: Copilot --- .../tests/test_smoke.py | 21 ++++++++++++++++++- .../tests/test_smoke_async.py | 21 ++++++++++++++++++- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke.py index db547309c644..3693167066de 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke.py @@ -68,7 +68,21 @@ def test_on_stop(self, webpubsubclient_endpoint): def on_stop(): nonlocal reopen_error try: - client.open() + # close() can race with immediate reopen, so retry briefly before failing. + for _ in range(10): + try: + client.open() + break + except OpenClientError: + time.sleep(1) + else: + raise RuntimeError("Failed to reopen client in stopped callback") + + for _ in range(30): + if client.is_connected(): + break + time.sleep(1) + assert client.is_connected() except Exception as e: reopen_error = e finally: @@ -87,6 +101,11 @@ def on_stop(): if not reopen_complete.wait(timeout=60): pytest.fail("on_stop callback failed to complete within 60 seconds") assert reopen_error is None, f"on_stop callback failed: {reopen_error}" + + for _ in range(30): + if client.is_connected(): + break + time.sleep(1) assert client.is_connected() # remove stopped event and close again diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke_async.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke_async.py index f206d0459372..94583af2c919 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke_async.py @@ -67,7 +67,21 @@ async def test_on_stop_async(self, webpubsubclient_endpoint): async def on_stop(): nonlocal reopen_error try: - await client.open() + # close() can race with immediate reopen, so retry briefly before failing. + for _ in range(10): + try: + await client.open() + break + except OpenClientError: + await asyncio.sleep(1) + else: + raise RuntimeError("Failed to reopen client in stopped callback") + + for _ in range(30): + if client.is_connected(): + break + await asyncio.sleep(1) + assert client.is_connected() except Exception as e: reopen_error = e finally: @@ -85,6 +99,11 @@ async def on_stop(): # wait for on_stop callback to finish reopening await asyncio.wait_for(reopen_complete.wait(), timeout=60) assert reopen_error is None, f"on_stop callback failed: {reopen_error}" + + for _ in range(30): + if client.is_connected(): + break + await asyncio.sleep(1) assert client.is_connected() # remove stopped event and close again From f451f021cc7c9a062f8da2fd521cc149e1a7d482 Mon Sep 17 00:00:00 2001 From: shiyingchen Date: Tue, 28 Apr 2026 19:05:06 +0800 Subject: [PATCH 14/20] update Co-authored-by: Copilot --- .../azure-messaging-webpubsubclient/tests/test_smoke.py | 6 ------ .../tests/test_smoke_async.py | 6 ------ 2 files changed, 12 deletions(-) diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke.py index 3693167066de..701f65b03aa8 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke.py @@ -102,12 +102,6 @@ def on_stop(): pytest.fail("on_stop callback failed to complete within 60 seconds") assert reopen_error is None, f"on_stop callback failed: {reopen_error}" - for _ in range(30): - if client.is_connected(): - break - time.sleep(1) - assert client.is_connected() - # remove stopped event and close again client.unsubscribe("stopped", on_stop) client.close() diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke_async.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke_async.py index 94583af2c919..db9a63ceb3a9 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke_async.py @@ -100,12 +100,6 @@ async def on_stop(): await asyncio.wait_for(reopen_complete.wait(), timeout=60) assert reopen_error is None, f"on_stop callback failed: {reopen_error}" - for _ in range(30): - if client.is_connected(): - break - await asyncio.sleep(1) - assert client.is_connected() - # remove stopped event and close again await client.unsubscribe("stopped", on_stop) await client.close() From 25afc464c160bd8d0765c879ea3f12f7cdc99379 Mon Sep 17 00:00:00 2001 From: shiyingchen Date: Wed, 29 Apr 2026 09:40:38 +0800 Subject: [PATCH 15/20] fix sample Co-authored-by: Copilot --- .../samples/send_compare_between_async_sync.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/samples/send_compare_between_async_sync.py b/sdk/webpubsub/azure-messaging-webpubsubclient/samples/send_compare_between_async_sync.py index 7493a936719b..d681640af789 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/samples/send_compare_between_async_sync.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/samples/send_compare_between_async_sync.py @@ -84,7 +84,7 @@ async def send_async() -> None: if __name__ == "__main__": send() - asyncio.get_event_loop().run_until_complete(send_async()) + asyncio.run(send_async()) print( f"it takes {TIME_COST} seconds to send {MESSAGE_COUNT} messages with Sync API" ) From 8bfaa36539bb99e392b4a8bfed9d5d0d23f76695 Mon Sep 17 00:00:00 2001 From: shiyingchen Date: Thu, 30 Apr 2026 17:14:49 +0800 Subject: [PATCH 16/20] update for comments Co-authored-by: Copilot --- .../azure-messaging-webpubsubclient/tests/conftest.py | 3 ++- .../azure-messaging-webpubsubclient/tests/test_smoke.py | 5 +++++ .../samples/get_client_access_token.py | 2 +- .../samples/get_client_access_token_async.py | 2 +- .../samples/integration_sample.py | 2 +- .../samples/send_messages_aad.py | 2 +- .../samples/send_messages_aad_apim_proxy.py | 2 +- .../samples/send_messages_connection_string.py | 2 +- .../samples/send_messages_connection_string_apim_proxy.py | 2 +- .../azure-messaging-webpubsubservice/tests/test_smoke.py | 6 +++--- .../tests/test_smoke_async.py | 6 +++--- 11 files changed, 20 insertions(+), 14 deletions(-) diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/conftest.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/conftest.py index c0351cc98007..691a602ce80b 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/conftest.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/conftest.py @@ -24,6 +24,7 @@ # # -------------------------------------------------------------------------- import os +import re import pytest from dotenv import load_dotenv from devtools_testutils import test_proxy, add_general_regex_sanitizer @@ -34,6 +35,6 @@ def add_sanitizers(test_proxy): endpoint = os.environ.get("WEBPUBSUBCLIENT_ENDPOINT", "WEBPUBSUBCLIENT_ENDPOINT") add_general_regex_sanitizer( - regex=endpoint, + regex=re.escape(endpoint), value="https://myservice.webpubsub.azure.com", ) diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke.py index 701f65b03aa8..676be6dd984d 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke.py @@ -172,8 +172,13 @@ def _test(enable_auto_rejoin, test_group_name, assert_func): if assert_func(test_group_name): break time.sleep(1) + assert assert_func(test_group_name) + + _test( + enable_auto_rejoin=True, test_group_name="test_rejoin_group", assert_func=lambda x: x in TEST_RESULT, + ) _test( enable_auto_rejoin=False, test_group_name="test_disable_rejoin_group", diff --git a/sdk/webpubsub/azure-messaging-webpubsubservice/samples/get_client_access_token.py b/sdk/webpubsub/azure-messaging-webpubsubservice/samples/get_client_access_token.py index f190afa72bcd..573d07a91aeb 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubservice/samples/get_client_access_token.py +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/samples/get_client_access_token.py @@ -40,7 +40,7 @@ endpoint = os.environ["WEBPUBSUB_ENDPOINT"] except KeyError: LOG.error( - "Missing environment variable 'WEBPUBSUB_ENDPOINT' - please set if before running the example" + "Missing environment variable 'WEBPUBSUB_ENDPOINT' - please set it before running the example" ) exit() diff --git a/sdk/webpubsub/azure-messaging-webpubsubservice/samples/get_client_access_token_async.py b/sdk/webpubsub/azure-messaging-webpubsubservice/samples/get_client_access_token_async.py index ca9b07d7102c..2a1bb796f283 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubservice/samples/get_client_access_token_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/samples/get_client_access_token_async.py @@ -43,7 +43,7 @@ async def main(): endpoint = os.environ["WEBPUBSUB_ENDPOINT"] except KeyError: LOG.error( - "Missing environment variable 'WEBPUBSUB_ENDPOINT' - please set if before running the example" + "Missing environment variable 'WEBPUBSUB_ENDPOINT' - please set it before running the example" ) exit() diff --git a/sdk/webpubsub/azure-messaging-webpubsubservice/samples/integration_sample.py b/sdk/webpubsub/azure-messaging-webpubsubservice/samples/integration_sample.py index 89c021b36dea..aeec6a8baf04 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubservice/samples/integration_sample.py +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/samples/integration_sample.py @@ -118,7 +118,7 @@ def test_overall_integration(endpoint: str): endpoint = os.environ["WEBPUBSUB_ENDPOINT"] except KeyError: LOG.error( - "Missing environment variable 'WEBPUBSUB_ENDPOINT' - please set if before running the example" + "Missing environment variable 'WEBPUBSUB_ENDPOINT' - please set it before running the example" ) exit() diff --git a/sdk/webpubsub/azure-messaging-webpubsubservice/samples/send_messages_aad.py b/sdk/webpubsub/azure-messaging-webpubsubservice/samples/send_messages_aad.py index 59e01d85bd32..4bd171ff6cbc 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubservice/samples/send_messages_aad.py +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/samples/send_messages_aad.py @@ -40,7 +40,7 @@ try: endpoint = os.environ["WEBPUBSUB_ENDPOINT"] except KeyError: - LOG.error("Missing environment variable 'WEBPUBSUB_ENDPOINT' - please set if before running the example") + LOG.error("Missing environment variable 'WEBPUBSUB_ENDPOINT' - please set it before running the example") exit() # Build a client through AAD diff --git a/sdk/webpubsub/azure-messaging-webpubsubservice/samples/send_messages_aad_apim_proxy.py b/sdk/webpubsub/azure-messaging-webpubsubservice/samples/send_messages_aad_apim_proxy.py index 876404e0a58a..7eac3bee49f4 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubservice/samples/send_messages_aad_apim_proxy.py +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/samples/send_messages_aad_apim_proxy.py @@ -43,7 +43,7 @@ reverse_proxy_endpoint = os.environ["WEBPUBSUB_REVERSE_PROXY_ENDPOINT"] except KeyError: LOG.error( - "Missing environment variable 'WEBPUBSUB_ENDPOINT' or 'WEBPUBSUB_REVERSE_PROXY_ENDPOINT' - please set if before running the example" + "Missing environment variable 'WEBPUBSUB_ENDPOINT' or 'WEBPUBSUB_REVERSE_PROXY_ENDPOINT' - please set it before running the example" ) exit() diff --git a/sdk/webpubsub/azure-messaging-webpubsubservice/samples/send_messages_connection_string.py b/sdk/webpubsub/azure-messaging-webpubsubservice/samples/send_messages_connection_string.py index f43cffdd1f5a..48c7b8946d2f 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubservice/samples/send_messages_connection_string.py +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/samples/send_messages_connection_string.py @@ -38,7 +38,7 @@ try: endpoint = os.environ["WEBPUBSUB_ENDPOINT"] except KeyError: - LOG.error("Missing environment variable 'WEBPUBSUB_ENDPOINT' - please set if before running the example") + LOG.error("Missing environment variable 'WEBPUBSUB_ENDPOINT' - please set it before running the example") exit() # Build a client through AAD. And for this example, we have enabled debug diff --git a/sdk/webpubsub/azure-messaging-webpubsubservice/samples/send_messages_connection_string_apim_proxy.py b/sdk/webpubsub/azure-messaging-webpubsubservice/samples/send_messages_connection_string_apim_proxy.py index 0850c67f1a6a..f26900f99772 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubservice/samples/send_messages_connection_string_apim_proxy.py +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/samples/send_messages_connection_string_apim_proxy.py @@ -41,7 +41,7 @@ reverse_proxy_endpoint = os.environ["WEBPUBSUB_REVERSE_PROXY_ENDPOINT"] except KeyError: LOG.error( - "Missing environment variable 'WEBPUBSUB_ENDPOINT' or 'WEBPUBSUB_REVERSE_PROXY_ENDPOINT' - please set if before running the example" + "Missing environment variable 'WEBPUBSUB_ENDPOINT' or 'WEBPUBSUB_REVERSE_PROXY_ENDPOINT' - please set it before running the example" ) exit() diff --git a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_smoke.py b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_smoke.py index 6230c603d1b1..fd733a26fd4d 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_smoke.py +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_smoke.py @@ -70,19 +70,19 @@ def test_get_client_access_token(self, webpubsub_endpoint): @WebpubsubPowerShellPreparer() @recorded_by_proxy - def test_hello_world_with_connection_string(self, webpubsub_endpoint): + def test_hello_world(self, webpubsub_endpoint): client = self.create_client(endpoint=webpubsub_endpoint, hub="hub") client.send_to_all(message="Hello, World!", content_type="text/plain") @WebpubsubPowerShellPreparer() @recorded_by_proxy - def test_hello_world_with_connection_string_json(self, webpubsub_endpoint): + def test_hello_world_json(self, webpubsub_endpoint): client = self.create_client(endpoint=webpubsub_endpoint, hub="hub") client.send_to_all(message={"hello": "world!"}) @WebpubsubPowerShellPreparer() @recorded_by_proxy - def test_hello_world_with_connection_string_binary(self, webpubsub_endpoint): + def test_hello_world_binary(self, webpubsub_endpoint): client = self.create_client(endpoint=webpubsub_endpoint, hub="hub") client.send_to_all(message=b"Hello, World!", content_type="application/octet-stream") diff --git a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_smoke_async.py b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_smoke_async.py index d89b59acc0e9..7ee810cd1d73 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_smoke_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_smoke_async.py @@ -38,19 +38,19 @@ async def test_get_client_access_token(self, webpubsub_endpoint): @WebpubsubPowerShellPreparer() @recorded_by_proxy_async - async def test_hello_world_with_connection_string(self, webpubsub_endpoint): + async def test_hello_world(self, webpubsub_endpoint): client = self.create_client(endpoint=webpubsub_endpoint, hub="hub") await client.send_to_all(message="Hello, World!", content_type="text/plain") @WebpubsubPowerShellPreparer() @recorded_by_proxy_async - async def test_hello_world_with_connection_string_json(self, webpubsub_endpoint): + async def test_hello_world_json(self, webpubsub_endpoint): client = self.create_client(endpoint=webpubsub_endpoint, hub="hub") await client.send_to_all(message={"hello": "world!"}) @WebpubsubPowerShellPreparer() @recorded_by_proxy_async - async def test_hello_world_with_connection_string_binary(self, webpubsub_endpoint): + async def test_hello_world_binary(self, webpubsub_endpoint): client = self.create_client(endpoint=webpubsub_endpoint, hub="hub") await client.send_to_all(message=b"Hello, World!", content_type="application/octet-stream") From 32fb1b1788b319211731ec701d17df9a03e39a7b Mon Sep 17 00:00:00 2001 From: shiyingchen Date: Wed, 6 May 2026 11:36:02 +0800 Subject: [PATCH 17/20] update test recordings --- sdk/webpubsub/azure-messaging-webpubsubservice/assets.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/webpubsub/azure-messaging-webpubsubservice/assets.json b/sdk/webpubsub/azure-messaging-webpubsubservice/assets.json index f0e9d9f02012..9d7bf5ac45a4 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubservice/assets.json +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "python", "TagPrefix": "python/webpubsub/azure-messaging-webpubsubservice", - "Tag": "python/webpubsub/azure-messaging-webpubsubservice_447df314c8" + "Tag": "python/webpubsub/azure-messaging-webpubsubservice_752b7f1c61" } From 4435aa5b629f5affadef58cb16136f4460b17a84 Mon Sep 17 00:00:00 2001 From: shiyingchen Date: Wed, 6 May 2026 14:54:22 +0800 Subject: [PATCH 18/20] use event-based signaling --- .../tests/conftest.py | 12 ++++++ .../tests/test_auto_connect.py | 27 ++++--------- .../tests/test_auto_connect_async.py | 30 ++++---------- .../tests/test_no_recovery_no_connect.py | 15 ++++--- .../test_no_recovery_no_connect_async.py | 10 ++++- .../tests/test_recovery.py | 21 +++------- .../tests/test_recovery_async.py | 20 +++------- .../tests/test_send_concurrently_async.py | 4 ++ .../tests/test_smoke.py | 28 +++++-------- .../tests/test_smoke_async.py | 28 ++++++------- .../tests/testcase.py | 33 ++++++++++++++- .../tests/testcase_async.py | 40 ++++++++++++++++++- 12 files changed, 151 insertions(+), 117 deletions(-) diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/conftest.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/conftest.py index 691a602ce80b..fc3b351ea3ee 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/conftest.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/conftest.py @@ -28,9 +28,21 @@ import pytest from dotenv import load_dotenv from devtools_testutils import test_proxy, add_general_regex_sanitizer +from testcase import TEST_RESULT +from testcase_async import TEST_RESULT_ASYNC load_dotenv() + +@pytest.fixture(autouse=True) +def clear_test_results(): + TEST_RESULT.clear() + TEST_RESULT_ASYNC.clear() + yield + TEST_RESULT.clear() + TEST_RESULT_ASYNC.clear() + + @pytest.fixture(scope="session", autouse=True) def add_sanitizers(test_proxy): endpoint = os.environ.get("WEBPUBSUBCLIENT_ENDPOINT", "WEBPUBSUBCLIENT_ENDPOINT") diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_auto_connect.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_auto_connect.py index aab466dd4226..2e711b2f437e 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_auto_connect.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_auto_connect.py @@ -4,10 +4,9 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # ------------------------------------------------------------------------- -import time import pytest from devtools_testutils import recorded_by_proxy -from testcase import WebpubsubClientTest, WebpubsubClientPowerShellPreparer, TEST_RESULT, on_group_message +from testcase import WebpubsubClientTest, WebpubsubClientPowerShellPreparer, TEST_RESULT from azure.messaging.webpubsubclient.models import WebPubSubProtocolType @@ -26,28 +25,16 @@ def test_auto_connect(self, webpubsubclient_endpoint): reconnect_retry_backoff_factor=0.1, ) name = "test_auto_connect" + connected_event, message_event = self.setup_events(client) with client: - # wait for connection_id to be updated - for _ in range(30): - if client._connection_id is not None: - break - time.sleep(1) + assert connected_event.wait(timeout=30), "Timed out waiting for initial connection" conn_id0 = client._connection_id - group_name = name - client.subscribe("group-message", on_group_message) - client.join_group(group_name) + client.join_group(name) + connected_event.clear() # reset for reconnection detection client._ws.sock.close(1001) # close the connection to trigger auto connect # wait for reconnect - for _ in range(30): - if client.is_connected() and client._connection_id != conn_id0: - break - time.sleep(1) - # retry send_to_group to allow async group rejoin to complete - for _ in range(10): - client.send_to_group(group_name, name, "text") - time.sleep(1) - if name in TEST_RESULT: - break + assert connected_event.wait(timeout=30), "Timed out waiting for reconnection" + self.retry_send_until_message(client, name, name, message_event, retries=10) conn_id1 = client._connection_id assert conn_id0 is not None assert conn_id1 is not None diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_auto_connect_async.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_auto_connect_async.py index 494556044bc8..ee977b44bdaa 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_auto_connect_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_auto_connect_async.py @@ -7,7 +7,7 @@ import asyncio import pytest from devtools_testutils.aio import recorded_by_proxy_async -from testcase_async import WebpubsubClientTestAsync, TEST_RESULT_ASYNC, on_group_message +from testcase_async import WebpubsubClientTestAsync, TEST_RESULT_ASYNC from testcase import WebpubsubClientPowerShellPreparer from azure.messaging.webpubsubclient.models import WebPubSubProtocolType @@ -26,30 +26,16 @@ async def test_auto_connect_async(self, webpubsubclient_endpoint): reconnect_retry_backoff_factor=0.1, ) name = "test_auto_connect_async" + connected_event, message_event = await self.setup_events(client) async with client: - # wait for connection_id to be updated - for _ in range(30): - if client._connection_id is not None: - break - await asyncio.sleep(1) + await asyncio.wait_for(connected_event.wait(), timeout=30) conn_id0 = client._connection_id - group_name = name - await client.subscribe("group-message", on_group_message) - await client.join_group(group_name) - await client._ws.sock.close( - code=1001 - ) # close the connection to trigger auto connect + await client.join_group(name) + connected_event.clear() # reset for reconnection detection + await client._ws.sock.close(code=1001) # close the connection to trigger auto connect # wait for reconnect - for _ in range(30): - if client.is_connected() and client._connection_id != conn_id0: - break - await asyncio.sleep(1) - await client.send_to_group(group_name, name, "text") - # wait for on_group_message callback to fire - for _ in range(10): - if name in TEST_RESULT_ASYNC: - break - await asyncio.sleep(1) + await asyncio.wait_for(connected_event.wait(), timeout=30) + await self.retry_send_until_message(client, name, name, message_event, retries=10) conn_id1 = client._connection_id assert conn_id0 is not None assert conn_id1 is not None diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_no_recovery_no_connect.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_no_recovery_no_connect.py index a8425074ce28..abc8b4306c02 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_no_recovery_no_connect.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_no_recovery_no_connect.py @@ -64,6 +64,12 @@ def test_disable_recovery_and_autoconnect_send_concurrently( with client: group_name = "test_disable_recovery_and_autoconnect_send_concurrently" client.join_group(group_name) + client._ws.sock.close(1001) # close connection + for _ in range(30): + if not client.is_connected(): + break + time.sleep(1) + assert not client.is_connected() def send(idx): client.send_to_group(group_name, f"hello_{idx}", "text") @@ -73,10 +79,7 @@ def send(idx): t = SafeThread(target=send, args=(i,)) t.start() all_threads.append(t) - if i == 50: - client._ws.sock.close(1001) # close connection - for i, t in enumerate(all_threads): - if i > 50: - with pytest.raises(Exception): - t.join() + for t in all_threads: + with pytest.raises(SendMessageError): + t.join() diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_no_recovery_no_connect_async.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_no_recovery_no_connect_async.py index 70055eb43201..15e0732dbf70 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_no_recovery_no_connect_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_no_recovery_no_connect_async.py @@ -59,9 +59,15 @@ async def test_disable_recovery_and_autoconnect_send_concurrently_async( async with client: group_name = "test_disable_recovery_and_autoconnect_send_concurrently_async" await client.join_group(group_name) - count = 10 - tasks = [client.send_to_group(group_name, "hello", "text") for _ in range(10)] await client._ws.session.close() # close connection + # wait for client to detect disconnection + for _ in range(30): + if not client.is_connected(): + break + await asyncio.sleep(1) + assert not client.is_connected() + + tasks = [client.send_to_group(group_name, "hello", "text") for _ in range(10)] for task in asyncio.as_completed(tasks): with pytest.raises(SendMessageError): await task diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_recovery.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_recovery.py index 6be5546b4207..94c2e9d07593 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_recovery.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_recovery.py @@ -4,10 +4,9 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # ------------------------------------------------------------------------- -import time import pytest from devtools_testutils import recorded_by_proxy -from testcase import WebpubsubClientTest, WebpubsubClientPowerShellPreparer, TEST_RESULT, on_group_message +from testcase import WebpubsubClientTest, WebpubsubClientPowerShellPreparer, TEST_RESULT @pytest.mark.live_test_only @@ -18,24 +17,14 @@ class TestWebpubsubClientRecovery(WebpubsubClientTest): def test_recovery(self, webpubsubclient_endpoint): client = self.create_client(endpoint=webpubsubclient_endpoint, message_retry_total=10) name = "test_recovery" + connected_event, message_event = self.setup_events(client) with client: - # wait for connection_id to be updated - for _ in range(30): - if client._connection_id is not None: - break - time.sleep(1) + assert connected_event.wait(timeout=30), "Timed out waiting for connection" conn_id0 = client._connection_id - group_name = name - client.subscribe("group-message", on_group_message) - client.join_group(group_name) + client.join_group(name) client._ws.sock.close(1001) # close connection to trigger recovery - client.send_to_group(group_name, name, "text") + self.retry_send_until_message(client, name, name, message_event) conn_id1 = client._connection_id - # wait for on_group_message callback to fire - for _ in range(10): - if name in TEST_RESULT: - break - time.sleep(1) assert name in TEST_RESULT assert conn_id0 is not None diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_recovery_async.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_recovery_async.py index 2092d6cdc6b3..cfaa76349345 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_recovery_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_recovery_async.py @@ -8,7 +8,7 @@ import pytest from devtools_testutils.aio import recorded_by_proxy_async from testcase import WebpubsubClientPowerShellPreparer -from testcase_async import WebpubsubClientTestAsync, TEST_RESULT_ASYNC, on_group_message +from testcase_async import WebpubsubClientTestAsync, TEST_RESULT_ASYNC @pytest.mark.live_test_only @@ -19,24 +19,14 @@ class TestWebpubsubClientRecoveryAsync(WebpubsubClientTestAsync): async def test_recovery_async(self, webpubsubclient_endpoint): client = await self.create_client(endpoint=webpubsubclient_endpoint, message_retry_total=10) name = "test_recovery_async" + connected_event, message_event = await self.setup_events(client) async with client: - # wait for connection_id to be updated - for _ in range(30): - if client._connection_id is not None: - break - await asyncio.sleep(1) + await asyncio.wait_for(connected_event.wait(), timeout=30) conn_id0 = client._connection_id - group_name = name - await client.subscribe("group-message", on_group_message) - await client.join_group(group_name) + await client.join_group(name) await client._ws.session.close() # close connection to trigger recovery - await client.send_to_group(group_name, name, "text") + await self.retry_send_until_message(client, name, name, message_event) conn_id1 = client._connection_id - # wait for on_group_message callback to fire - for _ in range(10): - if name in TEST_RESULT_ASYNC: - break - await asyncio.sleep(1) assert name in TEST_RESULT_ASYNC assert conn_id0 is not None diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_send_concurrently_async.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_send_concurrently_async.py index ac439ded053d..be3a87c60122 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_send_concurrently_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_send_concurrently_async.py @@ -20,4 +20,8 @@ async def test_send_concurrently_async(self, webpubsubclient_endpoint): async with client: group_name = "test_send_concurrently_async" await client.join_group(group_name) + for _ in range(30): + if client.is_connected(): + break + await asyncio.sleep(1) await asyncio.gather(*[client.send_to_group(group_name, f"hello_{idx}", "text") for idx in range(100)]) diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke.py index 676be6dd984d..64cae5524422 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke.py @@ -12,7 +12,6 @@ from testcase import ( WebpubsubClientTest, WebpubsubClientPowerShellPreparer, - on_group_message, TEST_RESULT, ) from azure.messaging.webpubsubclient import WebPubSubClient, WebPubSubClientCredential @@ -149,29 +148,20 @@ def _test(enable_auto_rejoin, test_group_name, assert_func): auto_rejoin_groups=enable_auto_rejoin, message_retry_total=10, ) - group_name = test_group_name - client.subscribe("group-message", on_group_message) + connected_event, message_event = self.setup_events(client) with client: - client.join_group(group_name) + client.join_group(test_group_name) + connected_event.clear() + message_event.clear() with client: - # retry send until connection is ready (open() runs in background thread) - for attempt in range(30): - try: - if not client.is_connected(): - time.sleep(1) - continue - client.send_to_group(group_name, group_name, "text") - break - except SendMessageError: - time.sleep(1) + assert connected_event.wait(timeout=30), "Timed out waiting for connection" + if enable_auto_rejoin: + self.retry_send_until_message(client, test_group_name, test_group_name, message_event) else: - raise RuntimeError("Failed to send after 30 attempts") + client.send_to_group(test_group_name, test_group_name, "text") # wait for on_group_message callback to fire - for _ in range(10): - if assert_func(test_group_name): - break - time.sleep(1) + message_event.wait(timeout=10) assert assert_func(test_group_name) _test( diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke_async.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke_async.py index db9a63ceb3a9..64e8c04d2ce8 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke_async.py @@ -11,7 +11,6 @@ from testcase import WebpubsubClientPowerShellPreparer from testcase_async import ( WebpubsubClientTestAsync, - on_group_message, TEST_RESULT_ASYNC, ) from azure.messaging.webpubsubclient.aio import WebPubSubClient as AsyncWebPubSubClient, WebPubSubClientCredential as AsyncWebPubSubClientCredential @@ -146,24 +145,23 @@ async def _test(enable_auto_rejoin, test_group_name, assert_func): endpoint=webpubsubclient_endpoint, auto_rejoin_groups=enable_auto_rejoin, ) - group_name = test_group_name - await client.subscribe("group-message", on_group_message) + connected_event, message_event = await self.setup_events(client) async with client: - await client.join_group(group_name) + await client.join_group(test_group_name) + connected_event.clear() + message_event.clear() async with client: - # wait for connection and auto-rejoin to complete - for _ in range(30): - if client.is_connected(): - break - await asyncio.sleep(1) - await asyncio.sleep(2) # extra time for auto-rejoin - await client.send_to_group(group_name, group_name, "text") + await asyncio.wait_for(connected_event.wait(), timeout=30) + if enable_auto_rejoin: + await self.retry_send_until_message(client, test_group_name, test_group_name, message_event) + else: + await client.send_to_group(test_group_name, test_group_name, "text") # wait for on_group_message callback to fire - for _ in range(10): - if assert_func(test_group_name): - break - await asyncio.sleep(1) + try: + await asyncio.wait_for(message_event.wait(), timeout=10) + except asyncio.TimeoutError: + pass assert assert_func(test_group_name) await _test( diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/testcase.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/testcase.py index 75f5289b3f10..b6b054bc523d 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/testcase.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/testcase.py @@ -6,10 +6,11 @@ # -------------------------------------------------------------------------- from typing import List import functools +import time import threading from devtools_testutils import AzureRecordedTestCase, PowerShellPreparer from azure.messaging.webpubsubclient import WebPubSubClient, WebPubSubClientCredential -from azure.messaging.webpubsubclient.models import OnGroupDataMessageArgs +from azure.messaging.webpubsubclient.models import OnGroupDataMessageArgs, SendMessageError from azure.messaging.webpubsubservice import WebPubSubServiceClient @@ -33,6 +34,36 @@ def create_client( **kwargs, ) + @staticmethod + def setup_events(client): + """Subscribe connected/group-message events and return (connected_event, message_event).""" + connected_event = threading.Event() + message_event = threading.Event() + + def _on_connected(*args, **kwargs): + connected_event.set() + + def _on_group_message(msg): + on_group_message(msg) + message_event.set() + + client.subscribe("connected", _on_connected) + client.subscribe("group-message", _on_group_message) + return connected_event, message_event + + @staticmethod + def retry_send_until_message(client, group_name, data, message_event, retries=30): + """Retry send_to_group until message_event fires, handling SendMessageError from rejoin lag.""" + for _ in range(retries): + try: + client.send_to_group(group_name, data, "text") + except SendMessageError: + time.sleep(1) + continue + if message_event.wait(timeout=2): + return + message_event.wait(timeout=2) + WebpubsubClientPowerShellPreparer = functools.partial( PowerShellPreparer, diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/testcase_async.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/testcase_async.py index 9f6d368f5a70..4fdaf0232d5e 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/testcase_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/testcase_async.py @@ -5,9 +5,10 @@ # license information. # -------------------------------------------------------------------------- from typing import List +import asyncio from devtools_testutils import AzureRecordedTestCase, PowerShellPreparer from azure.messaging.webpubsubclient.aio import WebPubSubClient, WebPubSubClientCredential -from azure.messaging.webpubsubclient.models import OnGroupDataMessageArgs +from azure.messaging.webpubsubclient.models import OnGroupDataMessageArgs, SendMessageError from azure.messaging.webpubsubservice.aio import WebPubSubServiceClient @@ -33,6 +34,43 @@ async def client_access_url_provider(): **kwargs, ) + @staticmethod + async def setup_events(client): + """Subscribe connected/group-message events and return (connected_event, message_event).""" + connected_event = asyncio.Event() + message_event = asyncio.Event() + + async def _on_connected(*args, **kwargs): + connected_event.set() + + async def _on_group_message(msg): + await on_group_message(msg) + message_event.set() + + await client.subscribe("connected", _on_connected) + await client.subscribe("group-message", _on_group_message) + return connected_event, message_event + + @staticmethod + async def retry_send_until_message(client, group_name, data, message_event, retries=30): + """Retry send_to_group until message_event fires, handling SendMessageError from rejoin lag.""" + for _ in range(retries): + try: + await client.send_to_group(group_name, data, "text") + except SendMessageError: + await asyncio.sleep(1) + continue + try: + await asyncio.wait_for(message_event.wait(), timeout=2) + return + except asyncio.TimeoutError: + pass + try: + await asyncio.wait_for(message_event.wait(), timeout=2) + except asyncio.TimeoutError: + pass + + TEST_RESULT_ASYNC = set() async def on_group_message(msg: OnGroupDataMessageArgs): From d03faf51a783b89302e9aabac6b8cb8d33dfe254 Mon Sep 17 00:00:00 2001 From: shiyingchen Date: Thu, 7 May 2026 10:09:36 +0800 Subject: [PATCH 19/20] add on_disconnected_event --- .../tests/test_auto_connect.py | 2 +- .../tests/test_auto_connect_async.py | 2 +- .../tests/test_no_recovery_no_connect.py | 14 ++----- .../test_no_recovery_no_connect_async.py | 15 ++----- .../tests/test_recovery.py | 2 +- .../tests/test_recovery_async.py | 2 +- .../tests/test_send_concurrently.py | 8 +--- .../tests/test_send_concurrently_async.py | 6 +-- .../tests/test_smoke.py | 39 +++++++++---------- .../tests/test_smoke_async.py | 36 ++++++++--------- .../tests/testcase.py | 9 ++++- .../tests/testcase_async.py | 9 ++++- .../tests/test_live_api_coverage.py | 36 ++++++----------- .../tests/test_live_api_coverage_async.py | 27 ++++++------- 14 files changed, 87 insertions(+), 120 deletions(-) diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_auto_connect.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_auto_connect.py index 2e711b2f437e..7d1942e42247 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_auto_connect.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_auto_connect.py @@ -25,7 +25,7 @@ def test_auto_connect(self, webpubsubclient_endpoint): reconnect_retry_backoff_factor=0.1, ) name = "test_auto_connect" - connected_event, message_event = self.setup_events(client) + connected_event, _, message_event = self.setup_events(client) with client: assert connected_event.wait(timeout=30), "Timed out waiting for initial connection" conn_id0 = client._connection_id diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_auto_connect_async.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_auto_connect_async.py index ee977b44bdaa..6158be968d6e 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_auto_connect_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_auto_connect_async.py @@ -26,7 +26,7 @@ async def test_auto_connect_async(self, webpubsubclient_endpoint): reconnect_retry_backoff_factor=0.1, ) name = "test_auto_connect_async" - connected_event, message_event = await self.setup_events(client) + connected_event, _, message_event = await self.setup_events(client) async with client: await asyncio.wait_for(connected_event.wait(), timeout=30) conn_id0 = client._connection_id diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_no_recovery_no_connect.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_no_recovery_no_connect.py index abc8b4306c02..10b1821562d8 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_no_recovery_no_connect.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_no_recovery_no_connect.py @@ -34,14 +34,10 @@ def test_disable_recovery_and_autoconnect(self, webpubsubclient_endpoint): name = "test_disable_recovery_and_autoconnect" with client: group_name = name - client.subscribe("group-message", on_group_message) + _, disconnected_event, _ = self.setup_events(client) client.join_group(group_name) client._ws.sock.close(1001) # close connection - # wait for client to detect disconnection so send raises SendMessageError - for _ in range(30): - if not client.is_connected(): - break - time.sleep(1) + assert disconnected_event.wait(timeout=30), "Timed out waiting for disconnection" with pytest.raises(SendMessageError): client.send_to_group(group_name, name, "text") time.sleep(3) # wait to confirm message was NOT received @@ -63,12 +59,10 @@ def test_disable_recovery_and_autoconnect_send_concurrently( with client: group_name = "test_disable_recovery_and_autoconnect_send_concurrently" + _, disconnected_event, _ = self.setup_events(client) client.join_group(group_name) client._ws.sock.close(1001) # close connection - for _ in range(30): - if not client.is_connected(): - break - time.sleep(1) + assert disconnected_event.wait(timeout=30), "Timed out waiting for disconnection" assert not client.is_connected() def send(idx): diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_no_recovery_no_connect_async.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_no_recovery_no_connect_async.py index 15e0732dbf70..9fed3de74f86 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_no_recovery_no_connect_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_no_recovery_no_connect_async.py @@ -29,14 +29,10 @@ async def test_disable_recovery_and_autoconnect_async(self, webpubsubclient_endp name = "test_disable_recovery_and_autoconnect_async" async with client: group_name = name - await client.subscribe("group-message", on_group_message) + _, disconnected_event, _ = await self.setup_events(client) await client.join_group(group_name) await client._ws.session.close() # close connection - # wait for client to detect disconnection so send raises SendMessageError - for _ in range(30): - if not client.is_connected(): - break - await asyncio.sleep(1) + await asyncio.wait_for(disconnected_event.wait(), timeout=30) with pytest.raises(SendMessageError): await client.send_to_group(group_name, name, "text") await asyncio.sleep(3) # wait to confirm message was NOT received @@ -58,13 +54,10 @@ async def test_disable_recovery_and_autoconnect_send_concurrently_async( async with client: group_name = "test_disable_recovery_and_autoconnect_send_concurrently_async" + _, disconnected_event, _ = await self.setup_events(client) await client.join_group(group_name) await client._ws.session.close() # close connection - # wait for client to detect disconnection - for _ in range(30): - if not client.is_connected(): - break - await asyncio.sleep(1) + await asyncio.wait_for(disconnected_event.wait(), timeout=30) assert not client.is_connected() tasks = [client.send_to_group(group_name, "hello", "text") for _ in range(10)] diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_recovery.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_recovery.py index 94c2e9d07593..9ccaf053bb7d 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_recovery.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_recovery.py @@ -17,7 +17,7 @@ class TestWebpubsubClientRecovery(WebpubsubClientTest): def test_recovery(self, webpubsubclient_endpoint): client = self.create_client(endpoint=webpubsubclient_endpoint, message_retry_total=10) name = "test_recovery" - connected_event, message_event = self.setup_events(client) + connected_event, _, message_event = self.setup_events(client) with client: assert connected_event.wait(timeout=30), "Timed out waiting for connection" conn_id0 = client._connection_id diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_recovery_async.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_recovery_async.py index cfaa76349345..218b612f8f9c 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_recovery_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_recovery_async.py @@ -19,7 +19,7 @@ class TestWebpubsubClientRecoveryAsync(WebpubsubClientTestAsync): async def test_recovery_async(self, webpubsubclient_endpoint): client = await self.create_client(endpoint=webpubsubclient_endpoint, message_retry_total=10) name = "test_recovery_async" - connected_event, message_event = await self.setup_events(client) + connected_event, _, message_event = await self.setup_events(client) async with client: await asyncio.wait_for(connected_event.wait(), timeout=30) conn_id0 = client._connection_id diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_send_concurrently.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_send_concurrently.py index a09039d50ed5..ed5a688d62a5 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_send_concurrently.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_send_concurrently.py @@ -4,7 +4,6 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # ------------------------------------------------------------------------- -import time import pytest from devtools_testutils import recorded_by_proxy from testcase import WebpubsubClientTest, WebpubsubClientPowerShellPreparer, SafeThread @@ -16,14 +15,11 @@ class TestWebpubsubClientSendConcurrently(WebpubsubClientTest): @recorded_by_proxy def test_send_concurrently(self, webpubsubclient_endpoint): client = self.create_client(endpoint=webpubsubclient_endpoint) + connected_event, _, _ = self.setup_events(client) with client: + assert connected_event.wait(timeout=30), "Timed out waiting for connection" group_name = "test_send_concurrently" client.join_group(group_name) - # wait for connection to stabilize before concurrent sends - for _ in range(30): - if client.is_connected(): - break - time.sleep(1) def send(idx): client.send_to_group(group_name, f"hello_{idx}", "text") diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_send_concurrently_async.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_send_concurrently_async.py index be3a87c60122..dedc96e76de2 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_send_concurrently_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_send_concurrently_async.py @@ -17,11 +17,9 @@ class TestWebpubsubClientSendConcurrentlyAsync(WebpubsubClientTestAsync): @recorded_by_proxy_async async def test_send_concurrently_async(self, webpubsubclient_endpoint): client = await self.create_client(endpoint=webpubsubclient_endpoint) + connected_event, _, _ = await self.setup_events(client) async with client: + await asyncio.wait_for(connected_event.wait(), timeout=30) group_name = "test_send_concurrently_async" await client.join_group(group_name) - for _ in range(30): - if client.is_connected(): - break - await asyncio.sleep(1) await asyncio.gather(*[client.send_to_group(group_name, f"hello_{idx}", "text") for idx in range(100)]) diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke.py index 64cae5524422..da0b3c842a72 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke.py @@ -29,9 +29,17 @@ class TestWebpubsubClientSmoke(WebpubsubClientTest): def test_call_back_deadlock(self, webpubsubclient_endpoint): client = self.create_client(endpoint=webpubsubclient_endpoint) group_name = "test_call_back_deadlock" + callback_completed = threading.Event() + callback_count = 0 + callback_count_lock = threading.Lock() def on_group_message(msg: OnGroupDataMessageArgs): + nonlocal callback_count client.send_to_group(group_name, msg.data, "text", no_echo=True) + with callback_count_lock: + callback_count += 1 + if callback_count >= 3: + callback_completed.set() with client: client.join_group(group_name) @@ -39,21 +47,18 @@ def on_group_message(msg: OnGroupDataMessageArgs): client.send_to_group(group_name, "hello test_call_back_deadlock1", "text") client.send_to_group(group_name, "hello test_call_back_deadlock2", "text") client.send_to_group(group_name, "hello test_call_back_deadlock3", "text") - # sleep to make sure the callback has enough time to execute before close - time.sleep(1) + assert callback_completed.wait(timeout=30), "Timed out waiting for callbacks to finish" @WebpubsubClientPowerShellPreparer() @recorded_by_proxy def test_context_manager(self, webpubsubclient_endpoint): client = self.create_client(endpoint=webpubsubclient_endpoint) + _, _, message_event = self.setup_events(client) with client: group_name = "test_context_manager" client.join_group(group_name) client.send_to_group(group_name, "test_context_manager", "text") - for _ in range(30): - if client._sequence_id.sequence_id > 0: - break - time.sleep(1) + assert message_event.wait(timeout=30), "Timed out waiting for context manager message" assert client._sequence_id.sequence_id > 0 # test on_stop @@ -61,6 +66,7 @@ def test_context_manager(self, webpubsubclient_endpoint): @recorded_by_proxy def test_on_stop(self, webpubsubclient_endpoint): client = self.create_client(endpoint=webpubsubclient_endpoint) + connected_event, disconnected_event, _ = self.setup_events(client) reopen_error = None reopen_complete = threading.Event() @@ -77,10 +83,8 @@ def on_stop(): else: raise RuntimeError("Failed to reopen client in stopped callback") - for _ in range(30): - if client.is_connected(): - break - time.sleep(1) + if not connected_event.wait(timeout=30): + raise RuntimeError("Timed out waiting for client to reconnect in stopped callback") assert client.is_connected() except Exception as e: reopen_error = e @@ -90,11 +94,9 @@ def on_stop(): with client: # open client again after close client.subscribe("stopped", on_stop) - for _ in range(30): - if client.is_connected(): - break - time.sleep(1) + assert connected_event.wait(timeout=30), "Timed out waiting for initial connection" assert client.is_connected() + connected_event.clear() client.close() # wait for on_stop callback to finish reopening if not reopen_complete.wait(timeout=60): @@ -103,12 +105,9 @@ def on_stop(): # remove stopped event and close again client.unsubscribe("stopped", on_stop) + disconnected_event.clear() client.close() - # wait for disconnect to finalize - for _ in range(30): - if not client.is_connected(): - break - time.sleep(1) + assert disconnected_event.wait(timeout=30), "Timed out waiting for client to disconnect" assert not client.is_connected() @WebpubsubClientPowerShellPreparer() @@ -148,7 +147,7 @@ def _test(enable_auto_rejoin, test_group_name, assert_func): auto_rejoin_groups=enable_auto_rejoin, message_retry_total=10, ) - connected_event, message_event = self.setup_events(client) + connected_event, _, message_event = self.setup_events(client) with client: client.join_group(test_group_name) diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke_async.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke_async.py index 64e8c04d2ce8..a8d65a792310 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke_async.py @@ -28,9 +28,15 @@ class TestWebpubsubClientSmokeAsync(WebpubsubClientTestAsync): async def test_call_back_deadlock_async(self, webpubsubclient_endpoint): client = await self.create_client(endpoint=webpubsubclient_endpoint) group_name = "test_call_back_deadlock_async" + callback_completed = asyncio.Event() + callback_count = 0 async def on_group_message(msg: OnGroupDataMessageArgs): + nonlocal callback_count await client.send_to_group(group_name, msg.data, "text", no_echo=True) + callback_count += 1 + if callback_count >= 3: + callback_completed.set() async with client: await client.join_group(group_name) @@ -38,21 +44,18 @@ async def on_group_message(msg: OnGroupDataMessageArgs): await client.send_to_group(group_name, "hello test_call_back_deadlock1", "text") await client.send_to_group(group_name, "hello test_call_back_deadlock2", "text") await client.send_to_group(group_name, "hello test_call_back_deadlock3", "text") - # sleep to make sure the callback has enough time to execute before close - await asyncio.sleep(1) + await asyncio.wait_for(callback_completed.wait(), timeout=30) @WebpubsubClientPowerShellPreparer() @recorded_by_proxy_async async def test_context_manager_async(self, webpubsubclient_endpoint): client = await self.create_client(endpoint=webpubsubclient_endpoint) + _, _, message_event = await self.setup_events(client) async with client: group_name = "test_context_manager_async" await client.join_group(group_name) await client.send_to_group(group_name, "test_context_manager", "text") - for _ in range(30): - if client._sequence_id.sequence_id > 0: - break - await asyncio.sleep(1) + await asyncio.wait_for(message_event.wait(), timeout=30) assert client._sequence_id.sequence_id > 0 # test on_stop @@ -60,6 +63,7 @@ async def test_context_manager_async(self, webpubsubclient_endpoint): @recorded_by_proxy_async async def test_on_stop_async(self, webpubsubclient_endpoint): client = await self.create_client(endpoint=webpubsubclient_endpoint) + connected_event, disconnected_event, _ = await self.setup_events(client) reopen_error = None reopen_complete = asyncio.Event() @@ -76,10 +80,7 @@ async def on_stop(): else: raise RuntimeError("Failed to reopen client in stopped callback") - for _ in range(30): - if client.is_connected(): - break - await asyncio.sleep(1) + await asyncio.wait_for(connected_event.wait(), timeout=30) assert client.is_connected() except Exception as e: reopen_error = e @@ -89,11 +90,9 @@ async def on_stop(): async with client: # open client again after close await client.subscribe("stopped", on_stop) - for _ in range(30): - if client.is_connected(): - break - await asyncio.sleep(1) + await asyncio.wait_for(connected_event.wait(), timeout=30) assert client.is_connected() + connected_event.clear() await client.close() # wait for on_stop callback to finish reopening await asyncio.wait_for(reopen_complete.wait(), timeout=60) @@ -101,12 +100,9 @@ async def on_stop(): # remove stopped event and close again await client.unsubscribe("stopped", on_stop) + disconnected_event.clear() await client.close() - # wait for disconnect to finalize - for _ in range(30): - if not client.is_connected(): - break - await asyncio.sleep(1) + await asyncio.wait_for(disconnected_event.wait(), timeout=30) assert not client.is_connected() @WebpubsubClientPowerShellPreparer() @@ -145,7 +141,7 @@ async def _test(enable_auto_rejoin, test_group_name, assert_func): endpoint=webpubsubclient_endpoint, auto_rejoin_groups=enable_auto_rejoin, ) - connected_event, message_event = await self.setup_events(client) + connected_event, _, message_event = await self.setup_events(client) async with client: await client.join_group(test_group_name) diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/testcase.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/testcase.py index b6b054bc523d..db014a195692 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/testcase.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/testcase.py @@ -36,20 +36,25 @@ def create_client( @staticmethod def setup_events(client): - """Subscribe connected/group-message events and return (connected_event, message_event).""" + """Subscribe connected/disconnected/group-message events and return their wait handles.""" connected_event = threading.Event() + disconnected_event = threading.Event() message_event = threading.Event() def _on_connected(*args, **kwargs): connected_event.set() + def _on_disconnected(*args, **kwargs): + disconnected_event.set() + def _on_group_message(msg): on_group_message(msg) message_event.set() client.subscribe("connected", _on_connected) + client.subscribe("disconnected", _on_disconnected) client.subscribe("group-message", _on_group_message) - return connected_event, message_event + return connected_event, disconnected_event, message_event @staticmethod def retry_send_until_message(client, group_name, data, message_event, retries=30): diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/testcase_async.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/testcase_async.py index 4fdaf0232d5e..29af098eaf0c 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/testcase_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/testcase_async.py @@ -36,20 +36,25 @@ async def client_access_url_provider(): @staticmethod async def setup_events(client): - """Subscribe connected/group-message events and return (connected_event, message_event).""" + """Subscribe connected/disconnected/group-message events and return their wait handles.""" connected_event = asyncio.Event() + disconnected_event = asyncio.Event() message_event = asyncio.Event() async def _on_connected(*args, **kwargs): connected_event.set() + async def _on_disconnected(*args, **kwargs): + disconnected_event.set() + async def _on_group_message(msg): await on_group_message(msg) message_event.set() await client.subscribe("connected", _on_connected) + await client.subscribe("disconnected", _on_disconnected) await client.subscribe("group-message", _on_group_message) - return connected_event, message_event + return connected_event, disconnected_event, message_event @staticmethod async def retry_send_until_message(client, group_name, data, message_event, retries=30): diff --git a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_live_api_coverage.py b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_live_api_coverage.py index 61ae8c78401e..8fe88a47ef28 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_live_api_coverage.py +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_live_api_coverage.py @@ -26,17 +26,15 @@ def _find_connection_id(self, client, group_name, user_id): return None def _wait_for_server_cleanup(self, delay_seconds=2): - """ - Wait for server-side cleanup after closing a connection. - - The server needs time to process the disconnection before accepting new connections. - This is a pragmatic wait since we don't have a direct signal for when cleanup completes. - - Args: - delay_seconds: Time to wait in seconds (default 2 seconds for server cleanup) - """ time.sleep(delay_seconds) + def _wait_for_connection_removed(self, client, connection_id): + for _ in range(30): + if not client.connection_exists(connection_id=connection_id): + return + time.sleep(1) + pytest.fail(f"Timed out waiting for connection {connection_id} to be removed") + @WebpubsubPowerShellPreparer() @recorded_by_proxy def test_live_api_coverage_all_apis_and_parameters(self, webpubsub_endpoint, webpubsub_socketio_endpoint): @@ -182,10 +180,7 @@ def test_live_api_coverage_all_apis_and_parameters(self, webpubsub_endpoint, web conn = self._find_connection_id(client, group_1, user_id) assert conn is not None client.close_group_connections(group=group_1, reason="live-coverage") - for _ in range(30): - if not client.connection_exists(connection_id=conn): - break - time.sleep(1) + self._wait_for_connection_removed(client, conn) assert not client.connection_exists(connection_id=conn) # close_user_connections @@ -194,10 +189,7 @@ def test_live_api_coverage_all_apis_and_parameters(self, webpubsub_endpoint, web conn = self._find_connection_id(client, group_1, user_id) assert conn is not None client.close_user_connections(user_id=user_id, reason="live-coverage") - for _ in range(30): - if not client.connection_exists(connection_id=conn): - break - time.sleep(1) + self._wait_for_connection_removed(client, conn) assert not client.connection_exists(connection_id=conn) # close_connection @@ -206,10 +198,7 @@ def test_live_api_coverage_all_apis_and_parameters(self, webpubsub_endpoint, web conn = self._find_connection_id(client, group_1, user_id) assert conn is not None client.close_connection(connection_id=conn, reason="live-coverage") - for _ in range(30): - if not client.connection_exists(connection_id=conn): - break - time.sleep(1) + self._wait_for_connection_removed(client, conn) assert not client.connection_exists(connection_id=conn) # close_all_connections @@ -218,10 +207,7 @@ def test_live_api_coverage_all_apis_and_parameters(self, webpubsub_endpoint, web conn = self._find_connection_id(client, group_1, user_id) assert conn is not None client.close_all_connections(reason="live-coverage") - for _ in range(30): - if not client.connection_exists(connection_id=conn): - break - time.sleep(1) + self._wait_for_connection_removed(client, conn) assert not client.connection_exists(connection_id=conn) ws = None diff --git a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_live_api_coverage_async.py b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_live_api_coverage_async.py index a429317c1c3a..94881d786932 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_live_api_coverage_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_live_api_coverage_async.py @@ -39,6 +39,13 @@ async def _wait_for_server_cleanup(self, delay_seconds=2): """ await asyncio.sleep(delay_seconds) + async def _wait_for_connection_removed(self, client, connection_id): + for _ in range(30): + if not await client.connection_exists(connection_id=connection_id): + return + await asyncio.sleep(1) + pytest.fail(f"Timed out waiting for connection {connection_id} to be removed") + @WebpubsubPowerShellPreparer() @recorded_by_proxy_async async def test_live_api_coverage_all_apis_and_parameters_async( @@ -212,10 +219,7 @@ async def test_live_api_coverage_all_apis_and_parameters_async( conn = await self._find_connection_id(client, group_1, user_id) assert conn is not None await client.close_group_connections(group=group_1, reason="live-coverage") - for _ in range(30): - if not await client.connection_exists(connection_id=conn): - break - await asyncio.sleep(1) + await self._wait_for_connection_removed(client, conn) assert not await client.connection_exists(connection_id=conn) # close_user_connections @@ -224,10 +228,7 @@ async def test_live_api_coverage_all_apis_and_parameters_async( conn = await self._find_connection_id(client, group_1, user_id) assert conn is not None await client.close_user_connections(user_id=user_id, reason="live-coverage") - for _ in range(30): - if not await client.connection_exists(connection_id=conn): - break - await asyncio.sleep(1) + await self._wait_for_connection_removed(client, conn) assert not await client.connection_exists(connection_id=conn) # close_connection @@ -236,10 +237,7 @@ async def test_live_api_coverage_all_apis_and_parameters_async( conn = await self._find_connection_id(client, group_1, user_id) assert conn is not None await client.close_connection(connection_id=conn, reason="live-coverage") - for _ in range(30): - if not await client.connection_exists(connection_id=conn): - break - await asyncio.sleep(1) + await self._wait_for_connection_removed(client, conn) assert not await client.connection_exists(connection_id=conn) # close_all_connections @@ -248,10 +246,7 @@ async def test_live_api_coverage_all_apis_and_parameters_async( conn = await self._find_connection_id(client, group_1, user_id) assert conn is not None await client.close_all_connections(reason="live-coverage") - for _ in range(30): - if not await client.connection_exists(connection_id=conn): - break - await asyncio.sleep(1) + await self._wait_for_connection_removed(client, conn) assert not await client.connection_exists(connection_id=conn) ws = None From df0f4e1a2f06a224fbf35187ac0890b3e80be2ec Mon Sep 17 00:00:00 2001 From: shiyingchen Date: Thu, 7 May 2026 10:42:03 +0800 Subject: [PATCH 20/20] fix timeout --- .../tests/test_smoke_async.py | 2 -- .../tests/test_live_api_coverage.py | 8 +------- .../tests/test_live_api_coverage_async.py | 17 +---------------- 3 files changed, 2 insertions(+), 25 deletions(-) diff --git a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke_async.py b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke_async.py index a8d65a792310..dd31e14c3659 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_smoke_async.py @@ -100,9 +100,7 @@ async def on_stop(): # remove stopped event and close again await client.unsubscribe("stopped", on_stop) - disconnected_event.clear() await client.close() - await asyncio.wait_for(disconnected_event.wait(), timeout=30) assert not client.is_connected() @WebpubsubClientPowerShellPreparer() diff --git a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_live_api_coverage.py b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_live_api_coverage.py index 8fe88a47ef28..7afc3d29ac56 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_live_api_coverage.py +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_live_api_coverage.py @@ -25,9 +25,6 @@ def _find_connection_id(self, client, group_name, user_id): time.sleep(1) return None - def _wait_for_server_cleanup(self, delay_seconds=2): - time.sleep(delay_seconds) - def _wait_for_connection_removed(self, client, connection_id): for _ in range(30): if not client.connection_exists(connection_id=connection_id): @@ -175,7 +172,7 @@ def test_live_api_coverage_all_apis_and_parameters(self, webpubsub_endpoint, web # close_group_connections (connection auto-joins group_1 via token) ws.close() - self._wait_for_server_cleanup() + self._wait_for_connection_removed(client, connection_id) ws = ws_connect(access_token["url"], open_timeout=30) conn = self._find_connection_id(client, group_1, user_id) assert conn is not None @@ -184,7 +181,6 @@ def test_live_api_coverage_all_apis_and_parameters(self, webpubsub_endpoint, web assert not client.connection_exists(connection_id=conn) # close_user_connections - self._wait_for_server_cleanup() ws = ws_connect(access_token["url"], open_timeout=30) conn = self._find_connection_id(client, group_1, user_id) assert conn is not None @@ -193,7 +189,6 @@ def test_live_api_coverage_all_apis_and_parameters(self, webpubsub_endpoint, web assert not client.connection_exists(connection_id=conn) # close_connection - self._wait_for_server_cleanup() ws = ws_connect(access_token["url"], open_timeout=30) conn = self._find_connection_id(client, group_1, user_id) assert conn is not None @@ -202,7 +197,6 @@ def test_live_api_coverage_all_apis_and_parameters(self, webpubsub_endpoint, web assert not client.connection_exists(connection_id=conn) # close_all_connections - self._wait_for_server_cleanup() ws = ws_connect(access_token["url"], open_timeout=30) conn = self._find_connection_id(client, group_1, user_id) assert conn is not None diff --git a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_live_api_coverage_async.py b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_live_api_coverage_async.py index 94881d786932..92d0125850df 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_live_api_coverage_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/tests/test_live_api_coverage_async.py @@ -27,18 +27,6 @@ async def _find_connection_id(self, client, group_name, user_id): await asyncio.sleep(1) return None - async def _wait_for_server_cleanup(self, delay_seconds=2): - """ - Wait for server-side cleanup after closing a connection. - - The server needs time to process the disconnection before accepting new connections. - This is a pragmatic wait since we don't have a direct signal for when cleanup completes. - - Args: - delay_seconds: Time to wait in seconds (default 2 seconds for server cleanup) - """ - await asyncio.sleep(delay_seconds) - async def _wait_for_connection_removed(self, client, connection_id): for _ in range(30): if not await client.connection_exists(connection_id=connection_id): @@ -214,7 +202,7 @@ async def test_live_api_coverage_all_apis_and_parameters_async( # close_group_connections (connection auto-joins group_1 via token) await ws.close() - await self._wait_for_server_cleanup() + await self._wait_for_connection_removed(client, connection_id) ws = await ws_connect(access_token["url"], open_timeout=30) conn = await self._find_connection_id(client, group_1, user_id) assert conn is not None @@ -223,7 +211,6 @@ async def test_live_api_coverage_all_apis_and_parameters_async( assert not await client.connection_exists(connection_id=conn) # close_user_connections - await self._wait_for_server_cleanup() ws = await ws_connect(access_token["url"], open_timeout=30) conn = await self._find_connection_id(client, group_1, user_id) assert conn is not None @@ -232,7 +219,6 @@ async def test_live_api_coverage_all_apis_and_parameters_async( assert not await client.connection_exists(connection_id=conn) # close_connection - await self._wait_for_server_cleanup() ws = await ws_connect(access_token["url"], open_timeout=30) conn = await self._find_connection_id(client, group_1, user_id) assert conn is not None @@ -241,7 +227,6 @@ async def test_live_api_coverage_all_apis_and_parameters_async( assert not await client.connection_exists(connection_id=conn) # close_all_connections - await self._wait_for_server_cleanup() ws = await ws_connect(access_token["url"], open_timeout=30) conn = await self._find_connection_id(client, group_1, user_id) assert conn is not None