summaryrefslogtreecommitdiff
path: root/opendc-faas/opendc-faas-simulator/src/test
diff options
context:
space:
mode:
authorDante Niewenhuis <d.niewenhuis@hotmail.com>2024-03-05 13:23:57 +0100
committerGitHub <noreply@github.com>2024-03-05 13:23:57 +0100
commit5864cbcbfe2eb8c36ca05c3a39c7e5916aeecaec (patch)
tree5b2773b8dc21c2e1b526fb70f829c376dd80532a /opendc-faas/opendc-faas-simulator/src/test
parentd28002a3c151d198298574312f32f1cb43f3a660 (diff)
Updated package versions, updated web server tests. (#207)
* Updated all package versions including kotlin. Updated all web-server tests to run. * Changed the java version of the tests. OpenDC now only supports java 19. * small update * test update * new update * updated docker version to 19 * updated docker version to 19
Diffstat (limited to 'opendc-faas/opendc-faas-simulator/src/test')
-rw-r--r--opendc-faas/opendc-faas-simulator/src/test/kotlin/org/opendc/faas/simulator/SimFaaSServiceTest.kt80
1 files changed, 43 insertions, 37 deletions
diff --git a/opendc-faas/opendc-faas-simulator/src/test/kotlin/org/opendc/faas/simulator/SimFaaSServiceTest.kt b/opendc-faas/opendc-faas-simulator/src/test/kotlin/org/opendc/faas/simulator/SimFaaSServiceTest.kt
index ee9114b5..f68860e3 100644
--- a/opendc-faas/opendc-faas-simulator/src/test/kotlin/org/opendc/faas/simulator/SimFaaSServiceTest.kt
+++ b/opendc-faas/opendc-faas-simulator/src/test/kotlin/org/opendc/faas/simulator/SimFaaSServiceTest.kt
@@ -50,57 +50,63 @@ import java.util.Random
* A test suite for the [FaaSService] implementation under simulated conditions.
*/
internal class SimFaaSServiceTest {
-
private lateinit var machineModel: MachineModel
@BeforeEach
fun setUp() {
val cpuNode = ProcessingNode("Intel", "Xeon", "amd64", 2)
- machineModel = MachineModel(
- /*cpus*/ List(cpuNode.coreCount) { ProcessingUnit(cpuNode, it, 1000.0) },
- /*memory*/ List(4) { MemoryUnit("Crucial", "MTA18ASF4G72AZ-3G2B1", 3200.0, 32_000) }
- )
+ machineModel =
+ MachineModel(
+ List(cpuNode.coreCount) { ProcessingUnit(cpuNode, it, 1000.0) },
+ List(4) { MemoryUnit("Crucial", "MTA18ASF4G72AZ-3G2B1", 3200.0, 32_000) },
+ )
}
@Test
- fun testSmoke() = runSimulation {
- val random = Random(0)
- val workload = spyk(object : SimFaaSWorkload, SimWorkload by SimWorkloads.runtime(1000, 1.0) {
- override suspend fun invoke() {
- delay(random.nextInt(1000).toLong())
- }
- })
+ fun testSmoke() =
+ runSimulation {
+ val random = Random(0)
+ val workload =
+ spyk(
+ object : SimFaaSWorkload, SimWorkload by SimWorkloads.runtime(1000, 1.0) {
+ override suspend fun invoke() {
+ delay(random.nextInt(1000).toLong())
+ }
+ },
+ )
- val delayInjector = StochasticDelayInjector(ColdStartModel.GOOGLE, random)
- val deployer = SimFunctionDeployer(dispatcher, machineModel, delayInjector) { workload }
- val service = FaaSService(
- dispatcher,
- deployer,
- RandomRoutingPolicy(),
- FunctionTerminationPolicyFixed(dispatcher, timeout = Duration.ofMillis(10000))
- )
+ val delayInjector = StochasticDelayInjector(ColdStartModel.GOOGLE, random)
+ val deployer = SimFunctionDeployer(dispatcher, machineModel, delayInjector) { workload }
+ val service =
+ FaaSService(
+ dispatcher,
+ deployer,
+ RandomRoutingPolicy(),
+ FunctionTerminationPolicyFixed(dispatcher, timeout = Duration.ofMillis(10000)),
+ )
- val client = service.newClient()
+ val client = service.newClient()
- val function = client.newFunction("test", 128)
- function.invoke()
- delay(2000)
+ val function = client.newFunction("test", 128)
+ function.invoke()
+ delay(2000)
- service.close()
- deployer.close()
+ service.close()
+ deployer.close()
- yield()
+ yield()
- val funcStats = service.getFunctionStats(function)
+ val funcStats = service.getFunctionStats(function)
- assertAll(
- { coVerify { workload.invoke() } },
- { assertEquals(1, funcStats.totalInvocations) },
- { assertEquals(1, funcStats.delayedInvocations) },
- { assertEquals(0, funcStats.failedInvocations) },
- { assertEquals(0.0, funcStats.waitTime.mean) }, // fixme: this is probably wrong, and should be 100
- { assertEquals(1285.0, funcStats.activeTime.mean) }
- )
- }
+ // fixme: waitTime is probably wrong, and should be 100
+ assertAll(
+ { coVerify { workload.invoke() } },
+ { assertEquals(1, funcStats.totalInvocations) },
+ { assertEquals(1, funcStats.delayedInvocations) },
+ { assertEquals(0, funcStats.failedInvocations) },
+ { assertEquals(0.0, funcStats.waitTime.mean) },
+ { assertEquals(1285.0, funcStats.activeTime.mean) },
+ )
+ }
}