diff --git a/theodolite-quarkus/src/test/kotlin/theodolite/CompositeStrategyTest.kt b/theodolite-quarkus/src/test/kotlin/theodolite/CompositeStrategyTest.kt index c2b30ab7eb23d60db39778218ad9d6a4c12799a6..49131352cfe517a382ddd7aa1be09d3fbe317466 100644 --- a/theodolite-quarkus/src/test/kotlin/theodolite/CompositeStrategyTest.kt +++ b/theodolite-quarkus/src/test/kotlin/theodolite/CompositeStrategyTest.kt @@ -98,7 +98,7 @@ class CompositeStrategyTest { val results = Results() val benchmark = TestBenchmark() val sloChecker: BenchmarkExecution.Slo = BenchmarkExecution.Slo() - val benchmarkExecutor = TestBenchmarkExecutorImpl(mockResults, benchmark, results, sloChecker, 0, 0,0) + val benchmarkExecutor = TestBenchmarkExecutorImpl(mockResults, benchmark, results, sloChecker, 0, 0, 0) val binarySearch = BinarySearch(benchmarkExecutor) val lowerBoundRestriction = LowerBoundRestriction(results) val strategy = diff --git a/theodolite-quarkus/src/test/kotlin/theodolite/ResourceLimitPatcherTest.kt b/theodolite-quarkus/src/test/kotlin/theodolite/ResourceLimitPatcherTest.kt index 4ae9ce23b31204b366dce7bcf000e4114d7f3f8f..e88192dd7fe4393494a4fb76bd74d1123bd75f1d 100644 --- a/theodolite-quarkus/src/test/kotlin/theodolite/ResourceLimitPatcherTest.kt +++ b/theodolite-quarkus/src/test/kotlin/theodolite/ResourceLimitPatcherTest.kt @@ -56,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.properties["container"] !! } + k8sResource.spec.template.spec.containers.filter { it.name == defCPU.properties["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 6f232961871c9d11929fc912a483e6e805cc7daf..2af6c632567bf47e150a74808ab009bd0bc0598a 100644 --- a/theodolite-quarkus/src/test/kotlin/theodolite/ResourceRequestPatcherTest.kt +++ b/theodolite-quarkus/src/test/kotlin/theodolite/ResourceRequestPatcherTest.kt @@ -55,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.properties["container"] !! } + k8sResource.spec.template.spec.containers.filter { it.name == defCPU.properties["container"]!! } .forEach { assertTrue(it.resources.requests["cpu"].toString() == cpuValue) assertTrue(it.resources.requests["memory"].toString() == memValue) diff --git a/theodolite-quarkus/src/test/kotlin/theodolite/TestBenchmark.kt b/theodolite-quarkus/src/test/kotlin/theodolite/TestBenchmark.kt index 6ddca296acced658609fcccb307a83047238e118..913a27a1b1c1412aa0a58baf9e11fafb1c7f4bd2 100644 --- a/theodolite-quarkus/src/test/kotlin/theodolite/TestBenchmark.kt +++ b/theodolite-quarkus/src/test/kotlin/theodolite/TestBenchmark.kt @@ -2,8 +2,8 @@ package theodolite import theodolite.benchmark.Benchmark import theodolite.benchmark.BenchmarkDeployment -import theodolite.util.LoadDimension import theodolite.util.ConfigurationOverride +import theodolite.util.LoadDimension import theodolite.util.Resource class TestBenchmark : Benchmark { diff --git a/theodolite-quarkus/src/test/kotlin/theodolite/execution/operator/ControllerDummy.kt b/theodolite-quarkus/src/test/kotlin/theodolite/execution/operator/ControllerDummy.kt index 79306ecdc9a05e571e1c039bba329d02717fb931..3ecc2ef422e579b616f304ec8c4b19110941dcea 100644 --- a/theodolite-quarkus/src/test/kotlin/theodolite/execution/operator/ControllerDummy.kt +++ b/theodolite-quarkus/src/test/kotlin/theodolite/execution/operator/ControllerDummy.kt @@ -19,19 +19,19 @@ class ControllerDummy(val client: NamespacedKubernetesClient) { private var controller: TheodoliteController val executionContext = K8sContextFactory() - .create( - API_VERSION, - SCOPE, - GROUP, - EXECUTION_PLURAL - ) + .create( + API_VERSION, + SCOPE, + GROUP, + EXECUTION_PLURAL + ) val benchmarkContext = K8sContextFactory() - .create( - API_VERSION, - SCOPE, - GROUP, - BENCHMARK_PLURAL - ) + .create( + API_VERSION, + SCOPE, + GROUP, + BENCHMARK_PLURAL + ) val executionStateHandler = ExecutionStateHandler( context = executionContext, diff --git a/theodolite-quarkus/src/test/kotlin/theodolite/execution/operator/ControllerTest.kt b/theodolite-quarkus/src/test/kotlin/theodolite/execution/operator/ControllerTest.kt index a56e27e7696955bcc5cfc6b04a64d842be211351..9174a4cc78933d4c028b2c2a73e1adb63047868f 100644 --- a/theodolite-quarkus/src/test/kotlin/theodolite/execution/operator/ControllerTest.kt +++ b/theodolite-quarkus/src/test/kotlin/theodolite/execution/operator/ControllerTest.kt @@ -38,7 +38,7 @@ class ControllerTest { benchmarkResourceList.items = listOf(benchmark1.getCR(), benchmark2.getCR()) // execution - val execution1 = ExecutionCRDummy(name = "matching-execution", benchmark = "Test-Benchmark") + val execution1 = ExecutionCRDummy(name = "matching-execution", benchmark = "Test-Benchmark") val execution2 = ExecutionCRDummy(name = "non-matching-execution", benchmark = "Test-Benchmark-456") val execution3 = ExecutionCRDummy(name = "second-matching-execution", benchmark = "Test-Benchmark") executionResourceList.items = listOf(execution1.getCR(), execution2.getCR(), execution3.getCR()) @@ -78,7 +78,8 @@ class ControllerTest { assertEquals(2, result.size) assertEquals( gson.toJson(benchmark), - gson.toJson(result.firstOrNull())) + gson.toJson(result.firstOrNull()) + ) } @Test @@ -92,23 +93,27 @@ class ControllerTest { assertEquals( gson.toJson(this.execution), - gson.toJson(result)) + gson.toJson(result) + ) } @Test fun setAdditionalLabelsTest() { val method = controller .javaClass - .getDeclaredMethod("setAdditionalLabels", + .getDeclaredMethod( + "setAdditionalLabels", String::class.java, String::class.java, List::class.java, - BenchmarkExecution::class.java) + BenchmarkExecution::class.java + ) method.isAccessible = true this.benchmark.appResource = listOf("test-resource.yaml") - method.invoke(controller, + method.invoke( + controller, "test-value", "test-name", this.benchmark.appResource, @@ -127,6 +132,7 @@ class ControllerTest { "test-value", this.execution .configOverrides.firstOrNull() - ?.value) + ?.value + ) } } \ No newline at end of file diff --git a/theodolite-quarkus/src/test/kotlin/theodolite/execution/operator/ExecutionEventHandlerTest.kt b/theodolite-quarkus/src/test/kotlin/theodolite/execution/operator/ExecutionEventHandlerTest.kt index 9d030f77a25a6d7831a1e67d49aa34f417faceab..9c3468eaa4df7573a1d909222d6faa7449fd7251 100644 --- a/theodolite-quarkus/src/test/kotlin/theodolite/execution/operator/ExecutionEventHandlerTest.kt +++ b/theodolite-quarkus/src/test/kotlin/theodolite/execution/operator/ExecutionEventHandlerTest.kt @@ -39,15 +39,18 @@ class ExecutionEventHandlerTest { this.factory = server.client.informers() val informerExecution = factory .sharedIndexInformerForCustomResource( - controllerDummy.executionContext, - ExecutionCRD::class.java, - BenchmarkExecutionList::class.java, - RESYNC_PERIOD - ) + controllerDummy.executionContext, + ExecutionCRD::class.java, + BenchmarkExecutionList::class.java, + RESYNC_PERIOD + ) - informerExecution.addEventHandler(ExecutionHandler( - controller = controllerDummy.getController(), - stateHandler = controllerDummy.executionStateHandler)) + informerExecution.addEventHandler( + ExecutionHandler( + controller = controllerDummy.getController(), + stateHandler = controllerDummy.executionStateHandler + ) + ) this.executionVersion1 = K8sResourceLoader(server.client) .loadK8sResource("Execution", testResourcePath + "test-execution.yaml") @@ -61,14 +64,14 @@ class ExecutionEventHandlerTest { } @AfterEach - fun tearDown(){ + fun tearDown() { server.after() factory.stopAllRegisteredInformers() } @Test @DisplayName("Test onAdd method for executions without execution state") - fun testWithoutState(){ + fun testWithoutState() { manager.deploy(executionVersion1) factory.startAllRegisteredInformers() sleep(500) @@ -82,7 +85,7 @@ class ExecutionEventHandlerTest { @Test @DisplayName("Test onAdd method for executions with execution state `RUNNING`") - fun testWithStateIsRunning(){ + fun testWithStateIsRunning() { manager.deploy(executionVersion1) stateHandler .setExecutionState( @@ -156,7 +159,8 @@ class ExecutionEventHandlerTest { stateHandler.setExecutionState( resourceName = executionName, - status = States.FAILURE ) + status = States.FAILURE + ) manager.deploy(executionVersion2) sleep(500) @@ -188,7 +192,8 @@ class ExecutionEventHandlerTest { assertEquals( States.RESTART, stateHandler.getExecutionState( - resourceName = executionName) + resourceName = executionName + ) ) } @@ -210,7 +215,8 @@ class ExecutionEventHandlerTest { assertEquals( States.RESTART, stateHandler.getExecutionState( - resourceName = executionName) + resourceName = executionName + ) ) } } \ No newline at end of file diff --git a/theodolite-quarkus/src/test/kotlin/theodolite/execution/operator/StateHandlerTest.kt b/theodolite-quarkus/src/test/kotlin/theodolite/execution/operator/StateHandlerTest.kt index d0bfff82fc11c819b4be500fee0baa15445f6f0b..1b92b1e2938df49be2a3a9950d8eb911a7963a40 100644 --- a/theodolite-quarkus/src/test/kotlin/theodolite/execution/operator/StateHandlerTest.kt +++ b/theodolite-quarkus/src/test/kotlin/theodolite/execution/operator/StateHandlerTest.kt @@ -15,7 +15,7 @@ import java.time.Duration class StateHandlerTest { private val testResourcePath = "./src/test/resources/k8s-resource-files/" - private val server = KubernetesServer(false,true) + private val server = KubernetesServer(false, true) private val context = K8sContextFactory().create( api = "v1", scope = "Namespaced", @@ -44,7 +44,7 @@ class StateHandlerTest { val handler = ExecutionStateHandler(client = server.client, context = context) assertTrue(handler.setExecutionState("example-execution", States.INTERRUPTED)) - assertEquals(States.INTERRUPTED,handler.getExecutionState("example-execution") ) + assertEquals(States.INTERRUPTED, handler.getExecutionState("example-execution")) } @Test @@ -53,6 +53,6 @@ class StateHandlerTest { val handler = ExecutionStateHandler(client = server.client, context = context) assertTrue(handler.setDurationState("example-execution", Duration.ofMillis(100))) - assertEquals("0s",handler.getDurationState("example-execution") ) + assertEquals("0s", handler.getDurationState("example-execution")) } } \ No newline at end of file diff --git a/theodolite-quarkus/src/test/kotlin/theodolite/k8s/K8sManagerTest.kt b/theodolite-quarkus/src/test/kotlin/theodolite/k8s/K8sManagerTest.kt index b57bf2b3b5c4a88ef092146bbec4abdd6278a1e6..931457b0fc65984c35516dca57dbe52e94184064 100644 --- a/theodolite-quarkus/src/test/kotlin/theodolite/k8s/K8sManagerTest.kt +++ b/theodolite-quarkus/src/test/kotlin/theodolite/k8s/K8sManagerTest.kt @@ -23,7 +23,7 @@ private val logger = KotlinLogging.logger {} @JsonIgnoreProperties(ignoreUnknown = true) class K8sManagerTest { @JsonIgnoreProperties(ignoreUnknown = true) - private final val server = KubernetesServer(false,true) + private final val server = KubernetesServer(false, true) private final val testResourcePath = "./src/test/resources/k8s-resource-files/" private final val resourceName = "test-resource" @@ -33,18 +33,18 @@ class K8sManagerTest { val defaultDeployment: Deployment = DeploymentBuilder() .withMetadata(metadata) .withNewSpec() - .editOrNewSelector() - .withMatchLabels(mapOf("app" to "test")) - .endSelector() + .editOrNewSelector() + .withMatchLabels(mapOf("app" to "test")) + .endSelector() .endSpec() .build() val defaultStatefulSet: StatefulSet = StatefulSetBuilder() .withMetadata(metadata) .withNewSpec() - .editOrNewSelector() - .withMatchLabels(mapOf("app" to "test")) - .endSelector() + .editOrNewSelector() + .withMatchLabels(mapOf("app" to "test")) + .endSelector() .endSpec() .build() @@ -139,14 +139,17 @@ class K8sManagerTest { var serviceMonitors = JSONObject(server.client.customResource(serviceMonitorContext).list()) .getJSONArray("items") - assertEquals(1,serviceMonitors.length()) - assertEquals("test-service-monitor", serviceMonitors.getJSONObject(0).getJSONObject("metadata").getString("name")) + assertEquals(1, serviceMonitors.length()) + assertEquals( + "test-service-monitor", + serviceMonitors.getJSONObject(0).getJSONObject("metadata").getString("name") + ) manager.remove(servicemonitor) serviceMonitors = JSONObject(server.client.customResource(serviceMonitorContext).list()) .getJSONArray("items") - assertEquals(0,serviceMonitors.length()) + assertEquals(0, serviceMonitors.length()) } } \ No newline at end of file diff --git a/theodolite-quarkus/src/test/kotlin/theodolite/k8s/K8sResourceLoaderTest.kt b/theodolite-quarkus/src/test/kotlin/theodolite/k8s/K8sResourceLoaderTest.kt index a87b36549820a43c16083817794a15eda6d2b565..5cb6f0c4cf09daeaa95a805ae965f5b592fd9647 100644 --- a/theodolite-quarkus/src/test/kotlin/theodolite/k8s/K8sResourceLoaderTest.kt +++ b/theodolite-quarkus/src/test/kotlin/theodolite/k8s/K8sResourceLoaderTest.kt @@ -15,7 +15,7 @@ import org.junit.jupiter.api.Test @QuarkusTest class K8sResourceLoaderTest { - private final val server = KubernetesServer(false,true) + private final val server = KubernetesServer(false, true) private final val testResourcePath = "./src/test/resources/k8s-resource-files/" @BeforeEach diff --git a/theodolite-quarkus/src/test/kotlin/theodolite/util/IOHandlerTest.kt b/theodolite-quarkus/src/test/kotlin/theodolite/util/IOHandlerTest.kt index 6984c3935da3d26f95565b758547a98e0eeb155f..6b8aa1d567fd2c93c1301fe3f953273e0f5d5420 100644 --- a/theodolite-quarkus/src/test/kotlin/theodolite/util/IOHandlerTest.kt +++ b/theodolite-quarkus/src/test/kotlin/theodolite/util/IOHandlerTest.kt @@ -14,6 +14,7 @@ import org.junitpioneer.jupiter.SetEnvironmentVariable const val FOLDER_URL = "Test-Folder" + @QuarkusTest internal class IOHandlerTest { @@ -28,10 +29,11 @@ internal class IOHandlerTest { IOHandler().writeStringToTextFile( fileURL = "${folder.absolutePath}/test-file.txt", - data = testContent) + data = testContent + ) assertEquals( - testContent, + testContent, IOHandler().readFileAsString("${folder.absolutePath}/test-file.txt") ) } @@ -42,18 +44,20 @@ internal class IOHandlerTest { val folder = temporaryFolder.newFolder(FOLDER_URL) val testContent = listOf( - listOf("apples","red"), - listOf("bananas","yellow"), - listOf("avocado","brown")) + listOf("apples", "red"), + listOf("bananas", "yellow"), + listOf("avocado", "brown") + ) val columns = listOf("Fruit", "Color") IOHandler().writeToCSVFile( fileURL = "${folder.absolutePath}/test-file", data = testContent, - columns = columns) + columns = columns + ) var expected = "Fruit,Color\n" - testContent.forEach { expected += it[0] + "," + it[1] + "\n" } + testContent.forEach { expected += it[0] + "," + it[1] + "\n" } assertEquals( expected.trim(), @@ -68,8 +72,9 @@ internal class IOHandlerTest { val testContent = Resource(0, emptyList()) IOHandler().writeToJSONFile( - fileURL = "${folder.absolutePath}/test-file.json", - objectToSave = testContent) + fileURL = "${folder.absolutePath}/test-file.json", + objectToSave = testContent + ) val expected = GsonBuilder().enableComplexMapKeySerialization().setPrettyPrinting().create().toJson(testContent) @@ -87,7 +92,7 @@ internal class IOHandlerTest { ClearEnvironmentVariable(key = "CREATE_RESULTS_FOLDER") ) fun testGetResultFolderURL_emptyEnvironmentVars() { - assertEquals("",IOHandler().getResultFolderURL()) + assertEquals("", IOHandler().getResultFolderURL()) } @@ -109,10 +114,10 @@ internal class IOHandlerTest { var exceptionWasThrown = false try { IOHandler().getResultFolderURL() - } catch (e: Exception){ - exceptionWasThrown = true - assertThat(e.toString(), containsString("Result folder not found")); - } + } catch (e: Exception) { + exceptionWasThrown = true + assertThat(e.toString(), containsString("Result folder not found")) + } assertTrue(exceptionWasThrown) } @@ -122,13 +127,13 @@ internal class IOHandlerTest { SetEnvironmentVariable(key = "CREATE_RESULTS_FOLDER", value = "true") ) fun testGetResultFolderURL_CreateFolderIfNotExist() { - assertEquals("$FOLDER_URL/", IOHandler().getResultFolderURL()) + assertEquals("$FOLDER_URL/", IOHandler().getResultFolderURL()) } @Test() - @ClearEnvironmentVariable(key = "RESULTS_FOLDER" ) + @ClearEnvironmentVariable(key = "RESULTS_FOLDER") @SetEnvironmentVariable(key = "CREATE_RESULTS_FOLDER", value = "true") fun testGetResultFolderURL_CreateFolderButNoFolderGiven() { - assertEquals("", IOHandler().getResultFolderURL()) + assertEquals("", IOHandler().getResultFolderURL()) } }