From 7448d5aeb021bb17c63cb280c78460e523c52627 Mon Sep 17 00:00:00 2001
From: "stu126940@mail.uni-kiel.de" <stu126940@mail.uni-kiel.de>
Date: Sun, 29 Aug 2021 16:41:38 +0200
Subject: [PATCH] update crd schemata, minor code changes

---
 theodolite/crd/crd-benchmark.yaml                    | 12 ++++++------
 theodolite/examples/operator/example-benchmark.yaml  |  6 +++---
 .../theodolite/benchmark/FileSystemResourceSet.kt    |  4 ++++
 .../main/kotlin/theodolite/benchmark/ResourceSets.kt |  4 ++--
 .../execution/operator/TheodoliteController.kt       |  4 ++--
 .../theodolite/benchmark/ConfigMapResourceSetTest.kt |  1 -
 6 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/theodolite/crd/crd-benchmark.yaml b/theodolite/crd/crd-benchmark.yaml
index ed604816a..57a144021 100644
--- a/theodolite/crd/crd-benchmark.yaml
+++ b/theodolite/crd/crd-benchmark.yaml
@@ -129,16 +129,16 @@ spec:
                 items:
                   type: object
                   properties:
-                    ConfigMapResourceSet:
+                    configMap:
                       type: object
                       properties:
-                        configmap:
+                        name:
                           type: string
                         files:
                           type: array
                           items:
                             type: string
-                    FileSystemResourceSet:
+                    fileSystem:
                       type: object
                       properties:
                         path:
@@ -152,16 +152,16 @@ spec:
                 items:
                   type: object
                   properties:
-                    ConfigMapResourceSet:
+                    configMap:
                       type: object
                       properties:
-                        configmap:
+                        name:
                           type: string
                         files:
                           type: array
                           items:
                             type: string
-                    FileSystemResourceSet:
+                    fileSystem:
                       type: object
                       properties:
                         path:
diff --git a/theodolite/examples/operator/example-benchmark.yaml b/theodolite/examples/operator/example-benchmark.yaml
index f5e388fca..53d422c7c 100644
--- a/theodolite/examples/operator/example-benchmark.yaml
+++ b/theodolite/examples/operator/example-benchmark.yaml
@@ -29,14 +29,14 @@ spec:
       - name: "theodolite-.*"
         removeOnly: True
   appResourceSets:
-    - FileSystemResourceSet:
+    - fileSystem:
          path: ./../../../../config
          files:
            - "uc1-kstreams-deployment.yaml"
            - "aggregation-service.yaml"
            - "jmx-configmap.yaml"
            - "uc1-service-monitor.yaml"
-    # - ConfigMapResourceSet:
+    # - configMap:
     #     configmap: "test-configmap"
     #    files:
     #      - "uc1-kstreams-deployment.yaml"
@@ -44,7 +44,7 @@ spec:
     #      - "jmx-configmap.yaml"
     #      - "uc1-service-monitor.yaml"
   loadGenResourceSets:
-    - FileSystemResourceSet:
+    - fileSystem:
         path: ./../../../../config
         files:
           - uc1-load-generator-service.yaml
diff --git a/theodolite/src/main/kotlin/theodolite/benchmark/FileSystemResourceSet.kt b/theodolite/src/main/kotlin/theodolite/benchmark/FileSystemResourceSet.kt
index 20591f3b6..723f81cf1 100644
--- a/theodolite/src/main/kotlin/theodolite/benchmark/FileSystemResourceSet.kt
+++ b/theodolite/src/main/kotlin/theodolite/benchmark/FileSystemResourceSet.kt
@@ -10,6 +10,7 @@ import theodolite.k8s.resourceLoader.K8sResourceLoaderFromFile
 import theodolite.util.DeploymentFailedException
 import theodolite.util.YamlParserFromFile
 import java.io.File
+import java.io.FileNotFoundException
 import java.lang.IllegalArgumentException
 
 private val logger = KotlinLogging.logger {}
@@ -50,6 +51,9 @@ class FileSystemResourceSet: ResourceSet, KubernetesResource {
             kind = parser.parse(resourcePath, HashMap<String, String>()::class.java)?.get("kind")!!
         } catch (e: NullPointerException) {
             throw DeploymentFailedException("Can not get Kind from resource $resourcePath, error is ${e.message}")
+        } catch (e: FileNotFoundException){
+            throw DeploymentFailedException("File $resourcePath not found")
+
         }
 
         return try {
diff --git a/theodolite/src/main/kotlin/theodolite/benchmark/ResourceSets.kt b/theodolite/src/main/kotlin/theodolite/benchmark/ResourceSets.kt
index 65de2b639..19c080809 100644
--- a/theodolite/src/main/kotlin/theodolite/benchmark/ResourceSets.kt
+++ b/theodolite/src/main/kotlin/theodolite/benchmark/ResourceSets.kt
@@ -13,10 +13,10 @@ import theodolite.util.DeploymentFailedException
 @RegisterForReflection
 @JsonInclude(JsonInclude.Include.NON_NULL)
 class ResourceSets: KubernetesResource {
-    @JsonProperty("ConfigMapResourceSet")
+    @JsonProperty("configMap")
     lateinit var  configMap: ConfigMapResourceSet
 
-    @JsonProperty("FileSystemResourceSet")
+    @JsonProperty("fileSystem")
     lateinit var fileSystem: FileSystemResourceSet
 
     fun loadResourceSet(client: NamespacedKubernetesClient): Collection<Pair<String, KubernetesResource>> {
diff --git a/theodolite/src/main/kotlin/theodolite/execution/operator/TheodoliteController.kt b/theodolite/src/main/kotlin/theodolite/execution/operator/TheodoliteController.kt
index e7b5ed429..8ead498a7 100644
--- a/theodolite/src/main/kotlin/theodolite/execution/operator/TheodoliteController.kt
+++ b/theodolite/src/main/kotlin/theodolite/execution/operator/TheodoliteController.kt
@@ -65,7 +65,8 @@ class TheodoliteController(
      * @see BenchmarkExecution
      */
     private fun runExecution(execution: BenchmarkExecution, benchmark: KubernetesBenchmark) {
-        val modifier = ConfigOverrideModifier(
+        try {
+            val modifier = ConfigOverrideModifier(
             execution = execution,
             resources = benchmark.loadKubernetesResources(benchmark.appResourceSets).map { it.first }
                     + benchmark.loadKubernetesResources(benchmark.loadGenResourceSets).map { it.first }
@@ -86,7 +87,6 @@ class TheodoliteController(
         executionStateHandler.setExecutionState(execution.name, States.RUNNING)
         executionStateHandler.startDurationStateTimer(execution.name)
 
-        try {
             executor = TheodoliteExecutor(execution, benchmark)
             executor.run()
             when (executionStateHandler.getExecutionState(execution.name)) {
diff --git a/theodolite/src/test/kotlin/theodolite/benchmark/ConfigMapResourceSetTest.kt b/theodolite/src/test/kotlin/theodolite/benchmark/ConfigMapResourceSetTest.kt
index f630d8d81..8b9fa6e4e 100644
--- a/theodolite/src/test/kotlin/theodolite/benchmark/ConfigMapResourceSetTest.kt
+++ b/theodolite/src/test/kotlin/theodolite/benchmark/ConfigMapResourceSetTest.kt
@@ -226,7 +226,6 @@ class ConfigMapResourceSetTest {
         try {
             resourceSet.getResourceSet(server.client)
         } catch (e: Exception) {
-            println( "haha " + e)
             ex = e
         }
         assertTrue(ex is DeploymentFailedException)
-- 
GitLab