MagicStack / MagicStack/uvloop

Tests trying to find unused ports are flakey when automated

オープン
#513 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
Cython
スター
11.9k
フォーク
616
PR マージ指標
30日以内にマージされた PR はありません

説明

  • uvloop version: 0.17.0
  • Python version: 3.10
  • Platform: nix/darwin
  • Can you reproduce the bug with PYTHONASYNCIODEBUG in env?: N/A
  • Does uvloop behave differently from vanilla asyncio? How?: N/A

The tests using find_free_port (like https://github.com/MagicStack/uvloop/blob/d2deffefa18653636eb03ea77a5dab6e4febf6c6/tests/test_tcp.py#L252) may fail in busy CI environments. For example building for nixpkgs involves running tests every time. It ends up with: (https://hydra.nixos.org/build/197525892/nixlog/1)

=================================== FAILURES ===================================
_______________________ Test_UV_TCP.test_create_server_5 _______________________
Traceback (most recent call last):
  File "/private/tmp/tmp.xkcj6kx4o4/tests/test_tcp.py", line 245, in test_create_server_5
    self.loop.run_until_complete(runner())
  File "uvloop/loop.pyx", line 1517, in uvloop.loop.Loop.run_until_complete
  File "/private/tmp/tmp.xkcj6kx4o4/tests/test_tcp.py", line 238, in runner
    srv = await self.loop.create_server(
  File "uvloop/loop.pyx", line 1790, in create_server
OSError: [Errno 48] error while attempting to bind on address ('::', 50000, 0, 0): address already in use
_______________________ Test_UV_TCP.test_create_server_6 _______________________
Traceback (most recent call last):
  File "/private/tmp/tmp.xkcj6kx4o4/tests/test_tcp.py", line 271, in test_create_server_6
    self.loop.run_until_complete(runner())
  File "uvloop/loop.pyx", line 1517, in uvloop.loop.Loop.run_until_complete
  File "/private/tmp/tmp.xkcj6kx4o4/tests/test_tcp.py", line 255, in runner
    srv1 = await self.loop.create_server(
  File "uvloop/loop.pyx", line 1790, in create_server
OSError: [Errno 48] error while attempting to bind on address ('::', 50000, 0, 0): address already in use
=============================== warnings summary ===============================

Do those tests need to use a common ipv4/6 socket? Could they use only one protocol at a time with port 0 and then get the local port number from the result?

Or maybe build the retry loop around the first socket creation rather than 2 independent steps?

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

tests/test_tcp.py から始め、特に test_create_server_5 と test_create_server_6 周辺で find_free_port を使用しているテストを確認してください。自動化された環境または負荷の高い環境で失敗を再現し、その後、ポート 0、共有 IPv4/IPv6 ソケット、または最初のソケット作成の再試行を使用する方法を評価してください。選択されたポートがすでに使用中であることが原因でテストが失敗しなくなれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
networking, testing
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。