Skip to content

Commit

Permalink
[fix][test] fix test testSyncNormalPositionWhenTBRecover
Browse files Browse the repository at this point in the history
  • Loading branch information
liangyepianzhou committed Feb 26, 2024
1 parent 1b1cfb5 commit 91f5f17
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,14 @@ public void testSyncNormalPositionWhenTBRecover(boolean clientEnableTransaction,
position = topicTransactionBuffer.getMaxReadPosition();
assertEquals(position, PositionImpl.EARLIEST);

// change to None state can recover
field.set(topicTransactionBuffer, TopicTransactionBufferState.State.None);

// invoke recover
Method method = TopicTransactionBuffer.class.getDeclaredMethod("recover");
method.setAccessible(true);
method.invoke(topicTransactionBuffer);

// change to None state can recover
field.set(topicTransactionBuffer, TopicTransactionBufferState.State.None);

// recover success again
checkTopicTransactionBufferState(clientEnableTransaction, topicTransactionBuffer);

Expand All @@ -236,13 +236,15 @@ public void testSyncNormalPositionWhenTBRecover(boolean clientEnableTransaction,
private void checkTopicTransactionBufferState(boolean clientEnableTransaction,
TopicTransactionBuffer topicTransactionBuffer) {
// recover success
Awaitility.await().until(() -> {
Awaitility.await().untilAsserted(() -> {
if (clientEnableTransaction) {
// recover success, client enable transaction will change to Ready State
return topicTransactionBuffer.getStats(false, false).state.equals(Ready.name());
assertEquals(topicTransactionBuffer.getStats(false, false).state,
Ready.name());
} else {
// recover success, client disable transaction will change to NoSnapshot State
return topicTransactionBuffer.getStats(false, false).state.equals(NoSnapshot.name());
assertEquals(topicTransactionBuffer.getStats(false, false).state,
NoSnapshot.name());
}
});
}
Expand Down

0 comments on commit 91f5f17

Please sign in to comment.