Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests.unit.pubsub_v1.subscriber.test_streaming_pull_manager: test_close_inactive_consumer failed #352

Closed
flaky-bot bot opened this issue Mar 27, 2021 · 2 comments · Fixed by #361
Closed
Assignees
Labels
api: pubsub Issues related to the googleapis/python-pubsub API. flakybot: flaky Tells the Flaky Bot not to close or comment on this issue. flakybot: issue An issue filed by the Flaky Bot. Should not be added manually. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. 🚨 This issue needs some love. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@flaky-bot
Copy link

flaky-bot bot commented Mar 27, 2021

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: d40d027
buildURL: Build Status, Sponge
status: failed

Test output
def test_close_inactive_consumer():
        (
            manager,
            consumer,
            dispatcher,
            leaser,
            heartbeater,
            scheduler,
        ) = make_running_manager()
        consumer.is_active = False
    manager.close()

    consumer.stop.assert_not_called()
    leaser.stop.assert_called_once()
  dispatcher.stop.assert_called_once()

tests/unit/pubsub_v1/subscriber/test_streaming_pull_manager.py:589:


_mock_self =

def assert_called_once(_mock_self):
    """assert that the mock was called only once.
    """
    self = _mock_self
    if not self.call_count == 1:
        msg = ("Expected '%s' to have been called once. Called %s times.%s"
               % (self._mock_name or 'mock',
                  self.call_count,
                  self._calls_repr()))
      raise AssertionError(msg)

E AssertionError: Expected 'stop' to have been called once. Called 0 times.

.nox/unit-3-7/lib/python3.7/site-packages/mock/mock.py:891: AssertionError

@flaky-bot flaky-bot bot added flakybot: issue An issue filed by the Flaky Bot. Should not be added manually. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. flakybot: flaky Tells the Flaky Bot not to close or comment on this issue. labels Mar 27, 2021
@flaky-bot
Copy link
Author

flaky-bot bot commented Mar 27, 2021

Looks like this issue is flaky. 😟

I'm going to leave this open and stop commenting.

A human should fix and close this.


When run at the same commit (d40d027), this test passed in one build (Build Status, Sponge) and failed in another build (Build Status, Sponge).

@product-auto-label product-auto-label bot added the api: pubsub Issues related to the googleapis/python-pubsub API. label Mar 27, 2021
@plamut
Copy link
Contributor

plamut commented Apr 1, 2021

I found where the problem is. The streaming pull manager's close() is now non-blocking, shutdown is performed in a background thread.

The test calls manager.close() and then immediately proceeds to assertions, meaning that there's a race between the main test thread and the background shutdown thread. I was not able to reproduce the issue on my machine, but was able to trigger it if I added a sleep for a fraction of a second to the _shutdown() method.

I'll see if there's an easy way to somehow synchronize with the background thread, or we might need to refactor the test to invoke the _shutdown() method directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: pubsub Issues related to the googleapis/python-pubsub API. flakybot: flaky Tells the Flaky Bot not to close or comment on this issue. flakybot: issue An issue filed by the Flaky Bot. Should not be added manually. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. 🚨 This issue needs some love. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants