File tree Expand file tree Collapse file tree 3 files changed +16
-7
lines changed
Async/NHSpecificTest/Logs Expand file tree Collapse file tree 3 files changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -159,12 +159,15 @@ public async Task WillGetSessionIdFromSessionLogsConcurrentAsync()
159
159
var semaphore = new SemaphoreSlim ( 0 ) ;
160
160
var failures = new ConcurrentBag < Exception > ( ) ;
161
161
var sessionIds = new ConcurrentDictionary < int , Guid > ( ) ;
162
+ var threadCount = 10 ;
163
+ if ( threadCount > TestDialect . MaxNumberOfConnections )
164
+ threadCount = TestDialect . MaxNumberOfConnections . Value ;
162
165
using ( var spy = new TextLogSpy ( "NHibernate.SQL" , "%message | SessionId: %property{sessionId}" ) )
163
166
{
164
167
await ( Task . WhenAll (
165
- Enumerable . Range ( 1 , 12 - 1 ) . Select ( async i =>
168
+ Enumerable . Range ( 1 , threadCount + 2 - 1 ) . Select ( async i =>
166
169
{
167
- if ( i > 10 )
170
+ if ( i > threadCount )
168
171
{
169
172
// Give some time to threads for reaching the wait, having all of them ready to do most of their job concurrently.
170
173
await ( Task . Delay ( 100 ) ) ;
@@ -198,7 +201,7 @@ public async Task WillGetSessionIdFromSessionLogsConcurrentAsync()
198
201
Assert . That ( failures , Is . Empty , $ "{ failures . Count } task(s) failed.") ;
199
202
200
203
var loggingEvent = spy . GetWholeLog ( ) ;
201
- for ( var i = 1 ; i < 11 ; i ++ )
204
+ for ( var i = 1 ; i < threadCount + 1 ; i ++ )
202
205
for ( var j = 0 ; j < 10 ; j ++ )
203
206
{
204
207
var sessionId = sessionIds [ i ] ;
Original file line number Diff line number Diff line change @@ -148,13 +148,16 @@ public void WillGetSessionIdFromSessionLogsConcurrent()
148
148
var semaphore = new SemaphoreSlim ( 0 ) ;
149
149
var failures = new ConcurrentBag < Exception > ( ) ;
150
150
var sessionIds = new ConcurrentDictionary < int , Guid > ( ) ;
151
+ var threadCount = 10 ;
152
+ if ( threadCount > TestDialect . MaxNumberOfConnections )
153
+ threadCount = TestDialect . MaxNumberOfConnections . Value ;
151
154
using ( var spy = new TextLogSpy ( "NHibernate.SQL" , "%message | SessionId: %property{sessionId}" ) )
152
155
{
153
156
Parallel . For (
154
- 1 , 12 ,
157
+ 1 , threadCount + 2 ,
155
158
i =>
156
159
{
157
- if ( i > 10 )
160
+ if ( i > threadCount )
158
161
{
159
162
// Give some time to threads for reaching the wait, having all of them ready to do most of their job concurrently.
160
163
Thread . Sleep ( 100 ) ;
@@ -188,7 +191,7 @@ public void WillGetSessionIdFromSessionLogsConcurrent()
188
191
Assert . That ( failures , Is . Empty , $ "{ failures . Count } task(s) failed.") ;
189
192
190
193
var loggingEvent = spy . GetWholeLog ( ) ;
191
- for ( var i = 1 ; i < 11 ; i ++ )
194
+ for ( var i = 1 ; i < threadCount + 1 ; i ++ )
192
195
for ( var j = 0 ; j < 10 ; j ++ )
193
196
{
194
197
var sessionId = sessionIds [ i ] ;
Original file line number Diff line number Diff line change @@ -64,7 +64,10 @@ public void TestQueryWithContainsInParallel()
64
64
Guid . NewGuid ( ) ,
65
65
Guid . NewGuid ( ) ,
66
66
} ;
67
- const int threadsToRun = 32 ;
67
+ var threadsToRun = 32 ;
68
+ if ( threadsToRun > TestDialect . MaxNumberOfConnections )
69
+ threadsToRun = TestDialect . MaxNumberOfConnections . Value ;
70
+
68
71
var events = new WaitHandle [ threadsToRun ] ;
69
72
var exceptions = new List < Exception > ( ) ;
70
73
for ( var i = 0 ; i < threadsToRun ; i ++ )
You can’t perform that action at this time.
0 commit comments