-
Notifications
You must be signed in to change notification settings - Fork 215
Closed
Labels
api: pubsubIssues related to the googleapis/python-pubsub API.Issues related to the googleapis/python-pubsub API.flakybot: flakyTells the Flaky Bot not to close or comment on this issue.Tells the Flaky Bot not to close or comment on this issue.flakybot: issueAn issue filed by the Flaky Bot. Should not be added manually.An issue filed by the Flaky Bot. Should not be added manually.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
This test failed!
To configure my behavior, see the Flaky Bot documentation.
If I'm commenting on this issue too often, add the flakybot: quiet label and
I will stop commenting.
commit: 5a47963
buildURL: Build Status, Sponge
status: failed
Test output
publisher =
topic_path_base = 'projects/precise-truck-742/topics/t-1692375611236'
subscription_path_base = 'projects/precise-truck-742/subscriptions/s-1692375611238'
cleanup = [(>, (), {'topic': 'projects/precise-truck-742/topics/t-1692375611236-not-leaking-open-sockets'})]
transport = 'rest'
@pytest.mark.parametrize("transport", ["grpc", "rest"])
def test_subscriber_not_leaking_open_sockets(
publisher, topic_path_base, subscription_path_base, cleanup, transport
):
# Make sure the topic and the supscription get deleted.
# NOTE: Since subscriber client will be closed in the test, we should not
# use the shared `subscriber` fixture, but instead construct a new client
# in this test.
# Also, since the client will get closed, we need another subscriber client
# to clean up the subscription. We also need to make sure that auxiliary
# subscriber releases the sockets, too.
custom_str = "-not-leaking-open-sockets"
subscription_path = subscription_path_base + custom_str
topic_path = topic_path_base + custom_str
subscriber = pubsub_v1.SubscriberClient(transport="grpc")
subscriber_2 = pubsub_v1.SubscriberClient(transport="grpc")
cleanup.append(
(subscriber_2.delete_subscription, (), {"subscription": subscription_path})
)
cleanup.append((subscriber_2.close, (), {}))
cleanup.append((publisher.delete_topic, (), {"topic": topic_path}))
# Create topic before starting to track connection count (any sockets opened
# by the publisher client are not counted by this test).
publisher.create_topic(name=topic_path)
current_process = psutil.Process()
conn_count_start = len(current_process.connections())
# Publish a few messages, then synchronously pull them and check that
# no sockets are leaked.
with subscriber:
subscriber.create_subscription(name=subscription_path, topic=topic_path)
# Publish a few messages, wait for the publish to succeed.
publish_futures = [
publisher.publish(topic_path, "message {}".format(i).encode())
for i in range(1, 4)
]
for future in publish_futures:
future.result()
# Synchronously pull messages.
response = subscriber.pull(subscription=subscription_path, max_messages=3)
assert len(response.received_messages) == 3
conn_count_end = len(current_process.connections())
# To avoid flakiness, use <= in the assertion, since on rare occasions additional
# sockets are closed, causing the == assertion to fail.
# https://github.com/googleapis/python-pubsub/issues/483#issuecomment-910122086
assert conn_count_end <= conn_count_start
E assert 2 <= 1
tests/system.py:495: AssertionError
Metadata
Metadata
Assignees
Labels
api: pubsubIssues related to the googleapis/python-pubsub API.Issues related to the googleapis/python-pubsub API.flakybot: flakyTells the Flaky Bot not to close or comment on this issue.Tells the Flaky Bot not to close or comment on this issue.flakybot: issueAn issue filed by the Flaky Bot. Should not be added manually.An issue filed by the Flaky Bot. Should not be added manually.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.