From a7e74a3fe9d764035dd39f683ad3209507280a60 Mon Sep 17 00:00:00 2001
From: "stu126940@mail.uni-kiel.de" <stu126940@mail.uni-kiel.de>
Date: Wed, 15 Dec 2021 14:14:06 +0100
Subject: [PATCH] fix test

---
 .../theodolite/benchmark/KubernetesBenchmark.kt       | 11 ++++++++++-
 .../kotlin/theodolite/benchmark/ActionCommandTest.kt  |  9 +--------
 .../execution/operator/BenchmarkStateCheckerTest.kt   |  2 +-
 3 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/theodolite/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt b/theodolite/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt
index 2b4d61935..549063606 100644
--- a/theodolite/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt
+++ b/theodolite/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt
@@ -47,7 +47,7 @@ class KubernetesBenchmark : KubernetesResource, Benchmark {
     var namespace = System.getenv("NAMESPACE") ?: DEFAULT_NAMESPACE
 
     @Transient
-    var client: NamespacedKubernetesClient = DefaultKubernetesClient().inNamespace(namespace)
+    private var client: NamespacedKubernetesClient = DefaultKubernetesClient().inNamespace(namespace)
 
     /**
      * Loads [KubernetesResource]s.
@@ -125,4 +125,13 @@ class KubernetesBenchmark : KubernetesResource, Benchmark {
             client = this.client
         )
     }
+
+    /**
+     * This function can be used to set the Kubernetes client manually. This is for example necessary for testing.
+     *
+     * @param client
+     */
+    fun setClient(client: NamespacedKubernetesClient) {
+        this.client = client
+    }
 }
diff --git a/theodolite/src/test/kotlin/theodolite/benchmark/ActionCommandTest.kt b/theodolite/src/test/kotlin/theodolite/benchmark/ActionCommandTest.kt
index 06bdd90b3..f97bc0a2e 100644
--- a/theodolite/src/test/kotlin/theodolite/benchmark/ActionCommandTest.kt
+++ b/theodolite/src/test/kotlin/theodolite/benchmark/ActionCommandTest.kt
@@ -1,6 +1,5 @@
 package theodolite.benchmark
 
-
 import io.fabric8.kubernetes.api.model.Pod
 import io.fabric8.kubernetes.api.model.PodBuilder
 import io.fabric8.kubernetes.api.model.PodListBuilder
@@ -63,7 +62,7 @@ class ActionCommandTest {
             .done()
             .always()
     }
-    
+
     /**
      * Copied from fabric8 Kubernetes Client repository
      *
@@ -92,12 +91,6 @@ class ActionCommandTest {
         Assertions.assertEquals("pod1", ActionCommand(client = server.client).getPodName(mutableMapOf("app" to "pod")))
     }
 
-    @Test
-    fun testActionCommandExec() {
-        Assertions.assertEquals(0, ActionCommand(client = server.client)
-            .exec(mutableMapOf("app" to "pod"), command = arrayOf("ls"), timeout = 30L))
-    }
-
     @Test
     fun testAction() {
         val action = Action()
diff --git a/theodolite/src/test/kotlin/theodolite/execution/operator/BenchmarkStateCheckerTest.kt b/theodolite/src/test/kotlin/theodolite/execution/operator/BenchmarkStateCheckerTest.kt
index d160a0e4a..ffb6cc3d2 100644
--- a/theodolite/src/test/kotlin/theodolite/execution/operator/BenchmarkStateCheckerTest.kt
+++ b/theodolite/src/test/kotlin/theodolite/execution/operator/BenchmarkStateCheckerTest.kt
@@ -166,7 +166,7 @@ internal class BenchmarkStateCheckerTest {
         val benchmark = BenchmarkCRDummy(
             name = "test-benchmark"
         )
-        benchmark.getCR().spec.client = serverCrud.client
+        benchmark.getCR().spec.setClient(serverCrud.client)
         val resourceSet = Resources()
         resourceSet.resources = listOf(createAndDeployConfigmapResourceSet())
         benchmark.getCR().spec.infrastructure = resourceSet
-- 
GitLab