2626using Foundatio . Repositories . Models ;
2727using Microsoft . Net . Http . Headers ;
2828using Xunit ;
29- using Xunit . Abstractions ;
3029using MediaTypeHeaderValue = System . Net . Http . Headers . MediaTypeHeaderValue ;
3130using Run = Exceptionless . Tests . Utility . Run ;
3231
@@ -59,6 +58,7 @@ protected override async Task ResetDataAsync()
5958 {
6059 await base . ResetDataAsync ( ) ;
6160 await _eventQueue . DeleteQueueAsync ( ) ;
61+ await _eventUserDescriptionQueue . DeleteQueueAsync ( ) ;
6262
6363 var service = GetService < SampleDataService > ( ) ;
6464 await service . CreateDataAsync ( ) ;
@@ -81,7 +81,7 @@ await SendRequestAsync(r => r
8181 Assert . Equal ( 0 , stats . Completed ) ;
8282
8383 var processEventsJob = GetService < EventPostsJob > ( ) ;
84- await processEventsJob . RunAsync ( ) ;
84+ await processEventsJob . RunAsync ( TestCancellationToken ) ;
8585 await RefreshDataAsync ( ) ;
8686
8787 stats = await _eventQueue . GetQueueStatsAsync ( ) ;
@@ -114,7 +114,7 @@ await SendRequestAsync(r => r
114114 Assert . Equal ( 0 , stats . Completed ) ;
115115
116116 var userDescriptionJob = GetService < EventUserDescriptionsJob > ( ) ;
117- await userDescriptionJob . RunAsync ( ) ;
117+ await userDescriptionJob . RunAsync ( TestCancellationToken ) ;
118118
119119 stats = await _eventUserDescriptionQueue . GetQueueStatsAsync ( ) ;
120120 Assert . Equal ( 1 , stats . Dequeued ) ;
@@ -150,11 +150,13 @@ await SendRequestAsync(r => r
150150 Assert . Equal ( 0 , stats . Completed ) ;
151151
152152 var userDescriptionJob = GetService < EventUserDescriptionsJob > ( ) ;
153- await userDescriptionJob . RunAsync ( ) ;
153+ await userDescriptionJob . RunAsync ( TestCancellationToken ) ;
154154
155155 stats = await _eventUserDescriptionQueue . GetQueueStatsAsync ( ) ;
156156 Assert . Equal ( 1 , stats . Dequeued ) ;
157157 Assert . Equal ( 1 , stats . Abandoned ) ; // Event doesn't exist
158+
159+ await _eventUserDescriptionQueue . DeleteQueueAsync ( ) ;
158160 }
159161
160162 [ Fact ]
@@ -174,7 +176,7 @@ await SendRequestAsync(r => r
174176 Assert . Equal ( 0 , stats . Completed ) ;
175177
176178 var processEventsJob = GetService < EventPostsJob > ( ) ;
177- await processEventsJob . RunAsync ( ) ;
179+ await processEventsJob . RunAsync ( TestCancellationToken ) ;
178180 await RefreshDataAsync ( ) ;
179181
180182 stats = await _eventQueue . GetQueueStatsAsync ( ) ;
@@ -192,15 +194,15 @@ public async Task CanPostCompressedStringAsync()
192194 byte [ ] data = Encoding . UTF8 . GetBytes ( message ) ;
193195 var ms = new MemoryStream ( ) ;
194196 await using ( var gzip = new GZipStream ( ms , CompressionMode . Compress , true ) )
195- await gzip . WriteAsync ( data , CancellationToken . None ) ;
197+ await gzip . WriteAsync ( data , TestCancellationToken ) ;
196198 ms . Position = 0 ;
197199
198200 var content = new StreamContent ( ms ) ;
199201 content . Headers . ContentType = new MediaTypeHeaderValue ( "text/plain" ) ;
200202 content . Headers . ContentEncoding . Add ( "gzip" ) ;
201203 var client = CreateHttpClient ( ) ;
202204 client . DefaultRequestHeaders . Add ( "Authorization" , "Bearer " + TestConstants . ApiKey ) ;
203- var response = await client . PostAsync ( "events" , content ) ;
205+ var response = await client . PostAsync ( "events" , content , TestCancellationToken ) ;
204206 Assert . Equal ( HttpStatusCode . Accepted , response . StatusCode ) ;
205207 Assert . True ( response . Headers . Contains ( Headers . ConfigurationVersion ) ) ;
206208
@@ -209,7 +211,7 @@ public async Task CanPostCompressedStringAsync()
209211 Assert . Equal ( 0 , stats . Completed ) ;
210212
211213 var processEventsJob = GetService < EventPostsJob > ( ) ;
212- await processEventsJob . RunAsync ( ) ;
214+ await processEventsJob . RunAsync ( TestCancellationToken ) ;
213215 await RefreshDataAsync ( ) ;
214216
215217 stats = await _eventQueue . GetQueueStatsAsync ( ) ;
@@ -236,7 +238,7 @@ await SendRequestAsync(r => r
236238 Assert . Equal ( 0 , stats . Completed ) ;
237239
238240 var processEventsJob = GetService < EventPostsJob > ( ) ;
239- await processEventsJob . RunAsync ( ) ;
241+ await processEventsJob . RunAsync ( TestCancellationToken ) ;
240242 await RefreshDataAsync ( ) ;
241243
242244 stats = await _eventQueue . GetQueueStatsAsync ( ) ;
@@ -272,7 +274,7 @@ await SendRequestAsync(r => r
272274 Assert . Equal ( 0 , stats . Completed ) ;
273275
274276 var processEventsJob = GetService < EventPostsJob > ( ) ;
275- await processEventsJob . RunAsync ( ) ;
277+ await processEventsJob . RunAsync ( TestCancellationToken ) ;
276278 await RefreshDataAsync ( ) ;
277279
278280 stats = await _eventQueue . GetQueueStatsAsync ( ) ;
@@ -308,7 +310,7 @@ await SendRequestAsync(r => r
308310
309311 var processEventsJob = GetService < EventPostsJob > ( ) ;
310312 var sw = Stopwatch . StartNew ( ) ;
311- await processEventsJob . RunUntilEmptyAsync ( ) ;
313+ await processEventsJob . RunUntilEmptyAsync ( TestCancellationToken ) ;
312314 sw . Stop ( ) ;
313315 _logger . LogInformation ( "{Duration:g}" , sw . Elapsed ) ;
314316
@@ -338,7 +340,7 @@ await SendRequestAsync(r => r
338340 Assert . Equal ( 0 , stats . Completed ) ;
339341
340342 var processEventsJob = GetService < EventPostsJob > ( ) ;
341- await processEventsJob . RunAsync ( ) ;
343+ await processEventsJob . RunAsync ( TestCancellationToken ) ;
342344 await RefreshDataAsync ( ) ;
343345
344346 stats = await _eventQueue . GetQueueStatsAsync ( ) ;
@@ -906,7 +908,7 @@ await SendRequestAsync(r => r
906908
907909 // process events
908910 var processEventsJob = GetService < EventPostsJob > ( ) ;
909- Assert . Equal ( JobResult . Success , await processEventsJob . RunAsync ( ) ) ;
911+ Assert . Equal ( JobResult . Success , await processEventsJob . RunAsync ( TestCancellationToken ) ) ;
910912
911913 var usageInfo = await usageService . GetUsageAsync ( organizationId ) ;
912914 Assert . Equal ( viewOrganization . MaxEventsPerMonth , usageInfo . CurrentUsage . Limit ) ;
@@ -970,7 +972,7 @@ await SendRequestAsync(r => r
970972 ) ;
971973
972974 // Run the job and verify usage
973- Assert . Equal ( JobResult . Success , await processEventsJob . RunAsync ( ) ) ;
975+ Assert . Equal ( JobResult . Success , await processEventsJob . RunAsync ( TestCancellationToken ) ) ;
974976
975977 viewOrganization = await SendRequestAsAsync < ViewOrganization > ( r => r
976978 . AsTestOrganizationUser ( )
@@ -995,7 +997,7 @@ await SendRequestAsync(r => r
995997 TimeProvider . Advance ( TimeSpan . FromMinutes ( 6 ) ) ;
996998
997999 var processUsageJob = GetService < EventUsageJob > ( ) ;
998- Assert . Equal ( JobResult . Success , await processUsageJob . RunAsync ( ) ) ;
1000+ Assert . Equal ( JobResult . Success , await processUsageJob . RunAsync ( TestCancellationToken ) ) ;
9991001
10001002 organization = await _organizationRepository . GetByIdAsync ( organizationId ) ;
10011003
@@ -1073,7 +1075,7 @@ public async Task SpaFallbackWorks()
10731075 . AppendPath ( "blah" )
10741076 . StatusCodeShouldBeOk ( )
10751077 ) ;
1076- string content = await response . Content . ReadAsStringAsync ( ) ;
1078+ string content = await response . Content . ReadAsStringAsync ( TestCancellationToken ) ;
10771079 Assert . Contains ( "exceptionless" , content ) ;
10781080
10791081 await SendRequestAsync ( r => r
@@ -1141,7 +1143,7 @@ await SendRequestAsync(r => r
11411143
11421144 // process events
11431145 var processEventsJob = GetService < EventPostsJob > ( ) ;
1144- Assert . Equal ( JobResult . Success , await processEventsJob . RunAsync ( ) ) ;
1146+ Assert . Equal ( JobResult . Success , await processEventsJob . RunAsync ( TestCancellationToken ) ) ;
11451147
11461148 var usageInfo = await usageService . GetUsageAsync ( organizationId ) ;
11471149 Assert . Equal ( viewOrganization . MaxEventsPerMonth , usageInfo . CurrentUsage . Limit ) ;
@@ -1202,7 +1204,7 @@ await SendRequestAsync(r => r
12021204 ) ;
12031205
12041206 // Run the job and verify usage
1205- Assert . Equal ( JobResult . Success , await processEventsJob . RunAsync ( ) ) ;
1207+ Assert . Equal ( JobResult . Success , await processEventsJob . RunAsync ( TestCancellationToken ) ) ;
12061208
12071209 viewOrganization = await SendRequestAsAsync < ViewOrganization > ( r => r
12081210 . AsTestOrganizationUser ( )
@@ -1250,7 +1252,7 @@ await SendRequestAsync(r => r
12501252 TimeProvider . Advance ( TimeSpan . FromMinutes ( 6 ) ) ;
12511253
12521254 var processUsageJob = GetService < EventUsageJob > ( ) ;
1253- Assert . Equal ( JobResult . Success , await processUsageJob . RunAsync ( ) ) ;
1255+ Assert . Equal ( JobResult . Success , await processUsageJob . RunAsync ( TestCancellationToken ) ) ;
12541256
12551257 organization = await _organizationRepository . GetByIdAsync ( organizationId ) ;
12561258
@@ -1346,7 +1348,7 @@ await CreateDataAsync(d =>
13461348 string ? nextPage = GetQueryStringValue ( links [ "next" ] , "page" ) ;
13471349 Assert . Equal ( "2" , nextPage ) ;
13481350
1349- var result = await response . Content . ReadFromJsonAsync < IReadOnlyCollection < PersistentEvent > > ( ) ;
1351+ var result = await response . Content . ReadFromJsonAsync < IReadOnlyCollection < PersistentEvent > > ( TestCancellationToken ) ;
13501352 Assert . NotNull ( result ) ;
13511353 string firstEventId = result . Single ( ) . Id ;
13521354
@@ -1369,7 +1371,7 @@ await CreateDataAsync(d =>
13691371 nextPage = GetQueryStringValue ( links [ "next" ] , "page" ) ;
13701372 Assert . Equal ( "3" , nextPage ) ;
13711373
1372- result = await response . Content . ReadFromJsonAsync < IReadOnlyCollection < PersistentEvent > > ( ) ;
1374+ result = await response . Content . ReadFromJsonAsync < IReadOnlyCollection < PersistentEvent > > ( TestCancellationToken ) ;
13731375 Assert . NotNull ( result ) ;
13741376 string secondEventId = result . Single ( ) . Id ;
13751377 Assert . NotEqual ( firstEventId , secondEventId ) ;
@@ -1390,7 +1392,7 @@ await CreateDataAsync(d =>
13901392 previousPage = GetQueryStringValue ( links [ "previous" ] , "page" ) ;
13911393 Assert . Equal ( "2" , previousPage ) ;
13921394
1393- result = await response . Content . ReadFromJsonAsync < IReadOnlyCollection < PersistentEvent > > ( ) ;
1395+ result = await response . Content . ReadFromJsonAsync < IReadOnlyCollection < PersistentEvent > > ( TestCancellationToken ) ;
13941396 Assert . NotNull ( result ) ;
13951397 string thirdEventId = result . Single ( ) . Id ;
13961398 Assert . NotEqual ( secondEventId , thirdEventId ) ;
@@ -1408,7 +1410,7 @@ await CreateDataAsync(d =>
14081410 links = ParseLinkHeaderValue ( response . Headers . GetValues ( HeaderNames . Link ) . ToArray ( ) ) ;
14091411 Assert . Equal ( 2 , links . Count ) ;
14101412
1411- result = await response . Content . ReadFromJsonAsync < IReadOnlyCollection < PersistentEvent > > ( ) ;
1413+ result = await response . Content . ReadFromJsonAsync < IReadOnlyCollection < PersistentEvent > > ( TestCancellationToken ) ;
14121414 Assert . NotNull ( result ) ;
14131415 Assert . Equal ( secondEventId , result . Single ( ) . Id ) ;
14141416 }
@@ -1446,7 +1448,7 @@ await CreateDataAsync(d =>
14461448 Assert . NotNull ( after ) ;
14471449 Assert . Equal ( before , after ) ;
14481450
1449- var result = await response . Content . ReadFromJsonAsync < IReadOnlyCollection < PersistentEvent > > ( ) ;
1451+ var result = await response . Content . ReadFromJsonAsync < IReadOnlyCollection < PersistentEvent > > ( TestCancellationToken ) ;
14501452 Assert . NotNull ( result ) ;
14511453 string firstEventId = result . Single ( ) . Id ;
14521454
@@ -1470,7 +1472,7 @@ await CreateDataAsync(d =>
14701472 Assert . NotNull ( after ) ;
14711473 Assert . Equal ( before , after ) ;
14721474
1473- result = await response . Content . ReadFromJsonAsync < IReadOnlyCollection < PersistentEvent > > ( ) ;
1475+ result = await response . Content . ReadFromJsonAsync < IReadOnlyCollection < PersistentEvent > > ( TestCancellationToken ) ;
14741476 Assert . NotNull ( result ) ;
14751477 string secondEventId = result . Single ( ) . Id ;
14761478 Assert . NotEqual ( firstEventId , secondEventId ) ;
@@ -1495,7 +1497,7 @@ await CreateDataAsync(d =>
14951497 Assert . NotNull ( after ) ;
14961498 Assert . Equal ( before , after ) ;
14971499
1498- result = await response . Content . ReadFromJsonAsync < IReadOnlyCollection < PersistentEvent > > ( ) ;
1500+ result = await response . Content . ReadFromJsonAsync < IReadOnlyCollection < PersistentEvent > > ( TestCancellationToken ) ;
14991501 Assert . NotNull ( result ) ;
15001502 string thirdEventId = result . Single ( ) . Id ;
15011503 Assert . NotEqual ( secondEventId , thirdEventId ) ;
@@ -1513,7 +1515,7 @@ await CreateDataAsync(d =>
15131515 links = ParseLinkHeaderValue ( response . Headers . GetValues ( HeaderNames . Link ) . ToArray ( ) ) ;
15141516 Assert . Equal ( 2 , links . Count ) ;
15151517
1516- result = await response . Content . ReadFromJsonAsync < IReadOnlyCollection < PersistentEvent > > ( ) ;
1518+ result = await response . Content . ReadFromJsonAsync < IReadOnlyCollection < PersistentEvent > > ( TestCancellationToken ) ;
15171519 Assert . NotNull ( result ) ;
15181520 Assert . Equal ( secondEventId , result . Single ( ) . Id ) ;
15191521 }
@@ -1549,7 +1551,7 @@ public async Task PostEvent_WithEnvironmentAndRequestInfo_ReturnsCorrectSnakeCas
15491551 TimeProvider . SetUtcNow ( new DateTime ( 2026 , 1 , 15 , 12 , 0 , 0 , DateTimeKind . Utc ) ) ;
15501552
15511553 string dataPath = Path . Combine ( ".." , ".." , ".." , "Controllers" , "Data" ) ;
1552- string eventJson = await File . ReadAllTextAsync ( Path . Combine ( dataPath , "event-serialization-input.json" ) ) ;
1554+ string eventJson = await File . ReadAllTextAsync ( Path . Combine ( dataPath , "event-serialization-input.json" ) , TestCancellationToken ) ;
15531555
15541556 await SendRequestAsync ( r => r
15551557 . Post ( )
@@ -1560,7 +1562,7 @@ await SendRequestAsync(r => r
15601562 ) ;
15611563
15621564 var processEventsJob = GetService < EventPostsJob > ( ) ;
1563- await processEventsJob . RunAsync ( ) ;
1565+ await processEventsJob . RunAsync ( TestCancellationToken ) ;
15641566 await RefreshDataAsync ( ) ;
15651567
15661568 var events = await _eventRepository . GetAllAsync ( ) ;
@@ -1572,8 +1574,8 @@ await SendRequestAsync(r => r
15721574 . StatusCodeShouldBeOk ( )
15731575 ) ;
15741576
1575- string actualJson = await response . Content . ReadAsStringAsync ( ) ;
1576- string expectedJson = ( await File . ReadAllTextAsync ( Path . Combine ( dataPath , "event-serialization-response.json" ) ) )
1577+ string actualJson = await response . Content . ReadAsStringAsync ( TestCancellationToken ) ;
1578+ string expectedJson = ( await File . ReadAllTextAsync ( Path . Combine ( dataPath , "event-serialization-response.json" ) , TestCancellationToken ) )
15771579 . Replace ( "<EVENT_ID>" , processedEvent . Id )
15781580 . Replace ( "<STACK_ID>" , processedEvent . StackId ) ;
15791581
0 commit comments