Skip to content

Commit daf5a88

Browse files
authored
add Peaky tests (#1144)
* build modifications to allow disabling Arcade * add Peaky infra and tests * remove InternalsVisibleTo * more Arcade fixes * cleanup * update Peaky packages * don't run Peaky tests in CI
1 parent 01cbe4f commit daf5a88

39 files changed

+1444
-124
lines changed

Directory.Build.targets

-11
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,6 @@
22

33
<Import Project="Sdk.targets" Sdk="Microsoft.DotNet.Arcade.Sdk" Condition="'$(DisableArcade)' != '1'" />
44

5-
<!--
6-
Arcade normally auto-adds the appropriate test packages, but in non-arcade scenarios they must be re-added.
7-
8-
Not doing this in each project because duplicate PackageReferences causes an Arcade build failure.
9-
-->
10-
<ItemGroup Condition="($(MSBuildProjectName.EndsWith('.Tests')) OR $(MSBuildProjectName.EndsWith('.IntegrationTests'))) AND '$(DisableArcade)' == '1'">
11-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
12-
<PackageReference Include="xunit" Version="2.4.2" />
13-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
14-
</ItemGroup>
15-
165
<!-- Consolidate FSharp package versions -->
176
<ItemGroup>
187
<PackageReference Update="FSharp.Core" Version="7.0.200" />

Directory.Packages.props

+23-14
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,33 @@
33
<PropertyGroup>
44
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
55
</PropertyGroup>
6+
67
<ItemGroup>
7-
<PackageVersion Include="Microsoft.DotNet.Interactive.CSharpProject" Version="1.0.0-beta.24168.2" />
8-
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.2" />
9-
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.2" />
10-
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="8.0.2" />
11-
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.2" />
12-
<PackageVersion Include="System.Drawing.Common" Version="8.0.2" />
13-
<PackageVersion Include="System.Net.Http" Version="4.3.4" />
14-
<PackageVersion Include="System.Security.Cryptography.X509Certificates" Version="4.3.2" />
15-
<PackageVersion Include="System.Reactive" Version="6.0.0" />
16-
<PackageVersion Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
178
<PackageVersion Include="Assent" Version="2.3.2" />
9+
<PackageVersion Include="coverlet.collector" Version="6.0.0" />
1810
<PackageVersion Include="FluentAssertions" Version="6.12.0" />
11+
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.3" />
12+
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="8.0.3" />
13+
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.3" />
14+
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.3" />
15+
<PackageVersion Include="Microsoft.DotNet.Interactive.CSharpProject" Version="1.0.0-beta.24168.2" />
1916
<PackageVersion Include="Microsoft.Playwright" Version="1.41.2" />
20-
<PackageVersion Include="coverlet.collector" Version="6.0.0" />
17+
<PackageVersion Include="peaky.client" Version="4.0.73" />
18+
<PackageVersion Include="peaky.xunit" Version="4.0.73" />
19+
<PackageVersion Include="Peaky" Version="4.0.77-beta" />
2120
<PackageVersion Include="PocketLogger" Version="0.8.2" />
22-
<PackageVersion Update="Microsoft.NET.Test.Sdk" Version="17.4.0" />
23-
<PackageVersion Update="xunit.runner.visualstudio" Version="2.4.5" />
24-
<PackageVersion Update="xunit" Version="2.4.2" />
21+
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.5.0" />
22+
<PackageVersion Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
23+
<PackageVersion Include="System.Drawing.Common" Version="8.0.3" />
24+
<PackageVersion Include="System.Net.Http" Version="4.3.4" />
25+
<PackageVersion Include="System.Reactive" Version="6.0.0" />
26+
<PackageVersion Include="System.Security.Cryptography.X509Certificates" Version="4.3.2" />
27+
<PackageVersion Include="xunit" Version="2.7.0" />
28+
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.7" />
29+
</ItemGroup>
30+
31+
<ItemGroup Condition="'$(DisableArcade)' == '1'">
32+
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
2533
</ItemGroup>
34+
2635
</Project>

PeakyTests.ipynb

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": null,
6+
"metadata": {
7+
"dotnet_interactive": {
8+
"language": "csharp"
9+
},
10+
"polyglot_notebook": {
11+
"kernelName": "csharp"
12+
},
13+
"vscode": {
14+
"languageId": "polyglot-notebook"
15+
}
16+
},
17+
"outputs": [],
18+
"source": [
19+
"#r \"nuget:Peaky.Client\"\n",
20+
"\n",
21+
"using Peaky.Client;\n",
22+
"using System.Net.Http;\n",
23+
"\n",
24+
"var peakyClient = new PeakyClient(new Uri(\"https://localhost:7061/tests\"));"
25+
]
26+
},
27+
{
28+
"cell_type": "code",
29+
"execution_count": null,
30+
"metadata": {
31+
"dotnet_interactive": {
32+
"language": "csharp"
33+
},
34+
"polyglot_notebook": {
35+
"kernelName": "csharp"
36+
},
37+
"vscode": {
38+
"languageId": "polyglot-notebook"
39+
}
40+
},
41+
"outputs": [],
42+
"source": [
43+
"var tests = await peakyClient.GetTestsAsync();\n",
44+
"tests"
45+
]
46+
},
47+
{
48+
"cell_type": "code",
49+
"execution_count": null,
50+
"metadata": {
51+
"dotnet_interactive": {
52+
"language": "csharp"
53+
},
54+
"polyglot_notebook": {
55+
"kernelName": "csharp"
56+
},
57+
"vscode": {
58+
"languageId": "polyglot-notebook"
59+
}
60+
},
61+
"outputs": [],
62+
"source": [
63+
"foreach (var test in tests)\n",
64+
"{\n",
65+
" var result = await test.GetResultAsync();\n",
66+
" result.Display();\n",
67+
"}"
68+
]
69+
}
70+
],
71+
"metadata": {
72+
"language_info": {
73+
"name": "python"
74+
}
75+
},
76+
"nbformat": 4,
77+
"nbformat_minor": 2
78+
}

TryDotNet.v3.ncrunchsolution

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<SolutionConfiguration>
22
<Settings>
33
<AllowParallelTestExecution>True</AllowParallelTestExecution>
4+
<EnableRDI>True</EnableRDI>
5+
<RdiConfigured>True</RdiConfigured>
46
<SolutionConfigured>True</SolutionConfigured>
57
</Settings>
68
</SolutionConfiguration>

eng/Versions.props

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<UsingToolSourceLink>false</UsingToolSourceLink>
55
<!-- opt-in properties -->
66
<UsingToolNuGetRepack>true</UsingToolNuGetRepack>
7+
<UsingToolXUnit>false</UsingToolXUnit>
78
<UsingToolSymbolUploader>true</UsingToolSymbolUploader>
89
<TestRunnerAdditionalArguments>-parallel none</TestRunnerAdditionalArguments>
910
</PropertyGroup>

src/Microsoft.TryDotNet.IntegrationTests/LearnFixture.cs

+3-14
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
using System.Text;
88
using System.Text.RegularExpressions;
99
using System.Threading.Tasks;
10-
1110
using Xunit;
1211

1312
namespace Microsoft.TryDotNet.IntegrationTests;
1413

1514
public partial class LearnFixture : IDisposable, IAsyncLifetime
1615
{
1716
private Process? _httpServer;
17+
1818
public Uri? Url { get; private set; }
1919

2020
public void Dispose()
@@ -24,7 +24,6 @@ public void Dispose()
2424
_httpServer = null;
2525
}
2626

27-
2827
public async Task InitializeAsync()
2928
{
3029
if (_httpServer is null)
@@ -34,13 +33,12 @@ public async Task InitializeAsync()
3433
var uriFound = false;
3534
_httpServer = CommandLine.StartProcess("pwsh", "-c npx http-server --cors", new DirectoryInfo(SitePath), (output) =>
3635
{
37-
3836
if (!uriFound)
3937
{
4038
buffer.AppendLine(output);
4139
var allText = buffer.ToString();
4240
var match = Regex.Match(allText, @".*(?<uri>http://\d+\.\d+\.\d+\.\d+:\d+).*",
43-
RegexOptions.Multiline);
41+
RegexOptions.Multiline);
4442
if (match.Success)
4543
{
4644
if (Uri.TryCreate(match.Groups["uri"].Value, UriKind.Absolute, out var uri))
@@ -58,16 +56,7 @@ public async Task InitializeAsync()
5856

5957
public Task DisposeAsync()
6058
{
61-
Dispose();
59+
Dispose();
6260
return Task.CompletedTask;
6361
}
64-
}
65-
66-
internal static class UriExtensions
67-
{
68-
public static Uri ToLocalHost(this Uri source)
69-
{
70-
var root = new Uri($"{source.Scheme}://127.0.0.1:{source.Port}");
71-
return new Uri(root,source.PathAndQuery);
72-
}
7362
}

src/Microsoft.TryDotNet.IntegrationTests/Microsoft.TryDotNet.IntegrationTests.csproj

+13-22
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313

1414
<ItemGroup>
1515
<PackageReference Include="Assent" />
16-
<PackageReference Include="FluentAssertions" />
1716
<PackageReference Include="Microsoft.Playwright" />
17+
<PackageReference Include="peaky.client" />
18+
<PackageReference Include="peaky.xunit" />
1819
<PackageReference Include="coverlet.collector" >
1920
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2021
<PrivateAssets>all</PrivateAssets>
@@ -24,21 +25,22 @@
2425
</PackageReference>
2526
<PackageReference Include="System.Net.Http" />
2627
<PackageReference Include="System.Security.Cryptography.X509Certificates" />
28+
<PackageReference Include="xunit" />
29+
<PackageReference Include="xunit.runner.visualstudio">
30+
<PrivateAssets>all</PrivateAssets>
31+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
32+
</PackageReference>
33+
</ItemGroup>
34+
35+
<ItemGroup Condition="'$(DisableArcade)' == '1'">
36+
<PackageReference Include="Microsoft.NET.Test.Sdk" />
2737
</ItemGroup>
2838

2939
<ItemGroup>
3040
<ProjectReference Include="..\Microsoft.TryDotNet\Microsoft.TryDotNet.csproj" />
3141
</ItemGroup>
3242

3343
<Target Name="DoSomethingElse" BeforeTargets="maybe">
34-
<!--<ItemGroup>
35-
<GeneratedLines Remove="*" />
36-
<GeneratedLines Include="namespace Microsoft.TryDotNet.IntegrationTests%3b"/>
37-
<GeneratedLines Include="public partial class AspNetProcess {"/>
38-
<GeneratedLines Include="public const string ToolPublishedPath = @&quot;$(PublishLocation)&quot;%3b"/>
39-
<GeneratedLines Include="}"/>
40-
</ItemGroup>-->
41-
4244
<PropertyGroup>
4345
<GeneratedContent>
4446
<![CDATA[
@@ -62,20 +64,9 @@ public partial class LearnFixture {
6264
<Compile Include="$(IntermediateOutputPath)\$(GeneratedFileName)" />
6365
</ItemGroup>
6466
</Target>
65-
<Target Name="PublishTool" BeforeTargets="CoreCompile">
67+
<Target Name="PublishTool" BeforeTargets="CoreCompile" Condition="'$(DisableArcade)' != '1'">
6668
<Exec Command="dotnet publish -o $(PublishLocation)" WorkingDirectory="$(MSBuildThisFileDirectory)..\Microsoft.TryDotNet" />
6769
</Target>
68-
<ItemGroup>
69-
<PackageReference Update="Microsoft.NET.Test.Sdk" />
70-
</ItemGroup>
71-
<ItemGroup>
72-
<PackageReference Update="xunit.runner.visualstudio">
73-
<PrivateAssets>all</PrivateAssets>
74-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
75-
</PackageReference>
76-
</ItemGroup>
77-
<ItemGroup>
78-
<PackageReference Update="xunit" />
79-
</ItemGroup>
70+
8071
</Project>
8172

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright (c) .NET Foundation and contributors. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
using System;
5+
using Peaky.Client;
6+
using Peaky.XUnit;
7+
8+
namespace Microsoft.TryDotNet.IntegrationTests;
9+
10+
public class PeakyTestDiscovery : PeakyXunitTestBase, IDisposable
11+
{
12+
private static readonly Uri _testDiscoveryUri = new("https://mls-monitoring.azurewebsites.net/tests/staging/orchestrator?deployment=true");
13+
14+
private readonly PeakyClient _peakyClient = new(_testDiscoveryUri);
15+
16+
public override PeakyClient PeakyClient => _peakyClient;
17+
18+
public void Dispose() => _peakyClient.Dispose();
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright (c) .NET Foundation and contributors. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
using System;
5+
using System.Net.Http;
6+
using System.Threading.Tasks;
7+
using FluentAssertions;
8+
using Peaky.Client;
9+
using Xunit;
10+
using Xunit.Abstractions;
11+
12+
namespace Microsoft.TryDotNet.IntegrationTests;
13+
14+
public class PeakyTests : IDisposable
15+
{
16+
private readonly ITestOutputHelper _output;
17+
18+
private readonly PeakyClient _peakyClient = new(new HttpClient());
19+
20+
public PeakyTests(ITestOutputHelper output)
21+
{
22+
_output = output;
23+
}
24+
25+
[Theory(Skip = "Work in progress")]
26+
[ClassData(typeof(PeakyTestDiscovery))]
27+
public async Task The_peaky_test_passes(Uri url)
28+
{
29+
var result = await _peakyClient.GetTestResultAsync(url);
30+
31+
_output.WriteLine(result.Content);
32+
33+
result.Passed.Should().BeTrue();
34+
}
35+
36+
public void Dispose() => _peakyClient.Dispose();
37+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright (c) .NET Foundation and contributors. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
using System;
5+
6+
namespace Microsoft.TryDotNet.IntegrationTests;
7+
8+
internal static class UriExtensions
9+
{
10+
public static Uri ToLocalHost(this Uri source)
11+
{
12+
var root = new Uri($"{source.Scheme}://127.0.0.1:{source.Port}");
13+
return new Uri(root,source.PathAndQuery);
14+
}
15+
}

0 commit comments

Comments
 (0)