From 0623f8a4d19f776d329953346fdddc19097e4400 Mon Sep 17 00:00:00 2001 From: "stu126940@mail.uni-kiel.de" <stu126940@mail.uni-kiel.de> Date: Mon, 7 Jun 2021 16:17:37 +0200 Subject: [PATCH] fix tests --- .../operator/TheodoliteController.kt | 2 +- .../theodolite/ResourceLimitPatcherTest.kt | 26 +++++++------------ .../theodolite/ResourceRequestPatcherTest.kt | 26 +++++-------------- 3 files changed, 17 insertions(+), 37 deletions(-) diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/execution/operator/TheodoliteController.kt b/theodolite-quarkus/src/main/kotlin/theodolite/execution/operator/TheodoliteController.kt index 9b27dd44d..90b136265 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/execution/operator/TheodoliteController.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/execution/operator/TheodoliteController.kt @@ -183,7 +183,7 @@ class TheodoliteController( val configurationOverride = ConfigurationOverride() configurationOverride.patcher = PatcherDefinition() configurationOverride.patcher.type = "LabelPatcher" - configurationOverride.patcher.config = mapOf("variableName" to labelName) + configurationOverride.patcher.config = mutableMapOf("variableName" to labelName) configurationOverride.patcher.resource = it configurationOverride.value = labelValue additionalConfigOverrides.add(configurationOverride) diff --git a/theodolite-quarkus/src/test/kotlin/theodolite/ResourceLimitPatcherTest.kt b/theodolite-quarkus/src/test/kotlin/theodolite/ResourceLimitPatcherTest.kt index 12f7c6896..1e947ed81 100644 --- a/theodolite-quarkus/src/test/kotlin/theodolite/ResourceLimitPatcherTest.kt +++ b/theodolite-quarkus/src/test/kotlin/theodolite/ResourceLimitPatcherTest.kt @@ -33,26 +33,18 @@ class ResourceLimitPatcherTest { val defCPU = PatcherDefinition() defCPU.resource = "cpu-memory-deployment.yaml" defCPU.type = "ResourceLimitPatcher" - defCPU.config =mutableListOf( - hashMapOf( - "key" to "limitedResource", - "value" to "cpu"), - hashMapOf( - "key" to "container", - "value" to "uc-application" - )) + defCPU.config = mutableMapOf( + "limitedResource" to "cpu", + "container" to "application" + ) val defMEM = PatcherDefinition() defMEM.resource = "cpu-memory-deployment.yaml" defMEM.type = "ResourceLimitPatcher" - defMEM.config =mutableListOf( - hashMapOf( - "key" to "limitedResource", - "value" to "memory"), - hashMapOf( - "key" to "container", - "value" to "uc-application" - )) + defMEM.config = mutableMapOf( + "limitedResource" to "memory", + "container" to "uc-application" + ) patcherFactory.createPatcher( patcherDefinition = defCPU, @@ -64,7 +56,7 @@ class ResourceLimitPatcherTest { k8sResources = listOf(Pair("cpu-memory-deployment.yaml", k8sResource)) ).patch(value = memValue) - k8sResource.spec.template.spec.containers.filter { it.name == defCPU.getValueByKey("container") } + k8sResource.spec.template.spec.containers.filter { it.name == defCPU.config["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 5dc2764d8..1c3f37ac3 100644 --- a/theodolite-quarkus/src/test/kotlin/theodolite/ResourceRequestPatcherTest.kt +++ b/theodolite-quarkus/src/test/kotlin/theodolite/ResourceRequestPatcherTest.kt @@ -33,29 +33,17 @@ class ResourceRequestPatcherTest { val defCPU = PatcherDefinition() defCPU.resource = "cpu-memory-deployment.yaml" defCPU.type = "ResourceRequestPatcher" - defCPU.config = mutableListOf( - hashMapOf( - "key" to "requestedResource", - "value" to "cpu" - ), - hashMapOf( - "key" to "container", - "value" to "uc-application" - ) + defCPU.config = mutableMapOf( + "requestedResource" to "cpu", + "container" to "application" ) val defMEM = PatcherDefinition() defMEM.resource = "cpu-memory-deployment.yaml" defMEM.type = "ResourceRequestPatcher" - defMEM.config = mutableListOf( - hashMapOf( - "key" to "requestedResource", - "value" to "memory" - ), - hashMapOf( - "key" to "container", - "value" to "uc-application" - ) + defMEM.config = mutableMapOf( + "requestedResource" to "memory", + "container" to "application" ) patcherFactory.createPatcher( @@ -67,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.getValueByKey("container") } + k8sResource.spec.template.spec.containers.filter { it.name == defCPU.config["container"] !! } .forEach { assertTrue(it.resources.requests["cpu"].toString() == cpuValue) assertTrue(it.resources.requests["memory"].toString() == memValue) -- GitLab