@@ -128,19 +128,22 @@ public void testClusterStateUpdateLogging() throws Exception {
128128 clusterApplierService .getClass ().getCanonicalName (),
129129 Level .TRACE ,
130130 "*failed to execute cluster state applier in [2s]*" ));
131+ mockAppender .addExpectation (
132+ new MockLogAppender .SeenEventExpectation (
133+ "test3" ,
134+ clusterApplierService .getClass ().getCanonicalName (),
135+ Level .DEBUG ,
136+ "*processing [test3]: took [0s] no change in cluster state*" ));
131137
132138 Logger clusterLogger = LogManager .getLogger ("org.elasticsearch.cluster.service" );
133139 Loggers .addAppender (clusterLogger , mockAppender );
134140 try {
135- final CountDownLatch latch = new CountDownLatch (3 );
136141 clusterApplierService .currentTimeOverride = System .nanoTime ();
137142 clusterApplierService .runOnApplierThread ("test1" ,
138143 currentState -> clusterApplierService .currentTimeOverride += TimeValue .timeValueSeconds (1 ).nanos (),
139144 new ClusterApplyListener () {
140145 @ Override
141- public void onSuccess (String source ) {
142- latch .countDown ();
143- }
146+ public void onSuccess (String source ) { }
144147
145148 @ Override
146149 public void onFailure (String source , Exception e ) {
@@ -159,31 +162,25 @@ public void onSuccess(String source) {
159162 }
160163
161164 @ Override
162- public void onFailure (String source , Exception e ) {
163- latch .countDown ();
164- }
165+ public void onFailure (String source , Exception e ) { }
165166 });
166167 // Additional update task to make sure all previous logging made it to the loggerName
167- // We don't check logging for this on since there is no guarantee that it will occur before our check
168168 clusterApplierService .runOnApplierThread ("test3" ,
169169 currentState -> {},
170170 new ClusterApplyListener () {
171171 @ Override
172- public void onSuccess (String source ) {
173- latch .countDown ();
174- }
172+ public void onSuccess (String source ) { }
175173
176174 @ Override
177175 public void onFailure (String source , Exception e ) {
178176 fail ();
179177 }
180178 });
181- latch . await ( );
179+ assertBusy ( mockAppender :: assertAllExpectationsMatched );
182180 } finally {
183181 Loggers .removeAppender (clusterLogger , mockAppender );
184182 mockAppender .stop ();
185183 }
186- mockAppender .assertAllExpectationsMatched ();
187184 }
188185
189186 @ TestLogging ("org.elasticsearch.cluster.service:WARN" ) // To ensure that we log cluster state events on WARN level
0 commit comments