From 33524079619544d3cf347210a3c092812eeda306 Mon Sep 17 00:00:00 2001
From: Marcel Becker <stu117960@mail.uni-kiel.de>
Date: Thu, 17 Feb 2022 14:16:36 +0100
Subject: [PATCH] Fixed execution yaml definition issues

---
 theodolite/crd/crd-execution.yaml             | 24 ++++++++++++-------
 .../benchmark/BenchmarkExecution.kt           |  8 +++----
 .../kotlin/theodolite/util/ResultsTest.kt     | 17 -------------
 .../k8s-resource-files/test-execution-1.yaml  |  7 +++---
 .../test-execution-update.yaml                |  8 ++++---
 .../k8s-resource-files/test-execution.yaml    | 12 ++++------
 6 files changed, 33 insertions(+), 43 deletions(-)

diff --git a/theodolite/crd/crd-execution.yaml b/theodolite/crd/crd-execution.yaml
index 3e87df678..fc5a78134 100644
--- a/theodolite/crd/crd-execution.yaml
+++ b/theodolite/crd/crd-execution.yaml
@@ -80,31 +80,37 @@ spec:
               execution: # def execution config
                 description: Defines the overall parameter for the execution.
                 type: object
-                required: ["strategy", "duration", "repetitions", "restrictions"]
+                required: ["strategy", "duration", "repetitions"]
                 properties:
                   metric:
-                    default: "demand"
                     type: string
-                    oneOf:
-                      - "demand"
-                      - "capacity"
+                    # default: "demand"
+                    # oneOf:
+                    #  - "demand"
+                    #  - "capacity"
                   strategy:
                     description: Defines the used strategy for the execution, either 'LinearSearch', 'BinarySearch' or 'InitialGuessSearch'
                     type: object
-                    name: string
+                    required: ["name"]
                     properties:
+                      name:
+                        type: string
+                      #properties:
+                      #  type: object
                       restrictions:
                         description: List of restriction strategies used to delimit the search space.
                         type: array
                         items:
                           type: string
-                      guessStrategy: string
-                      searchStrategy: string
+                      guessStrategy:
+                        type: string
+                      searchStrategy:
+                        type: string
                   duration:
                     description: Defines the duration of each experiment in seconds.
                     type: integer
                   repetitions:
-                    description: Numper of repititions for each experiments.
+                    description: Number of repititions for each experiments.
                     type: integer
                   loadGenerationDelay:
                     description: Seconds to wait between the start of the SUT and the load generator.
diff --git a/theodolite/src/main/kotlin/theodolite/benchmark/BenchmarkExecution.kt b/theodolite/src/main/kotlin/theodolite/benchmark/BenchmarkExecution.kt
index b5dd15623..838b74642 100644
--- a/theodolite/src/main/kotlin/theodolite/benchmark/BenchmarkExecution.kt
+++ b/theodolite/src/main/kotlin/theodolite/benchmark/BenchmarkExecution.kt
@@ -41,7 +41,7 @@ class BenchmarkExecution : KubernetesResource {
     @JsonDeserialize
     @RegisterForReflection
     class Execution : KubernetesResource {
-        lateinit var metric: String
+        var metric = "demand" //irgendwie mag er es nicht mit den default laden, wenn lateinit dann gibt es bei den tests fehler und muss bei var setzen
         lateinit var strategy: Strategy
         var duration by Delegates.notNull<Long>()
         var repetitions by Delegates.notNull<Int>()
@@ -56,9 +56,9 @@ class BenchmarkExecution : KubernetesResource {
     @RegisterForReflection
     class Strategy : KubernetesResource {
         lateinit var name: String
-        lateinit var restrictions: List<String>
-        lateinit var guessStrategy: String
-        lateinit var searchStrategy: String
+        var restrictions = emptyList<String>()
+        var guessStrategy = ""
+        var searchStrategy = ""
     }
 
     /**
diff --git a/theodolite/src/test/kotlin/theodolite/util/ResultsTest.kt b/theodolite/src/test/kotlin/theodolite/util/ResultsTest.kt
index f3556d807..cef83da3c 100644
--- a/theodolite/src/test/kotlin/theodolite/util/ResultsTest.kt
+++ b/theodolite/src/test/kotlin/theodolite/util/ResultsTest.kt
@@ -24,23 +24,6 @@ internal class ResultsTest {
         assertEquals(2, minRequiredInstances)
     }
 
-    @Test
-    @Disabled
-    // TODO necessary?
-    fun testMinRequiredInstancesWhenNotSuccessful() {
-        // This test is currently not implemented this way, but might later be the desired behavior.
-        val results = Results(Metric.from("demand"))
-        results.setResult(Pair(10000, 1), true)
-        results.setResult(Pair(10000, 2), true)
-        results.setResult(Pair(20000, 1), false)
-        results.setResult(Pair(20000, 2), false)
-
-        val minRequiredInstances = results.getOptYDimensionValue(20000)
-
-        assertNotNull(minRequiredInstances)
-        assertEquals(2, minRequiredInstances!!)
-    }
-
     @Test
     fun testGetMaxBenchmarkedLoadWhenAllSuccessfulDemand() {
         val results = Results(Metric.from("demand"))
diff --git a/theodolite/src/test/resources/k8s-resource-files/test-execution-1.yaml b/theodolite/src/test/resources/k8s-resource-files/test-execution-1.yaml
index 1407a9952..15f5f451a 100644
--- a/theodolite/src/test/resources/k8s-resource-files/test-execution-1.yaml
+++ b/theodolite/src/test/resources/k8s-resource-files/test-execution-1.yaml
@@ -19,10 +19,11 @@ spec:
       offset: 0
       warmup: 60 # in seconds
   execution:
-    strategy: "LinearSearch"
+    name: "RestrictionSearch"
+      restrictions:
+        - "LowerBound"
+      searchStrategy: "LinearSearch"
     duration: 300 # in seconds
     repetitions: 1
     loadGenerationDelay: 30 # in seconds
-    restrictions:
-      - "LowerBound"
   configOverrides: []
diff --git a/theodolite/src/test/resources/k8s-resource-files/test-execution-update.yaml b/theodolite/src/test/resources/k8s-resource-files/test-execution-update.yaml
index c075702da..37b83edbd 100644
--- a/theodolite/src/test/resources/k8s-resource-files/test-execution-update.yaml
+++ b/theodolite/src/test/resources/k8s-resource-files/test-execution-update.yaml
@@ -20,10 +20,12 @@ spec:
         externalSloUrl: "http://localhost:80/evaluate-slope"
         warmup: 60 # in seconds
   execution:
-    strategy: "LinearSearch"
+    strategy:
+      name: "RestrictionSearch"
+      restrictions:
+        - "LowerBound"
+      searchStrategy: "LinearSearch"
     duration: 300 # in seconds
     repetitions: 1
     loadGenerationDelay: 30 # in seconds
-    restrictions:
-      - "LowerBound"
   configOverrides: []
diff --git a/theodolite/src/test/resources/k8s-resource-files/test-execution.yaml b/theodolite/src/test/resources/k8s-resource-files/test-execution.yaml
index ee7a901c8..aee12f5fd 100644
--- a/theodolite/src/test/resources/k8s-resource-files/test-execution.yaml
+++ b/theodolite/src/test/resources/k8s-resource-files/test-execution.yaml
@@ -20,14 +20,12 @@ spec:
         externalSloUrl: "http://localhost:80/evaluate-slope"
         warmup: 60 # in seconds
   execution:
-    metric: "demand"
-    strategy: "RestrictionSearch"
-      properties:
-        restrictions:
-          - "LowerBound"
-        searchStrategy: "LinearSearch"
+    strategy:
+      name: "RestrictionSearch"
+      restrictions:
+        - "LowerBound"
+      searchStrategy: "LinearSearch"
     duration: 300 # in seconds
     repetitions: 1
     loadGenerationDelay: 30 # in seconds
-
   configOverrides: []
-- 
GitLab