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

Adjusted Results class for handling requests for both metrics

parent eb0387c7
No related branches found
No related tags found
1 merge request!215Redesign Strategy, Load, and Resources data types
This commit is part of merge request !215. Comments created here will be created in the context of that merge request.
Showing
with 94 additions and 53 deletions
...@@ -4,6 +4,7 @@ import mu.KotlinLogging ...@@ -4,6 +4,7 @@ import mu.KotlinLogging
import theodolite.benchmark.BenchmarkExecution import theodolite.benchmark.BenchmarkExecution
import theodolite.benchmark.KubernetesBenchmark import theodolite.benchmark.KubernetesBenchmark
import theodolite.patcher.PatcherDefinitionFactory import theodolite.patcher.PatcherDefinitionFactory
import theodolite.strategies.Metric
import theodolite.strategies.StrategyFactory import theodolite.strategies.StrategyFactory
import theodolite.util.* import theodolite.util.*
import java.io.File import java.io.File
...@@ -37,7 +38,7 @@ class TheodoliteExecutor( ...@@ -37,7 +38,7 @@ class TheodoliteExecutor(
* The [searchStrategy] is configured and able to find the minimum required resource for the given load. * The [searchStrategy] is configured and able to find the minimum required resource for the given load.
*/ */
private fun buildConfig(): Config { private fun buildConfig(): Config {
val results = Results() val results = Results(Metric.from(config.execution.metric))
val strategyFactory = StrategyFactory() val strategyFactory = StrategyFactory()
val executionDuration = Duration.ofSeconds(config.execution.duration) val executionDuration = Duration.ofSeconds(config.execution.duration)
...@@ -92,7 +93,7 @@ class TheodoliteExecutor( ...@@ -92,7 +93,7 @@ class TheodoliteExecutor(
resources = config.resources.resourceValues, resources = config.resources.resourceValues,
resourcePatcherDefinitions = resourcePatcherDefinition, resourcePatcherDefinitions = resourcePatcherDefinition,
searchStrategy = strategyFactory.createSearchStrategy(executor, config.execution.strategy, results), searchStrategy = strategyFactory.createSearchStrategy(executor, config.execution.strategy, results),
metric = config.execution.metric metric = Metric.from(config.execution.metric)
) )
} }
...@@ -120,7 +121,7 @@ class TheodoliteExecutor( ...@@ -120,7 +121,7 @@ class TheodoliteExecutor(
//execute benchmarks for each load for the demand metric, or for each resource amount for capacity metric //execute benchmarks for each load for the demand metric, or for each resource amount for capacity metric
try { try {
config.searchStrategy.findSuitableCapacity(config.loads, config.resources, config.metric) config.searchStrategy.applySearchStrategyByMetric(config.loads, config.resources, config.metric)
} finally { } finally {
ioHandler.writeToJSONFile( ioHandler.writeToJSONFile(
...@@ -148,7 +149,7 @@ class TheodoliteExecutor( ...@@ -148,7 +149,7 @@ class TheodoliteExecutor(
} }
private fun calculateDemandMetric(loads: List<Int>, results: Results): List<List<String>> { private fun calculateDemandMetric(loads: List<Int>, results: Results): List<List<String>> {
return loads.map { listOf(it.toString(), results.getMinRequiredInstances(it).toString()) } return loads.map { listOf(it.toString(), results.getMinRequiredYDimensionValue(it).toString()) }
} }
} }
package theodolite.strategies
enum class Metric(val value: String) {
DEMAND("demand"),
CAPACITY("capacity");
companion object {
fun from(metric: String): Metric =
values().find { it.value == metric } ?: throw IllegalArgumentException("Requested Metric does not exist")
}
}
\ No newline at end of file
...@@ -10,13 +10,13 @@ import theodolite.util.Results ...@@ -10,13 +10,13 @@ import theodolite.util.Results
*/ */
class LowerBoundRestriction(results: Results) : RestrictionStrategy(results) { class LowerBoundRestriction(results: Results) : RestrictionStrategy(results) {
override fun apply(load: Int, resources: List<Int>): List<Int> { override fun apply(xValue: Int, yValues: List<Int>): List<Int> {
val maxLoad: Int? = this.results.getMaxBenchmarkedLoad(load) val maxXValue: Int? = this.results.getMaxBenchmarkedXDimensionValue(xValue)
var lowerBound: Int = this.results.getMinRequiredInstances(maxLoad) var lowerBound: Int = this.results.getMinRequiredYDimensionValue(maxXValue)
if (lowerBound == Int.MIN_VALUE || lowerBound == Int.MAX_VALUE) { if (lowerBound == Int.MIN_VALUE || lowerBound == Int.MAX_VALUE) {
lowerBound = resources[0] lowerBound = yValues[0]
} }
return resources.filter { x -> x >= lowerBound } return yValues.filter { x -> x >= lowerBound }
} }
} }
...@@ -19,5 +19,5 @@ abstract class RestrictionStrategy(val results: Results) { ...@@ -19,5 +19,5 @@ abstract class RestrictionStrategy(val results: Results) {
* @return Returns a list containing only elements that have not been filtered out by the * @return Returns a list containing only elements that have not been filtered out by the
* restriction (possibly empty). * restriction (possibly empty).
*/ */
abstract fun apply(load: Int, resources: List<Int>): List<Int> abstract fun apply(xValue: Int, yValues: List<Int>): List<Int>
} }
...@@ -6,6 +6,7 @@ import theodolite.util.Results ...@@ -6,6 +6,7 @@ import theodolite.util.Results
private val logger = KotlinLogging.logger {} private val logger = KotlinLogging.logger {}
// TODO: Is actually just a heuristic approach. Not ensured to have opt solution. Maybe Talk to Sören about it.
/** /**
* Search strategy implementation for determining the smallest suitable resource demand. * Search strategy implementation for determining the smallest suitable resource demand.
* Starting with a resource amount provided by a guess strategy. * Starting with a resource amount provided by a guess strategy.
...@@ -39,8 +40,8 @@ class InitialGuessSearchStrategy(benchmarkExecutor: BenchmarkExecutor, guessStra ...@@ -39,8 +40,8 @@ class InitialGuessSearchStrategy(benchmarkExecutor: BenchmarkExecutor, guessStra
// Getting the lastLowestResource from results and calling firstGuess() with it // Getting the lastLowestResource from results and calling firstGuess() with it
if (!results.isEmpty()) { if (!results.isEmpty()) {
val maxLoad: Int? = this.results.getMaxBenchmarkedLoad(load) val maxLoad: Int? = this.results.getMaxBenchmarkedXDimensionValue(load)
lastLowestResource = this.results.getMinRequiredInstances(maxLoad) lastLowestResource = this.results.getMinRequiredYDimensionValue(maxLoad)
if (lastLowestResource == Int.MAX_VALUE) lastLowestResource = null if (lastLowestResource == Int.MAX_VALUE) lastLowestResource = null
} }
lastLowestResource = this.guessStrategy.firstGuess(resources, lastLowestResource) lastLowestResource = this.guessStrategy.firstGuess(resources, lastLowestResource)
......
...@@ -31,5 +31,6 @@ class RestrictionSearch( ...@@ -31,5 +31,6 @@ class RestrictionSearch(
for (strategy in this.restrictionStrategies) { for (strategy in this.restrictionStrategies) {
restrictedLoads = restrictedLoads.intersect(strategy.apply(resource, loads).toSet()).toList() restrictedLoads = restrictedLoads.intersect(strategy.apply(resource, loads).toSet()).toList()
} }
return this.searchStrategy.findSuitableLoad(resource, restrictedLoads)
} }
} }
\ No newline at end of file
...@@ -2,6 +2,7 @@ package theodolite.strategies.searchstrategy ...@@ -2,6 +2,7 @@ package theodolite.strategies.searchstrategy
import io.quarkus.runtime.annotations.RegisterForReflection import io.quarkus.runtime.annotations.RegisterForReflection
import theodolite.execution.BenchmarkExecutor import theodolite.execution.BenchmarkExecutor
import theodolite.strategies.Metric
import theodolite.util.Results import theodolite.util.Results
/** /**
...@@ -16,9 +17,9 @@ abstract class SearchStrategy(val benchmarkExecutor: BenchmarkExecutor, val gues ...@@ -16,9 +17,9 @@ abstract class SearchStrategy(val benchmarkExecutor: BenchmarkExecutor, val gues
val results: Results? = null) { val results: Results? = null) {
fun findSuitableCapacity(loads: List<Int>, resources: List<Int>, metric: String) { fun applySearchStrategyByMetric(loads: List<Int>, resources: List<Int>, metric: Metric) {
if (metric == "demand") { if (metric.value == "demand") {
//demand metric //demand metric
for (load in loads) { for (load in loads) {
if (benchmarkExecutor.run.get()) { if (benchmarkExecutor.run.get()) {
......
package theodolite.util package theodolite.util
import io.quarkus.runtime.annotations.RegisterForReflection import io.quarkus.runtime.annotations.RegisterForReflection
import theodolite.strategies.Metric
import theodolite.strategies.searchstrategy.SearchStrategy import theodolite.strategies.searchstrategy.SearchStrategy
/** /**
...@@ -18,5 +19,5 @@ data class Config( ...@@ -18,5 +19,5 @@ data class Config(
val resources: List<Int>, val resources: List<Int>,
val resourcePatcherDefinitions : List<PatcherDefinition>, val resourcePatcherDefinitions : List<PatcherDefinition>,
val searchStrategy: SearchStrategy, val searchStrategy: SearchStrategy,
val metric: String val metric: Metric
) )
package theodolite.util package theodolite.util
import io.quarkus.runtime.annotations.RegisterForReflection import io.quarkus.runtime.annotations.RegisterForReflection
import theodolite.strategies.Metric
/** /**
* Central class that saves the state of an execution of Theodolite. For an execution, it is used to save the result of * Central class that saves the state of an execution of Theodolite. For an execution, it is used to save the result of
...@@ -8,7 +9,9 @@ import io.quarkus.runtime.annotations.RegisterForReflection ...@@ -8,7 +9,9 @@ import io.quarkus.runtime.annotations.RegisterForReflection
* perform the [theodolite.strategies.restriction.RestrictionStrategy]. * perform the [theodolite.strategies.restriction.RestrictionStrategy].
*/ */
@RegisterForReflection @RegisterForReflection
class Results { //TODO: Initializing überall anpassen
class Results (val metric: Metric) {
//TODO: enum statt Boolean
private val results: MutableMap<Pair<Int, Int>, Boolean> = mutableMapOf() private val results: MutableMap<Pair<Int, Int>, Boolean> = mutableMapOf()
/** /**
...@@ -43,24 +46,27 @@ class Results { ...@@ -43,24 +46,27 @@ class Results {
* If no experiments have been marked as either successful or unsuccessful * If no experiments have been marked as either successful or unsuccessful
* yet, a Resource with the constant value Int.MIN_VALUE is returned. * yet, a Resource with the constant value Int.MIN_VALUE is returned.
*/ */
fun getMinRequiredInstances(load: Int?): Int { fun getMinRequiredYDimensionValue(xValue: Int?): Int {
if (this.results.isEmpty()) { if (this.results.isEmpty()) { //should add || xValue == null
return Int.MIN_VALUE return Int.MIN_VALUE
} }
var minRequiredInstances = Int.MAX_VALUE var minRequiredYValue = Int.MAX_VALUE
for (experiment in results) { for (experiment in results) {
// Get all successful experiments for requested load // Get all successful experiments for requested load
if (experiment.key.first == load && experiment.value) { if (getXDimensionValue(experiment.key) == xValue && experiment.value) {
if (experiment.key.second < minRequiredInstances) { val experimentYValue = getYDimensionValue(experiment.key)
if (experimentYValue < minRequiredYValue) {
// Found new smallest resources // Found new smallest resources
minRequiredInstances = experiment.key.second minRequiredYValue = experimentYValue
} }
} }
} }
return minRequiredInstances return minRequiredYValue
} }
// TODO: SÖREN FRAGEN WARUM WIR DAS BRAUCHEN UND NICHT EINFACH PREV, WEIL NICHT DURCHGELAUFEN?
// TODO Kommentar zu XDimension und YDimension
/** /**
* Get the largest LoadDimension that has been reported executed successfully (or unsuccessfully) so far, for a * Get the largest LoadDimension that has been reported executed successfully (or unsuccessfully) so far, for a
* LoadDimension and is smaller than the given LoadDimension. * LoadDimension and is smaller than the given LoadDimension.
...@@ -69,18 +75,19 @@ class Results { ...@@ -69,18 +75,19 @@ class Results {
* *
* @return the largest LoadDimension or null, if there is none for this LoadDimension * @return the largest LoadDimension or null, if there is none for this LoadDimension
*/ */
fun getMaxBenchmarkedLoad(load: Int): Int? { fun getMaxBenchmarkedXDimensionValue(xValue: Int): Int? {
var maxBenchmarkedLoad: Int? = null var maxBenchmarkedXValue: Int? = null
for (experiment in results) { for (experiment in results) {
if (experiment.key.first <= load) { val experimentXValue = getXDimensionValue(experiment.key)
if (maxBenchmarkedLoad == null) { if (experimentXValue <= xValue) { //warum \leq?
maxBenchmarkedLoad = experiment.key.first if (maxBenchmarkedXValue == null) {
} else if (maxBenchmarkedLoad < experiment.key.first) { maxBenchmarkedXValue = experimentXValue
maxBenchmarkedLoad = experiment.key.first } else if (maxBenchmarkedXValue < experimentXValue) {
maxBenchmarkedXValue = experimentXValue
} }
} }
} }
return maxBenchmarkedLoad return maxBenchmarkedXValue
} }
/** /**
...@@ -91,4 +98,18 @@ class Results { ...@@ -91,4 +98,18 @@ class Results {
fun isEmpty(): Boolean{ fun isEmpty(): Boolean{
return results.isEmpty() return results.isEmpty()
} }
fun getYDimensionValue(experimentKey: Pair<Int, Int>): Int{
if(metric.value == "demand"){
return experimentKey.second
}
return experimentKey.first
}
fun getXDimensionValue(experimentKey: Pair<Int, Int>): Int{
if(metric.value == "demand"){
return experimentKey.first
}
return experimentKey.second
}
} }
...@@ -5,6 +5,7 @@ import org.junit.jupiter.api.Assertions.assertEquals ...@@ -5,6 +5,7 @@ import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
import theodolite.benchmark.BenchmarkExecution import theodolite.benchmark.BenchmarkExecution
import theodolite.strategies.searchstrategy.InitialGuessSearchStrategy import theodolite.strategies.searchstrategy.InitialGuessSearchStrategy
import theodolite.strategies.Metric
import theodolite.util.Results import theodolite.util.Results
import mu.KotlinLogging import mu.KotlinLogging
import theodolite.strategies.searchstrategy.PrevResourceMinGuess import theodolite.strategies.searchstrategy.PrevResourceMinGuess
...@@ -27,7 +28,7 @@ class InitialGuessSearchStrategyTest { ...@@ -27,7 +28,7 @@ class InitialGuessSearchStrategyTest {
) )
val mockLoads: List<Int> = (0..6).toList() val mockLoads: List<Int> = (0..6).toList()
val mockResources: List<Int> = (0..6).toList() val mockResources: List<Int> = (0..6).toList()
val results = Results() val results = Results(Metric.from("demand"))
val benchmark = TestBenchmark() val benchmark = TestBenchmark()
val guessStrategy = PrevResourceMinGuess() val guessStrategy = PrevResourceMinGuess()
val sloChecker: BenchmarkExecution.Slo = BenchmarkExecution.Slo() val sloChecker: BenchmarkExecution.Slo = BenchmarkExecution.Slo()
...@@ -65,7 +66,7 @@ class InitialGuessSearchStrategyTest { ...@@ -65,7 +66,7 @@ class InitialGuessSearchStrategyTest {
) )
val mockLoads: List<Int> = (0..6).toList() val mockLoads: List<Int> = (0..6).toList()
val mockResources: List<Int> = (0..6).toList() val mockResources: List<Int> = (0..6).toList()
val results = Results() val results = Results(Metric.from("demand"))
val benchmark = TestBenchmark() val benchmark = TestBenchmark()
val guessStrategy = PrevResourceMinGuess() val guessStrategy = PrevResourceMinGuess()
val sloChecker: BenchmarkExecution.Slo = BenchmarkExecution.Slo() val sloChecker: BenchmarkExecution.Slo = BenchmarkExecution.Slo()
...@@ -103,7 +104,7 @@ class InitialGuessSearchStrategyTest { ...@@ -103,7 +104,7 @@ class InitialGuessSearchStrategyTest {
) )
val mockLoads: List<Int> = (0..6).toList() val mockLoads: List<Int> = (0..6).toList()
val mockResources: List<Int> = (0..6).toList() val mockResources: List<Int> = (0..6).toList()
val results = Results() val results = Results(Metric.from("demand"))
val benchmark = TestBenchmark() val benchmark = TestBenchmark()
val guessStrategy = PrevResourceMinGuess() val guessStrategy = PrevResourceMinGuess()
val sloChecker: BenchmarkExecution.Slo = BenchmarkExecution.Slo() val sloChecker: BenchmarkExecution.Slo = BenchmarkExecution.Slo()
......
...@@ -4,6 +4,7 @@ import io.quarkus.test.junit.QuarkusTest ...@@ -4,6 +4,7 @@ import io.quarkus.test.junit.QuarkusTest
import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
import theodolite.benchmark.BenchmarkExecution import theodolite.benchmark.BenchmarkExecution
import theodolite.strategies.Metric
import theodolite.strategies.restriction.LowerBoundRestriction import theodolite.strategies.restriction.LowerBoundRestriction
import theodolite.strategies.searchstrategy.BinarySearch import theodolite.strategies.searchstrategy.BinarySearch
import theodolite.strategies.searchstrategy.FullSearch import theodolite.strategies.searchstrategy.FullSearch
...@@ -28,7 +29,7 @@ class RestrictionSearchTest { ...@@ -28,7 +29,7 @@ class RestrictionSearchTest {
) )
val mockLoads: List<Int> = (0..6).toList() val mockLoads: List<Int> = (0..6).toList()
val mockResources: List<Int> = (0..6).toList() val mockResources: List<Int> = (0..6).toList()
val results = Results() val results = Results(Metric.from("demand"))
val benchmark = TestBenchmark() val benchmark = TestBenchmark()
val sloChecker: BenchmarkExecution.Slo = BenchmarkExecution.Slo() val sloChecker: BenchmarkExecution.Slo = BenchmarkExecution.Slo()
val benchmarkExecutor = TestBenchmarkExecutorImpl(mockResults, benchmark, results, listOf(sloChecker), 0, 0, 5) val benchmarkExecutor = TestBenchmarkExecutorImpl(mockResults, benchmark, results, listOf(sloChecker), 0, 0, 5)
...@@ -61,7 +62,7 @@ class RestrictionSearchTest { ...@@ -61,7 +62,7 @@ class RestrictionSearchTest {
) )
val mockLoads: List<Int> = (0..6).toList() val mockLoads: List<Int> = (0..6).toList()
val mockResources: List<Int> = (0..6).toList() val mockResources: List<Int> = (0..6).toList()
val results = Results() val results = Results(Metric.from("demand"))
val benchmark = TestBenchmark() val benchmark = TestBenchmark()
val sloChecker: BenchmarkExecution.Slo = BenchmarkExecution.Slo() val sloChecker: BenchmarkExecution.Slo = BenchmarkExecution.Slo()
val benchmarkExecutor = TestBenchmarkExecutorImpl(mockResults, benchmark, results, listOf(sloChecker), 0, 0, 5) val benchmarkExecutor = TestBenchmarkExecutorImpl(mockResults, benchmark, results, listOf(sloChecker), 0, 0, 5)
...@@ -94,7 +95,7 @@ class RestrictionSearchTest { ...@@ -94,7 +95,7 @@ class RestrictionSearchTest {
) )
val mockLoads: List<Int> = (0..6).toList() val mockLoads: List<Int> = (0..6).toList()
val mockResources: List<Int> = (0..6).toList() val mockResources: List<Int> = (0..6).toList()
val results = Results() val results = Results(Metric.from("demand"))
val benchmark = TestBenchmark() val benchmark = TestBenchmark()
val sloChecker: BenchmarkExecution.Slo = BenchmarkExecution.Slo() val sloChecker: BenchmarkExecution.Slo = BenchmarkExecution.Slo()
val benchmarkExecutorImpl = val benchmarkExecutorImpl =
...@@ -127,7 +128,7 @@ class RestrictionSearchTest { ...@@ -127,7 +128,7 @@ class RestrictionSearchTest {
) )
val mockLoads: List<Int> = (0..6).toList() val mockLoads: List<Int> = (0..6).toList()
val mockResources: List<Int> = (0..7).toList() val mockResources: List<Int> = (0..7).toList()
val results = Results() val results = Results(Metric.from("demand"))
val benchmark = TestBenchmark() val benchmark = TestBenchmark()
val sloChecker: BenchmarkExecution.Slo = BenchmarkExecution.Slo() val sloChecker: BenchmarkExecution.Slo = BenchmarkExecution.Slo()
val benchmarkExecutor = TestBenchmarkExecutorImpl(mockResults, benchmark, results, listOf(sloChecker), 0, 0, 0) val benchmarkExecutor = TestBenchmarkExecutorImpl(mockResults, benchmark, results, listOf(sloChecker), 0, 0, 0)
......
...@@ -4,13 +4,14 @@ import org.junit.jupiter.api.Assertions.assertEquals ...@@ -4,13 +4,14 @@ import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertNotNull import org.junit.jupiter.api.Assertions.assertNotNull
import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
import theodolite.strategies.Metric
import theodolite.util.Results import theodolite.util.Results
internal class LowerBoundRestrictionTest { internal class LowerBoundRestrictionTest {
@Test @Test
fun testNoPreviousResults() { fun testNoPreviousResults() {
val results = Results() val results = Results(Metric.from("demand"))
val strategy = LowerBoundRestriction(results) val strategy = LowerBoundRestriction(results)
val load = 10000 val load = 10000
val resources = listOf(1, 2, 3) val resources = listOf(1, 2, 3)
...@@ -22,7 +23,7 @@ internal class LowerBoundRestrictionTest { ...@@ -22,7 +23,7 @@ internal class LowerBoundRestrictionTest {
@Test @Test
fun testWithSuccessfulPreviousResults() { fun testWithSuccessfulPreviousResults() {
val results = Results() val results = Results(Metric.from("demand"))
results.setResult(10000, 1, true) results.setResult(10000, 1, true)
results.setResult(20000, 1, false) results.setResult(20000, 1, false)
results.setResult(20000, 2, true) results.setResult(20000, 2, true)
...@@ -39,7 +40,7 @@ internal class LowerBoundRestrictionTest { ...@@ -39,7 +40,7 @@ internal class LowerBoundRestrictionTest {
@Disabled @Disabled
fun testWithNoSuccessfulPreviousResults() { fun testWithNoSuccessfulPreviousResults() {
// This test is currently not implemented this way, but might later be the desired behavior. // This test is currently not implemented this way, but might later be the desired behavior.
val results = Results() val results = Results(Metric.from("demand"))
results.setResult(10000, 1, true) results.setResult(10000, 1, true)
results.setResult(20000, 1, false) results.setResult(20000, 1, false)
results.setResult(20000, 2, false) results.setResult(20000, 2, false)
...@@ -56,13 +57,13 @@ internal class LowerBoundRestrictionTest { ...@@ -56,13 +57,13 @@ internal class LowerBoundRestrictionTest {
@Test @Test
fun testNoPreviousResults2() { fun testNoPreviousResults2() {
val results = Results() val results = Results(Metric.from("demand"))
results.setResult(10000, 1, true) results.setResult(10000, 1, true)
results.setResult(20000, 2, true) results.setResult(20000, 2, true)
results.setResult(10000, 1, false) results.setResult(10000, 1, false)
results.setResult(20000, 2, true) results.setResult(20000, 2, true)
val minRequiredInstances = results.getMinRequiredInstances(20000) val minRequiredInstances = results.getMinRequiredYDimensionValue(20000)
assertNotNull(minRequiredInstances) assertNotNull(minRequiredInstances)
assertEquals(2, minRequiredInstances!!) assertEquals(2, minRequiredInstances!!)
...@@ -72,13 +73,13 @@ internal class LowerBoundRestrictionTest { ...@@ -72,13 +73,13 @@ internal class LowerBoundRestrictionTest {
@Disabled @Disabled
fun testMinRequiredInstancesWhenNotSuccessful() { fun testMinRequiredInstancesWhenNotSuccessful() {
// This test is currently not implemented this way, but might later be the desired behavior. // This test is currently not implemented this way, but might later be the desired behavior.
val results = Results() val results = Results(Metric.from("demand"))
results.setResult(10000, 1, true) results.setResult(10000, 1, true)
results.setResult(20000, 2, true) results.setResult(20000, 2, true)
results.setResult(10000, 1, false) results.setResult(10000, 1, false)
results.setResult(20000, 2, false) results.setResult(20000, 2, false)
val minRequiredInstances = results.getMinRequiredInstances(20000) val minRequiredInstances = results.getMinRequiredYDimensionValue(20000)
assertNotNull(minRequiredInstances) assertNotNull(minRequiredInstances)
assertEquals(2, minRequiredInstances!!) assertEquals(2, minRequiredInstances!!)
......
...@@ -5,19 +5,20 @@ import org.junit.jupiter.api.Assertions.assertEquals ...@@ -5,19 +5,20 @@ import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertNotNull import org.junit.jupiter.api.Assertions.assertNotNull
import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
import theodolite.strategies.Metric
@QuarkusTest @QuarkusTest
internal class ResultsTest { internal class ResultsTest {
@Test @Test
fun testMinRequiredInstancesWhenSuccessful() { fun testMinRequiredInstancesWhenSuccessful() {
val results = Results() val results = Results(Metric.from("demand"))
results.setResult(10000, 1, true) results.setResult(10000, 1, true)
results.setResult(10000, 2, true) results.setResult(10000, 2, true)
results.setResult(20000, 1, false) results.setResult(20000, 1, false)
results.setResult(20000, 2, true) results.setResult(20000, 2, true)
val minRequiredInstances = results.getMinRequiredInstances(20000) val minRequiredInstances = results.getMinRequiredYDimensionValue(20000)
assertNotNull(minRequiredInstances) assertNotNull(minRequiredInstances)
assertEquals(2, minRequiredInstances!!) assertEquals(2, minRequiredInstances!!)
...@@ -27,13 +28,13 @@ internal class ResultsTest { ...@@ -27,13 +28,13 @@ internal class ResultsTest {
@Disabled @Disabled
fun testMinRequiredInstancesWhenNotSuccessful() { fun testMinRequiredInstancesWhenNotSuccessful() {
// This test is currently not implemented this way, but might later be the desired behavior. // This test is currently not implemented this way, but might later be the desired behavior.
val results = Results() val results = Results(Metric.from("demand"))
results.setResult(10000, 1, true) results.setResult(10000, 1, true)
results.setResult(10000, 2, true) results.setResult(10000, 2, true)
results.setResult(20000, 1, false) results.setResult(20000, 1, false)
results.setResult(20000, 2, false) results.setResult(20000, 2, false)
val minRequiredInstances = results.getMinRequiredInstances(20000) val minRequiredInstances = results.getMinRequiredYDimensionValue(20000)
assertNotNull(minRequiredInstances) assertNotNull(minRequiredInstances)
assertEquals(2, minRequiredInstances!!) assertEquals(2, minRequiredInstances!!)
...@@ -46,23 +47,23 @@ internal class ResultsTest { ...@@ -46,23 +47,23 @@ internal class ResultsTest {
@Test @Test
fun testGetMaxBenchmarkedLoadWhenAllSuccessful() { fun testGetMaxBenchmarkedLoadWhenAllSuccessful() {
val results = Results() val results = Results(Metric.from("demand"))
results.setResult(10000, 1, true) results.setResult(10000, 1, true)
results.setResult(10000, 2, true) results.setResult(10000, 2, true)
val test1 = results.getMaxBenchmarkedLoad(100000)!! val test1 = results.getMaxBenchmarkedXDimensionValue(100000)!!
assertEquals(10000, test1) assertEquals(10000, test1)
} }
@Test @Test
fun testGetMaxBenchmarkedLoadWhenLargestNotSuccessful() { fun testGetMaxBenchmarkedLoadWhenLargestNotSuccessful() {
val results = Results() val results = Results(Metric.from("demand"))
results.setResult(10000, 1, true) results.setResult(10000, 1, true)
results.setResult(10000, 2, true) results.setResult(10000, 2, true)
results.setResult(20000, 1, false) results.setResult(20000, 1, false)
val test2 = results.getMaxBenchmarkedLoad(100000)!! val test2 = results.getMaxBenchmarkedXDimensionValue(100000)!!
assertEquals(20000, test2) assertEquals(20000, test2)
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment