Closed akudiyar closed 2 years ago
Most likely reason of this tests flakin is that crud reads data from replica before they have been replicated there. Need to reproduce this case and check. If so the following workaraound retrying method for selects can be used:
public class FlakyTestWa {
public static <T> Optional<T> execWithRetry(int tries, Supplier<Optional<T>> fn) {
Optional<T> result;
int c = 0;
do {
result = fn.get();
} while (c < tries && !result.isPresent());
return result;
}
}
...
//first entity must be returned
Optional<BookStore> bookStoreRecord = execWithRetry(3, () ->
bookStoreRepository.findById(BookStoreId.builder()
.bookId(1)
.receivedAt(ts).build())
);
assertThat(bookStoreRecord).hasValueSatisfying(actual -> {
assertThat(actual.getBookId()).isEqualTo(1);
assertThat(actual.getStoreNumber()).isEqualTo(123);
assertThat(actual.getReceivedAt()).isEqualTo(ts);
});
...
See the last run results https://github.com/tarantool/cartridge-springdata/actions/runs/664124454