From 940cf029aeccfeefdb73e6a50b114ffe29f44572 Mon Sep 17 00:00:00 2001 From: "stu126940@mail.uni-kiel.de" <stu126940@mail.uni-kiel.de> Date: Mon, 11 Jan 2021 16:00:46 +0100 Subject: [PATCH] add implementation for strategie related components composite strategy, binary search, lower bound restriction, some interfaces, composite test Co-authored-by: Simon Ehrenstein <stu200776@mail.uni-kiel.de> --- .../kotlin/theodolite/ExperimentConfig.kt | 26 ---------- .../kotlin/theodolite/ExperimentExecutor.kt | 9 ---- .../kotlin/theodolite/GreetingResource.kt | 14 ------ .../src/main/kotlin/theodolite/Main.kt | 23 --------- .../theodolite/execution/BenchmarkExecutor.kt | 8 +++ .../execution/TestBenchmarkExecutor.kt | 12 +++++ .../theodolite/strategies/BinarySearch.kt | 10 ---- .../strategies/EvenResourcesRestriction.kt | 12 ----- .../theodolite/strategies/LinearSearch.kt | 14 ------ .../strategies/LowerBoundRestriction.kt | 16 ------ .../restriction/LowerBoundRestriction.kt | 16 ++++++ .../strategies/searchstrategy/Benchmark.kt | 7 --- .../strategies/searchstrategy/BinarySearch.kt | 37 ++++++++++++++ .../searchstrategy/CompositeStrategy.kt | 16 ++++++ .../strategies/searchstrategy/LinearSearch.kt | 15 ++++++ .../searchstrategy/RestrictionStrategy.kt | 9 ++++ .../searchstrategy/SearchStrategy.kt | 8 ++- .../kotlin/theodolite/util/LoadDimension.kt | 17 +++++++ .../main/kotlin/theodolite/util/Resource.kt | 18 +++++++ .../main/kotlin/theodolite/util/Results.kt | 32 ++++++++++++ .../theodolite/NativeGreetingResourceIT.kt | 2 +- .../theodolite/CompositeStrategyTest.kt | 49 +++++++++++++++++++ .../kotlin/theodolite/GreetingResourceTest.kt | 20 -------- 23 files changed, 236 insertions(+), 154 deletions(-) delete mode 100644 theodolite-quarkus/src/main/kotlin/theodolite/ExperimentConfig.kt delete mode 100644 theodolite-quarkus/src/main/kotlin/theodolite/ExperimentExecutor.kt delete mode 100644 theodolite-quarkus/src/main/kotlin/theodolite/GreetingResource.kt create mode 100644 theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutor.kt create mode 100644 theodolite-quarkus/src/main/kotlin/theodolite/execution/TestBenchmarkExecutor.kt delete mode 100644 theodolite-quarkus/src/main/kotlin/theodolite/strategies/BinarySearch.kt delete mode 100644 theodolite-quarkus/src/main/kotlin/theodolite/strategies/EvenResourcesRestriction.kt delete mode 100644 theodolite-quarkus/src/main/kotlin/theodolite/strategies/LinearSearch.kt delete mode 100644 theodolite-quarkus/src/main/kotlin/theodolite/strategies/LowerBoundRestriction.kt create mode 100644 theodolite-quarkus/src/main/kotlin/theodolite/strategies/restriction/LowerBoundRestriction.kt delete mode 100644 theodolite-quarkus/src/main/kotlin/theodolite/strategies/searchstrategy/Benchmark.kt create mode 100644 theodolite-quarkus/src/main/kotlin/theodolite/strategies/searchstrategy/BinarySearch.kt create mode 100644 theodolite-quarkus/src/main/kotlin/theodolite/strategies/searchstrategy/CompositeStrategy.kt create mode 100644 theodolite-quarkus/src/main/kotlin/theodolite/strategies/searchstrategy/LinearSearch.kt create mode 100644 theodolite-quarkus/src/main/kotlin/theodolite/strategies/searchstrategy/RestrictionStrategy.kt create mode 100644 theodolite-quarkus/src/main/kotlin/theodolite/util/LoadDimension.kt create mode 100644 theodolite-quarkus/src/main/kotlin/theodolite/util/Resource.kt create mode 100644 theodolite-quarkus/src/main/kotlin/theodolite/util/Results.kt create mode 100644 theodolite-quarkus/src/test/kotlin/theodolite/CompositeStrategyTest.kt delete mode 100644 theodolite-quarkus/src/test/kotlin/theodolite/GreetingResourceTest.kt diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/ExperimentConfig.kt b/theodolite-quarkus/src/main/kotlin/theodolite/ExperimentConfig.kt deleted file mode 100644 index 5b2fb22c0..000000000 --- a/theodolite-quarkus/src/main/kotlin/theodolite/ExperimentConfig.kt +++ /dev/null @@ -1,26 +0,0 @@ -package theodolite - -import theodolite.strategies.SearchAlgorithm - -data class ExperimentConfig( - val useCase: Int, - val expId: Int, - val dimValues: Array<Int>, - val replicass: Array<Int>, - val partitions: Int, - val cpuLimit: String, - val memoryLimit: String, - val executionMinutes: Float, - val prometheusBaseUrl: String, - val reset: Boolean, - val namespace: String, - val resultPath: String, - val configurations: Any, - val restrictionStrategy: SearchAlgorithm, - val searchStrategy: SearchStrategy, - val benchmark: Any, // TODO - val sloChecker: Any // TODO -) { - - -} \ No newline at end of file diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/ExperimentExecutor.kt b/theodolite-quarkus/src/main/kotlin/theodolite/ExperimentExecutor.kt deleted file mode 100644 index 9c68ca5cf..000000000 --- a/theodolite-quarkus/src/main/kotlin/theodolite/ExperimentExecutor.kt +++ /dev/null @@ -1,9 +0,0 @@ -package theodolite - -class ExperimentExecutor( - val config: ExperimentConfig -) { - fun run() { - this.config.restrictionStrategy.restrictResource(); - } -} \ No newline at end of file diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/GreetingResource.kt b/theodolite-quarkus/src/main/kotlin/theodolite/GreetingResource.kt deleted file mode 100644 index 2cf79f2d8..000000000 --- a/theodolite-quarkus/src/main/kotlin/theodolite/GreetingResource.kt +++ /dev/null @@ -1,14 +0,0 @@ -package theodolite - -import javax.ws.rs.GET -import javax.ws.rs.Path -import javax.ws.rs.Produces -import javax.ws.rs.core.MediaType - -@Path("/hello-resteasy") -class GreetingResource { - - @GET - @Produces(MediaType.TEXT_PLAIN) - fun hello() = "Hello RESTEasy" -} \ No newline at end of file diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/Main.kt b/theodolite-quarkus/src/main/kotlin/theodolite/Main.kt index d606aedd8..26d1f112d 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/Main.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/Main.kt @@ -7,28 +7,5 @@ object Main { @JvmStatic fun main(args: Array<String>) { println("Starting Benchmarks") - - val config: ExperimentConfig = ExperimentConfig( - exp_id = 0, - use_case = 1, - dim_values = arrayOf(1,2,3), - configurations = TODO(), - domain_restriction_strategy = TODO(), - cpu_limit = "1000m", - execution_minutes = 5f, - memory_limit = "4gb", - namespace = "default", - partitions = 10, - prometheus_base_url = "http://localhost:9090", - replicass = arrayOf(1,2,3), - reset = false, - result_path = "./results", - search_strategy = TODO(), - subexperiment_evaluator = TODO(), - subexperiment_executor = TODO() - ) - - val executor: ExperimentExecutor = ExperimentExecutor(config) - executor.run() } } diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutor.kt b/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutor.kt new file mode 100644 index 000000000..e6ffc0165 --- /dev/null +++ b/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutor.kt @@ -0,0 +1,8 @@ +package theodolite.execution + +import theodolite.util.LoadDimension +import theodolite.util.Resource + +interface BenchmarkExecutor { + fun runExperiment(load: LoadDimension, res: Resource): Boolean; +} \ No newline at end of file diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/execution/TestBenchmarkExecutor.kt b/theodolite-quarkus/src/main/kotlin/theodolite/execution/TestBenchmarkExecutor.kt new file mode 100644 index 000000000..9fd2453c1 --- /dev/null +++ b/theodolite-quarkus/src/main/kotlin/theodolite/execution/TestBenchmarkExecutor.kt @@ -0,0 +1,12 @@ +package theodolite.execution + +import theodolite.execution.BenchmarkExecutor +import theodolite.util.LoadDimension +import theodolite.util.Resource + +class TestBenchmarkExecutor(val mockResults: Array<Array<Boolean>>): BenchmarkExecutor { + + override fun runExperiment(load: LoadDimension, res: Resource): Boolean { + return this.mockResults[load.get()][res.get()] + } +} \ No newline at end of file diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/strategies/BinarySearch.kt b/theodolite-quarkus/src/main/kotlin/theodolite/strategies/BinarySearch.kt deleted file mode 100644 index c9fd0f498..000000000 --- a/theodolite-quarkus/src/main/kotlin/theodolite/strategies/BinarySearch.kt +++ /dev/null @@ -1,10 +0,0 @@ -package theodolite.strategies - -import theodolite.strategies.searchstrategy.Benchmark -import theodolite.strategies.searchstrategy.SearchStrategy - -class BinarySearch(benchmark: Benchmark) : SearchStrategy(benchmark) { - override fun findSuitableResources(load: Int, resources: List<Int>): Int { - - } -} \ No newline at end of file diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/strategies/EvenResourcesRestriction.kt b/theodolite-quarkus/src/main/kotlin/theodolite/strategies/EvenResourcesRestriction.kt deleted file mode 100644 index 24078a23d..000000000 --- a/theodolite-quarkus/src/main/kotlin/theodolite/strategies/EvenResourcesRestriction.kt +++ /dev/null @@ -1,12 +0,0 @@ -package theodolite.strategies - -import theodolite.strategies.restriction.CompositeRestriction -import theodolite.strategies.restriction.Restriction - -class EvenResourcesRestriction(childRestriction: Restriction) : CompositeRestriction(childRestriction) { - override fun restrict(loads: List<Int>, resources: List<Int>) { - val filteredResources: List<Int> = resources.filter { x -> x % 2 == 0 }; - this.childRestriction.restrict(loads, filteredResources); - } - -} \ No newline at end of file diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/strategies/LinearSearch.kt b/theodolite-quarkus/src/main/kotlin/theodolite/strategies/LinearSearch.kt deleted file mode 100644 index 79938f7fa..000000000 --- a/theodolite-quarkus/src/main/kotlin/theodolite/strategies/LinearSearch.kt +++ /dev/null @@ -1,14 +0,0 @@ -package theodolite.strategies - -import theodolite.strategies.searchstrategy.Benchmark -import theodolite.strategies.searchstrategy.SearchStrategy - -class LinearSearch(benchmark: Benchmark) : SearchStrategy(benchmark) { - - override fun findSuitableResources(load: Int, resources: List<Int>): Int { - for (res in resources) { - if (this.benchmark.execute(load, res)) return resources.indexOf(res); - } - return resources.size; - } -} \ No newline at end of file diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/strategies/LowerBoundRestriction.kt b/theodolite-quarkus/src/main/kotlin/theodolite/strategies/LowerBoundRestriction.kt deleted file mode 100644 index 157281a4c..000000000 --- a/theodolite-quarkus/src/main/kotlin/theodolite/strategies/LowerBoundRestriction.kt +++ /dev/null @@ -1,16 +0,0 @@ -package theodolite.strategies - -import theodolite.strategies.restriction.PrimitiveRestriction -import theodolite.strategies.searchstrategy.SearchStrategy - -class LowerBoundRestriction(searchStrategy: SearchStrategy) : PrimitiveRestriction(searchStrategy) { - override fun restrict(loads: List<Int>, resources: List<Int>): List<Int> { - val lowerBounds: MutableList<Int> = ArrayList<Int>(); - var lowerBound = 0; - for (load in loads) { - lowerBound = this.searchStrategy.findSuitableResources(load, resources.subList(lowerBound, resources.size)); - lowerBounds.add(lowerBound); - } - return lowerBounds; - } -} \ No newline at end of file diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/strategies/restriction/LowerBoundRestriction.kt b/theodolite-quarkus/src/main/kotlin/theodolite/strategies/restriction/LowerBoundRestriction.kt new file mode 100644 index 000000000..fc5b6d538 --- /dev/null +++ b/theodolite-quarkus/src/main/kotlin/theodolite/strategies/restriction/LowerBoundRestriction.kt @@ -0,0 +1,16 @@ +package theodolite.strategies.restriction + +import theodolite.util.Results +import theodolite.strategies.searchstrategy.RestrictionStrategy +import theodolite.util.LoadDimension +import theodolite.util.Resource + +class LowerBoundRestriction(results: Results, loads: List<LoadDimension>) : RestrictionStrategy(results, loads) { + override fun next(load: LoadDimension, resources: List<Resource>): List<Resource> { + var lowerBound: Resource? = this.results.getRequiredInstances(load) + if(lowerBound == null) { + lowerBound = Resource(0) // TODO handle the null case + } + return resources.filter{x -> x.get() >= lowerBound.get()} + } +} \ No newline at end of file diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/strategies/searchstrategy/Benchmark.kt b/theodolite-quarkus/src/main/kotlin/theodolite/strategies/searchstrategy/Benchmark.kt deleted file mode 100644 index eb3e22a36..000000000 --- a/theodolite-quarkus/src/main/kotlin/theodolite/strategies/searchstrategy/Benchmark.kt +++ /dev/null @@ -1,7 +0,0 @@ -package theodolite.strategies.searchstrategy - -class Benchmark { - fun execute(load: Int, res: Int): Boolean { - return true; - } -} \ No newline at end of file diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/strategies/searchstrategy/BinarySearch.kt b/theodolite-quarkus/src/main/kotlin/theodolite/strategies/searchstrategy/BinarySearch.kt new file mode 100644 index 000000000..1bc22f7ca --- /dev/null +++ b/theodolite-quarkus/src/main/kotlin/theodolite/strategies/searchstrategy/BinarySearch.kt @@ -0,0 +1,37 @@ +package theodolite.strategies.searchstrategy + +import theodolite.execution.BenchmarkExecutor +import theodolite.util.LoadDimension +import theodolite.util.Resource +import java.lang.IllegalArgumentException + +class BinarySearch(benchmarkExecutor: BenchmarkExecutor) : SearchStrategy(benchmarkExecutor) { + override fun findSuitableResources(load: LoadDimension, resources: List<Resource>): Resource? { + val result = search(load, resources, 0, resources.size - 1) + if( result == -1 ) { + return null; + } + return resources[result] + } + + private fun search (load: LoadDimension, resources: List<Resource>, lower: Int, upper: Int): Int { + if (lower + 1 < upper ) { + throw IllegalArgumentException() + } + if (lower >= upper ) { + if (this.benchmarkExecutor.runExperiment(load, resources[upper])) return upper; + else { + if (lower + 1 == resources.size) return - 1 + return lower + 1; + } + } else { + val mid = (upper + lower) / 2 + if (this.benchmarkExecutor.runExperiment(load, resources[mid])) { + return search(load, resources, lower, mid - 1 ); + } else { + return search(load, resources, mid + 1 , upper); + } + } + } + +} \ No newline at end of file diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/strategies/searchstrategy/CompositeStrategy.kt b/theodolite-quarkus/src/main/kotlin/theodolite/strategies/searchstrategy/CompositeStrategy.kt new file mode 100644 index 000000000..79c34e326 --- /dev/null +++ b/theodolite-quarkus/src/main/kotlin/theodolite/strategies/searchstrategy/CompositeStrategy.kt @@ -0,0 +1,16 @@ +package theodolite.strategies.searchstrategy + +import theodolite.execution.BenchmarkExecutor +import theodolite.util.LoadDimension +import theodolite.util.Resource + +class CompositeStrategy(benchmarkExecutor: BenchmarkExecutor, val searchStrategy: SearchStrategy, val restrictionStrategies: List<RestrictionStrategy>) : SearchStrategy(benchmarkExecutor) { + + override fun findSuitableResources(load: LoadDimension,resources: List<Resource>): Resource? { + var restrictedResources: List<Resource> = resources + for (strategy in this.restrictionStrategies) { + restrictedResources.intersect(strategy.next(load, resources)) + } + return this.searchStrategy.findSuitableResources(load, restrictedResources) + } +} \ No newline at end of file diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/strategies/searchstrategy/LinearSearch.kt b/theodolite-quarkus/src/main/kotlin/theodolite/strategies/searchstrategy/LinearSearch.kt new file mode 100644 index 000000000..919689ed9 --- /dev/null +++ b/theodolite-quarkus/src/main/kotlin/theodolite/strategies/searchstrategy/LinearSearch.kt @@ -0,0 +1,15 @@ +package theodolite.strategies.searchstrategy + +import theodolite.execution.BenchmarkExecutor +import theodolite.util.LoadDimension +import theodolite.util.Resource + +class LinearSearch(benchmarkExecutor: BenchmarkExecutor) : SearchStrategy(benchmarkExecutor) { + + override fun findSuitableResources(load: LoadDimension, resources: List<Resource>): Resource? { + for (res in resources) { + if (this.benchmarkExecutor.runExperiment(load, res)) return res; + } + return null; + } +} \ No newline at end of file diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/strategies/searchstrategy/RestrictionStrategy.kt b/theodolite-quarkus/src/main/kotlin/theodolite/strategies/searchstrategy/RestrictionStrategy.kt new file mode 100644 index 000000000..7a6e43ce0 --- /dev/null +++ b/theodolite-quarkus/src/main/kotlin/theodolite/strategies/searchstrategy/RestrictionStrategy.kt @@ -0,0 +1,9 @@ +package theodolite.strategies.searchstrategy + +import theodolite.util.Results +import theodolite.util.LoadDimension +import theodolite.util.Resource + +abstract class RestrictionStrategy(val results: Results, val loads: List<LoadDimension>) { + public abstract fun next(load: LoadDimension, resources: List<Resource>): List<Resource>; +} \ No newline at end of file diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/strategies/searchstrategy/SearchStrategy.kt b/theodolite-quarkus/src/main/kotlin/theodolite/strategies/searchstrategy/SearchStrategy.kt index b42e78c9e..487499784 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/strategies/searchstrategy/SearchStrategy.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/strategies/searchstrategy/SearchStrategy.kt @@ -1,5 +1,9 @@ package theodolite.strategies.searchstrategy -abstract class SearchStrategy(val benchmark: Benchmark) { - abstract fun findSuitableResources(load: Int, resources: List<Int>): Int; +import theodolite.execution.BenchmarkExecutor +import theodolite.util.LoadDimension +import theodolite.util.Resource + +abstract class SearchStrategy(val benchmarkExecutor: BenchmarkExecutor) { + abstract fun findSuitableResources(load: LoadDimension, resources: List<Resource>): Resource?; } \ No newline at end of file diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/util/LoadDimension.kt b/theodolite-quarkus/src/main/kotlin/theodolite/util/LoadDimension.kt new file mode 100644 index 000000000..84de466a8 --- /dev/null +++ b/theodolite-quarkus/src/main/kotlin/theodolite/util/LoadDimension.kt @@ -0,0 +1,17 @@ +package theodolite.util + +class LoadDimension(val number: Int) { + public fun get(): Int { + return this.number; + } + public override fun equals(other: Any?): Boolean { + if (other is LoadDimension) { + return this.get() == other.get() + } + return false + } + + override fun hashCode(): Int { + return this.get().hashCode() + } +} \ No newline at end of file diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/util/Resource.kt b/theodolite-quarkus/src/main/kotlin/theodolite/util/Resource.kt new file mode 100644 index 000000000..9d1478c47 --- /dev/null +++ b/theodolite-quarkus/src/main/kotlin/theodolite/util/Resource.kt @@ -0,0 +1,18 @@ +package theodolite.util + +class Resource(val number: Int) { + public fun get(): Int { + return this.number; + } + + public override fun equals(other: Any?): Boolean { + if (other is Resource) { + return this.get() == other.get() + } + return false + } + + override fun hashCode(): Int { + return this.get().hashCode() + } +} \ No newline at end of file diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/util/Results.kt b/theodolite-quarkus/src/main/kotlin/theodolite/util/Results.kt new file mode 100644 index 000000000..1a4107612 --- /dev/null +++ b/theodolite-quarkus/src/main/kotlin/theodolite/util/Results.kt @@ -0,0 +1,32 @@ +package theodolite.util + +import theodolite.util.LoadDimension +import theodolite.util.Resource +import kotlin.math.exp + +class Results { + // load, instances + private val results: MutableMap<Pair<LoadDimension, Resource>, Boolean> = mutableMapOf() + + public fun setResult(experiment: Pair<LoadDimension, Resource>, successful: Boolean) { + this.results.put(experiment, successful) + } + + public fun getResult (experiment: Pair<LoadDimension, Resource>): Boolean? { + return this.results.get(experiment) + } + + public fun getRequiredInstances(load: LoadDimension): Resource? { + var requiredInstances: Resource? = null; + for(experiment in results) { + if(experiment.key.first == load && experiment.value){ + if(requiredInstances == null) { + requiredInstances = experiment.key.second + }else if (experiment.key.second.get() < requiredInstances.get()) { + requiredInstances = experiment.key.second + } + } + } + return requiredInstances + } +} \ No newline at end of file diff --git a/theodolite-quarkus/src/native-test/kotlin/theodolite/NativeGreetingResourceIT.kt b/theodolite-quarkus/src/native-test/kotlin/theodolite/NativeGreetingResourceIT.kt index 26e8900ff..6f17e6294 100644 --- a/theodolite-quarkus/src/native-test/kotlin/theodolite/NativeGreetingResourceIT.kt +++ b/theodolite-quarkus/src/native-test/kotlin/theodolite/NativeGreetingResourceIT.kt @@ -3,4 +3,4 @@ package theodolite import io.quarkus.test.junit.NativeImageTest @NativeImageTest -class NativeGreetingResourceIT : GreetingResourceTest() \ No newline at end of file +class NativeGreetingResourceIT : CompositeStrategyTest() \ No newline at end of file diff --git a/theodolite-quarkus/src/test/kotlin/theodolite/CompositeStrategyTest.kt b/theodolite-quarkus/src/test/kotlin/theodolite/CompositeStrategyTest.kt new file mode 100644 index 000000000..3bf4815e1 --- /dev/null +++ b/theodolite-quarkus/src/test/kotlin/theodolite/CompositeStrategyTest.kt @@ -0,0 +1,49 @@ +package theodolite + +import io.quarkus.test.junit.QuarkusTest +import org.junit.jupiter.api.Assertions.* +import org.junit.jupiter.api.Test +import theodolite.strategies.searchstrategy.LinearSearch +import theodolite.strategies.restriction.LowerBoundRestriction +import theodolite.strategies.searchstrategy.CompositeStrategy +import theodolite.execution.TestBenchmarkExecutor +import theodolite.util.LoadDimension +import theodolite.util.Resource +import theodolite.util.Results + +@QuarkusTest +class CompositeStrategyTest { + + @Test + fun testEnd2End() { + val mockResults = arrayOf( + arrayOf( true , true , true , true , true , true , true), + arrayOf( false, false, true , true , true , true , true), + arrayOf( false, false, true , true , true , true , true), + arrayOf( false, false, false, true , true , true , true), + arrayOf( false, false, false, false, true , true , true), + arrayOf( false, false, false, false, false, false, true), + arrayOf( false, false, false, false, false, false, false) + ) + val mockLoads: List<LoadDimension> = (0..6).map{number -> LoadDimension(number)} + val mockResources: List<Resource> = (0..6).map{number -> Resource(number)} + val benchmarkExecutor: TestBenchmarkExecutor = TestBenchmarkExecutor(mockResults) + val linearSearch: LinearSearch = LinearSearch(benchmarkExecutor); + val results: Results = Results(); + val lowerBoundRestriction: LowerBoundRestriction = LowerBoundRestriction(results, mockLoads); + val strategy: CompositeStrategy = CompositeStrategy(benchmarkExecutor, linearSearch, listOf(lowerBoundRestriction)) + + val actual: ArrayList<Resource?> = ArrayList<Resource?>() + val expected: ArrayList<Resource?> = ArrayList(listOf(0,2,2,3,4,6).map{ x -> Resource(x)}) + expected.add(null) + + for(load in mockLoads) { + actual.add(strategy.findSuitableResources(load, mockResources)) + } + + assertEquals(actual, expected) + } + + + +} \ No newline at end of file diff --git a/theodolite-quarkus/src/test/kotlin/theodolite/GreetingResourceTest.kt b/theodolite-quarkus/src/test/kotlin/theodolite/GreetingResourceTest.kt deleted file mode 100644 index 048093a7e..000000000 --- a/theodolite-quarkus/src/test/kotlin/theodolite/GreetingResourceTest.kt +++ /dev/null @@ -1,20 +0,0 @@ -package theodolite - -import io.quarkus.test.junit.QuarkusTest -import io.restassured.RestAssured.given -import org.hamcrest.CoreMatchers.`is` -import org.junit.jupiter.api.Test - -@QuarkusTest -class GreetingResourceTest { - - @Test - fun testHelloEndpoint() { - given() - .`when`().get("/hello-resteasy") - .then() - .statusCode(200) - .body(`is`("Hello RESTEasy")) - } - -} \ No newline at end of file -- GitLab