realm-kotlin
realm-kotlin copied to clipboard
Flaky test: SubscriptionTests.managedProperties [macOs]
On MacOS, tests have been discovered to be flaky in the following case:
val now = Clock.System.now().toRealmInstant()
val updatedSubs = realm.subscriptions.update {
add(realm.query<FlexParentObject>())
}
val sub = updatedSubs.first()
assertTrue(now <= sub.createdAt, "Was: $now <= ${sub.createdAt}")
Sometimes the last assertion fails with something like: kotlin.AssertionError: RealmInstant(epochSeconds=1653415696, nanosecondsOfSecond=19000000) <= RealmInstant(epochSeconds=1653415696, nanosecondsOfSecond=18749000)
The theory is that Clock.System.now() and Realm Core are using two different sources for their clocks, resulting in differences on the nanosecond scale. This means that sometimes the Core timestamp appears as being created before the Kotlin timestamp even though it was the opposite.
Example: https://ci.realm.io/blue/organizations/jenkins/realm%2Frealm-kotlin/detail/PR-824/25/tests
So far the work-around is just delaying tests that depend on this behaviour.