Add uploading IDE performance benchmarks to ES
This commit is contained in:
@@ -38,6 +38,7 @@ dependencies {
|
|||||||
testImplementation(commonDep("junit:junit"))
|
testImplementation(commonDep("junit:junit"))
|
||||||
testImplementation("com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.11.+")
|
testImplementation("com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.11.+")
|
||||||
testImplementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.11.+")
|
testImplementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.11.+")
|
||||||
|
testImplementation("khttp:khttp:1.0.0")
|
||||||
|
|
||||||
|
|
||||||
Platform[192].orHigher {
|
Platform[192].orHigher {
|
||||||
|
|||||||
@@ -359,6 +359,7 @@ class Stats(
|
|||||||
var buildId: Int? = null
|
var buildId: Int? = null
|
||||||
var agentName: String? = null
|
var agentName: String? = null
|
||||||
var buildBranch: String? = null
|
var buildBranch: String? = null
|
||||||
|
var commit: String? = null
|
||||||
|
|
||||||
System.getenv("TEAMCITY_BUILD_PROPERTIES_FILE")?.let { teamcityConfig ->
|
System.getenv("TEAMCITY_BUILD_PROPERTIES_FILE")?.let { teamcityConfig ->
|
||||||
val buildProperties = Properties()
|
val buildProperties = Properties()
|
||||||
@@ -367,6 +368,7 @@ class Stats(
|
|||||||
buildId = buildProperties["teamcity.build.id"]?.toString()?.toInt()
|
buildId = buildProperties["teamcity.build.id"]?.toString()?.toInt()
|
||||||
agentName = buildProperties["agent.name"]?.toString()
|
agentName = buildProperties["agent.name"]?.toString()
|
||||||
buildBranch = buildProperties["teamcity.build.branch"]?.toString()
|
buildBranch = buildProperties["teamcity.build.branch"]?.toString()
|
||||||
|
commit = buildProperties["build.vcs.number"]?.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (perfTestRawDataMs.isNotEmpty()) {
|
if (perfTestRawDataMs.isNotEmpty()) {
|
||||||
@@ -379,6 +381,7 @@ class Stats(
|
|||||||
val benchmark = Benchmark(
|
val benchmark = Benchmark(
|
||||||
agentName = agentName,
|
agentName = agentName,
|
||||||
buildBranch = buildBranch,
|
buildBranch = buildBranch,
|
||||||
|
commit = commit,
|
||||||
buildId = buildId,
|
buildId = buildId,
|
||||||
benchmark = name,
|
benchmark = name,
|
||||||
name = it.metricName,
|
name = it.metricName,
|
||||||
@@ -389,6 +392,7 @@ class Stats(
|
|||||||
)
|
)
|
||||||
|
|
||||||
benchmark.writeJson()
|
benchmark.writeJson()
|
||||||
|
ESUploader.upload(benchmark)
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
metric = null
|
metric = null
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.idea.perf.util
|
||||||
|
|
||||||
|
import khttp.structures.authorization.BasicAuthorization
|
||||||
|
import java.io.FileInputStream
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
object ESUploader {
|
||||||
|
var host: String? = null
|
||||||
|
var username: String? = null
|
||||||
|
var password: String? = null
|
||||||
|
|
||||||
|
var indexName = "kotlin_ide_benchmarks"
|
||||||
|
|
||||||
|
init {
|
||||||
|
host = System.getenv("es.hostname")
|
||||||
|
username = System.getenv("es.username")
|
||||||
|
password = System.getenv("es.password")
|
||||||
|
logMessage { "initialized es details $username @ $host" }
|
||||||
|
}
|
||||||
|
|
||||||
|
fun upload(benchmark: Benchmark) {
|
||||||
|
if (host == null) {
|
||||||
|
logMessage { "ES host is not specified, ${benchmark.id()} would not be uploaded" }
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
val url = "$host/$indexName/_doc/${benchmark.id()}"
|
||||||
|
val auth = if (username != null && password != null) {
|
||||||
|
BasicAuthorization(username!!, password!!)
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
val json = kotlinJsonMapper.writeValueAsString(benchmark)
|
||||||
|
|
||||||
|
val response = khttp.put(
|
||||||
|
url = url,
|
||||||
|
auth = auth,
|
||||||
|
headers = mapOf("Content-Type" to "application/json"),
|
||||||
|
data = json
|
||||||
|
)
|
||||||
|
logMessage { "${response.statusCode} -> ${response.jsonObject}" }
|
||||||
|
if (response.statusCode != 200 && response.statusCode != 201) {
|
||||||
|
throw IllegalStateException("Error code ${response.statusCode} -> ${response.text}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -30,6 +30,8 @@ data class Benchmark(
|
|||||||
var buildTimestamp: String,
|
var buildTimestamp: String,
|
||||||
@set:JsonProperty("buildBranch")
|
@set:JsonProperty("buildBranch")
|
||||||
var buildBranch: String?,
|
var buildBranch: String?,
|
||||||
|
@set:JsonProperty("commit")
|
||||||
|
var commit: String? = null,
|
||||||
@set:JsonProperty("buildId")
|
@set:JsonProperty("buildId")
|
||||||
var buildId: Int?,
|
var buildId: Int?,
|
||||||
@set:JsonProperty("metricValue")
|
@set:JsonProperty("metricValue")
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ fun main(args: Array<String>) {
|
|||||||
val warmUpBenchmark = Benchmark(
|
val warmUpBenchmark = Benchmark(
|
||||||
agentName = benchmark.agentName,
|
agentName = benchmark.agentName,
|
||||||
buildBranch = benchmark.buildBranch,
|
buildBranch = benchmark.buildBranch,
|
||||||
|
commit = benchmark.commit,
|
||||||
buildId = benchmark.buildId,
|
buildId = benchmark.buildId,
|
||||||
benchmark = benchmark.benchmark,
|
benchmark = benchmark.benchmark,
|
||||||
name = benchmark.name,
|
name = benchmark.name,
|
||||||
@@ -37,6 +38,7 @@ fun main(args: Array<String>) {
|
|||||||
metrics = it.metrics ?: emptyList()
|
metrics = it.metrics ?: emptyList()
|
||||||
)
|
)
|
||||||
warmUpBenchmark.writeJson()
|
warmUpBenchmark.writeJson()
|
||||||
|
ESUploader.upload(warmUpBenchmark)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -47,6 +49,7 @@ fun main(args: Array<String>) {
|
|||||||
val geomMeanBenchmark = Benchmark(
|
val geomMeanBenchmark = Benchmark(
|
||||||
agentName = loadBenchmark.agentName,
|
agentName = loadBenchmark.agentName,
|
||||||
buildBranch = loadBenchmark.buildBranch,
|
buildBranch = loadBenchmark.buildBranch,
|
||||||
|
commit = loadBenchmark.commit,
|
||||||
buildId = loadBenchmark.buildId,
|
buildId = loadBenchmark.buildId,
|
||||||
benchmark = loadBenchmark.benchmark,
|
benchmark = loadBenchmark.benchmark,
|
||||||
synthetic = true,
|
synthetic = true,
|
||||||
@@ -58,5 +61,6 @@ fun main(args: Array<String>) {
|
|||||||
.filter { it.synthetic != true && it.warmUp != true }
|
.filter { it.synthetic != true && it.warmUp != true }
|
||||||
.forEach { geomMeanBenchmark.merge(it) }
|
.forEach { geomMeanBenchmark.merge(it) }
|
||||||
geomMeanBenchmark.writeJson()
|
geomMeanBenchmark.writeJson()
|
||||||
|
ESUploader.upload(geomMeanBenchmark)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user