Skip to content

Commit

Permalink
Revert test changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
shyamnamboodiripad committed Apr 5, 2023
1 parent 2a7d1c5 commit 264766d
Showing 1 changed file with 0 additions and 102 deletions.
102 changes: 0 additions & 102 deletions src/dotnet-interactive.Tests/StdIoKernelConnectorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,38 +120,11 @@ public async Task it_can_create_a_proxy_kernel_to_more_than_one_remote_subkernel
SupportedKernelCommands = fsharpKernelInfo.SupportedKernelCommands
};

const string installHttpKernel =
"""
#r "Microsoft.DotNet.Interactive.HttpRequest.dll"
using Microsoft.DotNet.Interactive;
using Microsoft.DotNet.Interactive.HttpRequest;
HttpRequestKernelExtension.Load(KernelInvocationContext.Current.HandlingKernel.RootKernel);
""";

result = await csharpProxyKernel.SubmitCodeAsync(installHttpKernel);
result.Events.Last().Should().BeOfType<CommandSucceeded>();

var httpKernelInfo = result.Events.OfType<KernelInfoProduced>().Should().ContainSingle().Which.KernelInfo;
using var httpProxyKernel = await connector.CreateProxyKernelAsync(remoteInfo: httpKernelInfo);
var expectedHttpKernelInfo = new KernelInfo("http")
{
IsProxy = true,
IsComposite = false,
LanguageName = httpKernelInfo.LanguageName,
LanguageVersion = httpKernelInfo.LanguageVersion,
RemoteUri = httpKernelInfo.Uri,
SupportedDirectives = httpKernelInfo.SupportedDirectives,
SupportedKernelCommands = httpKernelInfo.SupportedKernelCommands
};

csharpProxyKernel.Name.Should().Be(csharpKernelInfo.LocalName);
csharpProxyKernel.KernelInfo.Should().BeEquivalentTo(expectedCSharpKernelInfo);

fsharpProxyKernel.Name.Should().Be("fsharp2");
fsharpProxyKernel.KernelInfo.Should().BeEquivalentTo(expectedFSharpKernelInfo);

httpProxyKernel.Name.Should().Be(httpKernelInfo.LocalName);
httpProxyKernel.KernelInfo.Should().BeEquivalentTo(expectedHttpKernelInfo);
}

[Fact]
Expand All @@ -162,81 +135,6 @@ public async Task it_throws_if_there_is_no_remote_subkernel_with_the_specified_n
await action.Should().ThrowAsync<InvalidOperationException>();
}

[Fact]
public async Task value_sharing_between_remote_kernels_works()
{
var connector = CreateConnector();
using var rootProxyKernel = await connector.CreateRootProxyKernelAsync();

var result = await rootProxyKernel.SendAsync(new RequestKernelInfo());
var kernelInfos = result.Events.OfType<KernelInfoProduced>().Select(e => e.KernelInfo);

using var _ = new AssertionScope();

var csharpKernelInfo = kernelInfos.Should().ContainSingle(i => i.LanguageName == "C#").Which;
using var csharpProxyKernel = await connector.CreateProxyKernelAsync(remoteInfo: csharpKernelInfo);
csharpProxyKernel.UseValueSharing();

var fsharpKernelInfo = kernelInfos.Should().ContainSingle(i => i.LanguageName == "F#").Which;
using var fsharpProxyKernel = await connector.CreateProxyKernelAsync(remoteInfo: fsharpKernelInfo);
fsharpProxyKernel.UseValueSharing();

using var composite = new CompositeKernel { csharpProxyKernel, fsharpProxyKernel };
composite.DefaultKernelName = csharpProxyKernel.Name;

result = await composite.SendAsync(new SubmitCode("let x = 123", "fsharp"));
result.Events.Last().Should().BeOfType<CommandSucceeded>();

result = await composite.SendAsync(new SubmitCode("#!set --name y --value @fsharp:x", "csharp"));
result.Events.Last().Should().BeOfType<CommandSucceeded>();

result = await composite.SendAsync(new SubmitCode("#!share --from fsharp x", "csharp"));
result.Events.Last().Should().BeOfType<CommandSucceeded>();

result = await composite.SendAsync(new SubmitCode("x + y", "csharp"));
result.Events.Last().Should().BeOfType<CommandSucceeded>();
var returnValueProduced = result.Events.OfType<ReturnValueProduced>().Should().ContainSingle().Which;
returnValueProduced.FormattedValues.Should().ContainSingle().Which.Value.Should().Contain("246");
}

[Fact]
public async Task command_splitting_across_multiple_remote_kernels_works()
{
var connector = CreateConnector();
using var rootProxyKernel = await connector.CreateRootProxyKernelAsync();

var result = await rootProxyKernel.SendAsync(new RequestKernelInfo());
var kernelInfos = result.Events.OfType<KernelInfoProduced>().Select(e => e.KernelInfo);

using var _ = new AssertionScope();

var csharpKernelInfo = kernelInfos.Should().ContainSingle(i => i.LanguageName == "C#").Which;
using var csharpProxyKernel = await connector.CreateProxyKernelAsync(remoteInfo: csharpKernelInfo);
csharpProxyKernel.UseValueSharing();

var fsharpKernelInfo = kernelInfos.Should().ContainSingle(i => i.LanguageName == "F#").Which;
using var fsharpProxyKernel = await connector.CreateProxyKernelAsync(remoteInfo: fsharpKernelInfo);
fsharpProxyKernel.UseValueSharing();

using var composite = new CompositeKernel { csharpProxyKernel, fsharpProxyKernel };
composite.DefaultKernelName = csharpProxyKernel.Name;

const string submission =
"""
#!fsharp
let x = 123
x
#!csharp
var y = 123;
y
""";

result = await composite.SendAsync(new SubmitCode(submission));
result.Events.Last().Should().BeOfType<CommandSucceeded>();
result.Events.OfType<ReturnValueProduced>().Should().AllSatisfy(
r => r.FormattedValues.Should().ContainSingle().Which.Value.Should().Contain("123"));
}

[Fact]
public async Task when_only_root_proxy_is_created_and_disposed_then_the_remote_process_is_killed()
{
Expand Down

0 comments on commit 264766d

Please sign in to comment.