@@ -83,6 +83,30 @@ describe('Transform tests', () => {
8383 expect ( mockedStopTransform . callCount ) . to . equals ( 1 ) ; // There is nothing to stop
8484 } ) ;
8585
86+ it ( 'should pass - 1 running transform (is the actual transform) - Created & Started new transform - Old deleted - Checkpoint taken over as query limition to new transform' , async ( ) => {
87+ const mockedGetTransformStats = setupElasticsearchMock ( client , 'transform.getTransformStats' , './test/mock/transform/getTransformStatsResponseOneStarted.json' , false ) ;
88+ const mockedPutTransform = setupElasticsearchMock ( client , 'transform.putTransform' , './test/mock/transform/putTransformResponse.json' , false ) ;
89+ const mockedDeleteTransform = setupElasticsearchMock ( client , 'transform.deleteTransform' , './test/mock/transform/stopTransformResponse.json' , false ) ;
90+ const mockedStartTransform = setupElasticsearchMock ( client , 'transform.startTransform' , './test/mock/transform/startTransformResponse.json' , false ) ;
91+ const mockedStopTransform = setupElasticsearchMock ( client , 'transform.stopTransform' , './test/mock/transform/stopTransformResponse.json' , false ) ;
92+
93+ const inputParameter = {
94+ transformId : 'traffic-summary-hourly' ,
95+ idSuffix : "v1" ,
96+ deletePreviousTransform : true ,
97+ body : JSON . parse ( fs . readFileSync ( './test/mock/transform/putTransformRequestBody.json' ) ) } ;
98+ const { value, output } = await flowNode . putTransform ( inputParameter ) ;
99+
100+ expect ( output ) . to . equal ( 'next' ) ;
101+ expect ( mockedGetTransformStats . callCount ) . to . equals ( 1 ) ; // should be called once to get all transforms
102+ expect ( mockedPutTransform . callCount ) . to . equals ( 1 ) ; // a new transform should be created
103+ // Transform body should have been extended about a query limitation
104+ expect ( mockedPutTransform . lastCall . arg . body . source . query ) . to . deep . equals ( { "bool" : { "should" : [ { "range" : { "@timestamp" : { "gt" : 1646913600000 } } } ] , "minimum_should_match" : 1 } } ) ;
105+ expect ( mockedStartTransform . callCount ) . to . equals ( 1 ) ; // and started
106+ expect ( mockedDeleteTransform . callCount ) . to . equals ( 1 ) ; // Previous transform should be deleted
107+ expect ( mockedStopTransform . callCount ) . to . equals ( 1 ) ; // There is nothing to stop
108+ } ) ;
109+
86110 it ( 'should return with noUpdate as the actual transform is still indexing' , async ( ) => {
87111 const mockedGetTransformStats = setupElasticsearchMock ( client , 'transform.getTransformStats' , './test/mock/transform/getTransformStatsResponseOneIndexing.json' , false ) ;
88112 const mockedPutTransform = setupElasticsearchMock ( client , 'transform.putTransform' , './test/mock/transform/putTransformResponse.json' , false ) ;
0 commit comments