Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public class when_invalid_data_is_sent_over_tcp<TLogFormat, TStreamId> : specifi
public async Task connection_should_be_closed_by_remote_party(string endpointProperty, bool secure)
{
IPEndPoint endpoint = (IPEndPoint)_nodes[0].GetType().GetProperty(endpointProperty).GetValue(_nodes[0], null);
await WaitForEndpoint(endpoint);

var closedEvent = new ManualResetEventSlim();
TaskCompletionSource<SocketError> connectionResult = new(TaskCreationOptions.RunContinuationsAsynchronously);

Expand Down Expand Up @@ -64,4 +66,26 @@ public async Task connection_should_be_closed_by_remote_party(string endpointPro
Assert.True(closedEvent.Wait(10000));
connection.Close("intentional close");
}

private static async Task WaitForEndpoint(IPEndPoint endpoint)
{
using var timeout = new CancellationTokenSource(TimeSpan.FromSeconds(5));

while (!timeout.IsCancellationRequested)
{
using var client = new TcpClient();

try
{
await client.ConnectAsync(endpoint.Address, endpoint.Port, timeout.Token);
return;
}
catch (Exception ex) when (ex is SocketException or OperationCanceledException)
{
await Task.Delay(100, CancellationToken.None);
}
}

throw new TimeoutException($"TCP endpoint {endpoint} did not accept connections before the test timeout.");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ public void Handle(ProjectionManagementMessage.Command.Enable message)
var projection = GetProjection(message.Name);
if (projection == null)
{
_logger.Error("DBG: PROJECTION *{projection}* NOT FOUND.", message.Name);
_logger.Error("Projection '{projection}' not found.", message.Name);
message.Envelope.ReplyWith(new ProjectionManagementMessage.NotFound());
}
else
Expand Down Expand Up @@ -602,12 +602,12 @@ public void Handle(ProjectionManagementMessage.Command.SetRunAs message)
return;
}

_logger.Information("Setting RunAs1 account for '{projection}' projection", message.Name);
_logger.Information("Setting RunAs account for '{projection}' projection", message.Name);

var projection = GetProjection(message.Name);
if (projection == null)
{
_logger.Error("DBG: PROJECTION *{projection}* NOT FOUND.", message.Name);
_logger.Error("Projection '{projection}' not found.", message.Name);
message.Envelope.ReplyWith(new ProjectionManagementMessage.NotFound());
}
else
Expand Down Expand Up @@ -636,7 +636,7 @@ public void Handle(ProjectionManagementMessage.Command.Reset message)
var projection = GetProjection(message.Name);
if (projection == null)
{
_logger.Error("DBG: PROJECTION *{projection}* NOT FOUND.", message.Name);
_logger.Error("Projection '{projection}' not found.", message.Name);
message.Envelope.ReplyWith(new ProjectionManagementMessage.NotFound());
}
else
Expand Down
Loading