Skip to content

Commit 8eb42f4

Browse files
Refactor futher
Avoids .NET Core runtime segfaults on OS X (80 runs of the suite so far without issues).
1 parent 0513eaf commit 8eb42f4

File tree

1 file changed

+13
-20
lines changed

1 file changed

+13
-20
lines changed

projects/client/Unit/src/unit/TestConcurrentAccessWithSharedConnection.cs

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -70,25 +70,18 @@ public void Dispose()
7070
[Test]
7171
public void TestConcurrentChannelOpenWithPublishing()
7272
{
73-
foreach (var i in Enumerable.Range(0, threads))
74-
{
75-
var t = new Thread(() => {
76-
// publishing on a shared channel is not supported
77-
// and would missing the point of this test anyway
78-
var ch = Conn.CreateModel();
79-
ch.ConfirmSelect();
80-
foreach (var j in Enumerable.Range(0, 10000))
81-
{
82-
var body = Encoding.ASCII.GetBytes(string.Empty);
83-
ch.BasicPublish(exchange: "", routingKey: "_______", basicProperties: ch.CreateBasicProperties(), body: body);
84-
}
85-
ch.WaitForConfirms(TimeSpan.FromSeconds(40));
86-
latch.Signal();
87-
});
88-
t.Start();
89-
}
90-
91-
Assert.IsTrue(latch.Wait(TimeSpan.FromSeconds(90)));
73+
TestConcurrentChannelOperations((conn) => {
74+
// publishing on a shared channel is not supported
75+
// and would missing the point of this test anyway
76+
var ch = Conn.CreateModel();
77+
ch.ConfirmSelect();
78+
foreach (var j in Enumerable.Range(0, 500))
79+
{
80+
var body = Encoding.ASCII.GetBytes(string.Empty);
81+
ch.BasicPublish(exchange: "", routingKey: "_______", basicProperties: ch.CreateBasicProperties(), body: body);
82+
}
83+
ch.WaitForConfirms(TimeSpan.FromSeconds(40));
84+
}, 30);
9285
}
9386

9487
// note: refactoring this further to use an Action causes .NET Core 1.x
@@ -99,7 +92,7 @@ public void TestConcurrentChannelOpenCloseLoop()
9992
TestConcurrentChannelOperations((conn) => {
10093
var ch = conn.CreateModel();
10194
ch.Close();
102-
}, 100);
95+
}, 50);
10396
}
10497

10598
protected void TestConcurrentChannelOperations(Action<IConnection> actions,

0 commit comments

Comments
 (0)