diff options
| author | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2021-04-21 16:35:52 +0200 |
|---|---|---|
| committer | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2021-04-21 16:37:18 +0200 |
| commit | 62678b2890a7f3640836b99ca2fec9efd7485929 (patch) | |
| tree | dc6d6e8bb495c019990513511d7ff042afde0f05 /simulator/opendc-serverless | |
| parent | 1c0568c31d60d4e690b4b9aec2e14f660b72a5c8 (diff) | |
simulator: Migrate to SimulationCoroutineDispatcher
This change migrates the remainder of the codebase to the
SimulationCoroutineDispatcher implementation.
Diffstat (limited to 'simulator/opendc-serverless')
2 files changed, 13 insertions, 26 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 1ab2d033..d9f5ee81 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 @@ -25,7 +25,6 @@ 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.* import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertDoesNotThrow @@ -34,7 +33,7 @@ import org.opendc.serverless.api.ServerlessFunction import org.opendc.serverless.service.deployer.FunctionDeployer import org.opendc.serverless.service.deployer.FunctionInstance import org.opendc.serverless.service.deployer.FunctionInstanceState -import org.opendc.simulator.core.DelayControllerClockAdapter +import org.opendc.simulator.core.runBlockingSimulation import java.util.* /** @@ -44,9 +43,8 @@ import java.util.* internal class ServerlessServiceTest { @Test - fun testClientState() = runBlockingTest { + fun testClientState() = runBlockingSimulation { val meter = MeterProvider.noop().get("opendc-serverless") - val clock = DelayControllerClockAdapter(this) val service = ServerlessService(coroutineContext, clock, meter, mockk(), mockk()) val client = assertDoesNotThrow { service.newClient() } @@ -60,9 +58,8 @@ internal class ServerlessServiceTest { } @Test - fun testClientInvokeUnknown() = runBlockingTest { + fun testClientInvokeUnknown() = runBlockingSimulation { val meter = MeterProvider.noop().get("opendc-serverless") - val clock = DelayControllerClockAdapter(this) val service = ServerlessService(coroutineContext, clock, meter, mockk(), mockk()) val client = service.newClient() @@ -71,9 +68,8 @@ internal class ServerlessServiceTest { } @Test - fun testClientFunctionCreation() = runBlockingTest { + fun testClientFunctionCreation() = runBlockingSimulation { val meter = MeterProvider.noop().get("opendc-serverless") - val clock = DelayControllerClockAdapter(this) val service = ServerlessService(coroutineContext, clock, meter, mockk(), mockk()) val client = service.newClient() @@ -84,9 +80,8 @@ internal class ServerlessServiceTest { } @Test - fun testClientFunctionQuery() = runBlockingTest { + fun testClientFunctionQuery() = runBlockingSimulation { val meter = MeterProvider.noop().get("opendc-serverless") - val clock = DelayControllerClockAdapter(this) val service = ServerlessService(coroutineContext, clock, meter, mockk(), mockk()) val client = service.newClient() @@ -99,9 +94,8 @@ internal class ServerlessServiceTest { } @Test - fun testClientFunctionFindById() = runBlockingTest { + fun testClientFunctionFindById() = runBlockingSimulation { val meter = MeterProvider.noop().get("opendc-serverless") - val clock = DelayControllerClockAdapter(this) val service = ServerlessService(coroutineContext, clock, meter, mockk(), mockk()) val client = service.newClient() @@ -114,9 +108,8 @@ internal class ServerlessServiceTest { } @Test - fun testClientFunctionFindByName() = runBlockingTest { + fun testClientFunctionFindByName() = runBlockingSimulation { val meter = MeterProvider.noop().get("opendc-serverless") - val clock = DelayControllerClockAdapter(this) val service = ServerlessService(coroutineContext, clock, meter, mockk(), mockk()) val client = service.newClient() @@ -129,9 +122,8 @@ internal class ServerlessServiceTest { } @Test - fun testClientFunctionDuplicateName() = runBlockingTest { + fun testClientFunctionDuplicateName() = runBlockingSimulation { val meter = MeterProvider.noop().get("opendc-serverless") - val clock = DelayControllerClockAdapter(this) val service = ServerlessService(coroutineContext, clock, meter, mockk(), mockk()) val client = service.newClient() @@ -142,9 +134,8 @@ internal class ServerlessServiceTest { } @Test - fun testClientFunctionDelete() = runBlockingTest { + fun testClientFunctionDelete() = runBlockingSimulation { val meter = MeterProvider.noop().get("opendc-serverless") - val clock = DelayControllerClockAdapter(this) val service = ServerlessService(coroutineContext, clock, meter, mockk(), mockk()) val client = service.newClient() @@ -158,9 +149,8 @@ internal class ServerlessServiceTest { } @Test - fun testClientFunctionCannotInvokeDeleted() = runBlockingTest { + fun testClientFunctionCannotInvokeDeleted() = runBlockingSimulation { val meter = MeterProvider.noop().get("opendc-serverless") - val clock = DelayControllerClockAdapter(this) val service = ServerlessService(coroutineContext, clock, meter, mockk(), mockk()) val client = service.newClient() @@ -172,9 +162,8 @@ internal class ServerlessServiceTest { } @Test - fun testClientFunctionInvoke() = runBlockingTest { + fun testClientFunctionInvoke() = runBlockingSimulation { val meter = MeterProvider.noop().get("opendc-serverless") - val clock = DelayControllerClockAdapter(this) val deployer = mockk<FunctionDeployer>() val service = ServerlessService(coroutineContext, clock, meter, deployer, mockk()) diff --git a/simulator/opendc-serverless/opendc-serverless-simulator/src/test/kotlin/org/opendc/serverless/simulator/SimServerlessServiceTest.kt b/simulator/opendc-serverless/opendc-serverless-simulator/src/test/kotlin/org/opendc/serverless/simulator/SimServerlessServiceTest.kt index 7411ffa1..9592d870 100644 --- a/simulator/opendc-serverless/opendc-serverless-simulator/src/test/kotlin/org/opendc/serverless/simulator/SimServerlessServiceTest.kt +++ b/simulator/opendc-serverless/opendc-serverless-simulator/src/test/kotlin/org/opendc/serverless/simulator/SimServerlessServiceTest.kt @@ -27,7 +27,6 @@ import io.mockk.spyk import io.opentelemetry.api.metrics.MeterProvider import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.delay -import kotlinx.coroutines.test.runBlockingTest import kotlinx.coroutines.yield import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test @@ -42,7 +41,7 @@ import org.opendc.simulator.compute.model.ProcessingNode import org.opendc.simulator.compute.model.ProcessingUnit import org.opendc.simulator.compute.workload.SimFlopsWorkload import org.opendc.simulator.compute.workload.SimWorkload -import org.opendc.simulator.core.DelayControllerClockAdapter +import org.opendc.simulator.core.runBlockingSimulation /** * A test suite for the [ServerlessService] implementation under simulated conditions. @@ -63,9 +62,8 @@ internal class SimServerlessServiceTest { } @Test - fun testSmoke() = runBlockingTest { + fun testSmoke() = runBlockingSimulation { val meter = MeterProvider.noop().get("opendc-serverless") - val clock = DelayControllerClockAdapter(this) val workload = spyk(object : SimServerlessWorkload, SimWorkload by SimFlopsWorkload(1000) { override suspend fun invoke() {} }) |
