Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merging pmaytak/perf #636

Merged
merged 23 commits into from
Oct 2, 2020
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
1fdba23
Perf project.
pmaytak Sep 9, 2020
56799dc
Add TestController.
pmaytak Sep 17, 2020
e774ab9
Added Perf.Client project that creates and HttpClient and sends reque…
pmaytak Sep 21, 2020
e95582f
Updated to not using the token array. Small logging fixes.
pmaytak Sep 21, 2020
ea0711a
Mostly updated to use AcquireTokenSilent instead of Tokens array.
pmaytak Sep 22, 2020
431e99b
Added a duration check to the inner loop.
pmaytak Sep 22, 2020
c8e5c6e
Disable JWT Handler debug messages. Add Accept header.
pmaytak Sep 22, 2020
540b3e7
Added empty action to weather controller.
pmaytak Sep 23, 2020
e3cc4ef
serialize msal cache + add timers
jennyf19 Sep 23, 2020
8c6923a
Added three controllers with different dependencies to IntegrationTes…
pmaytak Sep 24, 2020
18a003b
Update Kesterl Url.
pmaytak Sep 24, 2020
14ef2c7
add msal logs
jennyf19 Sep 24, 2020
0f4cad7
Added EventCounter counters for in-memory cache for read, write, remo…
pmaytak Sep 25, 2020
6550c59
Jennyf/perf (#612)
jennyf19 Sep 25, 2020
9cde630
changes to test runner (#615)
jennyf19 Sep 25, 2020
61244d0
Added EventCounter to distributed memory cache. Created folder EventS…
pmaytak Sep 25, 2020
73a89ee
Merge Henrikm/testrunner into pmaytak/perf (#634)
pmaytak Sep 30, 2020
cbbd4ec
Clean up.
pmaytak Sep 30, 2020
70afeab
Clean up.
pmaytak Sep 30, 2020
8788976
Renamed Perf folder to PerformanceTests. Moved perf related code from…
pmaytak Oct 1, 2020
b33b94f
Fixes.
pmaytak Oct 1, 2020
aa4a04f
Fixes.
pmaytak Oct 1, 2020
0b2c8d0
PR feedback.
pmaytak Oct 2, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions Microsoft.Identity.Web-without-blasorwasm2-sample.sln
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TodoListService", "tests\We
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TodoListClient", "tests\WebAppCallsWebApiCallsGraph\Client\TodoListClient.csproj", "{829BA99E-0E31-4CEE-9A59-CD91531B5ED4}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Identity.Web.Test.Integration", "tests\Microsoft.Identity.Web.Test.Integration\Microsoft.Identity.Web.Test.Integration.csproj", "{24DE8503-90EB-4788-A603-681DD4D7DB50}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Identity.Web.Test.Common", "tests\Microsoft.Identity.Web.Test.Common\Microsoft.Identity.Web.Test.Common.csproj", "{F37646FF-C346-4FF5-A111-2269952AB376}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Identity.Web.Test.LabInfrastructure", "tests\Microsoft.Identity.Web.Test.LabInfrastructure\Microsoft.Identity.Web.Test.LabInfrastructure.csproj", "{A9F4539F-51AB-4D98-9204-D76B336E0BE8}"
Expand Down Expand Up @@ -86,10 +84,6 @@ Global
{829BA99E-0E31-4CEE-9A59-CD91531B5ED4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{829BA99E-0E31-4CEE-9A59-CD91531B5ED4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{829BA99E-0E31-4CEE-9A59-CD91531B5ED4}.Release|Any CPU.Build.0 = Release|Any CPU
{24DE8503-90EB-4788-A603-681DD4D7DB50}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{24DE8503-90EB-4788-A603-681DD4D7DB50}.Debug|Any CPU.Build.0 = Debug|Any CPU
{24DE8503-90EB-4788-A603-681DD4D7DB50}.Release|Any CPU.ActiveCfg = Release|Any CPU
{24DE8503-90EB-4788-A603-681DD4D7DB50}.Release|Any CPU.Build.0 = Release|Any CPU
{F37646FF-C346-4FF5-A111-2269952AB376}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F37646FF-C346-4FF5-A111-2269952AB376}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F37646FF-C346-4FF5-A111-2269952AB376}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -122,7 +116,6 @@ Global
{9EAE4CCD-EDEB-4FAE-B873-F24714F070A4} = {48D133A6-50D7-4783-9048-148E4B4E1353}
{A6254A6A-B560-4DC1-8348-DED4D947ADCE} = {DA125992-5622-4D9D-B7AB-79CDC45A66B0}
{829BA99E-0E31-4CEE-9A59-CD91531B5ED4} = {DA125992-5622-4D9D-B7AB-79CDC45A66B0}
{24DE8503-90EB-4788-A603-681DD4D7DB50} = {79310504-1334-4F14-93C4-1240913224BA}
{F37646FF-C346-4FF5-A111-2269952AB376} = {79310504-1334-4F14-93C4-1240913224BA}
{A9F4539F-51AB-4D98-9204-D76B336E0BE8} = {79310504-1334-4F14-93C4-1240913224BA}
{893905EA-94D6-4F71-957A-43B194751DC7} = {D845507B-00E8-4506-954E-519CBC0B9F83}
Expand Down
27 changes: 27 additions & 0 deletions Microsoft.Identity.Web.sln
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,17 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Identity.Web.Micr
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebAppUiTests", "tests\IntegrationTests\WebAppUiTests\WebAppUiTests.csproj", "{25C82DF8-F0C8-4B6C-B8BA-6018C40ADE6F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Identity.Web.Perf.Benchmark", "tests\PerformanceTests\Microsoft.Identity.Web.Perf.Benchmark\Microsoft.Identity.Web.Perf.Benchmark.csproj", "{3C91F382-EDF8-45A3-B50D-330234C4C7C3}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PerformanceTests", "PerformanceTests", "{9B8BE2D5-9E66-450F-94AB-8E8DD954C62C}"
ProjectSection(SolutionItems) = preProject
tests\PerformanceTests\GenerateBulkUsers.ps1 = tests\PerformanceTests\GenerateBulkUsers.ps1
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Identity.Web.Perf.Client", "tests\PerformanceTests\Microsoft.Identity.Web.Perf.Client\Microsoft.Identity.Web.Perf.Client.csproj", "{DE4BDA66-2918-4DB1-804A-4D5A8D7BAB3C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PerformanceTestService", "tests\PerformanceTests\PerformanceTestService\PerformanceTestService.csproj", "{3AA1208A-3F05-4420-A9C6-B5B7C09EFE4A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -193,6 +204,18 @@ Global
{25C82DF8-F0C8-4B6C-B8BA-6018C40ADE6F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{25C82DF8-F0C8-4B6C-B8BA-6018C40ADE6F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{25C82DF8-F0C8-4B6C-B8BA-6018C40ADE6F}.Release|Any CPU.Build.0 = Release|Any CPU
{3C91F382-EDF8-45A3-B50D-330234C4C7C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3C91F382-EDF8-45A3-B50D-330234C4C7C3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3C91F382-EDF8-45A3-B50D-330234C4C7C3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3C91F382-EDF8-45A3-B50D-330234C4C7C3}.Release|Any CPU.Build.0 = Release|Any CPU
{DE4BDA66-2918-4DB1-804A-4D5A8D7BAB3C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DE4BDA66-2918-4DB1-804A-4D5A8D7BAB3C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DE4BDA66-2918-4DB1-804A-4D5A8D7BAB3C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DE4BDA66-2918-4DB1-804A-4D5A8D7BAB3C}.Release|Any CPU.Build.0 = Release|Any CPU
{3AA1208A-3F05-4420-A9C6-B5B7C09EFE4A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3AA1208A-3F05-4420-A9C6-B5B7C09EFE4A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3AA1208A-3F05-4420-A9C6-B5B7C09EFE4A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3AA1208A-3F05-4420-A9C6-B5B7C09EFE4A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -227,6 +250,10 @@ Global
{3EF671C3-7BD5-4125-8A98-EC34549BCDDD} = {79310504-1334-4F14-93C4-1240913224BA}
{D3C5B5F5-617E-4206-B9EF-915A27AF6863} = {3EF671C3-7BD5-4125-8A98-EC34549BCDDD}
{25C82DF8-F0C8-4B6C-B8BA-6018C40ADE6F} = {3EF671C3-7BD5-4125-8A98-EC34549BCDDD}
{3C91F382-EDF8-45A3-B50D-330234C4C7C3} = {9B8BE2D5-9E66-450F-94AB-8E8DD954C62C}
{9B8BE2D5-9E66-450F-94AB-8E8DD954C62C} = {79310504-1334-4F14-93C4-1240913224BA}
{DE4BDA66-2918-4DB1-804A-4D5A8D7BAB3C} = {9B8BE2D5-9E66-450F-94AB-8E8DD954C62C}
{3AA1208A-3F05-4420-A9C6-B5B7C09EFE4A} = {9B8BE2D5-9E66-450F-94AB-8E8DD954C62C}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F4FA8C4C-3251-41CC-939B-7892F5798549}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Graph;
Expand All @@ -14,7 +14,7 @@
namespace IntegrationTestService.Controllers
{
[ApiController]
[Microsoft.AspNetCore.Authorization.Authorize]
[Authorize]
[Route("SecurePage")]
public class WeatherForecastController : ControllerBase
{
Expand All @@ -34,7 +34,7 @@ public WeatherForecastController(
_graphServiceClient = graphServiceClient;
}

[HttpGet(TestConstants.SecurePageGetTokenAsync)]
[HttpGet(TestConstants.SecurePageGetTokenForUserAsync)]
public async Task<string> GetTokenAsync()
{
return await _tokenAcquisition.GetAccessTokenForUserAsync(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1; net5.0</TargetFrameworks>
<TargetFramework>netcoreapp3.1</TargetFramework>
<IsPackable>false</IsPackable>
pmaytak marked this conversation as resolved.
Show resolved Hide resolved
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>../../../build/MSAL.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\src\Microsoft.Identity.Web.MicrosoftGraph\Microsoft.Identity.Web.MicrosoftGraph.csproj" />
<ProjectReference Include="..\..\..\src\Microsoft.Identity.Web\Microsoft.Identity.Web.csproj" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
Expand Down
5 changes: 2 additions & 3 deletions tests/IntegrationTests/IntegrationTestService/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Identity.Client;
using Microsoft.Identity.Web;
using Microsoft.Identity.Web.Test.Common;
using Microsoft.Identity.Web.Test.LabInfrastructure;
Expand All @@ -22,12 +21,11 @@ public Startup(IConfiguration configuration)
}

public IConfiguration Configuration { get; }
private KeyVaultSecretsProvider _keyVault;

// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
_keyVault = new KeyVaultSecretsProvider();
KeyVaultSecretsProvider _keyVault = new KeyVaultSecretsProvider();
string ccaSecret = _keyVault.GetSecret(TestConstants.OBOClientKeyVaultUri).Value;

var builder = services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
Expand All @@ -42,6 +40,7 @@ public void ConfigureServices(IServiceCollection services)
{
options.ClientSecret = ccaSecret;
});

services.AddRazorPages(options =>
{
options.Conventions.AuthorizePage("/SecurePage");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1; net5.0</TargetFrameworks>
<TargetFramework>netcoreapp3.1</TargetFramework>
pmaytak marked this conversation as resolved.
Show resolved Hide resolved
<IsPackable>false</IsPackable>
</PropertyGroup>

Expand Down
7 changes: 6 additions & 1 deletion tests/Microsoft.Identity.Web.Test.Common/TestConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,12 @@ public static class TestConstants
public const string KeyVaultReference = "AzureADIdentityDivisionTestAgentCert";

// Integration tests
public const string SecurePageGetTokenAsync = "/SecurePage/GetTokenAsync";
public const string EmptyGetEmpty = "/Empty";
public const string TokenAcquisitionGetEmpty = "/TokenAcquisition";
public const string GraphClientGetEmpty = "/GraphClient";
public const string SecurePageGetEmpty = "/SecurePage/GetEmpty";
pmaytak marked this conversation as resolved.
Show resolved Hide resolved
public const string SecurePageGetTokenForUserAsync = "/SecurePage/GetTokenForUserAsync";
public const string SecurePageGetTokenForAppAsync = "/SecurePage/GetTokenForAppAsync";
public const string SecurePageCallDownstreamWebApi = "/SecurePage/CallDownstreamWebApiAsync";
public const string SecurePageCallDownstreamWebApiGeneric = "/SecurePage/CallDownstreamWebApiGenericAsync";
public const string SecurePageCallDownstreamWebApiGenericWithTokenAcquisitionOptions = "/SecurePage/CallDownstreamWebApiGenericWithTokenAcquisitionOptionsAsync";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,40 +31,39 @@ public AcquireTokenForUserIntegrationTests(WebApplicationFactory<Startup> factor
private readonly WebApplicationFactory<Startup> _factory;

[Theory]
[InlineData(TestConstants.SecurePageGetTokenAsync)]
[InlineData(TestConstants.SecurePageGetTokenForUserAsync)]
[InlineData(TestConstants.SecurePageCallDownstreamWebApi)]
[InlineData(TestConstants.SecurePageCallDownstreamWebApiGeneric)]
[InlineData(TestConstants.SecurePageCallMicrosoftGraph)]
[InlineData(TestConstants.SecurePageCallDownstreamWebApiGenericWithTokenAcquisitionOptions)]
[InlineData(TestConstants.SecurePageGetTokenAsync, false)]
// [InlineData(TestConstants.SecurePageCallDownstreamWebApi, false)]
// [InlineData(TestConstants.SecurePageCallDownstreamWebApiGeneric, false)]
// [InlineData(TestConstants.SecurePageCallMicrosoftGraph, false)]
[InlineData(TestConstants.SecurePageCallMicrosoftGraph, false)]
[InlineData(TestConstants.SecurePageCallDownstreamWebApi, false)]
[InlineData(TestConstants.SecurePageCallDownstreamWebApiGeneric, false)]
public async Task GetTokenForUserAsync(
string webApiUrl,
bool addInMemoryTokenCache = true)
string webApiUrl,
bool addInMemoryTokenCache = true)
{
// Arrange
var client = _factory.WithWebHostBuilder(builder =>
{
builder.ConfigureServices(services =>
{
if (!addInMemoryTokenCache)
if (addInMemoryTokenCache)
{
services.AddDistributedMemoryCache();
services.AddDistributedTokenCaches();
services.AddInMemoryTokenCaches();
}
else
{
services.AddInMemoryTokenCaches();
services.AddDistributedMemoryCache();
services.AddDistributedTokenCaches();
}

services.BuildServiceProvider();
});
})
.CreateClient(new WebApplicationFactoryClientOptions
{
AllowAutoRedirect = false,
AllowAutoRedirect = false,
});

var result = await AcquireTokenForLabUserAsync().ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1; net5.0</TargetFrameworks>
<TargetFramework>netcoreapp3.1</TargetFramework>
pmaytak marked this conversation as resolved.
Show resolved Hide resolved

<IsPackable>false</IsPackable>

Expand Down
34 changes: 34 additions & 0 deletions tests/PerformanceTests/GenerateBulkUsers.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
param(
[Parameter(Mandatory=$true)]
$TenantId,
[Parameter(Mandatory=$true, HelpMessage="Ex: domain.microsoft.com")]
$TenantDomain,
[Parameter(Mandatory=$true)]
$Password,
[Parameter(Mandatory=$true, HelpMessage="First user created will start with this suffix")]
$StartAtUserSuffix,
[Parameter(Mandatory=$true, HelpMessage="Number of users to create")]
$UsersToCreate,
[Parameter(HelpMessage="Prefix for each username")]
$UsernamePrefix = "MIWTestUser"
)

Write-Host "Creating ${UsersToCreate} users starting from user ${UsernamePrefix}${StartAtUserSuffix}"

Connect-AzureAD -TenantId $TenantId
Get-AzureADTenantDetail
$PasswordProfile = New-Object -TypeName Microsoft.Open.AzureAD.Model.PasswordProfile
$PasswordProfile.Password = $password
$PasswordProfile.ForceChangePasswordNextLogin = $false

$lastSuffix = $StartAtUserSuffix + $UsersToCreate
for ($i = $StartAtUserSuffix ; $i -lt $lastSuffix ; $i++)
{
$username = "${UsernamePrefix}${i}"
$displayName = "${username}FName ${username}LName"
$upn = "${Username}@${TenantDomain}"

New-AzureADUser -UserPrincipalName $upn -MailNickName $username -DisplayName $displayName -PasswordProfile $PasswordProfile -AccountEnabled $true
}

Get-AzureADUser -SearchString "MIWTestUser" | measure
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.12.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="3.1.8" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\IntegrationTests\IntegrationTestService\IntegrationTestService.csproj" />
<ProjectReference Include="..\..\Microsoft.Identity.Web.Test.LabInfrastructure\Microsoft.Identity.Web.Test.LabInfrastructure.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using System.Linq;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Running;
using BenchmarkDotNet.Toolchains.InProcess.Emit;

namespace Microsoft.Identity.Web.Perf.Benchmark
{
class Program
{
/// <remarks>
/// Invocation count - how many times to run a benchmark method in an iteration (set). Is probably interchangeable with IterationTime.
/// Iteration (target) count - how many sets of benchmark methods to run. The statistics of invocations are grouped per set.
/// Ex: Iteration count 2, invocation count 3 - 2 sets of 3 invocations each; 6 total.
/// Launch count - how many times to start the benchmark process.
/// Warmup count - how many iterations to run before the statistics are gathered.
/// </remarks>
static void Main(string[] args)
{
BenchmarkRunner.Run(typeof(Program).Assembly,
DefaultConfig.Instance
.WithOptions(ConfigOptions.DontOverwriteResults)
.AddJob(
Job.Default
.WithId("Job-TokenAcquisitionTests")
.WithLaunchCount(1)
//.WithInvocationCount(4)
//.WithIterationCount(2)
//.WithWarmupCount(0)
//.WithUnrollFactor(1)
));
Console.ReadKey();
}
}
}
Loading