@@ -53,6 +53,7 @@ public class TestConcurrentAccessWithSharedConnection : IntegrationFixture {
53
53
54
54
protected const int threads = 32 ;
55
55
protected CountdownEvent latch ;
56
+ protected TimeSpan completionTimeout = TimeSpan . FromSeconds ( 90 ) ;
56
57
57
58
[ SetUp ]
58
59
public void Init ( )
@@ -94,21 +95,39 @@ public void TestConcurrentChannelOpenWithPublishing()
94
95
// to segfault on OS X for no obvious reason
95
96
[ Test ]
96
97
public void TestConcurrentChannelOpenCloseLoop ( )
98
+ {
99
+ TestConcurrentChannelOperations ( ( conn ) => {
100
+ var ch = conn . CreateModel ( ) ;
101
+ ch . Close ( ) ;
102
+ } , 100 ) ;
103
+ }
104
+
105
+ protected void TestConcurrentChannelOperations ( Action < IConnection > actions ,
106
+ int iterations )
107
+ {
108
+ TestConcurrentChannelOperations ( actions , iterations , completionTimeout ) ;
109
+ }
110
+
111
+ protected void TestConcurrentChannelOperations ( Action < IConnection > actions ,
112
+ int iterations , TimeSpan timeout )
97
113
{
98
114
foreach ( var i in Enumerable . Range ( 0 , threads ) )
99
115
{
100
116
var t = new Thread ( ( ) => {
101
- foreach ( var j in Enumerable . Range ( 0 , 100 ) )
117
+ foreach ( var j in Enumerable . Range ( 0 , iterations ) )
102
118
{
103
- var ch = Conn . CreateModel ( ) ;
104
- ch . Close ( ) ;
119
+ actions ( Conn ) ;
105
120
}
106
121
latch . Signal ( ) ;
107
122
} ) ;
108
123
t . Start ( ) ;
109
124
}
110
125
111
- Assert . IsTrue ( latch . Wait ( TimeSpan . FromSeconds ( 90 ) ) ) ;
126
+ Assert . IsTrue ( latch . Wait ( timeout ) ) ;
127
+ // incorrect frame interleaving in these tests will result
128
+ // in an unrecoverable connection-level exception, thus
129
+ // closing the connection
130
+ Assert . IsTrue ( Conn . IsOpen ) ;
112
131
}
113
132
}
114
133
}
0 commit comments