jzhuge commented on pull request #1389:
URL: https://github.com/apache/iceberg/pull/1389#issuecomment-681321493
The PR is to enhance the testability of Snapshot, a feature sensitive to
timings, especially when expiring snapshots. It injects a clock that can be
either system clock in production or a test clock in testing. The PR adds a
test clock implementation that is fixed and can be reset or advanced. Please
note default Java 8 concrete clock classes like `Clock.fixed` are immutable.
Unit tests no longer have to perform busy wait or sleep like the following:
```
// t1: append and commit
// busy wait or sleep
// t2: append and commit
// busy wait or sleep
// expire snapshot before current time
```
Instead the tests will look like:
```
// t1: append and commit
// advance test clock by 1ms
// t1+1: append and commit
// advance test clock by 1ms
// expire snapshot before current time (t1+2)
```
or
```
// set the test clock to t1
// t1: append and commit
// set the test clock to t2
// t2: append and commit
// expire snapshot before t2+1
```
The unit tests can simulate running in the future, in the past, or in any
arbitrary point in time. The tests will run faster. And they will be slightly
more reliable as they don't rely on system clock.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]