Skip to content
Snippets Groups Projects
Commit f8bdee2f authored by Lorenz Boguhn's avatar Lorenz Boguhn Committed by Lorenz Boguhn
Browse files

Made python analysis working by post

parent 6b21d1a5
No related branches found
No related tags found
4 merge requests!159Re-implementation of Theodolite with Kotlin/Quarkus,!157Update Graal Image in CI pipeline,!92Introduce experiment evaluation,!83WIP: Re-implementation of Theodolite with Kotlin/Quarkus
......@@ -12,10 +12,12 @@ class MetricFetcher(private val prometheusURL: String) {
"query" to query,
"start" to toISODate(start),
"end" to toISODate(end),
"step" to "5s")
"step" to "5s"
)
val response = get("$prometheusURL/api/v1/query_range", params = parameter)
return response.jsonObject.getJSONObject("data").getJSONArray("result").getJSONObject(0)["values"]
//TODO FIX: NOTHING RECEIVED
return response.jsonObject.getJSONObject("data").getJSONArray("result")//.getJSONObject(0)["values"]
}
private fun toISODate(timestamp: Long): String {
......@@ -28,4 +30,4 @@ class MetricFetcher(private val prometheusURL: String) {
// TODO("pars with gson")
return ""
}
}
\ No newline at end of file
}
package theodolite.evaluation
import khttp.get
import khttp.post
import org.json.JSONObject
class SLOCheckerImpl(private val prometheusURL: String): SLOChecker {
class SLOCheckerImpl(private val prometheusURL: String) : SLOChecker {
override fun evaluate(start: Long, end: Long): Boolean {
val metricFetcher = MetricFetcher(prometheusURL = prometheusURL)
val totalLag = metricFetcher.fetchMetric(start, end, "sum by(group)(kafka_consumergroup_group_lag > 0)")
val parameter = mapOf("total_lag" to totalLag.toString())
val response = get("http://127.0.0.1:8000/evaluate-slope", params = parameter)
return response.jsonObject["suitable"] == "true"
val parameter = mapOf("total_lag" to totalLag)
//val response = get("http://127.0.0.1:8000/evaluate-slope", params = parameter)
val post = post("http://127.0.0.1:8000/evaluate-slope", data = JSONObject(parameter))
//println(JSONObject(parameter))
//println(post.text.toBoolean())
return post.text.toBoolean()//response.jsonObject["suitable"] == "true"
}
}
\ No newline at end of file
}
......@@ -39,6 +39,7 @@ abstract class BenchmarkExecutor(
*
*/
fun waitAndLog() {
logger.info { "Execution of a new benchmark started." }
for (i in 1.rangeTo(executionDuration.toMinutes())) {
Thread.sleep(Duration.ofMinutes(1).toMillis())
logger.info { "Executed: $i minutes" }
......
package theodolite.execution
import theodolite.benchmark.Benchmark
import theodolite.evaluation.SLOChecker
import theodolite.evaluation.SLOCheckerImpl
import theodolite.util.ConfigurationOverride
import theodolite.util.LoadDimension
import theodolite.util.Resource
import theodolite.util.Results
import java.sql.Time
import java.time.Duration
import java.time.Instant
......@@ -24,8 +22,10 @@ class BenchmarkExecutorImpl(
benchmarkDeployment.teardown()
// todo evaluate
val result = SLOCheckerImpl("http://localhost:32656")
.evaluate(Instant.now().toEpochMilli() - executionDuration.toMillis(),
Instant.now().toEpochMilli())
.evaluate( //TODO FIX HERE
Instant.now().toEpochMilli() - 3600 * 2000, //executionDuration.toMillis(),
Instant.now().toEpochMilli()
)
this.results.setResult(Pair(load, res), result)
return result
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment