-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Expand file tree
/
Copy pathtest_reconnect.py
More file actions
69 lines (61 loc) · 2.32 KB
/
test_reconnect.py
File metadata and controls
69 lines (61 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#-------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#--------------------------------------------------------------------------
import os
import time
import pytest
from azure.eventhub import (
EventData,
EventPosition,
EventHubError,
EventHubClient)
@pytest.mark.liveTest
def test_send_with_long_interval_sync(connstr_receivers, sleep):
connection_str, receivers = connstr_receivers
client = EventHubClient.from_connection_string(connection_str, network_tracing=False)
sender = client.create_producer()
with sender:
sender.send(EventData(b"A single event"))
for _ in range(1):
if sleep:
time.sleep(300)
else:
sender._handler._connection._conn.destroy()
sender.send(EventData(b"A single event"))
received = []
for r in receivers:
if not sleep:
r._handler._connection._conn.destroy()
received.extend(r.receive(timeout=5))
assert len(received) == 2
assert list(received[0].body)[0] == b"A single event"
@pytest.mark.liveTest
def test_send_with_forced_conn_close_sync(connstr_receivers, sleep):
pytest.skip("This test is similar to the above one")
connection_str, receivers = connstr_receivers
client = EventHubClient.from_connection_string(connection_str, network_tracing=False)
sender = client.create_producer()
with sender:
sender.send(EventData(b"A single event"))
sender._handler._connection._conn.destroy()
if sleep:
time.sleep(300)
else:
sender._handler._connection._conn.destroy()
sender.send(EventData(b"A single event"))
sender.send(EventData(b"A single event"))
if sleep:
time.sleep(300)
else:
sender._handler._connection._conn.destroy()
sender.send(EventData(b"A single event"))
sender.send(EventData(b"A single event"))
received = []
for r in receivers:
if not sleep:
r._handler._connection._conn.destroy()
received.extend(r.receive(timeout=1))
assert len(received) == 5
assert list(received[0].body)[0] == b"A single event"