h2oai / wave

Realtime Web Apps and Dashboards for Python and R
https://wave.h2o.ai
Apache License 2.0
3.9k stars 323 forks source link

Get rid of the warnings in py tests #2261

Closed mturoci closed 3 months ago

mturoci commented 4 months ago

cd py && make test

echo "Testing using LOCAL UPLOAD AND BASE URL" && H2O_WAVE_WAVED_DIR=".." H2O_WAVE_BASE_URL="/foo/" ./venv/bin/python -m tests
Testing using LOCAL UPLOAD AND BASE URL
2024/02/08 08:06:32 #
2024/02/08 08:06:32 # ┌────────────────┐ H2O Wave
2024/02/08 08:06:32 # │  ┐┌┐┐┌─┐┌ ┌┌─┐ │ (version) (build)
2024/02/08 08:06:32 # │  └┘└┘└─└└─┘└── │ © 2021 H2O.ai, Inc.
2024/02/08 08:06:32 # └────────────────┘
2024/02/08 08:06:32 # ┌──────────────────────────────────────────┐
2024/02/08 08:06:32 # │  Running at http://localhost:10101/foo/  │
2024/02/08 08:06:32 # └──────────────────────────────────────────┘
2024/02/08 08:06:32 # {"address":"assets/","source":"./assets","t":"public_dir"}
2024/02/08 08:06:32 # {"address":":10101","base-url":"/foo/","t":"listen","web-dir":"/Users/mturoci/projects/wave/ui/build"}
.................2024/02/08 08:06:33 # {"path":"/foo/_f/9c8bad93-e3b0-4b29-a7c8-8c862e0b3574/test.txt","t":"file_download"}
2024/02/08 08:06:33 # {"path":"/foo/_f/9c8bad93-e3b0-4b29-a7c8-8c862e0b3574/test.txt","t":"file_unload"}
2024/02/08 08:06:33 # {"error":"not found","path":"/foo/_f/9c8bad93-e3b0-4b29-a7c8-8c862e0b3574/test.txt","t":"file_download"}
.2024/02/08 08:06:33 # {"path":"/foo/_f/4f6cf8cb-1503-4205-b3de-378488f96e90/temp_file1.txt","t":"file_download"}
.........................2024/02/08 08:06:33 # {"path":"/foo/_f/07766f71-4e39-489b-bdd6-0b9987df0c74/dir1/test.txt","t":"file_download"}
..2024/02/08 08:06:33 # {"path":"/foo/_f/66d1a7cd-ce0d-47f0-9343-15a27135735c/test.txt","t":"file_download"}
2024/02/08 08:06:33 # {"path":"/foo/_f/66d1a7cd-ce0d-47f0-9343-15a27135735c/test.txt","t":"file_unload"}
2024/02/08 08:06:33 # {"error":"not found","path":"/foo/_f/66d1a7cd-ce0d-47f0-9343-15a27135735c/test.txt","t":"file_download"}
.2024/02/08 08:06:33 # {"path":"/foo/_f/c29f3ce4-9695-4bfc-94fc-47194428b7d3/temp_file1.txt","t":"file_download"}
...2024/02/08 08:06:33 # {"path":"/foo/_f/eaca45e9-485b-4a47-b049-e4e559906724/dir1/test.txt","t":"file_download"}
.............../Users/mturoci/.asdf/installs/python/3.10.10/lib/python3.10/asyncio/selector_events.py:710: ResourceWarning: unclosed transport <_SelectorSocketTransport fd=10>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/Users/mturoci/.asdf/installs/python/3.10.10/lib/python3.10/unittest/mock.py:2119: ResourceWarning: unclosed <socket.socket fd=13, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('127.0.0.1', 49513), raddr=('127.0.0.1', 10101)>
  if getattr(self, "_mock_methods", None) is not None:
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/Users/mturoci/.asdf/installs/python/3.10.10/lib/python3.10/asyncio/selector_events.py:710: ResourceWarning: unclosed transport <_SelectorSocketTransport fd=13>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/Users/mturoci/.asdf/installs/python/3.10.10/lib/python3.10/asyncio/selector_events.py:710: ResourceWarning: unclosed transport <_SelectorSocketTransport fd=11>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/Users/mturoci/.asdf/installs/python/3.10.10/lib/python3.10/asyncio/selector_events.py:710: ResourceWarning: unclosed transport <_SelectorSocketTransport fd=12>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/Users/mturoci/.asdf/installs/python/3.10.10/lib/python3.10/asyncio/selector_events.py:710: ResourceWarning: unclosed transport <_SelectorSocketTransport fd=14>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/Users/mturoci/.asdf/installs/python/3.10.10/lib/python3.10/asyncio/selector_events.py:710: ResourceWarning: unclosed transport <_SelectorSocketTransport fd=15>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
Devanshusisodiya commented 4 months ago

@mturoci The issue seems to start from here. Seems the issue is in mock_q or the way it is being called for the mentioned lines.

mturoci commented 4 months ago

Thanks for the initiative @Devanshusisodiya! Q is defined here.

Devanshusisodiya commented 4 months ago

Thanks for the initiative @Devanshusisodiya! Q is defined here.

Thanks @mturoci I just found it.

Devanshusisodiya commented 4 months ago

@mturoci Seems like the issue is in the run_on function in the tests where the arity is >1. Take a look at the following snapshot. The reason i could think of is that the way the AsyncMock instance is being called in run_on where arity > 1 must be fixed.

image
Devanshusisodiya commented 4 months ago

@mturoci Why are all the tests running a total of 4 iterations? And how are parameters of BASE_URL and H2O_WAVE_BASE_URL being set for the test runs?

mturoci commented 4 months ago

Why are all the tests running a total of 4 iterations?

each iteration uses a different server config. The link also answers the second question.