Skip to content

Commit 26ee2ff

Browse files
niemyjskiCopilot
andauthored
Upgraded to xunit.v3 (#2071)
* Upgraded to xunit.v3 * Updated to latest foundatio nightlies * Cleans up event user description queue Ensures the event user description queue is properly cleaned up during tests to prevent potential interference between test runs. * Apply suggestion from @Copilot Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
1 parent 458a813 commit 26ee2ff

File tree

62 files changed

+137
-191
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+137
-191
lines changed

src/Exceptionless.AppHost/Exceptionless.AppHost.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<PackageReference Include="Aspire.Hosting.JavaScript" Version="13.1.0" />
1212
<PackageReference Include="Aspire.Hosting.Redis" Version="13.1.0" />
1313
<PackageReference Include="AspNetCore.HealthChecks.Elasticsearch" Version="9.0.0" />
14-
<PackageReference Include="Foundatio.Minio" Version="12.0.0" />
14+
<PackageReference Include="Foundatio.Minio" Version="12.0.1-preview.0.8" />
1515
</ItemGroup>
1616

1717
<ItemGroup>

src/Exceptionless.Core/Exceptionless.Core.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
<PackageReference Include="AutoMapper" Version="14.0.0" />
2424
<PackageReference Include="Exceptionless.DateTimeExtensions" Version="4.0.1" />
2525
<PackageReference Include="FluentValidation" Version="12.1.1" />
26-
<PackageReference Include="Foundatio.Extensions.Hosting" Version="12.0.0" />
27-
<PackageReference Include="Foundatio.JsonNet" Version="12.0.0" />
26+
<PackageReference Include="Foundatio.Extensions.Hosting" Version="12.0.1-preview.0.71" />
27+
<PackageReference Include="Foundatio.JsonNet" Version="12.0.1-preview.0.71" />
2828
<PackageReference Include="MiniValidation" Version="0.9.2" />
2929
<PackageReference Include="NEST.JsonNetSerializer" Version="7.17.5" />
3030
<PackageReference Include="Handlebars.Net" Version="2.1.6" />
@@ -35,7 +35,7 @@
3535
<PackageReference Include="Stripe.net" Version="47.4.0" />
3636
<PackageReference Include="System.DirectoryServices" Version="10.0.1" />
3737
<PackageReference Include="UAParser" Version="3.1.47" />
38-
<PackageReference Include="Foundatio.Repositories.Elasticsearch" Version="7.17.17" Condition="'$(ReferenceFoundatioRepositoriesSource)' == '' OR '$(ReferenceFoundatioRepositoriesSource)' == 'false'" />
38+
<PackageReference Include="Foundatio.Repositories.Elasticsearch" Version="7.17.18-preview.0.20" Condition="'$(ReferenceFoundatioRepositoriesSource)' == '' OR '$(ReferenceFoundatioRepositoriesSource)' == 'false'" />
3939
<ProjectReference Include="..\..\..\..\Foundatio\Foundatio.Repositories\src\Foundatio.Repositories.Elasticsearch\Foundatio.Repositories.Elasticsearch.csproj" Condition="'$(ReferenceFoundatioRepositoriesSource)' == 'true'" />
4040
</ItemGroup>
4141
</Project>

src/Exceptionless.Insulation/Exceptionless.Insulation.csproj

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<ItemGroup>
3-
<PackageReference Include="AWSSDK.CloudWatch" Version="4.0.6.4" />
4-
<PackageReference Include="AWSSDK.Core" Version="4.0.3.8" />
5-
<PackageReference Include="AWSSDK.S3" Version="4.0.17" />
6-
<PackageReference Include="AWSSDK.SQS" Version="4.0.2.11" />
7-
83
<PackageReference Include="Geocoding.Google" Version="4.0.1" />
94
<PackageReference Include="MaxMind.GeoIP2" Version="5.4.1" />
10-
<PackageReference Include="Foundatio.Aliyun" Version="12.0.0" />
11-
<PackageReference Include="Foundatio.AWS" Version="12.0.0" />
12-
<PackageReference Include="Foundatio.AzureStorage" Version="12.0.0" />
13-
<PackageReference Include="Foundatio.Minio" Version="12.0.0" />
14-
<PackageReference Include="Foundatio.RabbitMQ" Version="12.0.0" />
15-
<PackageReference Include="Foundatio.Redis" Version="12.0.1-alpha.0.9" />
5+
<PackageReference Include="Foundatio.Aliyun" Version="12.0.1-preview.0.6" />
6+
<PackageReference Include="Foundatio.AWS" Version="12.0.1-preview.0.9" />
7+
<PackageReference Include="Foundatio.AzureStorage" Version="12.0.1-preview.0.7" />
8+
<PackageReference Include="Foundatio.Minio" Version="12.0.1-preview.0.8" />
9+
<PackageReference Include="Foundatio.RabbitMQ" Version="12.0.1-preview.0.9" />
10+
<PackageReference Include="Foundatio.Redis" Version="12.0.1-preview.0.20" />
1611
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="10.0.1" />
1712
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="10.0.1" />
1813
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.1" />

tests/Exceptionless.Tests/AppWebHostFactory.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class AppWebHostFactory : WebApplicationFactory<Startup>, IAsyncLifetime
1414

1515
public DistributedApplication App => _app ?? throw new InvalidOperationException("The application is not initialized");
1616

17-
public Task InitializeAsync()
17+
public async ValueTask InitializeAsync()
1818
{
1919
var options = new DistributedApplicationOptions { AssemblyName = typeof(ElasticsearchResource).Assembly.FullName, DisableDashboard = true };
2020
var builder = DistributedApplication.CreateBuilder(options);
@@ -28,7 +28,7 @@ public Task InitializeAsync()
2828

2929
_app = builder.Build();
3030

31-
return _app.StartAsync();
31+
await _app.StartAsync();
3232
}
3333

3434
protected override void ConfigureWebHost(IWebHostBuilder builder)
@@ -46,11 +46,12 @@ protected override IHostBuilder CreateHostBuilder()
4646
return Web.Program.CreateHostBuilder(config, Environments.Development);
4747
}
4848

49-
async Task IAsyncLifetime.DisposeAsync()
49+
public override async ValueTask DisposeAsync()
5050
{
5151
if (_app is not null)
5252
{
5353
await _app.DisposeAsync();
5454
}
55+
await base.DisposeAsync();
5556
}
5657
}

tests/Exceptionless.Tests/Billing/BillingManagerTests.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
using Exceptionless.Core.Billing;
1+
using Exceptionless.Core.Billing;
22
using Xunit;
3-
using Xunit.Abstractions;
43

54
namespace Exceptionless.Tests.Billing;
65

tests/Exceptionless.Tests/Controllers/AuthControllerTests.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Exceptionless.Core.Authorization;
1+
using Exceptionless.Core.Authorization;
22
using Exceptionless.Core.Configuration;
33
using Exceptionless.Core.Extensions;
44
using Exceptionless.Core.Models;
@@ -15,7 +15,6 @@
1515
using Foundatio.Repositories;
1616
using Microsoft.AspNetCore.Mvc;
1717
using Xunit;
18-
using Xunit.Abstractions;
1918
using User = Exceptionless.Core.Models.User;
2019

2120
namespace Exceptionless.Tests.Controllers;

tests/Exceptionless.Tests/Controllers/EventControllerTests.cs

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
using Foundatio.Repositories.Models;
2727
using Microsoft.Net.Http.Headers;
2828
using Xunit;
29-
using Xunit.Abstractions;
3029
using MediaTypeHeaderValue = System.Net.Http.Headers.MediaTypeHeaderValue;
3130
using 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

Comments
 (0)