Skip to content

Commit

Permalink
Minimise HttpOverHttp2Test flakes (#8207)
Browse files Browse the repository at this point in the history
  • Loading branch information
yschimke committed Jan 20, 2024
1 parent 357ded4 commit f6600e5
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions okhttp/src/test/java/okhttp3/internal/http2/HttpOverHttp2Test.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import assertk.assertions.isFalse
import assertk.assertions.isNull
import assertk.assertions.isTrue
import assertk.fail
import java.io.File
import java.io.IOException
import java.net.HttpURLConnection
import java.net.SocketTimeoutException
Expand Down Expand Up @@ -86,15 +85,16 @@ import okhttp3.tls.HandshakeCertificates
import okio.Buffer
import okio.BufferedSink
import okio.GzipSink
import okio.Path.Companion.toPath
import okio.buffer
import okio.fakefilesystem.FakeFileSystem
import org.junit.jupiter.api.AfterEach
import org.junit.jupiter.api.Assertions.assertArrayEquals
import org.junit.jupiter.api.Assumptions.assumeTrue
import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Tag
import org.junit.jupiter.api.Timeout
import org.junit.jupiter.api.extension.RegisterExtension
import org.junit.jupiter.api.io.TempDir
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.ArgumentsSource

Expand All @@ -107,9 +107,6 @@ class HttpOverHttp2Test {
override fun arguments() = listOf(Protocol.H2_PRIOR_KNOWLEDGE, Protocol.HTTP_2)
}

@TempDir
lateinit var tempDir: File

@RegisterExtension
val platform: PlatformRule = PlatformRule()

Expand All @@ -127,7 +124,8 @@ class HttpOverHttp2Test {
private lateinit var server: MockWebServer
private lateinit var protocol: Protocol
private lateinit var client: OkHttpClient
private lateinit var cache: Cache
private val fileSystem: FakeFileSystem = FakeFileSystem()
private val cache: Cache = Cache("/tmp/cache".toPath(), Long.MAX_VALUE, fileSystem)
private lateinit var scheme: String

private fun configureClientTestRule(): OkHttpClientTestRule {
Expand Down Expand Up @@ -164,10 +162,13 @@ class HttpOverHttp2Test {
.build()
scheme = "http"
}
cache = Cache(tempDir, Int.MAX_VALUE.toLong())
}

@AfterEach fun tearDown() {
// TODO reenable after https://github.com/square/okhttp/issues/8206
// fileSystem.checkNoOpenFiles()
cache.close()

java.net.Authenticator.setDefault(null)
}

Expand Down

0 comments on commit f6600e5

Please sign in to comment.