Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix MasterServiceTests.testClusterStateUpdateLogging #38142

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -325,11 +325,16 @@ public void testClusterStateUpdateLogging() throws Exception {
MasterService.class.getCanonicalName(),
Level.DEBUG,
"*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);
Loggers.addAppender(clusterLogger, mockAppender);
try {
final CountDownLatch latch = new CountDownLatch(4);
masterService.currentTimeOverride = System.nanoTime();
masterService.submitStateUpdateTask("test1", new ClusterStateUpdateTask() {
@Override
Expand All @@ -339,9 +344,7 @@ public ClusterState execute(ClusterState currentState) throws Exception {
}

@Override
public void clusterStateProcessed(String source, ClusterState oldState, ClusterState newState) {
latch.countDown();
}
public void clusterStateProcessed(String source, ClusterState oldState, ClusterState newState) { }

@Override
public void onFailure(String source, Exception e) {
Expand All @@ -361,9 +364,7 @@ public void clusterStateProcessed(String source, ClusterState oldState, ClusterS
}

@Override
public void onFailure(String source, Exception e) {
latch.countDown();
}
public void onFailure(String source, Exception e) { }
});
masterService.submitStateUpdateTask("test3", new ClusterStateUpdateTask() {
@Override
Expand All @@ -373,9 +374,7 @@ public ClusterState execute(ClusterState currentState) {
}

@Override
public void clusterStateProcessed(String source, ClusterState oldState, ClusterState newState) {
latch.countDown();
}
public void clusterStateProcessed(String source, ClusterState oldState, ClusterState newState) { }

@Override
public void onFailure(String source, Exception e) {
Expand All @@ -391,21 +390,18 @@ public ClusterState execute(ClusterState currentState) {
}

@Override
public void clusterStateProcessed(String source, ClusterState oldState, ClusterState newState) {
latch.countDown();
}
public void clusterStateProcessed(String source, ClusterState oldState, ClusterState newState) { }

@Override
public void onFailure(String source, Exception e) {
fail();
}
});
latch.await();
assertBusy(mockAppender::assertAllExpectationsMatched);
} finally {
Loggers.removeAppender(clusterLogger, mockAppender);
mockAppender.stop();
}
mockAppender.assertAllExpectationsMatched();
}

public void testClusterStateBatchedUpdates() throws BrokenBarrierException, InterruptedException {
Expand Down