Skip to content
Snippets Groups Projects
Commit 1bbcb555 authored by Benedikt Wetzel's avatar Benedikt Wetzel Committed by Sören Henning
Browse files

minor code enhancements and clean up

parent 9f895d26
Branches
Tags
4 merge requests!159Re-implementation of Theodolite with Kotlin/Quarkus,!157Update Graal Image in CI pipeline,!154Add more Kuberntes related tests,!83WIP: Re-implementation of Theodolite with Kotlin/Quarkus
Showing
with 88 additions and 68 deletions
......@@ -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 {
......
......@@ -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
......@@ -45,9 +45,12 @@ class ExecutionEventHandlerTest {
RESYNC_PERIOD
)
informerExecution.addEventHandler(ExecutionHandler(
informerExecution.addEventHandler(
ExecutionHandler(
controller = controllerDummy.getController(),
stateHandler = controllerDummy.executionStateHandler))
stateHandler = controllerDummy.executionStateHandler
)
)
this.executionVersion1 = K8sResourceLoader(server.client)
.loadK8sResource("Execution", testResourcePath + "test-execution.yaml")
......@@ -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
......@@ -140,7 +140,10 @@ class K8sManagerTest {
.getJSONArray("items")
assertEquals(1, serviceMonitors.length())
assertEquals("test-service-monitor", serviceMonitors.getJSONObject(0).getJSONObject("metadata").getString("name"))
assertEquals(
"test-service-monitor",
serviceMonitors.getJSONObject(0).getJSONObject("metadata").getString("name")
)
manager.remove(servicemonitor)
......
......@@ -14,6 +14,7 @@ import org.junitpioneer.jupiter.SetEnvironmentVariable
const val FOLDER_URL = "Test-Folder"
@QuarkusTest
internal class IOHandlerTest {
......@@ -28,7 +29,8 @@ internal class IOHandlerTest {
IOHandler().writeStringToTextFile(
fileURL = "${folder.absolutePath}/test-file.txt",
data = testContent)
data = testContent
)
assertEquals(
testContent,
......@@ -44,13 +46,15 @@ internal class IOHandlerTest {
val testContent = listOf(
listOf("apples", "red"),
listOf("bananas", "yellow"),
listOf("avocado","brown"))
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" }
......@@ -69,7 +73,8 @@ internal class IOHandlerTest {
IOHandler().writeToJSONFile(
fileURL = "${folder.absolutePath}/test-file.json",
objectToSave = testContent)
objectToSave = testContent
)
val expected = GsonBuilder().enableComplexMapKeySerialization().setPrettyPrinting().create().toJson(testContent)
......@@ -111,7 +116,7 @@ internal class IOHandlerTest {
IOHandler().getResultFolderURL()
} catch (e: Exception) {
exceptionWasThrown = true
assertThat(e.toString(), containsString("Result folder not found"));
assertThat(e.toString(), containsString("Result folder not found"))
}
assertTrue(exceptionWasThrown)
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment