Skip to content

Commit 7cd76e1

Browse files
Fix race condition in SimpleNioTransportTests.testTracerLog (#12139) (#12145)
The test currently blocks on receiving a response to the request for the "internal:testNotSeen" action. However, that response is sent from TransportService before the trace logger [writes its log message][1]. Since the test was not polling for this "sent response" log message to appear that meant it was possible for the test to remove/stop the mock log appender concurrently with the logging of that final message. The fix is to include this final log message as an expectation, so the test will poll until this message appears and the logger should be quiescent when the appender is removed and stopped. [1]: https://github.com/opensearch-project/OpenSearch/blob/71f1fabe149fd0777edf44502ace4a8f0911feeb/server/src/main/java/org/opensearch/transport/TransportService.java#L1273 (cherry picked from commit f55b9e0) Signed-off-by: Andrew Ross <andrross@amazon.com> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 900b475 commit 7cd76e1

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

test/framework/src/main/java/org/opensearch/transport/AbstractSimpleTransportTestCase.java

+8
Original file line numberDiff line numberDiff line change
@@ -1284,9 +1284,17 @@ public String executor() {
12841284
Level.TRACE,
12851285
notSeenReceived
12861286
);
1287+
final String notSeenResponseSent = ".*\\[internal:testNotSeen].*sent response.*";
1288+
final MockLogAppender.LoggingExpectation notSeenResponseSentExpectation = new MockLogAppender.PatternSeenEventExpectation(
1289+
"sent response",
1290+
"org.opensearch.transport.TransportService.tracer",
1291+
Level.TRACE,
1292+
notSeenResponseSent
1293+
);
12871294

12881295
appender.addExpectation(notSeenSentExpectation);
12891296
appender.addExpectation(notSeenReceivedExpectation);
1297+
appender.addExpectation(notSeenResponseSentExpectation);
12901298

12911299
PlainTransportFuture<StringMessageResponse> future = new PlainTransportFuture<>(noopResponseHandler);
12921300
serviceA.sendRequest(nodeB, "internal:testNotSeen", new StringMessageRequest(""), future);

0 commit comments

Comments
 (0)