14
14
15
15
@testable import AWSLambdaRuntimeCore
16
16
import Logging
17
+ import Lifecycle
17
18
import NIO
18
19
import NIOHTTP1
19
20
import XCTest
@@ -25,11 +26,16 @@ class LambdaLifecycleTest: XCTestCase {
25
26
defer { XCTAssertNoThrow ( try server. stop ( ) . wait ( ) ) }
26
27
let eventLoopGroup = MultiThreadedEventLoopGroup ( numberOfThreads: 1 )
27
28
defer { XCTAssertNoThrow ( try eventLoopGroup. syncShutdownGracefully ( ) ) }
28
-
29
+
30
+ let serviceLifecycle = ServiceLifecycle ( configuration: . init( shutdownSignal: [ ] , installBacktrace: false ) )
31
+ defer {
32
+ serviceLifecycle. shutdown ( )
33
+ serviceLifecycle. wait ( )
34
+ }
29
35
let eventLoop = eventLoopGroup. next ( )
30
36
let logger = Logger ( label: " TestLogger " )
31
37
let testError = TestError ( " kaboom " )
32
- let lifecycle = Lambda . Lifecycle ( eventLoop: eventLoop, logger: logger, factory: {
38
+ let lifecycle = Lambda . Lifecycle ( eventLoop: eventLoop, serviceLifecycle : serviceLifecycle , logger: logger, factory: {
33
39
$0. eventLoop. makeFailedFuture ( testError)
34
40
} )
35
41
@@ -68,6 +74,12 @@ class LambdaLifecycleTest: XCTestCase {
68
74
defer { XCTAssertNoThrow ( try server. stop ( ) . wait ( ) ) }
69
75
let eventLoopGroup = MultiThreadedEventLoopGroup ( numberOfThreads: 1 )
70
76
defer { XCTAssertNoThrow ( try eventLoopGroup. syncShutdownGracefully ( ) ) }
77
+
78
+ let serviceLifecycle = ServiceLifecycle ( configuration: . init( shutdownSignal: [ ] , installBacktrace: false ) )
79
+ defer {
80
+ serviceLifecycle. shutdown ( )
81
+ serviceLifecycle. wait ( )
82
+ }
71
83
72
84
var count = 0
73
85
let handler = CallbackLambdaHandler ( { XCTFail ( " Should not be reached " ) ; return $0. eventLoop. makeSucceededFuture ( $1) } ) { context in
@@ -77,7 +89,7 @@ class LambdaLifecycleTest: XCTestCase {
77
89
78
90
let eventLoop = eventLoopGroup. next ( )
79
91
let logger = Logger ( label: " TestLogger " )
80
- let lifecycle = Lambda . Lifecycle ( eventLoop: eventLoop, logger: logger, factory: {
92
+ let lifecycle = Lambda . Lifecycle ( eventLoop: eventLoop, serviceLifecycle : serviceLifecycle , logger: logger, factory: {
81
93
$0. eventLoop. makeSucceededFuture ( handler)
82
94
} )
83
95
@@ -94,6 +106,12 @@ class LambdaLifecycleTest: XCTestCase {
94
106
defer { XCTAssertNoThrow ( try server. stop ( ) . wait ( ) ) }
95
107
let eventLoopGroup = MultiThreadedEventLoopGroup ( numberOfThreads: 1 )
96
108
defer { XCTAssertNoThrow ( try eventLoopGroup. syncShutdownGracefully ( ) ) }
109
+
110
+ let serviceLifecycle = ServiceLifecycle ( configuration: . init( shutdownSignal: [ ] , installBacktrace: false ) )
111
+ defer {
112
+ serviceLifecycle. shutdown ( )
113
+ serviceLifecycle. wait ( )
114
+ }
97
115
98
116
var count = 0
99
117
let handler = CallbackLambdaHandler ( { XCTFail ( " Should not be reached " ) ; return $0. eventLoop. makeSucceededFuture ( $1) } ) { context in
@@ -103,7 +121,7 @@ class LambdaLifecycleTest: XCTestCase {
103
121
104
122
let eventLoop = eventLoopGroup. next ( )
105
123
let logger = Logger ( label: " TestLogger " )
106
- let lifecycle = Lambda . Lifecycle ( eventLoop: eventLoop, logger: logger, factory: {
124
+ let lifecycle = Lambda . Lifecycle ( eventLoop: eventLoop, serviceLifecycle : serviceLifecycle , logger: logger, factory: {
107
125
$0. eventLoop. makeSucceededFuture ( handler)
108
126
} )
109
127
0 commit comments