Skip to content

Commit fe81dfe

Browse files
authored
test: re-enable and fix timed-out unit tests in PublisherImplTest (#13180)
Fixes #13051
1 parent 9515991 commit fe81dfe

1 file changed

Lines changed: 8 additions & 14 deletions

File tree

java-pubsub/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/v1/PublisherImplTest.java

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -512,21 +512,19 @@ public void testEnableMessageOrdering_overwritesMaxAttempts() throws Exception {
512512
* <li>publish with key orderA, which should now succeed
513513
* </ol>
514514
*/
515-
/*
516-
Temporarily disabled due to https://github.com/googleapis/java-pubsub/issues/1861.
517-
TODO(maitrimangal): Enable once resolved.
518515
@Test
519516
public void testResumePublish() throws Exception {
520517
Publisher publisher =
521518
getTestPublisherBuilder()
522519
.setBatchingSettings(
523-
Publisher.Builder.DEFAULT_BATCHING_SETTINGS
524-
.toBuilder()
520+
Publisher.Builder.DEFAULT_BATCHING_SETTINGS.toBuilder()
525521
.setElementCountThreshold(2L)
526522
.build())
527523
.setEnableMessageOrdering(true)
528524
.build();
529525

526+
testPublisherServiceImpl.setExecutor(fakeExecutor);
527+
530528
ApiFuture<String> future1 = sendTestMessageWithOrderingKey(publisher, "m1", "orderA");
531529
ApiFuture<String> future2 = sendTestMessageWithOrderingKey(publisher, "m2", "orderA");
532530

@@ -536,7 +534,6 @@ public void testResumePublish() throws Exception {
536534

537535
// This exception should stop future publishing to the same key
538536
testPublisherServiceImpl.addPublishError(new StatusException(Status.INVALID_ARGUMENT));
539-
540537
fakeExecutor.advanceTime(Duration.ZERO);
541538

542539
try {
@@ -576,8 +573,8 @@ public void testResumePublish() throws Exception {
576573
testPublisherServiceImpl.addPublishResponse(
577574
PublishResponse.newBuilder().addMessageIds("5").addMessageIds("6"));
578575

579-
Assert.assertEquals("5", future5.get());
580-
Assert.assertEquals("6", future6.get());
576+
assertEquals("5", future5.get());
577+
assertEquals("6", future6.get());
581578

582579
// Resume publishing of "orderA", which should now succeed
583580
publisher.resumePublish("orderA");
@@ -588,8 +585,8 @@ public void testResumePublish() throws Exception {
588585
testPublisherServiceImpl.addPublishResponse(
589586
PublishResponse.newBuilder().addMessageIds("7").addMessageIds("8"));
590587

591-
Assert.assertEquals("7", future7.get());
592-
Assert.assertEquals("8", future8.get());
588+
assertEquals("7", future7.get());
589+
assertEquals("8", future8.get());
593590

594591
shutdownTestPublisher(publisher);
595592
}
@@ -598,10 +595,8 @@ public void testResumePublish() throws Exception {
598595
public void testPublishThrowExceptionForUnsubmittedOrderingKeyMessage() throws Exception {
599596
Publisher publisher =
600597
getTestPublisherBuilder()
601-
.setExecutorProvider(SINGLE_THREAD_EXECUTOR)
602598
.setBatchingSettings(
603-
Publisher.Builder.DEFAULT_BATCHING_SETTINGS
604-
.toBuilder()
599+
Publisher.Builder.DEFAULT_BATCHING_SETTINGS.toBuilder()
605600
.setElementCountThreshold(2L)
606601
.setDelayThresholdDuration(Duration.ofSeconds(500))
607602
.build())
@@ -644,7 +639,6 @@ public void testPublishThrowExceptionForUnsubmittedOrderingKeyMessage() throws E
644639
assertEquals(SequentialExecutorService.CallbackExecutor.CANCELLATION_EXCEPTION, e.getCause());
645640
}
646641
}
647-
*/
648642

649643
private ApiFuture<String> sendTestMessageWithOrderingKey(
650644
Publisher publisher, String data, String orderingKey) {

0 commit comments

Comments
 (0)