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

[BUG] pytest hangs on fresh install #101

Open
dbwiddis opened this issue Dec 17, 2023 · 2 comments
Open

[BUG] pytest hangs on fresh install #101

dbwiddis opened this issue Dec 17, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@dbwiddis
Copy link
Member

What is the bug?

Following a complete uninstall and reinstall of many programs via homebrew, I reinstalled packages per the development guide.

Running poetry run pytest -v hangs at about 28% complete, with the log at this point:

tests/server/test_async_host.py::TestAsyncHost::test_init PASSED                                                                                       [ 28%]
tests/server/test_async_host.py::TestAsyncHost::test_run 
----------------------------------------------------------------------- live log call ------------------------------------------------------------------------
INFO     root:async_host.py:33 < server=<socket.socket fd=21, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 53500)>
INFO     root:test_async_host.py:56 > PASS
INFO     root:test_async_host.py:56 > QUIT
INFO     root:async_host.py:49 b'\x04PASS'

How can one reproduce the bug?

Start with a clean install on macOS and follow installation steps at https://github.com/opensearch-project/opensearch-sdk-py/blob/main/DEVELOPER_GUIDE.md#building-and-testing

What is the expected behavior?

Unit tests complete. Or the developer guide tells me I'm supposed to start something else up before running them.

What is your host/environment?

platform darwin -- Python 3.9.6, pytest-7.4.3, pluggy-1.3.0
Apple M2 Max
macOS Sonoma 14.2

Do you have any additional context?

When interrupting with Ctrl-C, I get

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! KeyboardInterrupt !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
/Users/danielwiddis/git/opensearch-sdk-py/src/opensearch_sdk_py/transport/stream_input.py:58: KeyboardInterrupt
(to show a full traceback on KeyboardInterrupt use --full-trace)
=============================================================== 39 passed in 299.74s (0:04:59) ===============================================================
Task exception was never retrieved
future: <Task finished name='Task-40' coro=<AsyncHost.on_connection() done, defined at /Users/danielwiddis/git/opensearch-sdk-py/src/opensearch_sdk_py/server/async_host.py:44> exception=KeyboardInterrupt()>
@dbwiddis dbwiddis added bug Something isn't working untriaged Issues that require attention from the maintainers. labels Dec 17, 2023
@dbwiddis
Copy link
Member Author

Hang is in this line:

results = self.loop.run_until_complete(self.__both(["PASS", "QUIT"]))

Completes if I remove "PASS".

Loop in question:

def on_input(self, input: StreamInput) -> StreamOutput:
    while True:
        command = input.read_string()
        if command == "PASS":
            pass
        elif command == "EXCEPTION":
            self.terminating = True
            raise Exception(command)
        elif command == "QUIT":
            self.terminating = True
            response = StreamOutput()
            response.write_string("OK")
            return response

Tests pass if I put a return statement under the "PASS" conditional:

if command == "PASS":
    return

@dbwiddis
Copy link
Member Author

Even with the "return" fix above it's flaky, sometimes hanging (apparently sending \x04PASS\x04QUIT in one message).

My hunch is some sort of I/O buffer where if PASS is not processed fast enough it doesn't catch QUIT, but that's purely guesswork.

@dblock dblock removed the untriaged Issues that require attention from the maintainers. label Dec 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants