zymap commented on code in PR #3505:
URL: https://github.com/apache/bookkeeper/pull/3505#discussion_r981921160
##########
bookkeeper-server/src/test/java/org/apache/bookkeeper/client/SlowBookieTest.java:
##########
@@ -390,4 +390,32 @@ public void operationComplete(int rc, Set<LedgerFragment>
fragments) {
checklatch.await();
assertEquals("There should be no missing fragments", 0,
numFragments.get());
}
+
+ @Test
+ public void testWaitForWritable() throws Exception {
+ final ClientConfiguration conf = new ClientConfiguration();
+ conf.setMetadataServiceUri(zkUtil.getMetadataServiceUri());
+ BookKeeper bkc = new BookKeeper(conf);
+
+ byte[] pwd = new byte[]{};
+ try (LedgerHandle lh = bkc.createLedger(1, 1, 1,
BookKeeper.DigestType.CRC32, pwd)) {
+ long entryId = lh.addEntry(this.entry);
+
+ RoundRobinDistributionSchedule schedule = new
RoundRobinDistributionSchedule(1, 1, 1);
+ DistributionSchedule.WriteSet writeSet =
schedule.getWriteSet(entryId);
+
+ int slowBookieIndex =
writeSet.get(ThreadLocalRandom.current().nextInt(writeSet.size()));
+ List<BookieId> curEns = lh.getCurrentEnsemble();
+
+ // disable channel writable
+ setTargetChannelState(bkc, curEns.get(slowBookieIndex), 0, false);
+ boolean isWriteable = lh.waitForWritable(writeSet, 0, 1000);
Review Comment:
This is always true/false if you set the state before you call this method.
We need a test to make sure after the backoff retries, it returns the correct
state after the `waitForWritable`.
So the test case will be like this:
1. change the writable to false.
2. call the `waitForWriable`, it will retry with backoff.
3. at the same time, change the writable to true.
4. we should get the true from the step2 call.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]