Skip to content
Snippets Groups Projects
Commit 1d76c826 authored by Benedikt Wetzel's avatar Benedikt Wetzel
Browse files

merge upstream theodolite-kotlin

parents 06c654f0 e71cc3e5
No related branches found
No related tags found
4 merge requests!159Re-implementation of Theodolite with Kotlin/Quarkus,!157Update Graal Image in CI pipeline,!131Add definitions for UC1, UC2, UC3, UC4,!83WIP: Re-implementation of Theodolite with Kotlin/Quarkus
package theodolite.util
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import com.fasterxml.jackson.databind.annotation.JsonSerialize
import io.quarkus.runtime.annotations.RegisterForReflection
/**
......@@ -19,13 +20,6 @@ class PatcherDefinition {
*/
lateinit var resource: String
/**
* The container which the patcher is applied to
*/
lateinit var container: String
/**
* The variable name for the patcher
*/
lateinit var variableName: String
@JsonSerialize
lateinit var properties: MutableMap<String, String>
}
apiVersion: theodolite.com/v1
kind: execution
metadata:
name: theodolite-example-execution
spec:
benchmark: uc1-kstreams
load:
loadType: "NumSensors"
loadValues:
- 50000
resources:
resourceType: "Instances"
resourceValues:
- 1
slos:
- sloType: "lag trend"
threshold: 1000
prometheusUrl: "http://localhost:32656"
externalSloUrl: "http://localhost:80/evaluate-slope"
offset: 0
warmup: 0
execution:
strategy: "LinearSearch"
duration: 60
repetitions: 1
loadGenerationDelay: 30 # in seconds
restrictions:
- "LowerBound"
configOverrides: []
\ No newline at end of file
......@@ -31,27 +31,32 @@ class ResourceLimitPatcherTest {
val k8sResource = loader.loadK8sResource("Deployment", testPath + fileName) as Deployment
val defCPU = PatcherDefinition()
defCPU.variableName = "cpu"
defCPU.resource = "cpu-memory-deployment.yaml"
defCPU.container = "uc-application"
defCPU.type = "ResourceLimitPatcher"
defCPU.properties = mutableMapOf(
"limitedResource" to "cpu",
"container" to "application"
)
val defMEM = PatcherDefinition()
defMEM.variableName = "memory"
defMEM.resource = "cpu-memory-deployment.yaml"
defMEM.container = "uc-application"
defMEM.type = "ResourceLimitPatcher"
defMEM.properties = mutableMapOf(
"limitedResource" to "memory",
"container" to "uc-application"
)
patcherFactory.createPatcher(
patcherDefinition = defCPU,
k8sResources = listOf(Pair("cpu-memory-deployment.yaml", k8sResource))
).patch(value = cpuValue)
patcherFactory.createPatcher(
patcherDefinition = defMEM,
k8sResources = listOf(Pair("cpu-memory-deployment.yaml", k8sResource))
).patch(value = memValue)
k8sResource.spec.template.spec.containers.filter { it.name == defCPU.container }
k8sResource.spec.template.spec.containers.filter { it.name == defCPU.properties["container"] !! }
.forEach {
assertTrue(it.resources.limits["cpu"].toString() == cpuValue)
assertTrue(it.resources.limits["memory"].toString() == memValue)
......
......@@ -31,16 +31,20 @@ class ResourceRequestPatcherTest {
val k8sResource = loader.loadK8sResource("Deployment", testPath + fileName) as Deployment
val defCPU = PatcherDefinition()
defCPU.variableName = "cpu"
defCPU.resource = "cpu-memory-deployment.yaml"
defCPU.container = "uc-application"
defCPU.type = "ResourceRequestPatcher"
defCPU.properties = mutableMapOf(
"requestedResource" to "cpu",
"container" to "application"
)
val defMEM = PatcherDefinition()
defMEM.variableName = "memory"
defMEM.resource = "cpu-memory-deployment.yaml"
defMEM.container = "uc-application"
defMEM.type = "ResourceRequestPatcher"
defMEM.properties = mutableMapOf(
"requestedResource" to "memory",
"container" to "application"
)
patcherFactory.createPatcher(
patcherDefinition = defCPU,
......@@ -51,7 +55,7 @@ class ResourceRequestPatcherTest {
k8sResources = listOf(Pair("cpu-memory-deployment.yaml", k8sResource))
).patch(value = memValue)
k8sResource.spec.template.spec.containers.filter { it.name == defCPU.container }
k8sResource.spec.template.spec.containers.filter { it.name == defCPU.properties["container"] !! }
.forEach {
assertTrue(it.resources.requests["cpu"].toString() == cpuValue)
assertTrue(it.resources.requests["memory"].toString() == memValue)
......
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