Skip to content

Commit c389b96

Browse files
authored
Speed up shutdown in test cases (apache#3809)
* speed up shutdown in test cases * fix failed test
1 parent 6f09c60 commit c389b96

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/AutoRecoveryMainTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import static org.junit.Assert.assertTrue;
2727

2828
import java.io.IOException;
29+
import java.util.concurrent.TimeUnit;
2930
import org.apache.bookkeeper.bookie.BookieImpl;
3031
import org.apache.bookkeeper.meta.zk.ZKMetadataClientDriver;
3132
import org.apache.bookkeeper.net.BookieId;
@@ -118,7 +119,7 @@ public void testAutoRecoverySessionLoss() throws Exception {
118119
assertNotNull(currentAuditor);
119120
Auditor auditor1 = main1.auditorElector.getAuditor();
120121
assertEquals("Current Auditor should be AR1", currentAuditor, BookieImpl.getBookieId(confByIndex(0)));
121-
Awaitility.await().untilAsserted(() -> {
122+
Awaitility.waitAtMost(30, TimeUnit.SECONDS).untilAsserted(() -> {
122123
assertNotNull(auditor1);
123124
assertTrue("Auditor of AR1 should be running", auditor1.isRunning());
124125
});

bookkeeper-server/src/test/java/org/apache/bookkeeper/test/BookKeeperClusterTestCase.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ protected void stopBKCluster() throws Exception {
275275
bkc.close();
276276
}
277277

278+
stopReplicationService();
278279
for (ServerTester t : servers) {
279280
t.shutdown();
280281
}
@@ -316,6 +317,7 @@ protected void stopAllBookies() throws Exception {
316317
}
317318

318319
protected void stopAllBookies(boolean shutdownClient) throws Exception {
320+
stopReplicationService();
319321
for (ServerTester t : servers) {
320322
t.shutdown();
321323
}
@@ -607,6 +609,7 @@ public void restartBookies(Function<ServerConfiguration, ServerConfiguration> re
607609
throws Exception {
608610
// shut down bookie server
609611
List<ServerConfiguration> confs = new ArrayList<>();
612+
stopReplicationService();
610613
for (ServerTester server : servers) {
611614
server.shutdown();
612615
confs.add(server.getConfiguration());
@@ -964,7 +967,7 @@ public void shutdown() throws Exception {
964967

965968
if (autoRecovery != null) {
966969
if (LOG.isDebugEnabled()) {
967-
LOG.debug("Shutdown auto recovery for bookieserver: {}", address);
970+
LOG.debug("Shutdown auto recovery for bookie server: {}", address);
968971
}
969972
autoRecovery.shutdown();
970973
}

0 commit comments

Comments
 (0)