SSE ClientTransport fixes and tests (#27)
SSE fixes Additional SSE integration tests with everything server
This commit is contained in:
parent
89c4913ed7
commit
30f3f192ca
1 changed files with 381 additions and 81 deletions
63
tests/mcpdotnet.Tests/EverythingSseServerFixture.cs
Normal file
63
tests/mcpdotnet.Tests/EverythingSseServerFixture.cs
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
using System.Diagnostics;
|
||||
|
||||
namespace McpDotNet.Tests;
|
||||
|
||||
public class EverythingSseServerFixture : IAsyncDisposable
|
||||
{
|
||||
private Process _process;
|
||||
|
||||
public async Task StartAsync()
|
||||
{
|
||||
var processStartInfo = new ProcessStartInfo
|
||||
{
|
||||
FileName = "docker",
|
||||
Arguments = "run -p 3001:3001 --rm tzolov/mcp-everything-server:v1",
|
||||
RedirectStandardInput = true,
|
||||
RedirectStandardOutput = true,
|
||||
RedirectStandardError = true,
|
||||
UseShellExecute = false,
|
||||
};
|
||||
|
||||
_process = Process.Start(processStartInfo);
|
||||
|
||||
// Wait for the server to start
|
||||
await Task.Delay(10000);
|
||||
}
|
||||
public async ValueTask DisposeAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
// Find the container ID
|
||||
var psInfo = new ProcessStartInfo
|
||||
{
|
||||
FileName = "docker",
|
||||
Arguments = "ps -q --filter ancestor=tzolov/mcp-everything-server:v1",
|
||||
RedirectStandardOutput = true,
|
||||
UseShellExecute = false
|
||||
};
|
||||
|
||||
using var psProcess = Process.Start(psInfo);
|
||||
string containerId = await psProcess.StandardOutput.ReadToEndAsync();
|
||||
containerId = containerId.Trim();
|
||||
|
||||
if (!string.IsNullOrEmpty(containerId))
|
||||
{
|
||||
// Stop the container
|
||||
var stopInfo = new ProcessStartInfo
|
||||
{
|
||||
FileName = "docker",
|
||||
Arguments = $"stop {containerId}",
|
||||
UseShellExecute = false
|
||||
};
|
||||
|
||||
using var stopProcess = Process.Start(stopInfo);
|
||||
await stopProcess.WaitForExitAsync();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Log the exception but don't throw
|
||||
Console.Error.WriteLine($"Error stopping Docker container: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue