File tree Expand file tree Collapse file tree 3 files changed +26
-8
lines changed
osu.Server.QueueProcessor.Tests
osu.Server.QueueProcessor Expand file tree Collapse file tree 3 files changed +26
-8
lines changed Original file line number Diff line number Diff line change @@ -104,8 +104,11 @@ public void EnsureCancellingDoesNotLoseItems()
104
104
}
105
105
} ;
106
106
107
+ const int run_count = 5 ;
108
+
107
109
// start and stop processing multiple times, checking items are in a good state each time.
108
- for ( int i = 0 ; i < 5 ; i ++ )
110
+
111
+ for ( int i = 0 ; i < run_count ; i ++ )
109
112
{
110
113
var cts = new CancellationTokenSource ( ) ;
111
114
@@ -125,7 +128,11 @@ public void EnsureCancellingDoesNotLoseItems()
125
128
}
126
129
} , CancellationToken . None ) ;
127
130
128
- var receiveTask = Task . Run ( ( ) => processor . Run ( ( cts = new CancellationTokenSource ( ) ) . Token ) , CancellationToken . None ) ;
131
+ // Ensure there are some items in the queue before starting the processor.
132
+ while ( inFlightObjects . Count < 1000 )
133
+ Thread . Sleep ( 100 ) ;
134
+
135
+ var receiveTask = Task . Run ( ( ) => processor . Run ( cts . Token ) , CancellationToken . None ) ;
129
136
130
137
Thread . Sleep ( 1000 ) ;
131
138
@@ -135,8 +142,6 @@ public void EnsureCancellingDoesNotLoseItems()
135
142
receiveTask . Wait ( 10000 ) ;
136
143
137
144
output . WriteLine ( $ "Sent: { sent } In-flight: { inFlightObjects . Count } Processed: { processed } ") ;
138
-
139
- Assert . Equal ( inFlightObjects . Count , processor . GetQueueSize ( ) ) ;
140
145
}
141
146
142
147
var finalCts = new CancellationTokenSource ( 10000 ) ;
Original file line number Diff line number Diff line change @@ -93,8 +93,11 @@ public void EnsureCancellingDoesNotLoseItems()
93
93
}
94
94
} ;
95
95
96
+ const int run_count = 5 ;
97
+
96
98
// start and stop processing multiple times, checking items are in a good state each time.
97
- for ( int i = 0 ; i < 5 ; i ++ )
99
+
100
+ for ( int i = 0 ; i < run_count ; i ++ )
98
101
{
99
102
var cts = new CancellationTokenSource ( ) ;
100
103
@@ -114,7 +117,11 @@ public void EnsureCancellingDoesNotLoseItems()
114
117
}
115
118
} , CancellationToken . None ) ;
116
119
117
- var receiveTask = Task . Run ( ( ) => processor . Run ( ( cts = new CancellationTokenSource ( ) ) . Token ) , CancellationToken . None ) ;
120
+ // Ensure there are some items in the queue before starting the processor.
121
+ while ( inFlightObjects . Count < 1000 )
122
+ Thread . Sleep ( 100 ) ;
123
+
124
+ var receiveTask = Task . Run ( ( ) => processor . Run ( cts . Token ) , CancellationToken . None ) ;
118
125
119
126
Thread . Sleep ( 1000 ) ;
120
127
@@ -124,8 +131,6 @@ public void EnsureCancellingDoesNotLoseItems()
124
131
receiveTask . Wait ( 10000 ) ;
125
132
126
133
output . WriteLine ( $ "Sent: { sent } In-flight: { inFlightObjects . Count } Processed: { processed } ") ;
127
-
128
- Assert . Equal ( inFlightObjects . Count , processor . GetQueueSize ( ) ) ;
129
134
}
130
135
131
136
var finalCts = new CancellationTokenSource ( 10000 ) ;
Original file line number Diff line number Diff line change @@ -165,6 +165,14 @@ public void Run(CancellationToken cancellation = default)
165
165
}
166
166
167
167
Console . WriteLine ( "Shutting down.." ) ;
168
+
169
+ while ( totalInFlight > 0 )
170
+ {
171
+ Console . WriteLine ( $ "Waiting for remaining { totalInFlight } in-flight items...") ;
172
+ Thread . Sleep ( 5000 ) ;
173
+ }
174
+
175
+ Console . WriteLine ( "Bye!" ) ;
168
176
}
169
177
}
170
178
You can’t perform that action at this time.
0 commit comments