这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
9b014c5
Integration test wip
Jul 10, 2019
35ed865
Start working on integration test
Jul 10, 2019
9d8ca53
publish better
Jul 10, 2019
6234294
Copy files better
Jul 11, 2019
2f1c8c9
pack tests
Jul 11, 2019
e405038
brett feedback
Jul 11, 2019
534d012
Depend on windows
Jul 11, 2019
ad11f21
use packages artifact
Jul 11, 2019
8f9bf22
improve readability
Jul 11, 2019
f067391
really improve readability
Jul 11, 2019
36aa0e2
run tests
Jul 12, 2019
8d618b7
path
Jul 12, 2019
fb85085
paths are hard
Jul 12, 2019
31a2dda
parens
Jul 12, 2019
959161c
Merge branch 'master' into dev/rchande/integration-test
Jul 15, 2019
f48a9f7
typo
Jul 16, 2019
3578c81
syntax is hard
Jul 16, 2019
1e0dcbb
add variable
Jul 16, 2019
8eb51bc
use right variable syntax?
Jul 16, 2019
c0998c6
debug print value
Jul 16, 2019
7c9fd73
PACKAGESOURCE
Jul 16, 2019
e81fde8
more logging
Jul 16, 2019
683185d
TrySetException
Jul 16, 2019
8c99a67
logging
Jul 16, 2019
2372d4f
Merge branch 'master' into dev/rchande/integration-test
Jul 16, 2019
ca75f01
fix typo
Jul 16, 2019
98c3dd7
Merge branch 'dev/rchande/integration-test' of https://github.com/rch…
Jul 17, 2019
eef5590
Fix tests?
Jul 17, 2019
cd0d831
Merge branch 'dev/rchande/integration-test' of https://github.com/rch…
Jul 17, 2019
8a194b3
version
Jul 17, 2019
1dc938b
version
Jul 17, 2019
b122d7f
Merge branch 'master' of https://github.com/dotnet/try into dev/rchan…
Jul 17, 2019
3675287
use http
Jul 17, 2019
0de4baf
rearrange args
Jul 17, 2019
7fd07ff
Create log file
Jul 18, 2019
8f8cade
cleanup
Jul 18, 2019
efed370
Merge branch 'master' of https://github.com/dotnet/try into dev/rchan…
Jul 18, 2019
0c84608
Fix sln
Jul 18, 2019
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
10 changes: 7 additions & 3 deletions DotNetTry.sln
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28803.352
MinimumVisualStudioVersion = 10.0.40219.1
Expand Down Expand Up @@ -55,6 +54,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.DotNet.ProjectTem
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharpWorkspaceShim", "FSharpWorkspaceShim\FSharpWorkspaceShim.fsproj", "{9128FCED-2A19-4502-BCEE-BE1BAB6882EB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NotIntegrationTests", "NotIntegrationTests\NotIntegrationTests.csproj", "{EA6DDD48-941D-43C6-BAC1-07CF24F4C792}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.DotNet.Interactive.Rendering", "Microsoft.DotNet.Interactive.Rendering\Microsoft.DotNet.Interactive.Rendering.csproj", "{FBEA5F71-23F5-4412-A936-9B8E6E228968}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.DotNet.Interactive.Rendering.Tests", "Microsoft.DotNet.Interactive.Rendering.Tests\Microsoft.DotNet.Interactive.Rendering.Tests.csproj", "{B4B9DC70-6BA2-4BC1-A780-7FCEBDB1D218}"
Expand Down Expand Up @@ -161,6 +161,10 @@ Global
{9128FCED-2A19-4502-BCEE-BE1BAB6882EB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9128FCED-2A19-4502-BCEE-BE1BAB6882EB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9128FCED-2A19-4502-BCEE-BE1BAB6882EB}.Release|Any CPU.Build.0 = Release|Any CPU
{EA6DDD48-941D-43C6-BAC1-07CF24F4C792}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EA6DDD48-941D-43C6-BAC1-07CF24F4C792}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EA6DDD48-941D-43C6-BAC1-07CF24F4C792}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EA6DDD48-941D-43C6-BAC1-07CF24F4C792}.Release|Any CPU.Build.0 = Release|Any CPU
{FBEA5F71-23F5-4412-A936-9B8E6E228968}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FBEA5F71-23F5-4412-A936-9B8E6E228968}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FBEA5F71-23F5-4412-A936-9B8E6E228968}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -198,7 +202,7 @@ Global
{1F1A7554-1E88-4514-8602-EC00899E0C49} = {8192FEAD-BCE6-4E62-97E5-2E9EA884BD71}
{E047D81A-7A18-4A1A-98E8-EDBB51EBB7DB} = {6EE8F484-DFA2-4F0F-939F-400CE78DFAC2}
{9128FCED-2A19-4502-BCEE-BE1BAB6882EB} = {6EE8F484-DFA2-4F0F-939F-400CE78DFAC2}
{FBEA5F71-23F5-4412-A936-9B8E6E228968} = {6EE8F484-DFA2-4F0F-939F-400CE78DFAC2}
{EA6DDD48-941D-43C6-BAC1-07CF24F4C792} = {8192FEAD-BCE6-4E62-97E5-2E9EA884BD71}
{B4B9DC70-6BA2-4BC1-A780-7FCEBDB1D218} = {8192FEAD-BCE6-4E62-97E5-2E9EA884BD71}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
Expand Down
93 changes: 93 additions & 0 deletions NotIntegrationTests/DotnetTry.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using MLS.Agent;
using MLS.Agent.Tools;
using WorkspaceServer;

namespace NotIntegrationTests
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well what are they then?

{
public class DotnetTryFixture : IDisposable
{
private DisposableDirectory _disposableDirectory;
private Process _process;
private HttpClient _client;
private AsyncLazy<bool> _lazyReady;

public DotnetTryFixture()
{
_disposableDirectory = DisposableDirectory.Create();
_lazyReady = new AsyncLazy<bool>(ReadyAsync);
}

public void Dispose()
{
_process?.Kill();
_disposableDirectory.Dispose();
}

private async Task<bool> ReadyAsync()
{
var dotnet = new Dotnet();
var installResult = await dotnet.ToolInstall("dotnet-try", _disposableDirectory.Directory, version: "1.0.44142.42", addSource: GetPackageSource());
installResult.ThrowOnFailure();

await Start();
return true;
}

private async Task Start()
{
var tcs = new TaskCompletionSource<bool>();
var dotnetTry = _disposableDirectory.Directory.GetFiles("dotnet-try*").First().FullName;
_process = CommandLine.StartProcess(dotnetTry, "--port 7891 hosted", _disposableDirectory.Directory,
output =>
{
if (output.Contains("Now listening on"))
{
tcs.SetResult(true);
}
},
error =>
{
if (!string.IsNullOrWhiteSpace(error))
{
tcs.TrySetException(new Exception(error));
Console.Write(error);
}
});

_client = new HttpClient();
_client.BaseAddress = new Uri("http://localhost:7891");
await tcs.Task;
}

private PackageSource GetPackageSource([CallerFilePath] string callerFile = "")
{
var dotnetTryPackageSource = Environment.GetEnvironmentVariable("PACKAGESOURCE");

var directory = !string.IsNullOrWhiteSpace(dotnetTryPackageSource)
? new DirectoryInfo(dotnetTryPackageSource)
: new DirectoryInfo(Path.Combine(Path.GetDirectoryName(callerFile), "../artifacts/packages/Debug/Shipping"));

if (!directory.Exists)
{
throw new Exception($"Expected packages directory {directory.FullName} to exist but it does not");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a more specific exception that would be appropriate here?

}

return new PackageSource(directory.FullName);
}

public async Task<HttpResponseMessage> GetAsync(string requestUri)
{
await _lazyReady.ValueAsync();
return await _client.GetAsync(requestUri);
}
}
}
54 changes: 54 additions & 0 deletions NotIntegrationTests/IntegrationTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using System;
using System.Threading.Tasks;
using FluentAssertions;
using Xunit;

namespace NotIntegrationTests
{
public class UnitTest1 : IClassFixture<DotnetTryFixture>
{
private readonly DotnetTryFixture _fixture;

public UnitTest1(DotnetTryFixture fixture)
{
_fixture = fixture;
}

[Fact(Skip = "This doesn't work yet")]
public async Task Can_serve_blazor_console_code_runner()
{
var response = await _fixture.GetAsync(@"/LocalCodeRunner/blazor-console");

response.StatusCode.Should().Be(200);
var result = await response.Content.ReadAsStringAsync();
result.Should().Contain("Loading...");
}

[Fact]
public async Task Can_serve_bundleCss()
{
var response = await _fixture.GetAsync(@"/client/bundle.css");
response.StatusCode.Should().Be(200);
var content = await response.Content.ReadAsStringAsync();
content.Should().NotBeNullOrEmpty();
}

[Fact]
public async Task Can_serve_bundlejs()
{
var response = await _fixture.GetAsync(@"/client/2.bundle.js");
response.StatusCode.Should().Be(200);
var content = await response.Content.ReadAsStringAsync();
content.Should().NotBeNullOrEmpty();
}

[Fact]
public async Task Can_serve_clientapi()
{
var response = await _fixture.GetAsync(@"/api/trydotnet.min.js");
response.StatusCode.Should().Be(200);
var content = await response.Content.ReadAsStringAsync();
content.Should().NotBeNullOrEmpty();
}
}
}
23 changes: 23 additions & 0 deletions NotIntegrationTests/NotIntegrationTests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>

<IsPackable>true</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Clockwise" Version="1.0.261-beta" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.1" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
<PackageReference Include="FluentAssertions" Version="5.7.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\MLS.Agent.Tools\MLS.Agent.Tools.csproj" />
<ProjectReference Include="..\MLS.Agent\MLS.Agent.csproj" />
<ProjectReference Include="..\WorkspaceServer\WorkspaceServer.csproj" />
</ItemGroup>

</Project>
14 changes: 12 additions & 2 deletions WorkspaceServer/Dotnet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ public Task<CommandLineResult> Execute(string args, Budget budget = null) =>
_workingDirectory,
budget);

public Process StartProcess(string args, Action<string> output = null, Action<string> error = null) =>
CommandLine.StartProcess(
Path.FullName,
args,
_workingDirectory,
output,
error);

public Task<CommandLineResult> Publish(string args, Budget budget = null) =>
Execute("publish".AppendArgs(args), budget);

Expand Down Expand Up @@ -104,9 +112,11 @@ public Task<CommandLineResult> ToolInstall(
string packageName,
DirectoryInfo toolPath,
PackageSource addSource = null,
Budget budget = null)
Budget budget = null,
string version = null)
{
var args = $@"{packageName} --tool-path ""{RemoveTrailingSlash(toolPath.FullName)}"" --version 1.0.0";
var versionArg = version != null ? $"--version {version}" : "";
var args = $@"{packageName} --tool-path ""{RemoveTrailingSlash(toolPath.FullName)}"" {versionArg}";
if (addSource != null)
{
args += $@" --add-source ""{addSource}""";
Expand Down
66 changes: 59 additions & 7 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,19 @@ jobs:
continueOnError: true
condition: always()

- ${{ if and(ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}:
- task: PublishBuildArtifacts@1
displayName: Publish packages to artifacts container
inputs:
pathToPublish: $(Build.SourcesDirectory)\artifacts\packages\$(_BuildConfig)
artifactName: packages
artifactType: container
- task: PublishBuildArtifacts@1
displayName: Publish packages to artifacts container
inputs:
pathToPublish: $(Build.SourcesDirectory)\artifacts\packages\$(_BuildConfig)
artifactName: packages
artifactType: container

- task: PublishBuildArtifacts@1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If publishing the tests like this you can remove <IsPackable>true</> from NotIntegrationTests.csproj.

displayName: Publish integration tests dll
inputs:
pathToPublish: $(Build.SourcesDirectory)\artifacts\bin\NotIntegrationTests\$(_BuildConfig)
artifactName: integrationTests
artifactType: container

- template: /eng/common/templates/jobs/jobs.yml
parameters:
Expand All @@ -126,6 +132,52 @@ jobs:
enableTelemetry: true
helixRepo: dotnet/try
jobs:
- job: IntegrationTest
dependsOn: Windows_NT
condition: succeeded()
pool:
vmImage: ubuntu-16.04
variables:
- name: PACKAGESOURCE
value: $(System.DefaultWorkingDirectory)/packages/Shipping
- name: TryDotNetPackagesPath
value: $(Build.SourcesDirectory)/.trydotnet/packages
steps:
- checkout: none #skip checking out the default repository resource
- task: UseDotNet@2
displayName: Add dotnet
inputs:
packageType: sdk
version: $(DotNetSdkVersion)
installationPath: $(Agent.ToolsDirectory)/dotnet

- script: dotnet new -i Microsoft.AspNetCore.Blazor.Templates::$(BlazorTemplateVersion)
displayName: Install Blazor templates

- task: DownloadBuildArtifacts@0
displayName: 'Download built packages'
inputs:
artifactName: packages
downloadPath: $(System.DefaultWorkingDirectory)

- task: DownloadBuildArtifacts@0
displayName: 'Download built integrationtests'
inputs:
artifactName: integrationTests
downloadPath: $(System.DefaultWorkingDirectory)

- script: dotnet vstest $(System.DefaultWorkingDirectory)/integrationTests/netcoreapp3.0/NotIntegrationTests.dll --ResultsDirectory:$(System.DefaultWorkingDirectory)/testResults | tee $(Build.SourcesDirectory)\artifacts\log\$(_BuildConfig)\log.txt
displayName: Run integration tests

- task: PublishTestResults@2
displayName: Publish NPM Test Results
inputs:
testResultsFormat: 'VSTest'
testResultsFiles: '*.trx'
searchFolder: '$(SystemWorkingDirectory)/testResults'
continueOnError: true
condition: always()

- job: Linux
pool:
vmImage: ubuntu-16.04
Expand Down