Skip to content
Snippets Groups Projects
Commit f19a148c authored by Sören Henning's avatar Sören Henning
Browse files

Fix issue in restriction search, fix #402

parent 29066768
No related branches found
No related tags found
No related merge requests found
Pipeline #10029 failed
......@@ -13,11 +13,9 @@ import rocks.theodolite.core.Results
class LowerBoundRestriction(results: Results) : RestrictionStrategy(results) {
override fun apply(xValue: Int, yValues: List<Int>): List<Int> {
val maxXValue: Int? = this.results.getMaxBenchmarkedXDimensionValue(xValue)
var lowerBound: Int? = this.results.getOptYDimensionValue(maxXValue)
if (lowerBound == null) {
lowerBound = yValues[0]
}
val maxXValue = this.results.getMaxBenchmarkedXDimensionValue(xValue)
// Get previous largest y value or restrict to empty list
val lowerBound: Int = this.results.getOptYDimensionValue(maxXValue) ?: return listOf()
return yValues.filter { x -> x >= lowerBound }
}
......
......@@ -9,12 +9,37 @@ import rocks.theodolite.kubernetes.TestExperimentRunner
import rocks.theodolite.core.strategies.guessstrategy.PrevInstanceOptGuess
import rocks.theodolite.core.Results
import rocks.theodolite.core.createResultsFromArray
import rocks.theodolite.core.strategies.restrictionstrategy.LowerBoundRestriction
private val logger = KotlinLogging.logger {}
@QuarkusTest
class InitialGuessSearchStrategyTest {
@Test
fun initialGuessSearchNoMatch() {
val mockResults = createResultsFromArray(arrayOf(
arrayOf(true, true),
arrayOf(false, false),
arrayOf(true, true),
), Metric.DEMAND)
val mockLoads: List<Int> = (1..3).toList()
val mockResources: List<Int> = (1..2).toList()
val results = Results(Metric.DEMAND)
val guessStrategy = PrevInstanceOptGuess()
val benchmarkExecutor = TestExperimentRunner(results, mockResults)
val strategy = InitialGuessSearchStrategy(benchmarkExecutor,guessStrategy, results)
val actual: MutableList<Int?> = mutableListOf()
val expected: List<Int?> = listOf(1, null, 1)
for (load in mockLoads) {
actual.add(strategy.findSuitableResource(load, mockResources))
}
assertEquals(expected, actual)
}
@Test
fun testInitialGuessSearch() {
val mockResults = createResultsFromArray(arrayOf(
......
......@@ -14,7 +14,6 @@ import rocks.theodolite.core.createResultsFromArray
class RestrictionSearchTest {
@Test
@Disabled("Currently failing, has to be fixed")
fun restrictionSearchNoMatch() {
val mockResults = createResultsFromArray(arrayOf(
arrayOf(true, true),
......
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