Set custom timeout for flaky muted tests synchronization requests
Cause: Teamcity requests processes for average 80 seconds
This commit is contained in:
committed by
TeamCityServer
parent
27dd9484ba
commit
6a6e2a1c77
+4
-5
@@ -2,7 +2,6 @@ package org.jetbrains.kotlin.test.mutes
|
|||||||
|
|
||||||
import com.fasterxml.jackson.databind.JsonNode
|
import com.fasterxml.jackson.databind.JsonNode
|
||||||
import com.fasterxml.jackson.module.kotlin.treeToValue
|
import com.fasterxml.jackson.module.kotlin.treeToValue
|
||||||
import khttp.DEFAULT_TIMEOUT
|
|
||||||
import khttp.responses.Response
|
import khttp.responses.Response
|
||||||
import khttp.structures.authorization.Authorization
|
import khttp.structures.authorization.Authorization
|
||||||
|
|
||||||
@@ -12,7 +11,7 @@ private val headers = mapOf("Content-type" to "application/json", "Accept" to "a
|
|||||||
private val authUser = object : Authorization {
|
private val authUser = object : Authorization {
|
||||||
override val header = "Authorization" to "Bearer ${getMandatoryProperty("org.jetbrains.kotlin.test.mutes.teamcity.server.token")}"
|
override val header = "Authorization" to "Bearer ${getMandatoryProperty("org.jetbrains.kotlin.test.mutes.teamcity.server.token")}"
|
||||||
}
|
}
|
||||||
private const val customTimeout = DEFAULT_TIMEOUT * 4
|
private const val requestTimeoutSec = 120.0
|
||||||
|
|
||||||
|
|
||||||
internal fun getMutedTestsOnTeamcityForRootProject(rootScopeId: String): List<MuteTestJson> {
|
internal fun getMutedTestsOnTeamcityForRootProject(rootScopeId: String): List<MuteTestJson> {
|
||||||
@@ -34,7 +33,7 @@ private fun traverseAll(requestHref: String, requestParams: Map<String, String>)
|
|||||||
val jsonResponses = mutableListOf<JsonNode>()
|
val jsonResponses = mutableListOf<JsonNode>()
|
||||||
|
|
||||||
fun request(url: String, params: Map<String, String>): String {
|
fun request(url: String, params: Map<String, String>): String {
|
||||||
val currentResponse = khttp.get(url, headers, params, auth = authUser, timeout = customTimeout)
|
val currentResponse = khttp.get(url, headers, params, auth = authUser, timeout = requestTimeoutSec)
|
||||||
checkResponseAndLog(currentResponse)
|
checkResponseAndLog(currentResponse)
|
||||||
val currentJsonResponse = jsonObjectMapper.readTree(currentResponse.text)
|
val currentJsonResponse = jsonObjectMapper.readTree(currentResponse.text)
|
||||||
jsonResponses.add(currentJsonResponse)
|
jsonResponses.add(currentJsonResponse)
|
||||||
@@ -56,7 +55,7 @@ internal fun uploadMutedTests(uploadMap: Map<String, MuteTestJson>) {
|
|||||||
headers = headers,
|
headers = headers,
|
||||||
data = jsonObjectMapper.writeValueAsString(muteTestJson),
|
data = jsonObjectMapper.writeValueAsString(muteTestJson),
|
||||||
auth = authUser,
|
auth = authUser,
|
||||||
timeout = customTimeout
|
timeout = requestTimeoutSec
|
||||||
)
|
)
|
||||||
checkResponseAndLog(response)
|
checkResponseAndLog(response)
|
||||||
}
|
}
|
||||||
@@ -68,7 +67,7 @@ internal fun deleteMutedTests(deleteMap: Map<String, MuteTestJson>) {
|
|||||||
"$buildServerUrl/app/rest/mutes/id:${muteTestJson.id}",
|
"$buildServerUrl/app/rest/mutes/id:${muteTestJson.id}",
|
||||||
headers = headers,
|
headers = headers,
|
||||||
auth = authUser,
|
auth = authUser,
|
||||||
timeout = customTimeout
|
timeout = requestTimeoutSec
|
||||||
)
|
)
|
||||||
try {
|
try {
|
||||||
checkResponseAndLog(response)
|
checkResponseAndLog(response)
|
||||||
|
|||||||
Reference in New Issue
Block a user