Skip to content

Commit 9b536ea

Browse files
authored
Add A.M.Q perf tests (Azure#24019)
1 parent b66dea4 commit 9b536ea

14 files changed

+170
-9
lines changed

sdk/monitor/Azure.Monitor.Query/Azure.Monitor.Query.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Core.Experimental", "
1717
EndProject
1818
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Core", "..\..\core\Azure.Core\src\Azure.Core.csproj", "{753CF76A-180D-483D-93B8-BA7F243C5100}"
1919
EndProject
20+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Monitor.Query.Perf", "perf\Azure.Monitor.Query.Perf.csproj", "{E05FEA47-C575-44E1-83DA-A269A30122B1}"
21+
EndProject
2022
Global
2123
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2224
Debug|Any CPU = Debug|Any CPU
@@ -51,6 +53,10 @@ Global
5153
{753CF76A-180D-483D-93B8-BA7F243C5100}.Debug|Any CPU.Build.0 = Debug|Any CPU
5254
{753CF76A-180D-483D-93B8-BA7F243C5100}.Release|Any CPU.ActiveCfg = Release|Any CPU
5355
{753CF76A-180D-483D-93B8-BA7F243C5100}.Release|Any CPU.Build.0 = Release|Any CPU
56+
{E05FEA47-C575-44E1-83DA-A269A30122B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
57+
{E05FEA47-C575-44E1-83DA-A269A30122B1}.Debug|Any CPU.Build.0 = Debug|Any CPU
58+
{E05FEA47-C575-44E1-83DA-A269A30122B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
59+
{E05FEA47-C575-44E1-83DA-A269A30122B1}.Release|Any CPU.Build.0 = Release|Any CPU
5460
EndGlobalSection
5561
GlobalSection(SolutionProperties) = preSolution
5662
HideSolutionNode = FALSE
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<ProjectReference Include="..\..\..\..\common\Perf\Azure.Test.Perf\Azure.Test.Perf.csproj" />
9+
<ProjectReference Include="..\src\Azure.Monitor.Query.csproj" />
10+
<ProjectReference Include="$(AzureCoreTestFramework)" />
11+
<ProjectReference Include="..\tests\Azure.Monitor.Query.Tests.csproj" />
12+
</ItemGroup>
13+
14+
</Project>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
using Azure.Monitor.Query;
5+
using Azure.Monitor.Query.Tests;
6+
using Azure.Test.Perf;
7+
8+
namespace Azure.Data.AppConfiguration.Perf
9+
{
10+
public abstract class MonitorQueryPerfTest<T> : PerfTest<T> where T : PerfOptions
11+
{
12+
protected static MonitorQueryTestEnvironment TestEnvironment = new MonitorQueryTestEnvironment();
13+
protected string LogsQuery = @"
14+
let dt = datatable (DateTime: datetime, Bool:bool, Guid: guid, Int: int, Long:long, Double: double, String: string, Timespan: timespan, Decimal: decimal, Dynamic: dynamic)
15+
[
16+
datetime(2015-12-31 23:59:59.9), false, guid(74be27de-1e4e-49d9-b579-fe0b331d3642), 12345, 1, 12345.6789, 'string value', 10s, decimal(0.10101), dynamic({""a"":123, ""b"":""hello"", ""c"":[1,2,3], ""d"":{}})
17+
];
18+
range x from 1 to 100 step 1 | extend y=1 | join kind=fullouter dt on $left.y == $right.Long";
19+
20+
protected readonly LogsQueryClient LogsQueryClient;
21+
protected readonly MetricsQueryClient MetricsQueryClient;
22+
23+
protected MonitorQueryPerfTest(T options) : base(options)
24+
{
25+
LogsQueryClient = new LogsQueryClient(
26+
TestEnvironment.LogsEndpoint,
27+
TestEnvironment.Credential,
28+
ConfigureClientOptions(new LogsQueryClientOptions()));
29+
30+
MetricsQueryClient = new MetricsQueryClient(
31+
TestEnvironment.MetricsEndpoint,
32+
TestEnvironment.Credential,
33+
ConfigureClientOptions(new MetricsQueryClientOptions())
34+
);
35+
}
36+
}
37+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
using System.Reflection;
5+
using Azure.Test.Perf;
6+
7+
await PerfProgram.Main(Assembly.GetEntryAssembly(), args);
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
using System.Threading;
5+
using System.Threading.Tasks;
6+
using Azure.Core;
7+
using Azure.Test.Perf;
8+
9+
namespace Azure.Data.AppConfiguration.Perf
10+
{
11+
public sealed class QueryLogs: MonitorQueryPerfTest<PerfOptions>
12+
{
13+
public QueryLogs(CountOptions options) : base(options)
14+
{
15+
}
16+
17+
public override void Run(CancellationToken cancellationToken)
18+
{
19+
LogsQueryClient.Query(TestEnvironment.WorkspaceId, LogsQuery, DateTimeRange.All, cancellationToken: cancellationToken);
20+
}
21+
22+
public override async Task RunAsync(CancellationToken cancellationToken)
23+
{
24+
await LogsQueryClient.QueryAsync(TestEnvironment.WorkspaceId, LogsQuery, DateTimeRange.All, cancellationToken: cancellationToken).ConfigureAwait(false);
25+
}
26+
}
27+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
using System;
5+
using System.Threading;
6+
using System.Threading.Tasks;
7+
using Azure.Core;
8+
using Azure.Test.Perf;
9+
10+
namespace Azure.Data.AppConfiguration.Perf
11+
{
12+
public sealed class QueryLogsModels : MonitorQueryPerfTest<PerfOptions>
13+
{
14+
public QueryLogsModels(CountOptions options) : base(options)
15+
{
16+
}
17+
18+
public override void Run(CancellationToken cancellationToken)
19+
{
20+
LogsQueryClient.Query<TestModelForTypes>(TestEnvironment.WorkspaceId, LogsQuery, DateTimeRange.All, cancellationToken: cancellationToken);
21+
}
22+
23+
public override async Task RunAsync(CancellationToken cancellationToken)
24+
{
25+
await LogsQueryClient.QueryAsync<TestModelForTypes>(TestEnvironment.WorkspaceId, LogsQuery, DateTimeRange.All, cancellationToken: cancellationToken).ConfigureAwait(false);
26+
}
27+
28+
private record TestModelForTypes
29+
{
30+
public DateTimeOffset DateTime { get; set; }
31+
public bool Bool { get; set; }
32+
public Guid Guid { get; set; }
33+
public int Int { get; set; }
34+
public long Long { get; set; }
35+
public Double Double { get; set; }
36+
public String String { get; set; }
37+
public TimeSpan Timespan { get; set; }
38+
public Decimal Decimal { get; set; }
39+
public BinaryData Dynamic { get; set; }
40+
}
41+
}
42+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
using System.Threading;
5+
using System.Threading.Tasks;
6+
using Azure.Test.Perf;
7+
8+
namespace Azure.Data.AppConfiguration.Perf
9+
{
10+
public sealed class QueryMetrics : MonitorQueryPerfTest<PerfOptions>
11+
{
12+
private string[] _metrics = { "Event" };
13+
14+
public QueryMetrics(PerfOptions options) : base(options)
15+
{
16+
}
17+
18+
public override void Run(CancellationToken cancellationToken)
19+
{
20+
MetricsQueryClient.Query(TestEnvironment.MetricsResource, _metrics, cancellationToken: cancellationToken);
21+
}
22+
23+
public override async Task RunAsync(CancellationToken cancellationToken)
24+
{
25+
await MetricsQueryClient.QueryAsync(TestEnvironment.MetricsResource, _metrics, cancellationToken: cancellationToken);
26+
}
27+
}
28+
}

sdk/monitor/Azure.Monitor.Query/tests/LogsQueryClientClientLiveTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
namespace Azure.Monitor.Query.Tests
1515
{
16-
public class LogsQueryClientClientLiveTests : RecordedTestBase<MonitorQueryClientTestEnvironment>
16+
public class LogsQueryClientClientLiveTests : RecordedTestBase<MonitorQueryTestEnvironment>
1717
{
1818
private LogsTestData _logsTestData;
1919

sdk/monitor/Azure.Monitor.Query/tests/LogsQueryClientSamples.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
namespace Azure.Monitor.Query.Tests
1414
{
15-
public class LogsQueryClientSamples: SamplesBase<MonitorQueryClientTestEnvironment>
15+
public class LogsQueryClientSamples: SamplesBase<MonitorQueryTestEnvironment>
1616
{
1717
[Test]
1818
public async Task QueryLogsAsTable()

sdk/monitor/Azure.Monitor.Query/tests/LogsTestData.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ public class LogsTestData
4444
public string TableAName => TableANameSent + "_CL";
4545
public MonitorQueryTimeRange DataTimeRange => new MonitorQueryTimeRange(RetentionWindowStart, TimeSpan.FromDays(7));
4646

47-
private readonly MonitorQueryClientTestEnvironment _testEnvironment;
47+
private readonly MonitorQueryTestEnvironment _testEnvironment;
4848

49-
public LogsTestData(RecordedTestBase<MonitorQueryClientTestEnvironment> test)
49+
public LogsTestData(RecordedTestBase<MonitorQueryTestEnvironment> test)
5050
{
5151
_testEnvironment = test.TestEnvironment;
5252

0 commit comments

Comments
 (0)