summaryrefslogtreecommitdiff
path: root/simulator/opendc-serverless/opendc-serverless-service/src/test/kotlin/org
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-04-08 20:44:30 +0200
committerGitHub <noreply@github.com>2021-04-08 20:44:30 +0200
commit5fdbfbe7d340bc10f8b9eebd5aa23bdfd7dc4e18 (patch)
tree21020cd0451664006a5bf291a5c27dd74f6129d0 /simulator/opendc-serverless/opendc-serverless-service/src/test/kotlin/org
parent3fd45fc5befb1fc9a67d4494e8a3786a5dceae3a (diff)
parent831ba3d882a46dad2abe6ac281b736b729dc7080 (diff)
exp: Add serverless experiments (v1)
This pull request is the first in a series of pull request to add the serverless experiments from Soufiane Jounaid's BSc thesis to the main OpenDC repository. In this pull request, we add the serverless experiment and trace reader. * Add `opendc-experiments-serverless20` which will contain the serverless experiments. * Add `ServerlessTraceReader` which reads the traces from Soufiane's work. * Add support for cold start delays * Expose metrics per function.
Diffstat (limited to 'simulator/opendc-serverless/opendc-serverless-service/src/test/kotlin/org')
-rw-r--r--simulator/opendc-serverless/opendc-serverless-service/src/test/kotlin/org/opendc/serverless/service/ServerlessServiceTest.kt53
1 files changed, 32 insertions, 21 deletions
diff --git a/simulator/opendc-serverless/opendc-serverless-service/src/test/kotlin/org/opendc/serverless/service/ServerlessServiceTest.kt b/simulator/opendc-serverless/opendc-serverless-service/src/test/kotlin/org/opendc/serverless/service/ServerlessServiceTest.kt
index d9c2bcd2..bf99d0e7 100644
--- a/simulator/opendc-serverless/opendc-serverless-service/src/test/kotlin/org/opendc/serverless/service/ServerlessServiceTest.kt
+++ b/simulator/opendc-serverless/opendc-serverless-service/src/test/kotlin/org/opendc/serverless/service/ServerlessServiceTest.kt
@@ -23,6 +23,7 @@
package org.opendc.serverless.service
import io.mockk.*
+import io.opentelemetry.api.metrics.MeterProvider
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runBlockingTest
import org.junit.jupiter.api.Assertions.*
@@ -44,14 +45,15 @@ internal class ServerlessServiceTest {
@Test
fun testClientState() = runBlockingTest {
+ val meter = MeterProvider.noop().get("opendc-serverless")
val clock = DelayControllerClockAdapter(this)
- val service = ServerlessService(coroutineContext, clock, mockk(), mockk())
+ val service = ServerlessService(coroutineContext, clock, meter, mockk(), mockk())
val client = assertDoesNotThrow { service.newClient() }
assertDoesNotThrow { client.close() }
assertThrows<IllegalStateException> { client.queryFunctions() }
- assertThrows<IllegalStateException> { client.newFunction("test") }
+ assertThrows<IllegalStateException> { client.newFunction("test", 128) }
assertThrows<IllegalStateException> { client.invoke("test") }
assertThrows<IllegalStateException> { client.findFunction(UUID.randomUUID()) }
assertThrows<IllegalStateException> { client.findFunction("name") }
@@ -59,8 +61,9 @@ internal class ServerlessServiceTest {
@Test
fun testClientInvokeUnknown() = runBlockingTest {
+ val meter = MeterProvider.noop().get("opendc-serverless")
val clock = DelayControllerClockAdapter(this)
- val service = ServerlessService(coroutineContext, clock, mockk(), mockk())
+ val service = ServerlessService(coroutineContext, clock, meter, mockk(), mockk())
val client = service.newClient()
@@ -69,77 +72,83 @@ internal class ServerlessServiceTest {
@Test
fun testClientFunctionCreation() = runBlockingTest {
+ val meter = MeterProvider.noop().get("opendc-serverless")
val clock = DelayControllerClockAdapter(this)
- val service = ServerlessService(coroutineContext, clock, mockk(), mockk())
+ val service = ServerlessService(coroutineContext, clock, meter, mockk(), mockk())
val client = service.newClient()
- val function = client.newFunction("test")
+ val function = client.newFunction("test", 128)
assertEquals("test", function.name)
}
@Test
fun testClientFunctionQuery() = runBlockingTest {
+ val meter = MeterProvider.noop().get("opendc-serverless")
val clock = DelayControllerClockAdapter(this)
- val service = ServerlessService(coroutineContext, clock, mockk(), mockk())
+ val service = ServerlessService(coroutineContext, clock, meter, mockk(), mockk())
val client = service.newClient()
assertEquals(emptyList<ServerlessFunction>(), client.queryFunctions())
- val function = client.newFunction("test")
+ val function = client.newFunction("test", 128)
assertEquals(listOf(function), client.queryFunctions())
}
@Test
fun testClientFunctionFindById() = runBlockingTest {
+ val meter = MeterProvider.noop().get("opendc-serverless")
val clock = DelayControllerClockAdapter(this)
- val service = ServerlessService(coroutineContext, clock, mockk(), mockk())
+ val service = ServerlessService(coroutineContext, clock, meter, mockk(), mockk())
val client = service.newClient()
assertEquals(emptyList<ServerlessFunction>(), client.queryFunctions())
- val function = client.newFunction("test")
+ val function = client.newFunction("test", 128)
assertNotNull(client.findFunction(function.uid))
}
@Test
fun testClientFunctionFindByName() = runBlockingTest {
+ val meter = MeterProvider.noop().get("opendc-serverless")
val clock = DelayControllerClockAdapter(this)
- val service = ServerlessService(coroutineContext, clock, mockk(), mockk())
+ val service = ServerlessService(coroutineContext, clock, meter, mockk(), mockk())
val client = service.newClient()
assertEquals(emptyList<ServerlessFunction>(), client.queryFunctions())
- val function = client.newFunction("test")
+ val function = client.newFunction("test", 128)
assertNotNull(client.findFunction(function.name))
}
@Test
fun testClientFunctionDuplicateName() = runBlockingTest {
+ val meter = MeterProvider.noop().get("opendc-serverless")
val clock = DelayControllerClockAdapter(this)
- val service = ServerlessService(coroutineContext, clock, mockk(), mockk())
+ val service = ServerlessService(coroutineContext, clock, meter, mockk(), mockk())
val client = service.newClient()
- client.newFunction("test")
+ client.newFunction("test", 128)
- assertThrows<IllegalArgumentException> { client.newFunction("test") }
+ assertThrows<IllegalArgumentException> { client.newFunction("test", 128) }
}
@Test
fun testClientFunctionDelete() = runBlockingTest {
+ val meter = MeterProvider.noop().get("opendc-serverless")
val clock = DelayControllerClockAdapter(this)
- val service = ServerlessService(coroutineContext, clock, mockk(), mockk())
+ val service = ServerlessService(coroutineContext, clock, meter, mockk(), mockk())
val client = service.newClient()
- val function = client.newFunction("test")
+ val function = client.newFunction("test", 128)
assertNotNull(client.findFunction(function.uid))
function.delete()
assertNull(client.findFunction(function.uid))
@@ -150,11 +159,12 @@ internal class ServerlessServiceTest {
@Test
fun testClientFunctionCannotInvokeDeleted() = runBlockingTest {
+ val meter = MeterProvider.noop().get("opendc-serverless")
val clock = DelayControllerClockAdapter(this)
- val service = ServerlessService(coroutineContext, clock, mockk(), mockk())
+ val service = ServerlessService(coroutineContext, clock, meter, mockk(), mockk())
val client = service.newClient()
- val function = client.newFunction("test")
+ val function = client.newFunction("test", 128)
assertNotNull(client.findFunction(function.uid))
function.delete()
@@ -163,14 +173,15 @@ internal class ServerlessServiceTest {
@Test
fun testClientFunctionInvoke() = runBlockingTest {
+ val meter = MeterProvider.noop().get("opendc-serverless")
val clock = DelayControllerClockAdapter(this)
val deployer = mockk<FunctionDeployer>()
- val service = ServerlessService(coroutineContext, clock, deployer, mockk())
+ val service = ServerlessService(coroutineContext, clock, meter, deployer, mockk())
every { deployer.deploy(any()) } answers {
object : FunctionInstance {
override val state: FunctionInstanceState = FunctionInstanceState.Idle
- override val function: ServerlessFunction = it.invocation.args[0] as ServerlessFunction
+ override val function: FunctionObject = it.invocation.args[0] as FunctionObject
override suspend fun invoke() {}
@@ -179,7 +190,7 @@ internal class ServerlessServiceTest {
}
val client = service.newClient()
- val function = client.newFunction("test")
+ val function = client.newFunction("test", 128)
function.invoke()
}