Skip to content

Commit

Permalink
update stress streaming test to capture both in and out stream for St…
Browse files Browse the repository at this point in the history
…reamEcho scenario (dotnet#1849)
  • Loading branch information
KKhurin authored Apr 13, 2017
1 parent b01a9af commit f3173b9
Showing 1 changed file with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ public class StreamingRequestContext<ChannelType> : BasicRequestContext<ChannelT
public int StreamSize { get; set; }
public int BufferSize { get; set; }
public bool VerifyStreamContent { get; set; }
public Stream TheStream { get; set; }
public Stream StreamIn { get; set; }
public Stream StreamOut { get; set; }
}

public class StreamingTest<StreamingService, TestParams> : CommonMultiCallTest<StreamingService, TestParams, StreamingRequestContext<StreamingService>>
Expand Down Expand Up @@ -173,15 +174,15 @@ protected override StreamingRequestContext<StreamingService> CaptureRequestConte
protected override string PrintRequestDetails(StreamingRequestContext<StreamingService> requestDetails)
{
return base.PrintRequestDetails(requestDetails) +
String.Format (", TestScenario {0}, StreamSize {1}, StreamPosition {2}", requestDetails.TestScenario, requestDetails.StreamSize, requestDetails.TheStream?.Position);
String.Format (", TestScenario {0}, StreamSize {1}, StreamInPosition {2}, StreamOutPosition {3}", requestDetails.TestScenario, requestDetails.StreamSize, requestDetails.StreamIn?.Position, requestDetails.StreamOut?.Position);
}

private static async Task<int> TestGetStreamFromIntAsync(StreamingRequestContext<StreamingService> details)
{
details.TestScenario = StreamingScenarios.StreamIn; // update the scenario
using (var stream = await details.Channel.GetStreamFromIntAsync(details.StreamSize))
{
details.TheStream = stream;
details.StreamIn = stream;
var receivedStreamSize = await VerifiableStream.VerifyStreamAsync(stream, details.StreamSize, details.BufferSize, details.VerifyStreamContent);
if (receivedStreamSize != details.StreamSize)
{
Expand All @@ -195,7 +196,7 @@ private static async Task<int> TestGetIntFromStreamAsync(StreamingRequestContext
details.TestScenario = StreamingScenarios.StreamOut;
using (var stream = new VerifiableStream(details.StreamSize))
{
details.TheStream = stream;
details.StreamOut = stream;
int receivedSize = await details.Channel.GetIntFromStreamAsync(stream);
if (receivedSize != details.StreamSize)
{
Expand All @@ -209,9 +210,10 @@ private static async Task<int> TestEchoStreamAsync(StreamingRequestContext<Strea
details.TestScenario = StreamingScenarios.StreamEcho;
using (var stream = new VerifiableStream(details.StreamSize))
{
details.TheStream = stream;
details.StreamOut = stream;
using (var receivedStream = await details.Channel.EchoStreamAsync(stream))
{
details.StreamIn = receivedStream;
var receivedSize = await VerifiableStream.VerifyStreamAsync(receivedStream, details.StreamSize, details.BufferSize, details.VerifyStreamContent);
if (receivedSize != details.StreamSize)
{
Expand All @@ -227,7 +229,7 @@ private static int TestGetStreamFromInt(StreamingRequestContext<StreamingService
bool verifyStreamContent = details.VerifyStreamContent;
using (var stream = details.Channel.GetStreamFromInt(details.StreamSize))
{
details.TheStream = stream;
details.StreamIn = stream;
var receivedStreamSize = VerifiableStream.VerifyStream(stream, details.StreamSize, details.BufferSize, verifyStreamContent);
if (receivedStreamSize != details.StreamSize)
{
Expand All @@ -241,7 +243,7 @@ private static int TestGetIntFromStream(StreamingRequestContext<StreamingService
details.TestScenario = StreamingScenarios.StreamOut;
using (var stream = new VerifiableStream(details.StreamSize))
{
details.TheStream = stream;
details.StreamOut = stream;
int receivedSize = details.Channel.GetIntFromStream(stream);

if (receivedSize != details.StreamSize)
Expand All @@ -256,9 +258,10 @@ private static int TestEchoStream(StreamingRequestContext<StreamingService> deta
details.TestScenario = StreamingScenarios.StreamEcho;
using (var stream = new VerifiableStream(details.StreamSize))
{
details.TheStream = stream;
details.StreamOut = stream;
using (var receivedStream = details.Channel.EchoStream(stream))
{
details.StreamIn = receivedStream;
var receivedSize = VerifiableStream.VerifyStream(receivedStream, details.StreamSize, details.BufferSize, details.VerifyStreamContent);

if (receivedSize != details.StreamSize)
Expand Down

0 comments on commit f3173b9

Please sign in to comment.