File tree Expand file tree Collapse file tree 2 files changed +32
-25
lines changed
Tests/AWSLambdaRuntimeTests Expand file tree Collapse file tree 2 files changed +32
-25
lines changed Original file line number Diff line number Diff line change 1+ #if ServiceLifecycleSupport
2+ @testable import AWSLambdaRuntime
3+ import ServiceLifecycle
4+ import Testing
5+ import Logging
6+
7+ @Suite
8+ struct LambdaRuntimeServiceLifecycleTests {
9+ @Test
10+ func testLambdaRuntimeGracefulShutdown( ) async throws {
11+ let runtime = LambdaRuntime {
12+ ( event: String , context: LambdaContext ) in
13+ " Hello \( event) "
14+ }
15+
16+ let serviceGroup = ServiceGroup (
17+ services: [ runtime] ,
18+ gracefulShutdownSignals: [ . sigterm, . sigint] ,
19+ logger: Logger ( label: " TestLambdaRuntimeGracefulShutdown " )
20+ )
21+ try await withThrowingTaskGroup ( of: Void . self) { group in
22+ group. addTask {
23+ try await serviceGroup. run ( )
24+ }
25+ // wait a small amount to ensure we are waiting for continuation
26+ try await Task . sleep ( for: . milliseconds( 100 ) )
27+
28+ await serviceGroup. triggerGracefulShutdown ( )
29+ }
30+ }
31+ }
32+ #endif
Original file line number Diff line number Diff line change 1515import Logging
1616import NIOCore
1717import NIOPosix
18- import ServiceLifecycle
1918import Testing
2019
2120import struct Foundation. UUID
@@ -140,28 +139,4 @@ struct LambdaRuntimeClientTests {
140139 }
141140 }
142141 }
143- #if ServiceLifecycleSupport
144- @Test
145- func testLambdaRuntimeGracefulShutdown( ) async throws {
146- let runtime = LambdaRuntime {
147- ( event: String , context: LambdaContext ) in
148- " Hello \( event) "
149- }
150-
151- let serviceGroup = ServiceGroup (
152- services: [ runtime] ,
153- gracefulShutdownSignals: [ . sigterm, . sigint] ,
154- logger: Logger ( label: " TestLambdaRuntimeGracefulShutdown " )
155- )
156- try await withThrowingTaskGroup ( of: Void . self) { group in
157- group. addTask {
158- try await serviceGroup. run ( )
159- }
160- // wait a small amount to ensure we are waiting for continuation
161- try await Task . sleep ( for: . milliseconds( 100 ) )
162-
163- await serviceGroup. triggerGracefulShutdown ( )
164- }
165- }
166- #endif
167142}
You can’t perform that action at this time.
0 commit comments