Redesign tests based on `QueueTestHead` and `onFinalizeWeak`

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

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

評価

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

調査の方向性

QueueTestHead と request.body.onFinalizeWeak を組み合わせている Http1ClientStageSuite と ClientTimeoutSuite のテストから始めてください。org.http4s.blazecore.util.EntityBodyWriter#writeEntityBody、特に drain と writeEnd の順序を確認してください。テストが body-stream の finalization に依存せずにリクエストが送信されたことを検出し、報告されている flaky な挙動が発生しなくなれば完了です。

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

説明

module:blaze-client testing

Http1ClientStageSuite and ClientTimeoutSuite."Idle timeout on slow POST body" use a combo of QueueTestHead to mock the network side of the connection and request.body.onFinalizeWeak to trigger some action in QueueTestHead. In these tests onFinalizeWeak is meant to detect when the request has been sent. The problem is that finalisation of the request body stream, does not guarantee the request has been sent. This can be clearly seen in the code of org.http4s.blazecore.util.EntityBodyWriter#writeEntityBody where writeEnd is executed after drain:

  def writeEntityBody(p: EntityBody[F]): F[Boolean] = {
    val writeBody: F[Unit] = p.through(writePipe).compile.drain
    val writeBodyEnd: F[Boolean] = fromFutureNoShift(F.delay(writeEnd(Chunk.empty)))
    writeBody *> writeBodyEnd
  }

This issue leads to flaky tests like this one:
https://github.com/http4s/http4s/runs/4498891671?check_suite_focus=true#step:13:5129

主要言語
Scala
スター
371
フォーク
63
平均マージ
7時間 47分
マージ済み PR(30日)
5

環境構築

はじめの一歩

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

http4s/blaze のほかの issue

http4s/blaze の issue をすべて見る

似ている issue

Scala の issue をもっと見る

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

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