@@ -73,33 +73,34 @@ await this.WaitForProductChanges(
7373 }
7474
7575 /// <summary>
76- /// Verifies that manually setting the batch size correctly changes the number of changes processed at once
76+ /// Verifies that manually setting the batch size using the original config var correctly changes the
77+ /// number of changes processed at once.
7778 /// </summary>
7879 [ Fact ]
7980 public async Task BatchSizeOverrideTriggerTest ( )
8081 {
8182 // Use enough items to require 4 batches to be processed but then
82- // set the batch size to the same value so they can all be processed in one
83+ // set the max batch size to the same value so they can all be processed in one
8384 // batch. The test will only wait for ~1 batch worth of time so will timeout
84- // if the batch size isn't actually changed
85- const int batchSize = SqlTableChangeMonitor < object > . DefaultBatchSize * 4 ;
85+ // if the max batch size isn't actually changed
86+ const int maxBatchSize = SqlTableChangeMonitor < object > . DefaultMaxBatchSize * 4 ;
8687 const int firstId = 1 ;
87- const int lastId = batchSize ;
88+ const int lastId = maxBatchSize ;
8889 this . SetChangeTrackingForTable ( "Products" ) ;
8990 var taskCompletionSource = new TaskCompletionSource < bool > ( ) ;
9091 DataReceivedEventHandler handler = TestUtils . CreateOutputReceievedHandler (
9192 taskCompletionSource ,
92- @"Starting change consumption loop. BatchSize : (\d*) PollingIntervalMs: \d*" ,
93- "BatchSize " ,
94- batchSize . ToString ( ) ) ;
93+ @"Starting change consumption loop. MaxBatchSize : (\d*) PollingIntervalMs: \d*" ,
94+ "MaxBatchSize " ,
95+ maxBatchSize . ToString ( ) ) ;
9596 this . StartFunctionHost (
9697 nameof ( ProductsTriggerWithValidation ) ,
9798 SupportedLanguages . CSharp ,
9899 useTestFolder : true ,
99100 customOutputHandler : handler ,
100101 environmentVariables : new Dictionary < string , string > ( ) {
101- { "TEST_EXPECTED_BATCH_SIZE " , batchSize . ToString ( ) } ,
102- { "Sql_Trigger_BatchSize" , batchSize . ToString ( ) }
102+ { "TEST_EXPECTED_MAX_BATCH_SIZE " , maxBatchSize . ToString ( ) } ,
103+ { "Sql_Trigger_BatchSize" , maxBatchSize . ToString ( ) } // Use old BatchSize config
103104 }
104105 ) ;
105106
@@ -110,8 +111,50 @@ await this.WaitForProductChanges(
110111 ( ) => { this . InsertProducts ( firstId , lastId ) ; return Task . CompletedTask ; } ,
111112 id => $ "Product { id } ",
112113 id => id * 100 ,
113- this . GetBatchProcessingTimeout ( firstId , lastId , batchSize : batchSize ) ) ;
114- await taskCompletionSource . Task . TimeoutAfter ( TimeSpan . FromSeconds ( 5000 ) , "Timed out waiting for BatchSize configuration message" ) ;
114+ this . GetBatchProcessingTimeout ( firstId , lastId , maxBatchSize : maxBatchSize ) ) ;
115+ await taskCompletionSource . Task . TimeoutAfter ( TimeSpan . FromSeconds ( 5 ) , "Timed out waiting for MaxBatchSize configuration message" ) ;
116+ }
117+
118+ /// <summary>
119+ /// Verifies that manually setting the max batch size correctly changes the number of changes processed at once
120+ /// </summary>
121+ [ Fact ]
122+ public async Task MaxBatchSizeOverrideTriggerTest ( )
123+ {
124+ // Use enough items to require 4 batches to be processed but then
125+ // set the max batch size to the same value so they can all be processed in one
126+ // batch. The test will only wait for ~1 batch worth of time so will timeout
127+ // if the max batch size isn't actually changed
128+ const int maxBatchSize = SqlTableChangeMonitor < object > . DefaultMaxBatchSize * 4 ;
129+ const int firstId = 1 ;
130+ const int lastId = maxBatchSize ;
131+ this . SetChangeTrackingForTable ( "Products" ) ;
132+ var taskCompletionSource = new TaskCompletionSource < bool > ( ) ;
133+ DataReceivedEventHandler handler = TestUtils . CreateOutputReceievedHandler (
134+ taskCompletionSource ,
135+ @"Starting change consumption loop. MaxBatchSize: (\d*) PollingIntervalMs: \d*" ,
136+ "MaxBatchSize" ,
137+ maxBatchSize . ToString ( ) ) ;
138+ this . StartFunctionHost (
139+ nameof ( ProductsTriggerWithValidation ) ,
140+ SupportedLanguages . CSharp ,
141+ useTestFolder : true ,
142+ customOutputHandler : handler ,
143+ environmentVariables : new Dictionary < string , string > ( ) {
144+ { "TEST_EXPECTED_MAX_BATCH_SIZE" , maxBatchSize . ToString ( ) } ,
145+ { "Sql_Trigger_MaxBatchSize" , maxBatchSize . ToString ( ) }
146+ }
147+ ) ;
148+
149+ await this . WaitForProductChanges (
150+ firstId ,
151+ lastId ,
152+ SqlChangeOperation . Insert ,
153+ ( ) => { this . InsertProducts ( firstId , lastId ) ; return Task . CompletedTask ; } ,
154+ id => $ "Product { id } ",
155+ id => id * 100 ,
156+ this . GetBatchProcessingTimeout ( firstId , lastId , maxBatchSize : maxBatchSize ) ) ;
157+ await taskCompletionSource . Task . TimeoutAfter ( TimeSpan . FromSeconds ( 5 ) , "Timed out waiting for MaxBatchSize configuration message" ) ;
115158 }
116159
117160 /// <summary>
@@ -124,13 +167,13 @@ public async Task PollingIntervalOverrideTriggerTest()
124167 // Use enough items to require 5 batches to be processed - the test will
125168 // only wait for the expected time and timeout if the default polling
126169 // interval isn't actually modified.
127- const int lastId = SqlTableChangeMonitor < object > . DefaultBatchSize * 5 ;
170+ const int lastId = SqlTableChangeMonitor < object > . DefaultMaxBatchSize * 5 ;
128171 const int pollingIntervalMs = SqlTableChangeMonitor < object > . DefaultPollingIntervalMs / 2 ;
129172 this . SetChangeTrackingForTable ( "Products" ) ;
130173 var taskCompletionSource = new TaskCompletionSource < bool > ( ) ;
131174 DataReceivedEventHandler handler = TestUtils . CreateOutputReceievedHandler (
132175 taskCompletionSource ,
133- @"Starting change consumption loop. BatchSize : \d* PollingIntervalMs: (\d*)" ,
176+ @"Starting change consumption loop. MaxBatchSize : \d* PollingIntervalMs: (\d*)" ,
134177 "PollingInterval" ,
135178 pollingIntervalMs . ToString ( ) ) ;
136179 this . StartFunctionHost (
@@ -151,7 +194,7 @@ await this.WaitForProductChanges(
151194 id => $ "Product { id } ",
152195 id => id * 100 ,
153196 this . GetBatchProcessingTimeout ( firstId , lastId , pollingIntervalMs : pollingIntervalMs ) ) ;
154- await taskCompletionSource . Task . TimeoutAfter ( TimeSpan . FromSeconds ( 5000 ) , "Timed out waiting for PollingInterval configuration message" ) ;
197+ await taskCompletionSource . Task . TimeoutAfter ( TimeSpan . FromSeconds ( 5 ) , "Timed out waiting for PollingInterval configuration message" ) ;
155198 }
156199
157200 /// <summary>
0 commit comments