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

Made python analysis working by post

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