From f8bdee2f1d826c11f4dc04c30c482771c604d4a9 Mon Sep 17 00:00:00 2001 From: lorenz <stu203404@mail.uni-kiel.de> Date: Thu, 11 Mar 2021 01:58:41 +0100 Subject: [PATCH] Made python analysis working by post --- .../theodolite/evaluation/MetricFetcher.kt | 8 +++++--- .../theodolite/evaluation/SLOCheckerImpl.kt | 17 +++++++++++------ .../theodolite/execution/BenchmarkExecutor.kt | 1 + .../execution/BenchmarkExecutorImpl.kt | 8 ++++---- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/evaluation/MetricFetcher.kt b/theodolite-quarkus/src/main/kotlin/theodolite/evaluation/MetricFetcher.kt index f64880411..d95d5971b 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/evaluation/MetricFetcher.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/evaluation/MetricFetcher.kt @@ -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 +} diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/evaluation/SLOCheckerImpl.kt b/theodolite-quarkus/src/main/kotlin/theodolite/evaluation/SLOCheckerImpl.kt index 594803f06..8a638d7f2 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/evaluation/SLOCheckerImpl.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/evaluation/SLOCheckerImpl.kt @@ -1,14 +1,19 @@ 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 +} diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutor.kt b/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutor.kt index 1e9398122..94363d97e 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutor.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutor.kt @@ -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" } diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutorImpl.kt b/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutorImpl.kt index 99f21294a..47c5eac7e 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutorImpl.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutorImpl.kt @@ -1,13 +1,11 @@ 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 } -- GitLab