From b274cfcc907e223f5ad9eb13317d928b2d5fe61c Mon Sep 17 00:00:00 2001 From: "stu126940@mail.uni-kiel.de" <stu126940@mail.uni-kiel.de> Date: Fri, 4 Jun 2021 10:30:41 +0200 Subject: [PATCH] update test and configuration files in order to a config map to configure patchers --- .../example-benchmark-yaml-resource.yaml | 12 +++- .../example-execution-yaml-resource.yaml | 58 ++++++++++-------- .../config/example-operator-benchmark.yaml | 24 +++++--- .../config/example-operator-execution.yaml | 60 +++++++++++-------- .../example-benchmark-k8s-resource.yaml | 4 +- .../example-execution-k8s-resource.yaml | 9 +-- .../theodolite/ResourceLimitPatcherTest.kt | 23 +++++-- .../theodolite/ResourceRequestPatcherTest.kt | 26 ++++++-- 8 files changed, 134 insertions(+), 82 deletions(-) diff --git a/theodolite-quarkus/config/example-benchmark-yaml-resource.yaml b/theodolite-quarkus/config/example-benchmark-yaml-resource.yaml index cdc2122d9..9c04a94c5 100644 --- a/theodolite-quarkus/config/example-benchmark-yaml-resource.yaml +++ b/theodolite-quarkus/config/example-benchmark-yaml-resource.yaml @@ -17,12 +17,18 @@ loadTypes: patchers: - type: "EnvVarPatcher" resource: "uc1-load-generator-deployment.yaml" - container: "workload-generator" - variableName: "NUM_SENSORS" + config: + - key: "variableName" + value: "NUM_SENSORS" + - key: "container" + value: "workload-generator" - type: "NumSensorsLoadGeneratorReplicaPatcher" resource: "uc1-load-generator-deployment.yaml" + config: + - key: "loadGenMaxRecords" + value: "15000" kafkaConfig: - bootstrapServer: "localhost:31290" + bootstrapServer: "localhost:9092" topics: - name: "input" numPartitions: 40 diff --git a/theodolite-quarkus/config/example-execution-yaml-resource.yaml b/theodolite-quarkus/config/example-execution-yaml-resource.yaml index e0b327a02..099347641 100644 --- a/theodolite-quarkus/config/example-execution-yaml-resource.yaml +++ b/theodolite-quarkus/config/example-execution-yaml-resource.yaml @@ -5,7 +5,7 @@ load: loadValues: [25000, 50000, 75000, 100000, 125000, 150000] resources: resourceType: "Instances" - resourceValues: [1, 2, 3, 4, 5] + resourceValues: [7, 1, 2, 3, 4, 5] slos: - sloType: "lag trend" threshold: 2000 @@ -20,29 +20,39 @@ execution: loadGenerationDelay: 30 # in seconds, optional field, default is 0 seconds restrictions: - "LowerBound" -configOverrides: [] -# - patcher: -# type: "NodeSelectorPatcher" -# resource: "uc1-load-generator-deployment.yaml" -# variableName: "env" -# value: "prod" -# - patcher: -# type: "NodeSelectorPatcher" -# resource: "uc1-kstreams-deployment.yaml" -# variableName: "env" -# value: "prod" -# - patcher: -# type: "ResourceLimitPatcher" -# resource: "uc1-kstreams-deployment.yaml" -# container: "uc-application" -# variableName: "cpu" -# value: "1000m" -# - patcher: -# type: "ResourceLimitPatcher" -# resource: "uc1-kstreams-deployment.yaml" -# container: "uc-application" -# variableName: "memory" -# value: "2Gi" +configOverrides: + - patcher: + type: "NodeSelectorPatcher" + resource: "uc1-load-generator-deployment.yaml" + config: + - key: "variableName" + value: "env" + value: "prod" + - patcher: + type: "NodeSelectorPatcher" + resource: "uc1-kstreams-deployment.yaml" + config: + - key: "variableName" + value: "env" + value: "prod" + - patcher: + type: "ResourceLimitPatcher" + resource: "uc1-kstreams-deployment.yaml" + config: + - key: "container" + value: "uc-application" + - key: "limitedResource" + value: "cpu" + value: "1000m" + - patcher: + type: "ResourceLimitPatcher" + resource: "uc1-kstreams-deployment.yaml" + config: + - key: "container" + value: "uc-application" + - key: "limitedResource" + value: "memory" + value: "2Gi" # - patcher: # type: "SchedulerNamePatcher" # resource: "uc1-kstreams-deployment.yaml" diff --git a/theodolite-quarkus/config/example-operator-benchmark.yaml b/theodolite-quarkus/config/example-operator-benchmark.yaml index 5cf39492a..1e93972d2 100644 --- a/theodolite-quarkus/config/example-operator-benchmark.yaml +++ b/theodolite-quarkus/config/example-operator-benchmark.yaml @@ -9,7 +9,7 @@ spec: - "jmx-configmap.yaml" - "uc1-service-monitor.yaml" loadGenResource: - - "uc1-load-generator-deployment.yaml" + - "uc1-load-generator-deployment.yaml" - "uc1-load-generator-service.yaml" resourceTypes: - typeName: "Instances" @@ -17,14 +17,20 @@ spec: - type: "ReplicaPatcher" resource: "uc1-kstreams-deployment.yaml" loadTypes: - - typeName: "NumSensors" - patchers: - - type: "EnvVarPatcher" - resource: "uc1-load-generator-deployment.yaml" - container: "workload-generator" - variableName: "NUM_SENSORS" - - type: "NumSensorsLoadGeneratorReplicaPatcher" - resource: "uc1-load-generator-deployment.yaml" + - typeName: "NumSensors" + patchers: + - type: "EnvVarPatcher" + resource: "uc1-load-generator-deployment.yaml" + config: + - key: "variableName" + value: "NUM_SENSORS" + - key: "container" + value: "workload-generator" + - type: "NumSensorsLoadGeneratorReplicaPatcher" + resource: "uc1-load-generator-deployment.yaml" + config: + - key: "loadGenMaxRecords" + value: "15000" kafkaConfig: bootstrapServer: "theodolite-cp-kafka:9092" topics: diff --git a/theodolite-quarkus/config/example-operator-execution.yaml b/theodolite-quarkus/config/example-operator-execution.yaml index e01ea377e..10927fb83 100644 --- a/theodolite-quarkus/config/example-operator-execution.yaml +++ b/theodolite-quarkus/config/example-operator-execution.yaml @@ -25,29 +25,37 @@ spec: restrictions: - "LowerBound" configOverrides: [] - # - patcher: - # type: "NodeSelectorPatcher" - # resource: "uc1-load-generator-deployment.yaml" - # variableName: "env" - # value: "prod" - # - patcher: - # type: "NodeSelectorPatcher" - # resource: "uc1-kstreams-deployment.yaml" - # variableName: "env" - # value: "prod" - # - patcher: - # type: "ResourceLimitPatcher" - # resource: "uc1-kstreams-deployment.yaml" - # container: "uc-application" - # variableName: "cpu" - # value: "1000m" - # - patcher: - # type: "ResourceLimitPatcher" - # resource: "uc1-kstreams-deployment.yaml" - # container: "uc-application" - # variableName: "memory" - # value: "2Gi" - # - patcher: - # type: "SchedulerNamePatcher" - # resource: "uc1-kstreams-deployment.yaml" - # value: "random-scheduler" +# - patcher: +# type: "NodeSelectorPatcher" +# resource: "uc1-load-generator-deployment123.yaml" +# variableName: "env" +# value: "prod" +# - patcher: +# type: "NodeSelectorPatcher" +# resource: "uc1-kstreams-deployment.yaml" +# config: +# - key: "variableName" +# value: "env" +# value: "prod" +# - patcher: +# type: "ResourceLimitPatcher" +# resource: "uc1-kstreams-deployment.yaml" +# config: +# - key: "container" +# value: "uc-application" +# - key: "variableName" +# value: "cpu" +# value: "1000m" +# - patcher: +# type: "ResourceLimitPatcher" +# resource: "uc1-kstreams-deployment.yaml" +# config: +# - key: "container" +# value: "uc-application" +# - key: "variableName" +# value: "memory" +# value: "2Gi" +# - patcher: +# type: "SchedulerNamePatcher" +# resource: "uc1-kstreams-deployment.yaml" +# value: "random-scheduler" diff --git a/theodolite-quarkus/src/main/resources/operator/example-benchmark-k8s-resource.yaml b/theodolite-quarkus/src/main/resources/operator/example-benchmark-k8s-resource.yaml index e0df9e462..f6a7dc333 100644 --- a/theodolite-quarkus/src/main/resources/operator/example-benchmark-k8s-resource.yaml +++ b/theodolite-quarkus/src/main/resources/operator/example-benchmark-k8s-resource.yaml @@ -23,9 +23,9 @@ spec: - type: "EnvVarPatcher" resource: "uc1-load-generator-deployment.yaml" config: - - key: container + - key: "container" value: "workload-generator" - - key: variableName + - key: "variableName" value: "NUM_SENSORS" kafkaConfig: bootstrapServer: "localhost:31290" diff --git a/theodolite-quarkus/src/main/resources/operator/example-execution-k8s-resource.yaml b/theodolite-quarkus/src/main/resources/operator/example-execution-k8s-resource.yaml index 5d7596663..b81bbcd44 100644 --- a/theodolite-quarkus/src/main/resources/operator/example-execution-k8s-resource.yaml +++ b/theodolite-quarkus/src/main/resources/operator/example-execution-k8s-resource.yaml @@ -26,11 +26,4 @@ spec: loadGenerationDelay: 30 # in seconds restrictions: - "LowerBound" - configOverrides: - - patcher: - type: "NodeSelectorPatcher" - resource: "uc1-kstreams-deployment.yaml" - config: - - key: variableName - value: env - value: "prod" + configOverrides: [] \ No newline at end of file diff --git a/theodolite-quarkus/src/test/kotlin/theodolite/ResourceLimitPatcherTest.kt b/theodolite-quarkus/src/test/kotlin/theodolite/ResourceLimitPatcherTest.kt index 4f4308a35..12f7c6896 100644 --- a/theodolite-quarkus/src/test/kotlin/theodolite/ResourceLimitPatcherTest.kt +++ b/theodolite-quarkus/src/test/kotlin/theodolite/ResourceLimitPatcherTest.kt @@ -31,27 +31,40 @@ 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.config =mutableListOf( + hashMapOf( + "key" to "limitedResource", + "value" to "cpu"), + hashMapOf( + "key" to "container", + "value" to "uc-application" + )) val defMEM = PatcherDefinition() - defMEM.variableName = "memory" defMEM.resource = "cpu-memory-deployment.yaml" - defMEM.container = "uc-application" defMEM.type = "ResourceLimitPatcher" + defMEM.config =mutableListOf( + hashMapOf( + "key" to "limitedResource", + "value" to "memory"), + hashMapOf( + "key" to "container", + "value" 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.getValueByKey("container") } .forEach { assertTrue(it.resources.limits["cpu"].toString() == cpuValue) assertTrue(it.resources.limits["memory"].toString() == memValue) diff --git a/theodolite-quarkus/src/test/kotlin/theodolite/ResourceRequestPatcherTest.kt b/theodolite-quarkus/src/test/kotlin/theodolite/ResourceRequestPatcherTest.kt index 721442270..5dc2764d8 100644 --- a/theodolite-quarkus/src/test/kotlin/theodolite/ResourceRequestPatcherTest.kt +++ b/theodolite-quarkus/src/test/kotlin/theodolite/ResourceRequestPatcherTest.kt @@ -31,16 +31,32 @@ 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.config = mutableListOf( + hashMapOf( + "key" to "requestedResource", + "value" to "cpu" + ), + hashMapOf( + "key" to "container", + "value" to "uc-application" + ) + ) val defMEM = PatcherDefinition() - defMEM.variableName = "memory" defMEM.resource = "cpu-memory-deployment.yaml" - defMEM.container = "uc-application" defMEM.type = "ResourceRequestPatcher" + defMEM.config = mutableListOf( + hashMapOf( + "key" to "requestedResource", + "value" to "memory" + ), + hashMapOf( + "key" to "container", + "value" to "uc-application" + ) + ) patcherFactory.createPatcher( patcherDefinition = defCPU, @@ -51,7 +67,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.getValueByKey("container") } .forEach { assertTrue(it.resources.requests["cpu"].toString() == cpuValue) assertTrue(it.resources.requests["memory"].toString() == memValue) -- GitLab