@@ -164,81 +164,6 @@ describe('Integration Test', () => {
164164 } ) ;
165165 } ) ;
166166
167- it ( 'should run trigger successfully' , async ( ) => {
168- helpers . mockApiTaskStepResponse ( env ) ;
169-
170- nock ( 'https://api.acme.com' )
171- . post ( '/subscribe' )
172- . reply ( 200 , {
173- id : 'subscription_12345'
174- } )
175- . get ( '/customers' )
176- . reply ( 200 , customers ) ;
177-
178- await amqpHelper . publishMessage ( inputMessage , {
179- parentMessageId,
180- threadId
181- } ) ;
182- runner . run ( settings . readFrom ( env ) , ipc ) ;
183- const { message, queueName } = await new Promise ( resolve => amqpHelper . on (
184- 'data' ,
185- ( message , queueName ) => resolve ( { message, queueName } )
186- ) ) ;
187-
188- const { properties, content } = message ;
189- const { body } = encryptor . decryptMessageContent ( content , encoding ) ;
190- expect ( queueName ) . to . eql ( amqpHelper . nextStepQueue ) ;
191-
192- expect ( properties . headers . messageId ) . to . be . a ( 'string' ) ;
193- delete properties . headers . start ;
194- delete properties . headers . end ;
195- delete properties . headers . cid ;
196- delete properties . headers . messageId ;
197-
198- expect ( properties . headers ) . to . deep . equal ( {
199- execId : env . ELASTICIO_EXEC_ID ,
200- taskId : env . ELASTICIO_FLOW_ID ,
201- workspaceId : env . ELASTICIO_WORKSPACE_ID ,
202- containerId : env . ELASTICIO_CONTAINER_ID ,
203- userId : env . ELASTICIO_USER_ID ,
204- stepId : env . ELASTICIO_STEP_ID ,
205- compId : env . ELASTICIO_COMP_ID ,
206- function : env . ELASTICIO_FUNCTION ,
207- threadId,
208- parentMessageId,
209- protocolVersion : protocolVersion
210- } ) ;
211-
212- delete properties . headers ;
213-
214- expect ( properties ) . to . deep . equal ( {
215- contentType : 'application/json' ,
216- contentEncoding : 'utf8' ,
217- deliveryMode : undefined ,
218- priority : undefined ,
219- correlationId : undefined ,
220- replyTo : undefined ,
221- expiration : undefined ,
222- messageId : undefined ,
223- timestamp : undefined ,
224- type : undefined ,
225- userId : undefined ,
226- appId : undefined ,
227- clusterId : undefined
228- } ) ;
229-
230- expect ( body ) . to . deep . equal ( {
231- originalMsg : inputMessage ,
232- customers : customers ,
233- subscription : {
234- id : 'subscription_12345' ,
235- cfg : {
236- apiKey : 'secret'
237- }
238- }
239- } ) ;
240- } ) ;
241-
242167 it ( 'should run trigger successfully for input protocolVersion 2' , async ( ) => {
243168 helpers . mockApiTaskStepResponse ( env ) ;
244169
@@ -1250,6 +1175,70 @@ describe('Integration Test', () => {
12501175 } ) ;
12511176 }
12521177
1178+ it ( 'should make all HTTP requests with keep alive agent' , async ( ) => {
1179+ env . ELASTICIO_STEP_ID = 'step_2' ;
1180+ env . ELASTICIO_FLOW_ID = '5559edd38968ec0736000003' ;
1181+ env . ELASTICIO_FUNCTION = 'trigger_with_keep_alive' ;
1182+
1183+ helpers . mockApiTaskStepResponse ( env ) ;
1184+
1185+ nock ( 'http://api.acme.com' )
1186+ . get ( '/customers' )
1187+ . reply ( 200 , customers ) ;
1188+
1189+ await amqpHelper . publishMessage ( inputMessage , {
1190+ parentMessageId,
1191+ threadId
1192+ } ) ;
1193+ runner . run ( settings . readFrom ( env ) , ipc ) ;
1194+ const { message } = await new Promise ( resolve => amqpHelper . on (
1195+ 'data' ,
1196+ ( message , queueName ) => resolve ( { message, queueName } )
1197+ ) ) ;
1198+
1199+ const { content } = message ;
1200+ const { body } = encryptor . decryptMessageContent ( content , 'base64' ) ;
1201+
1202+ expect ( body ) . to . deep . equal ( {
1203+ originalMsg : inputMessage ,
1204+ customers,
1205+ keepAlive : true
1206+ } ) ;
1207+ } ) ;
1208+
1209+ it ( 'should make all HTTPS requests with keep alive agent' , async ( ) => {
1210+ env . ELASTICIO_STEP_ID = 'step_2' ;
1211+ env . ELASTICIO_FLOW_ID = '5559edd38968ec0736000003' ;
1212+ env . ELASTICIO_FUNCTION = 'trigger_with_keep_alive' ;
1213+
1214+ inputMessage . body . isHttps = true ;
1215+
1216+ helpers . mockApiTaskStepResponse ( env ) ;
1217+
1218+ nock ( 'https://api.acme.com' )
1219+ . get ( '/customers' )
1220+ . reply ( 200 , customers ) ;
1221+
1222+ await amqpHelper . publishMessage ( inputMessage , {
1223+ parentMessageId,
1224+ threadId
1225+ } ) ;
1226+ runner . run ( settings . readFrom ( env ) , ipc ) ;
1227+ const { message } = await new Promise ( resolve => amqpHelper . on (
1228+ 'data' ,
1229+ ( message , queueName ) => resolve ( { message, queueName } )
1230+ ) ) ;
1231+
1232+ const { content } = message ;
1233+ const { body } = encryptor . decryptMessageContent ( content , 'base64' ) ;
1234+
1235+ expect ( body ) . to . deep . equal ( {
1236+ originalMsg : inputMessage ,
1237+ customers,
1238+ keepAlive : true
1239+ } ) ;
1240+ } ) ;
1241+
12531242 it ( 'should fail if queue deleted' , async ( ) => {
12541243 helpers . mockApiTaskStepResponse ( env ) ;
12551244
0 commit comments