Skip to content
Snippets Groups Projects
Commit 866c39e4 authored by Marcel Samir Becker's avatar Marcel Samir Becker
Browse files

Added CRDExecution Parsing Test

parent 141a5693
Branches
Tags
1 merge request!215Redesign Strategy, Load, and Resources data types
...@@ -1784,7 +1784,7 @@ Contains the Kafka configuration. ...@@ -1784,7 +1784,7 @@ Contains the Kafka configuration.
<td> <td>
Specifies the load values that are benchmarked.<br/> Specifies the load values that are benchmarked.<br/>
</td> </td>
<td>false</td> <td>true</td>
</tr><tr> </tr><tr>
<td><b>name</b></td> <td><b>name</b></td>
<td>string</td> <td>string</td>
......
...@@ -35,7 +35,7 @@ class BenchmarkExecution : KubernetesResource { ...@@ -35,7 +35,7 @@ class BenchmarkExecution : KubernetesResource {
lateinit var configOverrides: MutableList<ConfigurationOverride?> lateinit var configOverrides: MutableList<ConfigurationOverride?>
/** /**
* This execution encapsulates the [strategy], the [duration], the [repetitions], and the [restrictions] * This execution encapsulates the [strategy], the [duration], and the [repetitions],
* which are used for the concrete benchmark experiments. * which are used for the concrete benchmark experiments.
*/ */
@JsonDeserialize @JsonDeserialize
...@@ -51,8 +51,9 @@ class BenchmarkExecution : KubernetesResource { ...@@ -51,8 +51,9 @@ class BenchmarkExecution : KubernetesResource {
/** /**
* This Strategy encapsulates the [restrictions], [guessStrategy] and [searchStrategy], * This Strategy encapsulates the [restrictions], [guessStrategy] and [searchStrategy],
* which are used for restricting the resources, the guess Strategy for the [InitialGuessSearchStrategy] and * which are used for restricting the resources, the guess Strategy for the
* the actual [SearchStrategy] which is used. * [theodolite.strategies.searchstrategy.InitialGuessSearchStrategy] and the name of the actual
* [theodolite.strategies.searchstrategy.SearchStrategy] which is used.
*/ */
@JsonDeserialize @JsonDeserialize
@RegisterForReflection @RegisterForReflection
......
package theodolite.model.crd
import io.fabric8.kubernetes.api.model.KubernetesResourceList
import io.fabric8.kubernetes.client.dsl.MixedOperation
import io.fabric8.kubernetes.client.dsl.Resource
import io.fabric8.kubernetes.client.server.mock.KubernetesServer
import io.quarkus.test.junit.QuarkusTest
import io.quarkus.test.kubernetes.client.KubernetesTestServer
import io.quarkus.test.kubernetes.client.WithKubernetesTestServer
import org.junit.jupiter.api.AfterEach
import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.mockito.internal.matchers.apachecommons.ReflectionEquals
import org.apache.commons.lang3.builder.EqualsBuilder
import org.hamcrest.MatcherAssert.assertThat
import org.hamcrest.Matchers.instanceOf
import org.mockito.kotlin.isA
import org.mockito.kotlin.mock
import theodolite.benchmark.BenchmarkExecution
import theodolite.execution.operator.*
import theodolite.util.ConfigurationOverride
import java.io.FileInputStream
// TODO move somewhere else
typealias ExecutionClient = MixedOperation<ExecutionCRD, KubernetesResourceList<ExecutionCRD>, Resource<ExecutionCRD>>
@WithKubernetesTestServer
@QuarkusTest
internal class CRDExecutionTest {
@KubernetesTestServer
private lateinit var server: KubernetesServer
lateinit var executionClient: ExecutionClient
lateinit var controller: TheodoliteController
lateinit var stateHandler: ExecutionStateHandler
lateinit var eventHandler: ExecutionEventHandler
@BeforeEach
fun setUp() {
server.before()
this.server.client
.apiextensions().v1()
.customResourceDefinitions()
.load(FileInputStream("crd/crd-execution.yaml"))
.create()
this.executionClient = this.server.client.resources(ExecutionCRD::class.java)
this.controller = mock()
this.stateHandler = ExecutionStateHandler(server.client)
this.eventHandler = ExecutionEventHandler(this.controller, this.stateHandler)
}
@AfterEach
fun tearDown() {
server.after()
}
@Test
fun checkParsingCRDTest(){
// BenchmarkExecution from yaml
val execution = executionClient.load(ClassLoader.getSystemResourceAsStream("k8s-resource-files/test-execution.yaml")).create().spec
assertEquals(0, execution.executionId)
assertEquals("test", execution.name)
assertEquals("uc1-kstreams", execution.benchmark)
assertEquals(mutableListOf<ConfigurationOverride?>(), execution.configOverrides)
assertEquals("NumSensors", execution.loads.loadType)
assertEquals(listOf(25000, 50000, 75000, 100000, 125000, 150000),execution.loads.loadValues)
assertEquals("Instances", execution.resources.resourceType)
assertEquals(listOf(1, 2, 3, 4, 5), execution.resources.resourceValues)
assertEquals("demand", execution.execution.metric)
assertEquals(300, execution.execution.duration)
assertEquals(1, execution.execution.repetitions)
assertEquals("RestrictionSearch", execution.execution.strategy.name)
assertEquals("LinearSearch", execution.execution.strategy.searchStrategy)
assertEquals(listOf("LowerBound"), execution.execution.strategy.restrictions)
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment