1
0
mirror of https://github.com/bitwarden/server.git synced 2025-05-08 13:12:16 -05:00

Change to using Theory

This commit is contained in:
Hinton 2025-05-08 11:21:51 +02:00
parent e1f5c90e8a
commit 933c5c82ca
No known key found for this signature in database
GPG Key ID: 5F7295599C5D965C

View File

@ -7,37 +7,28 @@ using Xunit.Abstractions;
namespace Bit.Api.IntegrationTest.AdminConsole.Controllers;
public class OrganizationUsersControllerPerformanceTest : IClassFixture<ApiApplicationFactory>, IAsyncLifetime
public class OrganizationUsersControllerPerformanceTest
{
private readonly HttpClient _client;
private readonly ApiApplicationFactory _factory;
private readonly ITestOutputHelper _testOutputHelper;
public OrganizationUsersControllerPerformanceTest(ApiApplicationFactory factory, ITestOutputHelper testOutputHelper)
public OrganizationUsersControllerPerformanceTest(ITestOutputHelper testOutputHelper)
{
_factory = factory;
_factory = new ApiApplicationFactory();
_testOutputHelper = testOutputHelper;
_client = _factory.CreateClient();
}
public Task InitializeAsync()
{
return Task.CompletedTask;
}
public Task DisposeAsync()
{
_client.Dispose();
return Task.CompletedTask;
}
[Fact(Skip = "Performance testing")]
public async Task Get_SmallOrg()
[Theory(Skip = "Performance test")]
[InlineData(100)]
[InlineData(60000)]
public async Task GetAsync(int seats)
{
var db = _factory.GetDatabaseContext();
var seeder = new OrganizationWithUsersRecipe(db);
var orgId = seeder.Seed("Org", 100, "large.test");
var orgId = seeder.Seed("Org", seats, "large.test");
var tokens = await _factory.LoginAsync("admin@large.test", "c55hlJ/cfdvTd4awTXUqow6X3cOQCfGwn11o3HblnPs=");
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokens.Token);
@ -51,30 +42,6 @@ public class OrganizationUsersControllerPerformanceTest : IClassFixture<ApiAppli
Assert.NotEmpty(result);
stopwatch.Stop();
_testOutputHelper.WriteLine($"Seed: 100; Request duration: {stopwatch.ElapsedMilliseconds} ms");
_testOutputHelper.WriteLine($"Seed: {seats}; Request duration: {stopwatch.ElapsedMilliseconds} ms");
}
[Fact(Skip = "Performance testing")]
public async Task Get_LargeOrg()
{
var db = _factory.GetDatabaseContext();
var seeder = new OrganizationWithUsersRecipe(db);
var orgId = seeder.Seed("Org", 60000, "large.test");
var tokens = await _factory.LoginAsync("admin@large.test", "c55hlJ/cfdvTd4awTXUqow6X3cOQCfGwn11o3HblnPs=");
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokens.Token);
var stopwatch = System.Diagnostics.Stopwatch.StartNew();
var response = await _client.GetAsync($"/organizations/{orgId}/users?includeCollections=true");
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
var result = await response.Content.ReadAsStringAsync();
Assert.NotEmpty(result);
stopwatch.Stop();
_testOutputHelper.WriteLine($"Seed: 60000; Request duration: {stopwatch.ElapsedMilliseconds} ms");
}
}