@@ -48,9 +48,6 @@ import kotlinx.coroutines.test.runTest
48
48
import kotlinx.serialization.json.Json
49
49
import platform.posix.getenv
50
50
import platform.posix.setenv
51
- import kotlin.experimental.ExperimentalNativeApi
52
- import kotlin.native.runtime.GC
53
- import kotlin.native.runtime.NativeRuntimeApi
54
51
import kotlin.test.BeforeTest
55
52
import kotlin.test.Test
56
53
import kotlin.test.assertFailsWith
@@ -361,68 +358,6 @@ class LambdaRuntimeTest {
361
358
verify(not ) { lambdaRunner.env.terminate() }
362
359
}
363
360
364
- @OptIn(NativeRuntimeApi ::class , ExperimentalStdlibApi ::class , ExperimentalNativeApi ::class )
365
- @Test
366
- fun `Validate leaks` () = runTest {
367
- val invocationCount = 3
368
- var invocationIndex = 0
369
- val events = buildList(invocationCount) {
370
- repeat(invocationCount) { add(" Hello world" ) }
371
- }
372
-
373
- val lambdaRunner = createRunner(MockEngine { request ->
374
- val path = request.url.encodedPath
375
- when {
376
- path.contains(" invocation/next" ) -> {
377
- if (invocationIndex >= invocationCount) {
378
- respondError(HttpStatusCode .InternalServerError , headers = headers {
379
- append(HttpHeaders .ContentType , " application/json" )
380
- append(" Lambda-Runtime-Aws-Request-Id" , context.awsRequestId)
381
- append(" Lambda-Runtime-Deadline-Ms" , context.deadlineTimeInMs.toString())
382
- append(" Lambda-Runtime-Invoked-Function-Arn" , context.invokedFunctionArn)
383
- })
384
- } else {
385
- respondNextEventSuccess(events[invocationIndex++ ])
386
- }
387
- }
388
-
389
- path.contains(" /invocation/${context.awsRequestId} /response" ) -> respond(
390
- content = ByteReadChannel (" Ok" ),
391
- status = HttpStatusCode .Accepted ,
392
- headers = headersOf(HttpHeaders .ContentType , " application/json" )
393
- )
394
-
395
- else -> respondBadRequest()
396
- }
397
- })
398
-
399
- val handler = object : LambdaBufferedHandler <String , String > {
400
- override suspend fun handleRequest (input : String , context : Context ): String = " Hello"
401
- }
402
-
403
- assertFailsWith<TerminateException > {
404
- lambdaRunner.run { handler }
405
- }
406
-
407
- GC .collect()
408
- GC .lastGCInfo?.let {gcInfo->
409
- println (
410
- " Heap Size Before: ${
411
- gcInfo.memoryUsageBefore.map {
412
- it.key + " - " + it.value.totalObjectsSizeBytes / 1024 / 1024
413
- }
414
- } "
415
- )
416
- println (
417
- " Heap Size After: ${
418
- gcInfo.memoryUsageAfter.map {
419
- it.key + " - " + it.value.totalObjectsSizeBytes / 1024 / 1024
420
- }
421
- } "
422
- )
423
- }
424
- }
425
-
426
361
@OptIn(ExperimentalForeignApi ::class )
427
362
private fun mockEnvironment () {
428
363
if (getenv(AWS_LAMBDA_FUNCTION_NAME )?.toKString().isNullOrEmpty()) {
0 commit comments