Skip to content

Commit

Permalink
test(alchemist-grid): result should be made available locally
Browse files Browse the repository at this point in the history
  • Loading branch information
kelvin-olaiya committed Sep 14, 2023
1 parent 1e96009 commit 53d6bff
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import it.unibo.alchemist.boundary.grid.cluster.management.ObservableClusterRegi
import it.unibo.alchemist.boundary.grid.cluster.storage.EtcdKVStore
import it.unibo.alchemist.boundary.grid.communication.RabbitmqConfig
import it.unibo.alchemist.boundary.launchers.ConfigurationProvider.getEtcdEndpoints
import it.unibo.alchemist.boundary.launchers.ConfigurationProvider.getRabbitmqConfig
import org.slf4j.LoggerFactory
import java.util.UUID

Expand All @@ -27,7 +28,7 @@ class ServerLauncher(
private val logger = LoggerFactory.getLogger(ServerLauncher::class.java)

override fun launch(loader: Loader) {
RabbitmqConfig.setUpConnection(ConfigurationProvider.getRabbitmqConfig(configurationPath))
RabbitmqConfig.setUpConnection(getRabbitmqConfig(configurationPath))
val serverID = UUID.randomUUID()
logger.debug("Server assigned ID: {}", serverID)
val metadata = mapOf<String, String>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ import it.unibo.alchemist.test.utils.TestConstants.clientConfigFile
import it.unibo.alchemist.test.utils.TestConstants.composeFilePath
import it.unibo.alchemist.test.utils.TestConstants.registry
import it.unibo.alchemist.test.utils.TestConstants.serverConfigFile
import java.nio.file.Files
import java.nio.file.Path
import java.util.stream.Collectors
import kotlin.io.path.deleteIfExists
import kotlin.io.path.name
import kotlin.time.Duration.Companion.minutes
import kotlin.time.Duration.Companion.seconds

class DistributionTest : StringSpec({
Expand All @@ -36,7 +42,7 @@ class DistributionTest : StringSpec({
val cluster = ClusterImpl(registry)
awaitServerJoin(cluster, SERVERS_TO_LAUNCH, 10.seconds)
startClient(clientConfigFile).use {
until(30.seconds) {
until(20.seconds) {
registry.simulations().size == 1
}
val simulationID = registry.simulations().first()
Expand All @@ -50,7 +56,7 @@ class DistributionTest : StringSpec({
val cluster = ClusterImpl(registry)
awaitServerJoin(cluster, SERVERS_TO_LAUNCH, 10.seconds)
startClient(clientConfigFile).use { _ ->
until(30.seconds) {
until(20.seconds) {
registry.simulations().size == 1
}
val simulationID = registry.simulations().first()
Expand All @@ -63,4 +69,23 @@ class DistributionTest : StringSpec({
}
}
}

"Results must be made available locally" {
startServers(serverConfigFile, SERVERS_TO_LAUNCH).use { _ ->
val cluster = ClusterImpl(registry)
awaitServerJoin(cluster, SERVERS_TO_LAUNCH, 10.seconds)
startClient(clientConfigFile).use {
until(20.seconds) {
registry.simulations().size == 1
}
eventually(1.minutes) {
val results = Files.list(Path.of(".")).filter {
it.name.startsWith("time_export")
}.collect(Collectors.toList())
results shouldHaveSize SIMULATION_BATCH_SIZE
results.forEach { it.deleteIfExists() }
}
}
}
}
})
4 changes: 2 additions & 2 deletions alchemist-grid/src/test/resources/client-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ export:

terminate:
- type: AfterTime
parameters: 50000
parameters: 6000

launcher:
type: DistributedExecution
parameters: ["../alchemist-grid/src/test/resources/distribution-config.yml", [verticalEnd, horizontalEnd]]
parameters: ["../alchemist-grid/src/test/resources/distribution-config.yml", [verticalEnd, horizontalEnd], "./"]

0 comments on commit 53d6bff

Please sign in to comment.