@@ -86,6 +86,8 @@ public class BlockStreamServiceIT {
86
86
private Path testPath ;
87
87
private Config testConfig ;
88
88
89
+ private static final int testTimeout = 100 ;
90
+
89
91
@ BeforeEach
90
92
public void setUp () throws IOException {
91
93
testPath = Files .createTempDirectory (TEMP_DIR );
@@ -103,11 +105,11 @@ public void tearDown() {
103
105
104
106
@ Test
105
107
public void testPublishBlockStreamRegistrationAndExecution ()
106
- throws InterruptedException , IOException , NoSuchAlgorithmException {
108
+ throws IOException , NoSuchAlgorithmException {
107
109
108
110
final BlockStreamService blockStreamService =
109
111
new BlockStreamService (
110
- 50L ,
112
+ 1500L ,
111
113
new ItemAckBuilder (),
112
114
streamMediator ,
113
115
blockPersistenceHandler ,
@@ -131,21 +133,22 @@ public void testPublishBlockStreamRegistrationAndExecution()
131
133
PublishStreamResponse .newBuilder ().setAcknowledgement (itemAck ).build ();
132
134
133
135
// Verify the BlockItem message is sent to the mediator
134
- verify (streamMediator , timeout (50 ).times (1 )).publishEvent (blockItem );
136
+ verify (streamMediator , timeout (testTimeout ).times (1 )).publishEvent (blockItem );
135
137
136
138
// Verify our custom StreamObserver implementation builds and sends
137
139
// a response back to the producer
138
- verify (publishStreamResponseObserver , timeout (50 ).times (1 )).onNext (publishStreamResponse );
140
+ verify (publishStreamResponseObserver , timeout (testTimeout ).times (1 ))
141
+ .onNext (publishStreamResponse );
139
142
140
143
// Close the stream as Helidon does
141
144
streamObserver .onCompleted ();
142
145
143
146
// verify the onCompleted() method is invoked on the wrapped StreamObserver
144
- verify (publishStreamResponseObserver , timeout (50 ).times (1 )).onCompleted ();
147
+ verify (publishStreamResponseObserver , timeout (testTimeout ).times (1 )).onCompleted ();
145
148
}
146
149
147
150
@ Test
148
- public void testSubscribeBlockStream () throws InterruptedException {
151
+ public void testSubscribeBlockStream () {
149
152
150
153
final ServiceStatus serviceStatus = new ServiceStatusImpl ();
151
154
serviceStatus .setWebServer (webServer );
@@ -185,13 +188,16 @@ public void testSubscribeBlockStream() throws InterruptedException {
185
188
final SubscribeStreamResponse subscribeStreamResponse =
186
189
SubscribeStreamResponse .newBuilder ().setBlockItem (blockItems .getFirst ()).build ();
187
190
188
- verify (subscribeStreamObserver1 , timeout (50 ).times (1 )).onNext (subscribeStreamResponse );
189
- verify (subscribeStreamObserver2 , timeout (50 ).times (1 )).onNext (subscribeStreamResponse );
190
- verify (subscribeStreamObserver3 , timeout (50 ).times (1 )).onNext (subscribeStreamResponse );
191
+ verify (subscribeStreamObserver1 , timeout (testTimeout ).times (1 ))
192
+ .onNext (subscribeStreamResponse );
193
+ verify (subscribeStreamObserver2 , timeout (testTimeout ).times (1 ))
194
+ .onNext (subscribeStreamResponse );
195
+ verify (subscribeStreamObserver3 , timeout (testTimeout ).times (1 ))
196
+ .onNext (subscribeStreamResponse );
191
197
}
192
198
193
199
@ Test
194
- public void testFullHappyPath () throws IOException , InterruptedException {
200
+ public void testFullHappyPath () throws IOException {
195
201
int numberOfBlocks = 100 ;
196
202
197
203
final BlockStreamService blockStreamService = buildBlockStreamService ();
@@ -226,7 +232,7 @@ public void testFullHappyPath() throws IOException, InterruptedException {
226
232
}
227
233
228
234
@ Test
229
- public void testFullWithSubscribersAddedDynamically () throws IOException , InterruptedException {
235
+ public void testFullWithSubscribersAddedDynamically () throws IOException {
230
236
231
237
int numberOfBlocks = 100 ;
232
238
@@ -296,7 +302,7 @@ public void testFullWithSubscribersAddedDynamically() throws IOException, Interr
296
302
}
297
303
298
304
@ Test
299
- public void testSubAndUnsubWhileStreaming () throws IOException , InterruptedException {
305
+ public void testSubAndUnsubWhileStreaming () throws IOException {
300
306
301
307
int numberOfBlocks = 100 ;
302
308
@@ -384,8 +390,7 @@ public void testSubAndUnsubWhileStreaming() throws IOException, InterruptedExcep
384
390
}
385
391
386
392
@ Test
387
- public void testMediatorExceptionHandlingWhenPersistenceFailure ()
388
- throws IOException , InterruptedException {
393
+ public void testMediatorExceptionHandlingWhenPersistenceFailure () throws IOException {
389
394
final Map <
390
395
EventHandler <ObjectEvent <SubscribeStreamResponse >>,
391
396
BatchEventProcessor <ObjectEvent <SubscribeStreamResponse >>>
@@ -444,9 +449,12 @@ public void testMediatorExceptionHandlingWhenPersistenceFailure()
444
449
// before the IOException was thrown.
445
450
final SubscribeStreamResponse subscribeStreamResponse =
446
451
SubscribeStreamResponse .newBuilder ().setBlockItem (blockItems .getFirst ()).build ();
447
- verify (subscribeStreamObserver1 , timeout (50 ).times (1 )).onNext (subscribeStreamResponse );
448
- verify (subscribeStreamObserver2 , timeout (50 ).times (1 )).onNext (subscribeStreamResponse );
449
- verify (subscribeStreamObserver3 , timeout (50 ).times (1 )).onNext (subscribeStreamResponse );
452
+ verify (subscribeStreamObserver1 , timeout (testTimeout ).times (1 ))
453
+ .onNext (subscribeStreamResponse );
454
+ verify (subscribeStreamObserver2 , timeout (testTimeout ).times (1 ))
455
+ .onNext (subscribeStreamResponse );
456
+ verify (subscribeStreamObserver3 , timeout (testTimeout ).times (1 ))
457
+ .onNext (subscribeStreamResponse );
450
458
451
459
// Verify all the consumers received the end of stream response
452
460
// TODO: Fix the response code when it's available
@@ -456,9 +464,9 @@ public void testMediatorExceptionHandlingWhenPersistenceFailure()
456
464
SubscribeStreamResponse .SubscribeStreamResponseCode
457
465
.READ_STREAM_SUCCESS )
458
466
.build ();
459
- verify (subscribeStreamObserver1 , timeout (50 ).times (1 )).onNext (endStreamResponse );
460
- verify (subscribeStreamObserver2 , timeout (50 ).times (1 )).onNext (endStreamResponse );
461
- verify (subscribeStreamObserver3 , timeout (50 ).times (1 )).onNext (endStreamResponse );
467
+ verify (subscribeStreamObserver1 , timeout (testTimeout ).times (1 )).onNext (endStreamResponse );
468
+ verify (subscribeStreamObserver2 , timeout (testTimeout ).times (1 )).onNext (endStreamResponse );
469
+ verify (subscribeStreamObserver3 , timeout (testTimeout ).times (1 )).onNext (endStreamResponse );
462
470
463
471
// Verify all the consumers were unsubscribed
464
472
for (final var s : subscribers .keySet ()) {
@@ -473,8 +481,9 @@ public void testMediatorExceptionHandlingWhenPersistenceFailure()
473
481
.build ();
474
482
final var endOfStreamResponse =
475
483
PublishStreamResponse .newBuilder ().setStatus (endOfStream ).build ();
476
- verify (publishStreamResponseObserver , timeout (50 ).times (2 )).onNext (endOfStreamResponse );
477
- verify (webServer , timeout (50 ).times (1 )).stop ();
484
+ verify (publishStreamResponseObserver , timeout (testTimeout ).times (2 ))
485
+ .onNext (endOfStreamResponse );
486
+ verify (webServer , timeout (testTimeout ).times (1 )).stop ();
478
487
479
488
// Now verify the block was removed from the file system.
480
489
final BlockReader <Block > blockReader = new BlockAsDirReader (JUNIT , testConfig );
@@ -489,7 +498,7 @@ public void testMediatorExceptionHandlingWhenPersistenceFailure()
489
498
SingleBlockResponse .SingleBlockResponseCode
490
499
.READ_BLOCK_NOT_AVAILABLE )
491
500
.build ();
492
- verify (singleBlockResponseStreamObserver , timeout (50 ).times (1 ))
501
+ verify (singleBlockResponseStreamObserver , timeout (testTimeout ).times (1 ))
493
502
.onNext (expectedSingleBlockNotAvailable );
494
503
495
504
// TODO: Fix the response code when it's available
@@ -499,7 +508,7 @@ public void testMediatorExceptionHandlingWhenPersistenceFailure()
499
508
SubscribeStreamResponse .SubscribeStreamResponseCode
500
509
.READ_STREAM_SUCCESS )
501
510
.build ();
502
- verify (subscribeStreamObserver4 , timeout (50 ).times (1 ))
511
+ verify (subscribeStreamObserver4 , timeout (testTimeout ).times (1 ))
503
512
.onNext (expectedSubscriberStreamNotAvailable );
504
513
}
505
514
@@ -535,9 +544,9 @@ private static void verifySubscribeStreamResponse(
535
544
final SubscribeStreamResponse stateProofStreamResponse =
536
545
buildSubscribeStreamResponse (stateProofBlockItem );
537
546
538
- verify (streamObserver , timeout (50 ).times (1 )).onNext (headerSubStreamResponse );
539
- verify (streamObserver , timeout (50 ).times (8 )).onNext (bodySubStreamResponse );
540
- verify (streamObserver , timeout (50 ).times (1 )).onNext (stateProofStreamResponse );
547
+ verify (streamObserver , timeout (testTimeout ).times (1 )).onNext (headerSubStreamResponse );
548
+ verify (streamObserver , timeout (testTimeout ).times (8 )).onNext (bodySubStreamResponse );
549
+ verify (streamObserver , timeout (testTimeout ).times (1 )).onNext (stateProofStreamResponse );
541
550
}
542
551
}
543
552
0 commit comments