[K/N] Fix deprecations and warnings in performance infra

This commit is contained in:
Pavel Kunyavskiy
2022-10-10 11:39:48 +02:00
committed by Space Team
parent 0947834f0d
commit b01808ddf5
9 changed files with 34 additions and 36 deletions
@@ -156,7 +156,7 @@ kotlin {
}
}
}
fromPreset(presets.js, 'js') {
fromPreset(presets.jsIr, 'js') {
compilations.main.kotlinOptions {
main = "noCall"
}
@@ -184,7 +184,7 @@ kotlin {
}
}
js {
js(IR) {
browser {
distribution {
directory = new File("$projectDir/web/")
@@ -119,7 +119,7 @@ data class BuildInfo(val buildNumber: String, val startTime: String, val endTime
val buildTypeElement = data.getOptionalField("buildType")
val buildType = buildTypeElement?.let {
elementToString(buildTypeElement, "buildType")
} ?: null
}
return BuildInfo(buildNumber, startTime, endTime, CommitsList(commits), branch, agentInfo, buildType)
} else {
error("Top level entity is expected to be an object. Please, check origin files.")
@@ -161,7 +161,7 @@ abstract class ElasticSearchIndex(val indexName: String, val connector: ElasticS
"mappings": {
"properties": {
${mapping.map { (property, type) ->
"\"${property}\": { \"type\": \"${type.name.toLowerCase()}\"${if (type == ElasticSearchType.DATE) "," +
"\"${property}\": { \"type\": \"${type.name.lowercase()}\"${if (type == ElasticSearchType.DATE) "," +
"\"format\": \"basic_date_time_no_millis\"" else ""} }"
}.joinToString()}}
}
@@ -27,7 +27,7 @@ class BenchmarksIndexesDispatcher(connector: ElasticSearchConnector, val feature
// Becnhmarks indexes to work with in case of existing feature values.
private val benchmarksIndexes =
if (featureValues.isNotEmpty())
featureValues.map { it to BenchmarksIndex("benchmarks_${it.replace(" ", "_").toLowerCase()}", connector) }
featureValues.map { it to BenchmarksIndex("benchmarks_${it.replace(" ", "_").lowercase()}", connector) }
.toMap()
else emptyMap()
@@ -122,7 +122,7 @@ class BenchmarksIndexesDispatcher(connector: ElasticSearchConnector, val feature
"bool": {
"must": [
{ "match": { "benchmarks.metric": "$metricName" } },
{ "terms": { "benchmarks.name": [${samples.map { "\"${it.toLowerCase()}\"" }.joinToString()}] }}
{ "terms": { "benchmarks.name": [${samples.map { "\"${it.lowercase()}\"" }.joinToString()}] }}
]
}
}, "inner_hits": {
@@ -50,7 +50,7 @@ internal fun getBuildsDescription(type: String?, branch: String?, agentInfo: Str
{ "regexp": { "buildNumber": { "value": "${if (it == "release")
".*eap.*|.*release.*|.*rc.*" else ".*dev.*"}" } }
},
{ "match": { "buildType": "${it.toUpperCase()}" } }
{ "match": { "buildType": "${it.uppercase()}" } }
]
}},
{ "bool": {
@@ -10,7 +10,7 @@ external fun require(module: String): dynamic
external val process: dynamic
external val __dirname: dynamic
fun main(args: Array<String>) {
fun main() {
println("Server Starting!")
val express = require("express")
@@ -28,7 +28,7 @@ fun main(args: Array<String>) {
app.set("view engine", "ejs")
app.use(express.static("ui"))
val server = http.createServer(app)
http.createServer(app)
app.listen(port, {
println("App listening on port " + port + "!")
})
@@ -24,7 +24,7 @@ object CachableResponseDispatcher {
action: (success: (result: Any) -> Unit, reject: () -> Unit) -> Unit) {
cachedResponses[request.url]?.let {
// Update cache value if needed. Update only if last result was get later than 2 minutes.
if (it.time.elapsedNow().inMinutes > 2.0) {
if (it.time.elapsedNow().inWholeMinutes >= 2.0) {
println("Cache update for ${request.url}...")
action({ result: Any ->
cachedResponses[request.url] = CachedResponse(result, TimeSource.Monotonic.markNow())
@@ -45,6 +45,7 @@ internal fun convertToNewFormat(data: JsonObject): List<Any> {
}
// Convert data results to expected format.
@Suppress("UNCHECKED_CAST")
internal fun convert(json: String, buildNumber: String, target: String): List<BenchmarksReport> {
val data = JsonTreeParser.parse(json)
val reports = if (data is JsonArray) {
@@ -143,12 +144,12 @@ data class BuildRegister(val buildId: String, val teamCityUser: String, val team
val data = JsonTreeParser.parse(response).jsonObject
data.getArray("build").forEach {
(it as JsonObject).getObject("revisions").getArray("revision").forEach {
val currentBranch = (it as JsonObject).getPrimitive("vcsBranchName").content.removePrefix("refs/heads/")
val currentProject = (it as JsonObject).getObject("vcs-root-instance").getPrimitive("name").content
it as JsonObject
val currentBranch = it.getPrimitive("vcsBranchName").content.removePrefix("refs/heads/")
val currentProject = it.getObject("vcs-root-instance").getPrimitive("name").content
if (projects.anyMatches(currentProject)) {
branch = currentBranch
}
return@forEach
}
}
branch ?: error("No project from list $projects can be found in build $buildId")
@@ -476,7 +477,7 @@ fun router(networkConnector: NetworkConnector) {
distinctValues("branch", buildInfoIndex).then { results ->
success(results)
}.catch { errorMessage ->
error(errorMessage.message ?: "Failed getting branches list.")
println(errorMessage.message ?: "Failed getting branches list.")
reject()
}
}
@@ -51,7 +51,7 @@ repositories {
apply plugin: 'kotlin-multiplatform'
kotlin {
js {
js(IR) {
browser {
binaries.executable()
distribution {
@@ -103,8 +103,7 @@ fun customizeChart(chart: dynamic, chartContainer: String, jquerySelector: dynam
var element = data.element
if (data.type == "point") {
val pointSize = 12
val currentBuild = builds.get(data.index)
currentBuild?.let { currentBuild ->
builds.get(data.index)?.let { currentBuild ->
// Higlight builds with failures.
if (currentBuild.failuresNumber > 0) {
val svgParameters: dynamic = object {}
@@ -148,9 +147,10 @@ fun customizeChart(chart: dynamic, chartContainer: String, jquerySelector: dynam
append("time: ${currentBuild.formattedStartTime}-${currentBuild.formattedFinishTime}<br>")
append("Commits:<br>")
val commitsList = (JsonTreeParser.parse("{${currentBuild.commits}}") as JsonObject).getArray("commits").map {
it as JsonObject
Commit(
(it as JsonObject).getPrimitive("revision").content,
(it as JsonObject).getPrimitive("developer").content
it.getPrimitive("revision").content,
it.getPrimitive("developer").content
)
}
val commits = if (commitsList.size > 3) commitsList.slice(0..2) else commitsList
@@ -171,11 +171,11 @@ fun customizeChart(chart: dynamic, chartContainer: String, jquerySelector: dynam
})
chart.on("created", {
val currentChart = jquerySelector
val parameters: dynamic = object {}
parameters["selector"] = "[data-chart-tooltip=\"$chartContainer\"]"
parameters["container"] = "#$chartContainer"
parameters["html"] = true
currentChart.tooltip(parameters)
val chartParameters: dynamic = object {}
chartParameters["selector"] = "[data-chart-tooltip=\"$chartContainer\"]"
chartParameters["container"] = "#$chartContainer"
chartParameters["html"] = true
currentChart.tooltip(chartParameters)
})
}
@@ -189,7 +189,7 @@ external fun encodeURIComponent(url: String): String
fun getDatesComponents() = "${beforeDate?.let {"&before=${encodeURIComponent(it)}"} ?: ""}" +
"${afterDate?.let {"&after=${encodeURIComponent(it)}"} ?: ""}"
fun main(args: Array<String>) {
fun main() {
val serverUrl = window.location.origin // use "http://localhost:3000" for local debug.
val zoomRatio = 2
@@ -216,6 +216,7 @@ fun main(args: Array<String>) {
// Add release branches to selector.
branches.filter { it != "master" }.forEach {
if ("^v?(\\d|\\.)+(-M\\d)?(-fixes)?$".toRegex().matches(it)) {
@Suppress("UNUSED_VARIABLE") // it's used within js block
val option = Option(it, it)
js("$('#inputGroupBranch')").append(js("$(option)"))
}
@@ -310,8 +311,7 @@ fun main(args: Array<String>) {
val metricUrl = "$serverUrl/metricValue/${parameters["target"]}/"
val unstableBenchmarksPromise = sendGetRequest("$serverUrl/unstable").then { response ->
val unstableList = response as String
val unstableBenchmarksPromise = sendGetRequest("$serverUrl/unstable").then { unstableList ->
val data = JsonTreeParser.parse(unstableList)
if (data !is JsonArray) {
error("Response is expected to be an array.")
@@ -322,15 +322,13 @@ fun main(args: Array<String>) {
}
// Get builds description.
val buildsInfoPromise = sendGetRequest(descriptionUrl).then { response ->
val buildsInfo = response as String
val buildsInfoPromise = sendGetRequest(descriptionUrl).then { buildsInfo ->
val data = JsonTreeParser.parse(buildsInfo)
if (data !is JsonArray) {
error("Response is expected to be an array.")
}
data.jsonArray.map {
val element = it as JsonElement
if (element.isNull) null else Build.create(element as JsonObject)
if (it.isNull) null else Build.create(it as JsonObject)
}
}
@@ -405,12 +403,12 @@ fun main(args: Array<String>) {
else ""
val requestedMetric = if (metric.startsWith("EXECUTION_TIME")) "EXECUTION_TIME" else metric
val url = "$metricUrl$requestedMetric$getParameters$branchParameter${
val queryUrl = "$metricUrl$requestedMetric$getParameters$branchParameter${
if (parameters["type"] != "all")
(if (getParameters.isEmpty() && branchParameter.isEmpty()) "?" else "&") + "type=${parameters["type"]}"
else ""
}&count=$buildsNumberToShow${getDatesComponents()}"
sendGetRequest(url)
sendGetRequest(queryUrl)
}.toTypedArray()
// Get metrics values for charts.
@@ -422,8 +420,7 @@ fun main(args: Array<String>) {
}
val labels = results.map { it.first }
val values = results[0]?.second?.size?.let { (0..it - 1).map { i -> results.map { it.second[i] } } }
?: emptyList()
val values = results[0].second.size.let { (0..it - 1).map { i -> results.map { it.second[i] } } }
labels to values
}
val labels = valuesList[0].first
@@ -436,7 +433,7 @@ fun main(args: Array<String>) {
compileData = labels to values.map { it.map { it?.let { it / 1000 } } }
compileChart = Chartist.Line("#compile_chart",
getChartData(labels, compileData.second),
getChartOptions(valuesToShow["COMPILE_TIME"]!![0]!!["samples"]!!.split(',').toTypedArray(),
getChartOptions(valuesToShow["COMPILE_TIME"]!![0]["samples"]!!.split(',').toTypedArray(),
"Time, milliseconds"))
buildsInfoPromise.then { builds ->
customizeChart(compileChart, "compile_chart", js("$(\"#compile_chart\")"), builds, parameters)