Skip to content

Commit

Permalink
test: Add additional logging
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelpri10 committed May 14, 2024
1 parent 696148b commit 9459949
Showing 1 changed file with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,6 @@ public void testEnableMessageOrdering_overwritesMaxAttempts() throws Exception {
* <li>publish with key orderA, which should now succeed
* </ol>
*/
/*
@Test
public void testResumePublish() throws Exception {
System.out.println("Starting testResumePublish");
Expand All @@ -532,6 +531,8 @@ public void testResumePublish() throws Exception {
assertFalse(future1.isDone());
assertFalse(future2.isDone());

System.out.println("Publish 1 and 2");

// This exception should stop future publishing to the same key
testPublisherServiceImpl.addPublishError(new StatusException(Status.INVALID_ARGUMENT));

Expand All @@ -541,12 +542,14 @@ public void testResumePublish() throws Exception {
future1.get();
fail("This should fail.");
} catch (ExecutionException e) {
System.out.println("Message 1 failed");
}

try {
future2.get();
fail("This should fail.");
} catch (ExecutionException e) {
System.out.println("Message 2 failed");
}

// Submit new requests with orderA that should fail.
Expand All @@ -558,13 +561,15 @@ public void testResumePublish() throws Exception {
fail("This should fail.");
} catch (ExecutionException e) {
assertEquals(SequentialExecutorService.CallbackExecutor.CANCELLATION_EXCEPTION, e.getCause());
System.out.println("Message 3 failed");
}

try {
future4.get();
fail("This should fail.");
} catch (ExecutionException e) {
assertEquals(SequentialExecutorService.CallbackExecutor.CANCELLATION_EXCEPTION, e.getCause());
System.out.println("Message 4 failed");
}

// Submit a new request with orderB, which should succeed
Expand All @@ -577,26 +582,32 @@ public void testResumePublish() throws Exception {
assertEquals("5", future5.get());
assertEquals("6", future6.get());

System.out.println("Publish and receive 5 and 6");

// Resume publishing of "orderA", which should now succeed
publisher.resumePublish("orderA");

System.out.println("Resume publishing of orderA");

ApiFuture<String> future7 = sendTestMessageWithOrderingKey(publisher, "m7", "orderA");
ApiFuture<String> future8 = sendTestMessageWithOrderingKey(publisher, "m8", "orderA");

testPublisherServiceImpl.addPublishResponse(
PublishResponse.newBuilder().addMessageIds("7").addMessageIds("8"));

System.out.println("Publish of 7 and 8");

assertEquals("7", future7.get());
assertEquals("8", future8.get());

System.out.println("Receive 7 and 8");

shutdownTestPublisher(publisher);
System.out.println("Ending testResumePublish");
}
*/

@Test
public void testPublishThrowExceptionForUnsubmittedOrderingKeyMessage() throws Exception {
System.out.println("Starting testPublishThrowExceptionForUnsubmittedOrderingKeyMessage");
Publisher publisher =
getTestPublisherBuilder()
.setExecutorProvider(SINGLE_THREAD_EXECUTOR)
Expand Down Expand Up @@ -635,7 +646,7 @@ public void testPublishThrowExceptionForUnsubmittedOrderingKeyMessage() throws E
} catch (ExecutionException e) {
assertEquals(SequentialExecutorService.CallbackExecutor.CANCELLATION_EXCEPTION, e.getCause());
}
fakeExecutor.advanceTime(Duration.ofSeconds(5));
fakeExecutor.advanceTime(Duration.ZERO);

// A subsequent attempt fails immediately.
ApiFuture<String> publishFuture4 = sendTestMessageWithOrderingKey(publisher, "D", "a");
Expand All @@ -645,7 +656,6 @@ public void testPublishThrowExceptionForUnsubmittedOrderingKeyMessage() throws E
} catch (ExecutionException e) {
assertEquals(SequentialExecutorService.CallbackExecutor.CANCELLATION_EXCEPTION, e.getCause());
}
System.out.println("Ending testPublishThrowExceptionForUnsubmittedOrderingKeyMessage");
}

private ApiFuture<String> sendTestMessageWithOrderingKey(
Expand Down

0 comments on commit 9459949

Please sign in to comment.