Fix MasterServiceTests.testClusterStateUpdateLogging (#38116)
This changes the test to not use a `CountDownlatch`, instead adding an assertion for the final logging message and waiting until the `MockAppender` has seen it before proceeding. Related to df2c06f6f30f7e23a6863a3f72fc3bdb7648885c Resolves #23739
This commit is contained in:
parent
f3cde06a1d
commit
c67a9663af
|
@ -328,11 +328,16 @@ public class MasterServiceTests extends ESTestCase {
|
||||||
MasterService.class.getCanonicalName(),
|
MasterService.class.getCanonicalName(),
|
||||||
Level.DEBUG,
|
Level.DEBUG,
|
||||||
"*processing [test3]: took [3s] done publishing updated cluster state (version: *, uuid: *)"));
|
"*processing [test3]: took [3s] done publishing updated cluster state (version: *, uuid: *)"));
|
||||||
|
mockAppender.addExpectation(
|
||||||
|
new MockLogAppender.SeenEventExpectation(
|
||||||
|
"test4",
|
||||||
|
MasterService.class.getCanonicalName(),
|
||||||
|
Level.DEBUG,
|
||||||
|
"*processing [test4]: took [0s] no change in cluster state"));
|
||||||
|
|
||||||
Logger clusterLogger = LogManager.getLogger(MasterService.class);
|
Logger clusterLogger = LogManager.getLogger(MasterService.class);
|
||||||
Loggers.addAppender(clusterLogger, mockAppender);
|
Loggers.addAppender(clusterLogger, mockAppender);
|
||||||
try {
|
try {
|
||||||
final CountDownLatch latch = new CountDownLatch(4);
|
|
||||||
masterService.currentTimeOverride = System.nanoTime();
|
masterService.currentTimeOverride = System.nanoTime();
|
||||||
masterService.submitStateUpdateTask("test1", new ClusterStateUpdateTask() {
|
masterService.submitStateUpdateTask("test1", new ClusterStateUpdateTask() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -342,9 +347,7 @@ public class MasterServiceTests extends ESTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clusterStateProcessed(String source, ClusterState oldState, ClusterState newState) {
|
public void clusterStateProcessed(String source, ClusterState oldState, ClusterState newState) { }
|
||||||
latch.countDown();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(String source, Exception e) {
|
public void onFailure(String source, Exception e) {
|
||||||
|
@ -364,9 +367,7 @@ public class MasterServiceTests extends ESTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(String source, Exception e) {
|
public void onFailure(String source, Exception e) { }
|
||||||
latch.countDown();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
masterService.submitStateUpdateTask("test3", new ClusterStateUpdateTask() {
|
masterService.submitStateUpdateTask("test3", new ClusterStateUpdateTask() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -376,9 +377,7 @@ public class MasterServiceTests extends ESTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clusterStateProcessed(String source, ClusterState oldState, ClusterState newState) {
|
public void clusterStateProcessed(String source, ClusterState oldState, ClusterState newState) { }
|
||||||
latch.countDown();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(String source, Exception e) {
|
public void onFailure(String source, Exception e) {
|
||||||
|
@ -394,21 +393,18 @@ public class MasterServiceTests extends ESTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clusterStateProcessed(String source, ClusterState oldState, ClusterState newState) {
|
public void clusterStateProcessed(String source, ClusterState oldState, ClusterState newState) { }
|
||||||
latch.countDown();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(String source, Exception e) {
|
public void onFailure(String source, Exception e) {
|
||||||
fail();
|
fail();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
latch.await();
|
assertBusy(mockAppender::assertAllExpectationsMatched);
|
||||||
} finally {
|
} finally {
|
||||||
Loggers.removeAppender(clusterLogger, mockAppender);
|
Loggers.removeAppender(clusterLogger, mockAppender);
|
||||||
mockAppender.stop();
|
mockAppender.stop();
|
||||||
}
|
}
|
||||||
mockAppender.assertAllExpectationsMatched();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testClusterStateBatchedUpdates() throws BrokenBarrierException, InterruptedException {
|
public void testClusterStateBatchedUpdates() throws BrokenBarrierException, InterruptedException {
|
||||||
|
|
Loading…
Reference in New Issue