diff --git a/theodolite/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt b/theodolite/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt index 2b4d6193539177c9e6260d326f4b57c60a012f8c..549063606eb99838680292ad5e3e5d15ea5832be 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 06bdd90b3b3c82e1bcbe59a1f3e9e35e2f338486..f97bc0a2e42e64255ec411bffcae3946bc5c5bc4 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 d160a0e4a0a5d8a1d4fa4636909de5ff38b5e836..ffb6cc3d24a0ccd9044aba7c76b9822562fb0d4f 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