Skip to content
Snippets Groups Projects
Commit 5ac54e1b authored by Sören Henning's avatar Sören Henning
Browse files

Merge branch '186-add-prefix-to-output-files' into 'theodolite-kotlin'

Add prefix to output files to link results and experiment

See merge request !111
parents e2360a94 4e35b0b7
No related branches found
No related tags found
4 merge requests!159Re-implementation of Theodolite with Kotlin/Quarkus,!157Update Graal Image in CI pipeline,!111Add prefix to output files to link results and experiment,!83WIP: Re-implementation of Theodolite with Kotlin/Quarkus
Pipeline #2719 passed
Showing
with 48 additions and 20 deletions
...@@ -11,6 +11,7 @@ import kotlin.properties.Delegates ...@@ -11,6 +11,7 @@ import kotlin.properties.Delegates
@JsonDeserialize @JsonDeserialize
@RegisterForReflection @RegisterForReflection
class BenchmarkExecution : CustomResource(), Namespaced { class BenchmarkExecution : CustomResource(), Namespaced {
var executionId: Int = 0
lateinit var name: String lateinit var name: String
lateinit var benchmark: String lateinit var benchmark: String
lateinit var load: LoadDefinition lateinit var load: LoadDefinition
......
...@@ -26,7 +26,6 @@ class KubernetesBenchmark : Benchmark, CustomResource(), Namespaced { ...@@ -26,7 +26,6 @@ class KubernetesBenchmark : Benchmark, CustomResource(), Namespaced {
private fun loadKubernetesResources(resources: List<String>): List<Pair<String, KubernetesResource>> { private fun loadKubernetesResources(resources: List<String>): List<Pair<String, KubernetesResource>> {
val parser = YamlParser() val parser = YamlParser()
val loader = K8sResourceLoader(DefaultKubernetesClient().inNamespace(namespace)) val loader = K8sResourceLoader(DefaultKubernetesClient().inNamespace(namespace))
return resources return resources
.map { resource -> .map { resource ->
......
...@@ -9,7 +9,10 @@ import java.time.Instant ...@@ -9,7 +9,10 @@ import java.time.Instant
private val logger = KotlinLogging.logger {} private val logger = KotlinLogging.logger {}
class AnalysisExecutor(private val slo: BenchmarkExecution.Slo) { class AnalysisExecutor(
private val slo: BenchmarkExecution.Slo,
private val executionId: Int
) {
private val fetcher = MetricFetcher( private val fetcher = MetricFetcher(
prometheusURL = slo.prometheusUrl, prometheusURL = slo.prometheusUrl,
...@@ -26,8 +29,7 @@ class AnalysisExecutor(private val slo: BenchmarkExecution.Slo) { ...@@ -26,8 +29,7 @@ class AnalysisExecutor(private val slo: BenchmarkExecution.Slo) {
query = "sum by(group)(kafka_consumergroup_group_lag >= 0)" query = "sum by(group)(kafka_consumergroup_group_lag >= 0)"
) )
CsvExporter().toCsv(name = "${load.get()}_${res.get()}_${slo.sloType}", prom = prometheusData) CsvExporter().toCsv(name = "$executionId-${load.get()}-${res.get()}-${slo.sloType}", prom = prometheusData)
val sloChecker = SloCheckerFactory().create( val sloChecker = SloCheckerFactory().create(
slotype = slo.sloType, slotype = slo.sloType,
externalSlopeURL = slo.externalSloUrl, externalSlopeURL = slo.externalSloUrl,
......
...@@ -25,7 +25,8 @@ abstract class BenchmarkExecutor( ...@@ -25,7 +25,8 @@ abstract class BenchmarkExecutor(
val results: Results, val results: Results,
val executionDuration: Duration, val executionDuration: Duration,
configurationOverrides: List<ConfigurationOverride?>, configurationOverrides: List<ConfigurationOverride?>,
val slo: BenchmarkExecution.Slo val slo: BenchmarkExecution.Slo,
val executionId: Int
) { ) {
var run: AtomicBoolean = AtomicBoolean(true) var run: AtomicBoolean = AtomicBoolean(true)
......
...@@ -19,8 +19,9 @@ class BenchmarkExecutorImpl( ...@@ -19,8 +19,9 @@ class BenchmarkExecutorImpl(
results: Results, results: Results,
executionDuration: Duration, executionDuration: Duration,
private val configurationOverrides: List<ConfigurationOverride?>, private val configurationOverrides: List<ConfigurationOverride?>,
slo: BenchmarkExecution.Slo slo: BenchmarkExecution.Slo,
) : BenchmarkExecutor(benchmark, results, executionDuration, configurationOverrides, slo) { executionId: Int
) : BenchmarkExecutor(benchmark, results, executionDuration, configurationOverrides, slo, executionId) {
override fun runExperiment(load: LoadDimension, res: Resource): Boolean { override fun runExperiment(load: LoadDimension, res: Resource): Boolean {
var result = false var result = false
val benchmarkDeployment = benchmark.buildDeployment(load, res, this.configurationOverrides) val benchmarkDeployment = benchmark.buildDeployment(load, res, this.configurationOverrides)
...@@ -36,7 +37,7 @@ class BenchmarkExecutorImpl( ...@@ -36,7 +37,7 @@ class BenchmarkExecutorImpl(
if (this.run.get()) { if (this.run.get()) {
result = result =
AnalysisExecutor(slo = slo).analyze(load = load, res = res, executionDuration = executionDuration) AnalysisExecutor(slo = slo, executionId = executionId).analyze(load = load, res = res, executionDuration = executionDuration)
this.results.setResult(Pair(load, res), result) this.results.setResult(Pair(load, res), result)
} }
benchmarkDeployment.teardown() benchmarkDeployment.teardown()
......
package theodolite.execution package theodolite.execution
import com.google.gson.GsonBuilder
import theodolite.benchmark.BenchmarkExecution import theodolite.benchmark.BenchmarkExecution
import theodolite.benchmark.KubernetesBenchmark import theodolite.benchmark.KubernetesBenchmark
import theodolite.patcher.PatcherDefinitionFactory import theodolite.patcher.PatcherDefinitionFactory
...@@ -9,6 +10,7 @@ import theodolite.util.Config ...@@ -9,6 +10,7 @@ import theodolite.util.Config
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.io.PrintWriter
import java.time.Duration import java.time.Duration
class TheodoliteExecutor( class TheodoliteExecutor(
...@@ -37,11 +39,12 @@ class TheodoliteExecutor( ...@@ -37,11 +39,12 @@ class TheodoliteExecutor(
executor = executor =
BenchmarkExecutorImpl( BenchmarkExecutorImpl(
kubernetesBenchmark, benchmark = kubernetesBenchmark,
results, results = results,
executionDuration, executionDuration = executionDuration,
config.configOverrides, configurationOverrides = config.configOverrides,
config.slos[0] slo = config.slos[0],
executionId = config.executionId
) )
return Config( return Config(
...@@ -72,6 +75,9 @@ class TheodoliteExecutor( ...@@ -72,6 +75,9 @@ class TheodoliteExecutor(
} }
fun run() { fun run() {
storeAsFile(this.config, "${this.config.executionId}-execution-configuration")
storeAsFile(kubernetesBenchmark, "${this.config.executionId}-benchmark-configuration")
val config = buildConfig() val config = buildConfig()
// execute benchmarks for each load // execute benchmarks for each load
for (load in config.loads) { for (load in config.loads) {
...@@ -79,5 +85,14 @@ class TheodoliteExecutor( ...@@ -79,5 +85,14 @@ class TheodoliteExecutor(
config.compositeStrategy.findSuitableResource(load, config.resources) config.compositeStrategy.findSuitableResource(load, config.resources)
} }
} }
storeAsFile(config.compositeStrategy.benchmarkExecutor.results, "${this.config.executionId}-result")
}
private fun <T> storeAsFile(saveObject: T, filename: String) {
val gson = GsonBuilder().enableComplexMapKeySerialization().setPrettyPrinting().create()
PrintWriter(filename).use { pw ->
pw.println(gson.toJson(saveObject))
}
} }
} }
...@@ -2,6 +2,7 @@ package theodolite.execution.operator ...@@ -2,6 +2,7 @@ package theodolite.execution.operator
import io.fabric8.kubernetes.client.NamespacedKubernetesClient import io.fabric8.kubernetes.client.NamespacedKubernetesClient
import io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext import io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext
import khttp.patch
import mu.KotlinLogging import mu.KotlinLogging
import theodolite.benchmark.BenchmarkExecution import theodolite.benchmark.BenchmarkExecution
import theodolite.benchmark.KubernetesBenchmark import theodolite.benchmark.KubernetesBenchmark
...@@ -10,17 +11,20 @@ import java.lang.Thread.sleep ...@@ -10,17 +11,20 @@ import java.lang.Thread.sleep
import java.util.concurrent.ConcurrentHashMap import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.ConcurrentLinkedDeque import java.util.concurrent.ConcurrentLinkedDeque
import java.util.concurrent.atomic.AtomicBoolean import java.util.concurrent.atomic.AtomicBoolean
import java.util.concurrent.atomic.AtomicInteger
private val logger = KotlinLogging.logger {} private val logger = KotlinLogging.logger {}
class TheodoliteController( class TheodoliteController(
val client: NamespacedKubernetesClient, val client: NamespacedKubernetesClient,
val executionContext: CustomResourceDefinitionContext val executionContext: CustomResourceDefinitionContext,
val path: String
) { ) {
lateinit var executor: TheodoliteExecutor lateinit var executor: TheodoliteExecutor
val executionsQueue: ConcurrentLinkedDeque<BenchmarkExecution> = ConcurrentLinkedDeque() val executionsQueue: ConcurrentLinkedDeque<BenchmarkExecution> = ConcurrentLinkedDeque()
val benchmarks: ConcurrentHashMap<String, KubernetesBenchmark> = ConcurrentHashMap() val benchmarks: ConcurrentHashMap<String, KubernetesBenchmark> = ConcurrentHashMap()
var isUpdated = AtomicBoolean(false) var isUpdated = AtomicBoolean(false)
var executionID = AtomicInteger(0)
fun run() { fun run() {
while (true) { while (true) {
...@@ -59,7 +63,9 @@ class TheodoliteController( ...@@ -59,7 +63,9 @@ class TheodoliteController(
@Synchronized @Synchronized
fun runExecution(execution: BenchmarkExecution, benchmark: KubernetesBenchmark) { fun runExecution(execution: BenchmarkExecution, benchmark: KubernetesBenchmark) {
execution.executionId = executionID.getAndSet(executionID.get() + 1)
isUpdated.set(false) isUpdated.set(false)
benchmark.path = path
logger.info { "Start execution ${execution.name} with benchmark ${benchmark.name}." } logger.info { "Start execution ${execution.name} with benchmark ${benchmark.name}." }
executor = TheodoliteExecutor(config = execution, kubernetesBenchmark = benchmark) executor = TheodoliteExecutor(config = execution, kubernetesBenchmark = benchmark)
executor.run() executor.run()
......
...@@ -44,7 +44,8 @@ class TheodoliteOperator { ...@@ -44,7 +44,8 @@ class TheodoliteOperator {
val executionContext = contextFactory.create(API_VERSION, SCOPE, GROUP, EXECUTION_PLURAL) val executionContext = contextFactory.create(API_VERSION, SCOPE, GROUP, EXECUTION_PLURAL)
val benchmarkContext = contextFactory.create(API_VERSION, SCOPE, GROUP, BENCHMARK_PLURAL) val benchmarkContext = contextFactory.create(API_VERSION, SCOPE, GROUP, BENCHMARK_PLURAL)
val controller = TheodoliteController(client = client, executionContext = executionContext) val appResource = System.getenv("THEODOLITE_APP_RESOURCES") ?: "./config"
val controller = TheodoliteController(client = client, executionContext = executionContext, path = appResource)
val informerFactory = client.informers() val informerFactory = client.informers()
val informerExecution = informerFactory.sharedIndexInformerForCustomResource( val informerExecution = informerFactory.sharedIndexInformerForCustomResource(
......
...@@ -31,7 +31,7 @@ class CompositeStrategyTest { ...@@ -31,7 +31,7 @@ class CompositeStrategyTest {
val results = Results() val results = Results()
val benchmark = TestBenchmark() val benchmark = TestBenchmark()
val sloChecker: BenchmarkExecution.Slo = BenchmarkExecution.Slo() val sloChecker: BenchmarkExecution.Slo = BenchmarkExecution.Slo()
val benchmarkExecutor = TestBenchmarkExecutorImpl(mockResults, benchmark, results, sloChecker) val benchmarkExecutor = TestBenchmarkExecutorImpl(mockResults, benchmark, results, sloChecker, 0)
val linearSearch = LinearSearch(benchmarkExecutor) val linearSearch = LinearSearch(benchmarkExecutor)
val lowerBoundRestriction = LowerBoundRestriction(results) val lowerBoundRestriction = LowerBoundRestriction(results)
val strategy = val strategy =
...@@ -65,7 +65,7 @@ class CompositeStrategyTest { ...@@ -65,7 +65,7 @@ class CompositeStrategyTest {
val benchmark = TestBenchmark() val benchmark = TestBenchmark()
val sloChecker: BenchmarkExecution.Slo = BenchmarkExecution.Slo() val sloChecker: BenchmarkExecution.Slo = BenchmarkExecution.Slo()
val benchmarkExecutorImpl = val benchmarkExecutorImpl =
TestBenchmarkExecutorImpl(mockResults, benchmark, results, sloChecker) TestBenchmarkExecutorImpl(mockResults, benchmark, results, sloChecker, 0)
val binarySearch = BinarySearch(benchmarkExecutorImpl) val binarySearch = BinarySearch(benchmarkExecutorImpl)
val lowerBoundRestriction = LowerBoundRestriction(results) val lowerBoundRestriction = LowerBoundRestriction(results)
val strategy = val strategy =
...@@ -98,7 +98,7 @@ class CompositeStrategyTest { ...@@ -98,7 +98,7 @@ class CompositeStrategyTest {
val results = Results() val results = Results()
val benchmark = TestBenchmark() val benchmark = TestBenchmark()
val sloChecker: BenchmarkExecution.Slo = BenchmarkExecution.Slo() val sloChecker: BenchmarkExecution.Slo = BenchmarkExecution.Slo()
val benchmarkExecutor = TestBenchmarkExecutorImpl(mockResults, benchmark, results, sloChecker) val benchmarkExecutor = TestBenchmarkExecutorImpl(mockResults, benchmark, results, sloChecker, 0)
val binarySearch = BinarySearch(benchmarkExecutor) val binarySearch = BinarySearch(benchmarkExecutor)
val lowerBoundRestriction = LowerBoundRestriction(results) val lowerBoundRestriction = LowerBoundRestriction(results)
val strategy = val strategy =
......
...@@ -12,14 +12,16 @@ class TestBenchmarkExecutorImpl( ...@@ -12,14 +12,16 @@ class TestBenchmarkExecutorImpl(
private val mockResults: Array<Array<Boolean>>, private val mockResults: Array<Array<Boolean>>,
benchmark: Benchmark, benchmark: Benchmark,
results: Results, results: Results,
slo: BenchmarkExecution.Slo slo: BenchmarkExecution.Slo,
executionId: Int
) : ) :
BenchmarkExecutor( BenchmarkExecutor(
benchmark, benchmark,
results, results,
executionDuration = Duration.ofSeconds(1), executionDuration = Duration.ofSeconds(1),
configurationOverrides = emptyList(), configurationOverrides = emptyList(),
slo = slo slo = slo,
executionId = executionId
) { ) {
override fun runExperiment(load: LoadDimension, res: Resource): Boolean { override fun runExperiment(load: LoadDimension, res: Resource): Boolean {
......
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