Skip to content

Commit 3eb29e8

Browse files
committed
Fix flaky slowlog test
Signed-off-by: David Zane <davizane@amazon.com>
1 parent 5c183b8 commit 3eb29e8

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
3636
- Harden detection of HTTP/3 support by ensuring Quic native libraries are available for the target platform ([#20680](https://github.com/opensearch-project/OpenSearch/pull/20680))
3737
- Fallback to netty client if AWS Crt client is not available on the target platform / architecture ([#20698](https://github.com/opensearch-project/OpenSearch/pull/20698))
3838
- Fix ShardSearchFailure in transport-grpc ([#20641](https://github.com/opensearch-project/OpenSearch/pull/20641))
39+
- Fix flaky slowlog test ([#20726](https://github.com/opensearch-project/OpenSearch/pull/20726))
3940

4041
### Dependencies
4142
- Bump shadow-gradle-plugin from 8.3.9 to 9.3.1 ([#20569](https://github.com/opensearch-project/OpenSearch/pull/20569))

server/src/test/java/org/opensearch/action/search/SearchRequestSlowLogTests.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,27 +88,25 @@ public static void cleanup() {
8888

8989
public void testMultipleSlowLoggersUseSingleLog4jLogger() {
9090
LoggerContext context = (LoggerContext) LogManager.getContext(false);
91+
String loggerName = SearchRequestSlowLog.CLUSTER_SEARCH_REQUEST_SLOWLOG_PREFIX + ".SearchRequestSlowLog";
9192

92-
new MockSearchPhaseContext(1);
9393
ClusterService clusterService1 = ClusterServiceUtils.createClusterService(
9494
Settings.EMPTY,
9595
new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS),
9696
null
9797
);
9898
new SearchRequestSlowLog(clusterService1);
99-
int numberOfLoggersBefore = context.getLoggers().size();
99+
Logger logger1 = context.getLogger(loggerName);
100100

101-
new MockSearchPhaseContext(1);
102101
ClusterService clusterService2 = ClusterServiceUtils.createClusterService(
103102
Settings.EMPTY,
104103
new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS),
105104
null
106105
);
107-
new SearchRequestOperationsCompositeListenerFactory();
108106
new SearchRequestSlowLog(clusterService2);
107+
Logger logger2 = context.getLogger(loggerName);
109108

110-
int numberOfLoggersAfter = context.getLoggers().size();
111-
assertThat(numberOfLoggersAfter, equalTo(numberOfLoggersBefore));
109+
assertSame(logger1, logger2);
112110
}
113111

114112
public void testOnRequestEnd() {

0 commit comments

Comments
 (0)