public void Test1MinuteFullLoadMultipleAsynchronous() { const int numServants = 16; var handler = new ZeroFailureToleranceStrategy(); bool failed = false; handler.OnResolutionFailedEvent += () => failed = true; using (var silo = new SharpRemote.Hosting.OutOfProcessSilo(failureHandler: handler)) { silo.Start(); var proxies = Enumerable.Range(0, numServants) .Select(unused => silo.CreateGrain <IDoImportStuff, DoesImportantStuff>()).ToArray(); long numCalls = 0; var start = DateTime.Now; var last = start; var now = start; while ((now = DateTime.Now) - start < TimeSpan.FromMinutes(1)) { var input = new Input { ImportantName = "Kittyfisto", ImportantNumber = 42 }; foreach (var proxy in proxies) { proxy.WorkAsync(input); } ++numCalls; var rtt = silo.RoundtripTime; var received = silo.NumBytesReceived; var sent = silo.NumBytesSent; if (now - last > TimeSpan.FromSeconds(10)) { TestContext.Progress.WriteLine("#{0} calls, {1}μs rtt, {2} received, {3} sent", numCalls, rtt.Ticks / 10, FormatSize(received), FormatSize(sent) ); last = now; } failed.Should().BeFalse("Because the connection shouldn't have failed"); } } }
public void Test1MinuteFullLoadSynchronous() { var handler = new ZeroFailureToleranceStrategy(); bool failed = false; handler.OnResolutionFailedEvent += () => failed = true; using (var silo = new SharpRemote.Hosting.OutOfProcessSilo(failureHandler: handler)) { silo.Start(); var proxy = silo.CreateGrain <IDoImportStuff, DoesImportantStuff>(); long numCalls = 0; var start = DateTime.Now; var last = start; var now = start; while ((now = DateTime.Now) - start < TimeSpan.FromMinutes(1)) { proxy.Work(new Input { ImportantName = "Kittyfisto", ImportantNumber = 42 }); ++numCalls; var rtt = silo.RoundtripTime; var received = silo.NumBytesReceived; var sent = silo.NumBytesSent; if (now - last > TimeSpan.FromSeconds(10)) { TestContext.Progress.WriteLine("#{0} calls, {1}μs rtt, {2} received, {3} sent", numCalls, rtt.Ticks / 10, FormatSize(received), FormatSize(sent) ); last = now; } failed.Should().BeFalse("Because the connection shouldn't have failed"); } var result = proxy.Result; result.Should().NotBeNull(); result.NumInputs.Should().Be(numCalls); result.NumCharacters.Should().Be("Kittyfisto".Length * numCalls); result.Sum.Should().Be(42 * numCalls); } }