From d36bea0f81a4f347a0401c1936bf98a5a4983bb0 Mon Sep 17 00:00:00 2001 From: Yunhao Ling Date: Fri, 4 Oct 2019 01:12:59 -0700 Subject: [PATCH] Fix proxy test --- .../test_azure_event_hubs_receive_async.py | 17 +++++++++++++++++ samples/test_azure_event_hubs_receive.py | 19 ++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/samples/asynctests/test_azure_event_hubs_receive_async.py b/samples/asynctests/test_azure_event_hubs_receive_async.py index 55f6de6a6..63b1bde22 100644 --- a/samples/asynctests/test_azure_event_hubs_receive_async.py +++ b/samples/asynctests/test_azure_event_hubs_receive_async.py @@ -128,6 +128,23 @@ async def test_event_hubs_batch_receive_async(live_eventhub_config): log.info("Sequence Number: {}".format(annotations.get(b'x-opt-sequence-number'))) +@pytest.mark.asyncio +async def test_event_hubs_client_web_socket_async(live_eventhub_config): + uri = "sb://{}/{}".format(live_eventhub_config['hostname'], live_eventhub_config['event_hub']) + sas_auth = authentication.SASTokenAsync.from_shared_access_key( + uri, live_eventhub_config['key_name'], live_eventhub_config['access_key'], + transport_type=uamqp.TransportType.AmqpOverWebsocket) + + source = "amqps://{}/{}/ConsumerGroups/{}/Partitions/{}".format( + live_eventhub_config['hostname'], + live_eventhub_config['event_hub'], + live_eventhub_config['consumer_group'], + live_eventhub_config['partition']) + + async with uamqp.ReceiveClientAsync(source, auth=sas_auth, debug=False, timeout=5000, prefetch=50) as receive_client: + receive_client.receive_message_batch(max_batch_size=10) + + @pytest.mark.asyncio async def test_event_hubs_receive_with_runtime_metric_async(live_eventhub_config): uri = "sb://{}/{}".format(live_eventhub_config['hostname'], live_eventhub_config['event_hub']) diff --git a/samples/test_azure_event_hubs_receive.py b/samples/test_azure_event_hubs_receive.py index 02e41e0f9..d932e964a 100644 --- a/samples/test_azure_event_hubs_receive.py +++ b/samples/test_azure_event_hubs_receive.py @@ -85,8 +85,25 @@ def test_event_hubs_single_batch_receive(live_eventhub_config): assert len(message) <= 300 +def test_event_hubs_client_web_socket(live_eventhub_config): + uri = "sb://{}/{}".format(live_eventhub_config['hostname'], live_eventhub_config['event_hub']) + sas_auth = authentication.SASTokenAuth.from_shared_access_key( + uri, live_eventhub_config['key_name'], live_eventhub_config['access_key'], + transport_type=uamqp.TransportType.AmqpOverWebsocket) + + source = "amqps://{}/{}/ConsumerGroups/{}/Partitions/{}".format( + live_eventhub_config['hostname'], + live_eventhub_config['event_hub'], + live_eventhub_config['consumer_group'], + live_eventhub_config['partition']) + + with uamqp.ReceiveClient(source, auth=sas_auth, debug=False, timeout=5000, prefetch=50) as receive_client: + receive_client.receive_message_batch(max_batch_size=10) + + def test_event_hubs_client_proxy_settings(live_eventhub_config): - proxy_settings={'proxy_hostname':'127.0.0.1', 'proxy_port': 12345} + pytest.skip("skipping the test in CI due to no proxy server") + proxy_settings={'proxy_hostname': '127.0.0.1', 'proxy_port': 12345} uri = "sb://{}/{}".format(live_eventhub_config['hostname'], live_eventhub_config['event_hub']) sas_auth = authentication.SASTokenAuth.from_shared_access_key( uri, live_eventhub_config['key_name'], live_eventhub_config['access_key'], http_proxy=proxy_settings)