From 5864cbcbfe2eb8c36ca05c3a39c7e5916aeecaec Mon Sep 17 00:00:00 2001 From: Dante Niewenhuis Date: Tue, 5 Mar 2024 13:23:57 +0100 Subject: 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 --- .../org/opendc/faas/service/FaaSServiceTest.kt | 179 +++++++++++---------- 1 file changed, 94 insertions(+), 85 deletions(-) (limited to 'opendc-faas/opendc-faas-service/src/test') diff --git a/opendc-faas/opendc-faas-service/src/test/kotlin/org/opendc/faas/service/FaaSServiceTest.kt b/opendc-faas/opendc-faas-service/src/test/kotlin/org/opendc/faas/service/FaaSServiceTest.kt index 9676744b..72a5f2c8 100644 --- a/opendc-faas/opendc-faas-service/src/test/kotlin/org/opendc/faas/service/FaaSServiceTest.kt +++ b/opendc-faas/opendc-faas-service/src/test/kotlin/org/opendc/faas/service/FaaSServiceTest.kt @@ -41,136 +41,145 @@ import java.util.UUID * Test suite for the [FaaSService] implementation. */ internal class FaaSServiceTest { - @Test - fun testClientState() = runSimulation { - val service = FaaSService(dispatcher, mockk(), mockk(), mockk()) - - val client = assertDoesNotThrow { service.newClient() } - assertDoesNotThrow { client.close() } - - assertThrows { client.queryFunctions() } - assertThrows { client.newFunction("test", 128) } - assertThrows { client.invoke("test") } - assertThrows { client.findFunction(UUID.randomUUID()) } - assertThrows { client.findFunction("name") } - } + fun testClientState() = + runSimulation { + val service = FaaSService(dispatcher, mockk(), mockk(), mockk()) + + val client = assertDoesNotThrow { service.newClient() } + assertDoesNotThrow { client.close() } + + assertThrows { client.queryFunctions() } + assertThrows { client.newFunction("test", 128) } + assertThrows { client.invoke("test") } + assertThrows { client.findFunction(UUID.randomUUID()) } + assertThrows { client.findFunction("name") } + } @Test - fun testClientInvokeUnknown() = runSimulation { - val service = FaaSService(dispatcher, mockk(), mockk(), mockk()) + fun testClientInvokeUnknown() = + runSimulation { + val service = FaaSService(dispatcher, mockk(), mockk(), mockk()) - val client = service.newClient() + val client = service.newClient() - assertThrows { client.invoke("test") } - } + assertThrows { client.invoke("test") } + } @Test - fun testClientFunctionCreation() = runSimulation { - val service = FaaSService(dispatcher, mockk(), mockk(), mockk()) + fun testClientFunctionCreation() = + runSimulation { + val service = FaaSService(dispatcher, mockk(), mockk(), mockk()) - val client = service.newClient() + val client = service.newClient() - val function = client.newFunction("test", 128) + val function = client.newFunction("test", 128) - assertEquals("test", function.name) - } + assertEquals("test", function.name) + } @Test - fun testClientFunctionQuery() = runSimulation { - val service = FaaSService(dispatcher, mockk(), mockk(), mockk()) + fun testClientFunctionQuery() = + runSimulation { + val service = FaaSService(dispatcher, mockk(), mockk(), mockk()) - val client = service.newClient() + val client = service.newClient() - assertEquals(emptyList(), client.queryFunctions()) + assertEquals(emptyList(), client.queryFunctions()) - val function = client.newFunction("test", 128) + val function = client.newFunction("test", 128) - assertEquals(listOf(function), client.queryFunctions()) - } + assertEquals(listOf(function), client.queryFunctions()) + } @Test - fun testClientFunctionFindById() = runSimulation { - val service = FaaSService(dispatcher, mockk(), mockk(), mockk()) + fun testClientFunctionFindById() = + runSimulation { + val service = FaaSService(dispatcher, mockk(), mockk(), mockk()) - val client = service.newClient() + val client = service.newClient() - assertEquals(emptyList(), client.queryFunctions()) + assertEquals(emptyList(), client.queryFunctions()) - val function = client.newFunction("test", 128) + val function = client.newFunction("test", 128) - assertNotNull(client.findFunction(function.uid)) - } + assertNotNull(client.findFunction(function.uid)) + } @Test - fun testClientFunctionFindByName() = runSimulation { - val service = FaaSService(dispatcher, mockk(), mockk(), mockk()) + fun testClientFunctionFindByName() = + runSimulation { + val service = FaaSService(dispatcher, mockk(), mockk(), mockk()) - val client = service.newClient() + val client = service.newClient() - assertEquals(emptyList(), client.queryFunctions()) + assertEquals(emptyList(), client.queryFunctions()) - val function = client.newFunction("test", 128) + val function = client.newFunction("test", 128) - assertNotNull(client.findFunction(function.name)) - } + assertNotNull(client.findFunction(function.name)) + } @Test - fun testClientFunctionDuplicateName() = runSimulation { - val service = FaaSService(dispatcher, mockk(), mockk(), mockk()) + fun testClientFunctionDuplicateName() = + runSimulation { + val service = FaaSService(dispatcher, mockk(), mockk(), mockk()) - val client = service.newClient() + val client = service.newClient() - client.newFunction("test", 128) + client.newFunction("test", 128) - assertThrows { client.newFunction("test", 128) } - } + assertThrows { client.newFunction("test", 128) } + } @Test - fun testClientFunctionDelete() = runSimulation { - val service = FaaSService(dispatcher, mockk(), mockk(), mockk()) - - val client = service.newClient() - val function = client.newFunction("test", 128) - assertNotNull(client.findFunction(function.uid)) - function.delete() - assertNull(client.findFunction(function.uid)) - - // Delete should be idempotent - function.delete() - } + fun testClientFunctionDelete() = + runSimulation { + val service = FaaSService(dispatcher, mockk(), mockk(), mockk()) + + val client = service.newClient() + val function = client.newFunction("test", 128) + assertNotNull(client.findFunction(function.uid)) + function.delete() + assertNull(client.findFunction(function.uid)) + + // Delete should be idempotent + function.delete() + } @Test - fun testClientFunctionCannotInvokeDeleted() = runSimulation { - val service = FaaSService(dispatcher, mockk(), mockk(), mockk()) + fun testClientFunctionCannotInvokeDeleted() = + runSimulation { + val service = FaaSService(dispatcher, mockk(), mockk(), mockk()) - val client = service.newClient() - val function = client.newFunction("test", 128) - assertNotNull(client.findFunction(function.uid)) - function.delete() + val client = service.newClient() + val function = client.newFunction("test", 128) + assertNotNull(client.findFunction(function.uid)) + function.delete() - assertThrows { function.invoke() } - } + assertThrows { function.invoke() } + } @Test - fun testClientFunctionInvoke() = runSimulation { - val deployer = mockk() - val service = FaaSService(dispatcher, deployer, mockk(), mockk(relaxUnitFun = true)) + fun testClientFunctionInvoke() = + runSimulation { + val deployer = mockk() + val service = FaaSService(dispatcher, deployer, mockk(), mockk(relaxUnitFun = true)) - every { deployer.deploy(any(), any()) } answers { - object : FunctionInstance { - override val state: FunctionInstanceState = FunctionInstanceState.Idle - override val function: FunctionObject = it.invocation.args[0] as FunctionObject + every { deployer.deploy(any(), any()) } answers { + object : FunctionInstance { + override val state: FunctionInstanceState = FunctionInstanceState.Idle + override val function: FunctionObject = it.invocation.args[0] as FunctionObject - override suspend fun invoke() {} + override suspend fun invoke() {} - override fun close() {} + override fun close() {} + } } - } - val client = service.newClient() - val function = client.newFunction("test", 128) + val client = service.newClient() + val function = client.newFunction("test", 128) - function.invoke() - } + function.invoke() + } } -- cgit v1.2.3