aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Jan Tattermusch <jtattermusch@users.noreply.github.com>2017-04-18 20:25:52 +0200
committerGravatar GitHub <noreply@github.com>2017-04-18 20:25:52 +0200
commite38856419bec91bb91c495f40599174624f4d98c (patch)
treeeca5c4a6c7ad559fa7510b9d3a0bb44d3c3c27ca /src
parent8938943fce977e0a2a3bd160b18277ef52f8c353 (diff)
parented94e39ee8f5efd65330d72eb0bc5603efe12091 (diff)
Merge pull request #10703 from jtattermusch/csharp_fix_handler_race
Fix race in setting handler in tests.
Diffstat (limited to 'src')
-rw-r--r--src/csharp/Grpc.Core.Tests/AppDomainUnloadTest.cs8
-rw-r--r--src/csharp/Grpc.Core.Tests/UserAgentStringTest.cs19
2 files changed, 14 insertions, 13 deletions
diff --git a/src/csharp/Grpc.Core.Tests/AppDomainUnloadTest.cs b/src/csharp/Grpc.Core.Tests/AppDomainUnloadTest.cs
index d7ebdb4201..7858e77b27 100644
--- a/src/csharp/Grpc.Core.Tests/AppDomainUnloadTest.cs
+++ b/src/csharp/Grpc.Core.Tests/AppDomainUnloadTest.cs
@@ -72,10 +72,6 @@ namespace Grpc.Core.Tests
public AppDomainTestClass()
{
var helper = new MockServiceHelper(Host);
- var server = helper.GetServer();
- server.Start();
- var channel = helper.GetChannel();
-
var readyToShutdown = new TaskCompletionSource<object>();
helper.DuplexStreamingHandler = new DuplexStreamingServerMethod<string, string>(async (requestStream, responseStream, context) =>
{
@@ -83,6 +79,10 @@ namespace Grpc.Core.Tests
await requestStream.ToListAsync();
});
+ var server = helper.GetServer();
+ server.Start();
+ var channel = helper.GetChannel();
+
var call = Calls.AsyncDuplexStreamingCall(helper.CreateDuplexStreamingCall());
readyToShutdown.Task.Wait(); // make sure handler is running
}
diff --git a/src/csharp/Grpc.Core.Tests/UserAgentStringTest.cs b/src/csharp/Grpc.Core.Tests/UserAgentStringTest.cs
index cc830086a6..74b4997f69 100644
--- a/src/csharp/Grpc.Core.Tests/UserAgentStringTest.cs
+++ b/src/csharp/Grpc.Core.Tests/UserAgentStringTest.cs
@@ -63,10 +63,6 @@ namespace Grpc.Core.Tests
public void DefaultUserAgentString()
{
helper = new MockServiceHelper(Host);
- server = helper.GetServer();
- server.Start();
- channel = helper.GetChannel();
-
helper.UnaryHandler = new UnaryServerMethod<string, string>((request, context) =>
{
var userAgentString = context.RequestHeaders.First(m => (m.Key == "user-agent")).Value;
@@ -75,6 +71,11 @@ namespace Grpc.Core.Tests
Assert.IsTrue(parts[1].StartsWith("grpc-c/"));
return Task.FromResult("PASS");
});
+
+ server = helper.GetServer();
+ server.Start();
+ channel = helper.GetChannel();
+
Assert.AreEqual("PASS", Calls.BlockingUnaryCall(helper.CreateUnaryCall(), ""));
}
@@ -83,11 +84,6 @@ namespace Grpc.Core.Tests
{
helper = new MockServiceHelper(Host,
channelOptions: new[] { new ChannelOption(ChannelOptions.PrimaryUserAgentString, "XYZ") });
- server = helper.GetServer();
- server.Start();
- channel = helper.GetChannel();
-
- channel = helper.GetChannel();
helper.UnaryHandler = new UnaryServerMethod<string, string>((request, context) =>
{
var userAgentString = context.RequestHeaders.First(m => (m.Key == "user-agent")).Value;
@@ -95,6 +91,11 @@ namespace Grpc.Core.Tests
Assert.AreEqual("XYZ", parts[0]);
return Task.FromResult("PASS");
});
+
+ server = helper.GetServer();
+ server.Start();
+ channel = helper.GetChannel();
+
Assert.AreEqual("PASS", Calls.BlockingUnaryCall(helper.CreateUnaryCall(), ""));
}
}