Skip to content

Commit

Permalink
fix test.
Browse files Browse the repository at this point in the history
  • Loading branch information
Technoboy- committed Aug 16, 2022
1 parent a756613 commit 23a7e95
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1403,12 +1403,14 @@ public void testReplicatorWithFailedAck() throws Exception {
ConcurrentOpenHashMap<String, Replicator> replicators = topic.getReplicators();
PersistentReplicator replicator = (PersistentReplicator) replicators.get("r2");

Awaitility.await().timeout(50, TimeUnit.SECONDS)
Awaitility.await().pollInterval(1, TimeUnit.SECONDS).timeout(30, TimeUnit.SECONDS)
.untilAsserted(() -> assertEquals(org.apache.pulsar.broker.service.AbstractReplicator.State.Started,
replicator.getState()));

assertEquals(replicator.getState(), org.apache.pulsar.broker.service.AbstractReplicator.State.Started);
ManagedCursorImpl cursor = (ManagedCursorImpl) replicator.getCursor();
Awaitility.await().pollInterval(1, TimeUnit.SECONDS).timeout(30, TimeUnit.SECONDS)
.until(() -> cursor.getMarkDeletedPosition().getEntryId() == 1);
cursor.setState(State.Closed);

Field field = ManagedCursorImpl.class.getDeclaredField("state");
Expand All @@ -1420,14 +1422,14 @@ public void testReplicatorWithFailedAck() throws Exception {
Position deletedPos = cursor.getMarkDeletedPosition();
Position readPos = cursor.getReadPosition();

Awaitility.await().timeout(30, TimeUnit.SECONDS).until(
Awaitility.await().pollInterval(1, TimeUnit.SECONDS).timeout(30, TimeUnit.SECONDS).until(
() -> cursor.getMarkDeletedPosition().getEntryId() != (cursor.getReadPosition().getEntryId() - 1));

assertNotEquals((readPos.getEntryId() - 1), deletedPos.getEntryId());

field.set(cursor, State.Open);

Awaitility.await().timeout(30, TimeUnit.SECONDS).until(
Awaitility.await().pollInterval(1, TimeUnit.SECONDS).timeout(30, TimeUnit.SECONDS).until(
() -> cursor.getMarkDeletedPosition().getEntryId() == (cursor.getReadPosition().getEntryId() - 1));

deletedPos = cursor.getMarkDeletedPosition();
Expand Down

0 comments on commit 23a7e95

Please sign in to comment.