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

Minimise HttpOverHttp2Test flakes #8207

Merged
merged 2 commits into from
Jan 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can’t leave a TODO: re-enable after X when X is already closed; that’s cheating!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, true. I'll bite the bullet and look again!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cache.close()

java.net.Authenticator.setDefault(null)
}

Expand Down