From 26ccf57b60d33402f8da8543f4850fe3e5f5ae19 Mon Sep 17 00:00:00 2001 From: Clemente Date: Tue, 9 Jul 2024 16:34:49 +0200 Subject: [PATCH 01/42] Bump core --- .github/workflows/include-static-analysis.yml | 8 +++-- CHANGELOG.md | 3 +- packages/external/core | 2 +- .../mongodb/internal/SyncSessionImpl.kt | 2 +- .../kotlin/test/common/EncryptionTests.kt | 1 + .../kotlin/test/mongodb/common/AppTests.kt | 2 ++ .../common/SyncClientResetIntegrationTests.kt | 30 ++++++------------- .../test/mongodb/common/SyncedRealmTests.kt | 4 +-- 8 files changed, 24 insertions(+), 28 deletions(-) diff --git a/.github/workflows/include-static-analysis.yml b/.github/workflows/include-static-analysis.yml index 2232554864..8ba58acab0 100644 --- a/.github/workflows/include-static-analysis.yml +++ b/.github/workflows/include-static-analysis.yml @@ -35,6 +35,7 @@ jobs: run: ./gradlew ktlintCheck - name: Stash Ktlint results + if: always() run: | rm -rf /tmp/ktlint rm -rf /tmp/detekt @@ -50,6 +51,7 @@ jobs: - name: Publish Ktlint results uses: actions/upload-artifact@v4 + if: always() with: name: Ktlint Analyzer report path: /tmp/ktlint/* @@ -83,9 +85,10 @@ jobs: run: ./gradlew :gradle-plugin:publishAllPublicationsToTestRepository --info --stacktrace - name: Run Detekt - run: ./gradlew detekt + run: ./gradlew /tmp/detekt - - name: Stash Detekt results + - name: Stash Detekt results + if: always() run: | rm -rf /tmp/detekt mkdir /tmp/detekt @@ -99,6 +102,7 @@ jobs: - name: Publish Detekt results uses: actions/upload-artifact@v4 + if: always() with: name: Detekt Analyzer report path: /tmp/detekt/* diff --git a/CHANGELOG.md b/CHANGELOG.md index 3473190aa2..f7ad8ee030 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,7 +25,8 @@ * Minimum R8: 8.0.34. ### Internal -* None. +* Reworked test app initializer framework. +* Updated to Realm Core 14.10.3 commit 3334d3869b8cba9a4ae63247f80f3f1739e32c07. ## 2.1.0 (2024-07-12) diff --git a/packages/external/core b/packages/external/core index c280bdb175..3334d3869b 160000 --- a/packages/external/core +++ b/packages/external/core @@ -1 +1 @@ -Subproject commit c280bdb17522323d5c30dc32a2b9efc9dc80ca3b +Subproject commit 3334d3869b8cba9a4ae63247f80f3f1739e32c07 diff --git a/packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/internal/SyncSessionImpl.kt b/packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/internal/SyncSessionImpl.kt index 9fcfdc8a1b..c7dd207ae4 100644 --- a/packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/internal/SyncSessionImpl.kt +++ b/packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/internal/SyncSessionImpl.kt @@ -168,7 +168,7 @@ internal open class SyncSessionImpl( nativePointer, error, message, - true + false ) } diff --git a/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/EncryptionTests.kt b/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/EncryptionTests.kt index 0377f0a106..247d601820 100644 --- a/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/EncryptionTests.kt +++ b/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/EncryptionTests.kt @@ -69,6 +69,7 @@ class EncryptionTests { // Initialize an encrypted Realm val encryptedConf = RealmConfiguration .Builder( + schema = setOf(Sample::class) ) .directory(tmpDir) diff --git a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/AppTests.kt b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/AppTests.kt index 373678ac1c..6639cd873f 100644 --- a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/AppTests.kt +++ b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/AppTests.kt @@ -415,6 +415,7 @@ class AppTests { } @Test + @Ignore fun encryptedMetadataRealm_openWithWrongKeyThrows() { val tempDir = PlatformUtils.createTempDir() @@ -456,6 +457,7 @@ class AppTests { } @Test + @Ignore fun encryptedMetadataRealm_openWithoutKeyThrows() { val tempDir = PlatformUtils.createTempDir() diff --git a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SyncClientResetIntegrationTests.kt b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SyncClientResetIntegrationTests.kt index 66a26acc6b..660fac5c7d 100644 --- a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SyncClientResetIntegrationTests.kt +++ b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SyncClientResetIntegrationTests.kt @@ -710,10 +710,8 @@ class SyncClientResetIntegrationTests { exception: ClientResetRequiredException ) { // Notify that this callback has been invoked - assertEquals( - "[Sync][AutoClientResetFailed(1028)] A fatal error occurred during client reset: 'User-provided callback failed'.", - exception.message - ) + assertTrue(exception.message!!.contains("User-provided callback failed")) + assertIs(exception.cause) assertEquals( "User exception", @@ -788,10 +786,8 @@ class SyncClientResetIntegrationTests { exception: ClientResetRequiredException ) { // Notify that this callback has been invoked - assertEquals( - "[Sync][AutoClientResetFailed(1028)] A fatal error occurred during client reset: 'User-provided callback failed'.", - exception.message - ) + assertTrue(exception.message!!.contains("User-provided callback failed")) + channel.trySendOrFail(ClientResetEvents.ON_MANUAL_RESET_FALLBACK) } }).build() @@ -1123,10 +1119,8 @@ class SyncClientResetIntegrationTests { exception: ClientResetRequiredException ) { // Notify that this callback has been invoked - assertEquals( - "[Sync][AutoClientResetFailed(1028)] A fatal error occurred during client reset: 'User-provided callback failed'.", - exception.message - ) + assertTrue(exception.message!!.contains("User-provided callback failed")) + channel.trySendOrFail(ClientResetEvents.ON_MANUAL_RESET_FALLBACK) } }).build() @@ -1193,11 +1187,8 @@ class SyncClientResetIntegrationTests { // Validate that files have been moved after explicit reset assertFalse(fileExists(originalFilePath)) assertTrue(fileExists(recoveryFilePath)) - - assertEquals( - "[Sync][AutoClientResetFailed(1028)] A fatal error occurred during client reset: 'User-provided callback failed'.", - exception.message - ) + println(exception.message) + assertTrue(exception.message!!.contains("User-provided callback failed")) channel.trySendOrFail(ClientResetEvents.ON_MANUAL_RESET_FALLBACK) } @@ -1400,10 +1391,7 @@ class SyncClientResetIntegrationTests { assertFalse(fileExists(originalFilePath)) assertTrue(fileExists(recoveryFilePath)) - assertEquals( - "[Sync][AutoClientResetFailed(1028)] A fatal error occurred during client reset: 'User-provided callback failed'.", - exception.message - ) + assertTrue(exception.message!!.contains("User-provided callback failed")) channel.trySendOrFail(ClientResetEvents.ON_MANUAL_RESET_FALLBACK) } diff --git a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SyncedRealmTests.kt b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SyncedRealmTests.kt index b5bf6141a9..a2f657cedd 100644 --- a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SyncedRealmTests.kt +++ b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SyncedRealmTests.kt @@ -350,14 +350,14 @@ class SyncedRealmTests { syncSession = (realm.syncSession as SyncSessionImpl).nativePointer, error = ErrorCode.RLM_ERR_ACCOUNT_NAME_IN_USE, errorMessage = "Non fatal error", - isFatal = true, // flipped https://jira.mongodb.org/browse/RCORE-2146 + isFatal = false, ) RealmInterop.realm_sync_session_handle_error_for_testing( syncSession = (realm.syncSession as SyncSessionImpl).nativePointer, error = ErrorCode.RLM_ERR_INTERNAL_SERVER_ERROR, errorMessage = "Fatal error", - isFatal = false, // flipped https://jira.mongodb.org/browse/RCORE-2146 + isFatal = true, ) } } From 61f45b06642365f7cc47acdae747c2106e9e1151 Mon Sep 17 00:00:00 2001 From: Clemente Date: Tue, 9 Jul 2024 18:02:43 +0200 Subject: [PATCH 02/42] add workaround for encryption app tests --- .../kotlin/test/platform/PlatformUtils.kt | 4 ++++ .../kotlin/test/platform/PlatformUtils.kt | 1 + .../kotlin/test/platform/PlatformUtils.kt | 5 +++++ .../kotlin/test/platform/PlatformUtils.kt | 4 ++++ .../kotlin/test/mongodb/common/AppTests.kt | 20 +++++++++++++++---- 5 files changed, 30 insertions(+), 4 deletions(-) diff --git a/packages/test-base/src/androidMain/kotlin/io/realm/kotlin/test/platform/PlatformUtils.kt b/packages/test-base/src/androidMain/kotlin/io/realm/kotlin/test/platform/PlatformUtils.kt index cfc7d1f33f..706f9815c4 100644 --- a/packages/test-base/src/androidMain/kotlin/io/realm/kotlin/test/platform/PlatformUtils.kt +++ b/packages/test-base/src/androidMain/kotlin/io/realm/kotlin/test/platform/PlatformUtils.kt @@ -56,6 +56,10 @@ actual object PlatformUtils { } SystemClock.sleep(5000) // 5 seconds to give the GC some time to process } + + actual fun copyFile(originPath: String, targetPath: String) { + File(originPath).copyTo(File(targetPath)) + } } // Allocs as much garbage as we can. Pass maxSize = 0 to use all available memory in the process. diff --git a/packages/test-base/src/commonMain/kotlin/io/realm/kotlin/test/platform/PlatformUtils.kt b/packages/test-base/src/commonMain/kotlin/io/realm/kotlin/test/platform/PlatformUtils.kt index ee6a77661d..60b595f793 100644 --- a/packages/test-base/src/commonMain/kotlin/io/realm/kotlin/test/platform/PlatformUtils.kt +++ b/packages/test-base/src/commonMain/kotlin/io/realm/kotlin/test/platform/PlatformUtils.kt @@ -7,6 +7,7 @@ import kotlin.time.Duration expect object PlatformUtils { fun createTempDir(prefix: String = Utils.createRandomString(16), readOnly: Boolean = false): String fun deleteTempDir(path: String) + fun copyFile(originPath: String, targetPath: String) fun sleep(duration: Duration) fun threadId(): ULong fun triggerGC() diff --git a/packages/test-base/src/jvmMain/kotlin/io/realm/kotlin/test/platform/PlatformUtils.kt b/packages/test-base/src/jvmMain/kotlin/io/realm/kotlin/test/platform/PlatformUtils.kt index 498ba62df6..c9708e5148 100644 --- a/packages/test-base/src/jvmMain/kotlin/io/realm/kotlin/test/platform/PlatformUtils.kt +++ b/packages/test-base/src/jvmMain/kotlin/io/realm/kotlin/test/platform/PlatformUtils.kt @@ -16,6 +16,7 @@ package io.realm.kotlin.test.platform +import java.io.File import java.nio.file.Files import java.nio.file.Path import java.nio.file.Paths @@ -41,6 +42,10 @@ actual object PlatformUtils { return dir.absolutePathString() } + actual fun copyFile(originPath: String, targetPath: String) { + File(originPath).copyTo(File(targetPath)) + } + actual fun deleteTempDir(path: String) { val rootPath: Path = Paths.get(path) val pathsToDelete: List = diff --git a/packages/test-base/src/nativeDarwin/kotlin/io/realm/kotlin/test/platform/PlatformUtils.kt b/packages/test-base/src/nativeDarwin/kotlin/io/realm/kotlin/test/platform/PlatformUtils.kt index d92ec1d549..324734b843 100644 --- a/packages/test-base/src/nativeDarwin/kotlin/io/realm/kotlin/test/platform/PlatformUtils.kt +++ b/packages/test-base/src/nativeDarwin/kotlin/io/realm/kotlin/test/platform/PlatformUtils.kt @@ -72,4 +72,8 @@ actual object PlatformUtils { actual fun triggerGC() { GC.collect() } + + actual fun copyFile(originPath: String, targetPath: String) { + platform.Foundation.NSFileManager.defaultManager.copyItemAtPath(originPath, targetPath, null) + } } diff --git a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/AppTests.kt b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/AppTests.kt index 6639cd873f..3739f40c92 100644 --- a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/AppTests.kt +++ b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/AppTests.kt @@ -415,7 +415,6 @@ class AppTests { } @Test - @Ignore fun encryptedMetadataRealm_openWithWrongKeyThrows() { val tempDir = PlatformUtils.createTempDir() @@ -439,12 +438,19 @@ class AppTests { // Create a configuration pointing to the metadata Realm for that app val metadataDir = "${app.configuration.syncRootDirectory}/mongodb-realm/${app.configuration.appId}/server-utility/metadata/" + + // We cannot validate if the test app metadata realm is encrypted directly, as it is cached + // and subsequent access wont validate the encryption key. Copying the Realm allows to bypass + // the cache. + PlatformUtils.copyFile(metadataDir + "sync_metadata.realm", metadataDir + "copy_sync_metadata.realm") + val wrongKey = TestHelper.getRandomKey() val config = RealmConfiguration .Builder(setOf()) - .name("sync_metadata.realm") + .name("copy_sync_metadata.realm") .directory(metadataDir) .encryptionKey(wrongKey) + .schemaVersion(7) .build() assertTrue(fileExists(config.path)) @@ -457,7 +463,6 @@ class AppTests { } @Test - @Ignore fun encryptedMetadataRealm_openWithoutKeyThrows() { val tempDir = PlatformUtils.createTempDir() @@ -480,10 +485,17 @@ class AppTests { // Create a configuration pointing to the metadata Realm for that app val metadataDir = "${app.configuration.syncRootDirectory}/mongodb-realm/${app.configuration.appId}/server-utility/metadata/" + + // We cannot validate if the test app metadata realm is encrypted directly, as it is cached + // and subsequent access wont validate the encryption key. Copying the Realm allows to bypass + // the cache. + PlatformUtils.copyFile(metadataDir + "sync_metadata.realm", metadataDir + "copy_sync_metadata.realm") + val config = RealmConfiguration .Builder(setOf()) - .name("sync_metadata.realm") + .name("copy_sync_metadata.realm") .directory(metadataDir) + .schemaVersion(7) .build() assertTrue(fileExists(config.path)) From 2c61ee4209962b76b44a268e00a5de4588512827 Mon Sep 17 00:00:00 2001 From: Clemente Date: Tue, 9 Jul 2024 18:15:25 +0200 Subject: [PATCH 03/42] linting --- .../kotlin/io/realm/kotlin/test/common/EncryptionTests.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/EncryptionTests.kt b/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/EncryptionTests.kt index 247d601820..02526a98e1 100644 --- a/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/EncryptionTests.kt +++ b/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/EncryptionTests.kt @@ -69,7 +69,7 @@ class EncryptionTests { // Initialize an encrypted Realm val encryptedConf = RealmConfiguration .Builder( - + schema = setOf(Sample::class) ) .directory(tmpDir) From c860bed3038b3b6ecd1899103cc560eaa1a79692 Mon Sep 17 00:00:00 2001 From: Clemente Date: Wed, 10 Jul 2024 10:01:29 +0200 Subject: [PATCH 04/42] Remove tmp --- .github/workflows/include-static-analysis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/include-static-analysis.yml b/.github/workflows/include-static-analysis.yml index 8ba58acab0..60ec663580 100644 --- a/.github/workflows/include-static-analysis.yml +++ b/.github/workflows/include-static-analysis.yml @@ -85,7 +85,7 @@ jobs: run: ./gradlew :gradle-plugin:publishAllPublicationsToTestRepository --info --stacktrace - name: Run Detekt - run: ./gradlew /tmp/detekt + run: ./gradlew detekt - name: Stash Detekt results if: always() From 6497b0640da7c2d88bf0e022d06b3afa0f924f76 Mon Sep 17 00:00:00 2001 From: Clemente Date: Wed, 10 Jul 2024 10:31:06 +0200 Subject: [PATCH 05/42] Try to fix test --- .../kotlin/test/mongodb/common/FLXProgressListenerTests.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt index 9c67b39196..8a4b5eebbf 100644 --- a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt +++ b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt @@ -40,6 +40,7 @@ import kotlinx.coroutines.flow.buffer import kotlinx.coroutines.flow.filter import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.last +import kotlinx.coroutines.flow.onStart import kotlinx.coroutines.flow.scan import kotlinx.coroutines.flow.takeWhile import kotlinx.coroutines.supervisorScope @@ -148,8 +149,10 @@ class FLXProgressListenerTests { fun uploadProgressListener_changesOnly() = runBlocking { Realm.open(createSyncConfig(app.createUserAndLogin())).use { realm -> for (i in 0..3) { - realm.writeSampleData(TEST_SIZE, timeout = TIMEOUT) realm.syncSession.progressAsFlow(Direction.UPLOAD, ProgressMode.CURRENT_CHANGES) + .onStart { + realm.writeSampleData(TEST_SIZE, timeout = TIMEOUT) + } .run { withTimeout(TIMEOUT) { last().let { From b7364d254c98a33d9851f84b24f5ab7c5020b81d Mon Sep 17 00:00:00 2001 From: Clemente Date: Wed, 10 Jul 2024 10:59:35 +0200 Subject: [PATCH 06/42] Point to cores issue --- .../kotlin/io/realm/kotlin/test/mongodb/common/AppTests.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/AppTests.kt b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/AppTests.kt index 3739f40c92..c129bb95cc 100644 --- a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/AppTests.kt +++ b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/AppTests.kt @@ -439,6 +439,7 @@ class AppTests { // Create a configuration pointing to the metadata Realm for that app val metadataDir = "${app.configuration.syncRootDirectory}/mongodb-realm/${app.configuration.appId}/server-utility/metadata/" + // Workaround for https://github.com/realm/realm-core/issues/7876 // We cannot validate if the test app metadata realm is encrypted directly, as it is cached // and subsequent access wont validate the encryption key. Copying the Realm allows to bypass // the cache. @@ -486,6 +487,7 @@ class AppTests { // Create a configuration pointing to the metadata Realm for that app val metadataDir = "${app.configuration.syncRootDirectory}/mongodb-realm/${app.configuration.appId}/server-utility/metadata/" + // Workaround for https://github.com/realm/realm-core/issues/7876 // We cannot validate if the test app metadata realm is encrypted directly, as it is cached // and subsequent access wont validate the encryption key. Copying the Realm allows to bypass // the cache. From 72835731a3f20e3f7fb5bfabc778fc57010bf51a Mon Sep 17 00:00:00 2001 From: Clemente Date: Wed, 10 Jul 2024 11:04:46 +0200 Subject: [PATCH 07/42] revet fix --- .../kotlin/test/mongodb/common/FLXProgressListenerTests.kt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt index 8a4b5eebbf..9c67b39196 100644 --- a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt +++ b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt @@ -40,7 +40,6 @@ import kotlinx.coroutines.flow.buffer import kotlinx.coroutines.flow.filter import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.last -import kotlinx.coroutines.flow.onStart import kotlinx.coroutines.flow.scan import kotlinx.coroutines.flow.takeWhile import kotlinx.coroutines.supervisorScope @@ -149,10 +148,8 @@ class FLXProgressListenerTests { fun uploadProgressListener_changesOnly() = runBlocking { Realm.open(createSyncConfig(app.createUserAndLogin())).use { realm -> for (i in 0..3) { + realm.writeSampleData(TEST_SIZE, timeout = TIMEOUT) realm.syncSession.progressAsFlow(Direction.UPLOAD, ProgressMode.CURRENT_CHANGES) - .onStart { - realm.writeSampleData(TEST_SIZE, timeout = TIMEOUT) - } .run { withTimeout(TIMEOUT) { last().let { From 642ddc7c5d9c8c8b36399402bfce2136284b54e8 Mon Sep 17 00:00:00 2001 From: Clemente Date: Wed, 10 Jul 2024 14:54:55 +0200 Subject: [PATCH 08/42] Bump timeout --- packages/external/core | 2 +- .../kotlin/test/mongodb/common/FLXProgressListenerTests.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/external/core b/packages/external/core index 3334d3869b..7c31f5d8fc 160000 --- a/packages/external/core +++ b/packages/external/core @@ -1 +1 @@ -Subproject commit 3334d3869b8cba9a4ae63247f80f3f1739e32c07 +Subproject commit 7c31f5d8fc9d76dc9e9274b0caf55144dee855c2 diff --git a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt index 9c67b39196..53728762cf 100644 --- a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt +++ b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt @@ -239,7 +239,7 @@ class FLXProgressListenerTests { try { val flow = realm.syncSession.progressAsFlow(Direction.UPLOAD, ProgressMode.INDEFINITELY) val job = async { - withTimeout(10.seconds) { + withTimeout(30.seconds) { flow.collect { channel.trySend(true) } From 354b99dcab56a499577b2c3f06562580c19aa8ac Mon Sep 17 00:00:00 2001 From: Clemente Date: Wed, 10 Jul 2024 15:51:37 +0200 Subject: [PATCH 09/42] allow initialRealm_partitionBasedSync to be rerun --- .../realm/kotlin/test/mongodb/common/SyncedRealmTests.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SyncedRealmTests.kt b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SyncedRealmTests.kt index a2f657cedd..4d30150a34 100644 --- a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SyncedRealmTests.kt +++ b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SyncedRealmTests.kt @@ -1650,14 +1650,17 @@ class SyncedRealmTests { println("Partition based sync bundled realm is in ${config2.path}") } - // This test cannot run multiple times on the same server instance as the primary - // key of the objects from asset-pbs.realm will not be unique on secondary runs. @Test fun initialRealm_partitionBasedSync() { val (email, password) = randomEmail() to "password1234" val user = runBlocking { app.createUserAndLogIn(email, password) } + + runBlocking { + app.asTestApp.deleteDocuments(app.configuration.appId, "ParentPk", "{}") + } + val config1 = createPartitionSyncConfig( user = user, partitionValue = partitionValue, name = "db1", errorHandler = object : SyncSession.ErrorHandler { From e790f6f7cab6592fe9e74d1d6e659f69d9a7d75a Mon Sep 17 00:00:00 2001 From: Clemente Date: Wed, 10 Jul 2024 17:27:33 +0200 Subject: [PATCH 10/42] Ignore test --- .../kotlin/test/mongodb/common/FLXProgressListenerTests.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt index 53728762cf..106d289c5e 100644 --- a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt +++ b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt @@ -48,6 +48,7 @@ import kotlinx.coroutines.withTimeout import kotlin.random.Random import kotlin.test.AfterTest import kotlin.test.BeforeTest +import kotlin.test.Ignore import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertFailsWith @@ -145,6 +146,7 @@ class FLXProgressListenerTests { } @Test + @Ignore // disabled until https://github.com/realm/realm-core/issues/7869 is fixed fun uploadProgressListener_changesOnly() = runBlocking { Realm.open(createSyncConfig(app.createUserAndLogin())).use { realm -> for (i in 0..3) { From c89bb1ea10c7675a312b615fabd9fe6ea6919f16 Mon Sep 17 00:00:00 2001 From: Clemente Date: Thu, 11 Jul 2024 07:51:58 +0200 Subject: [PATCH 11/42] Use assertContains --- .../mongodb/common/SyncClientResetIntegrationTests.kt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SyncClientResetIntegrationTests.kt b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SyncClientResetIntegrationTests.kt index 660fac5c7d..5e96219439 100644 --- a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SyncClientResetIntegrationTests.kt +++ b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SyncClientResetIntegrationTests.kt @@ -65,6 +65,7 @@ import kotlin.reflect.KClass import kotlin.test.AfterTest import kotlin.test.BeforeTest import kotlin.test.Test +import kotlin.test.assertContains import kotlin.test.assertEquals import kotlin.test.assertFalse import kotlin.test.assertIs @@ -710,7 +711,7 @@ class SyncClientResetIntegrationTests { exception: ClientResetRequiredException ) { // Notify that this callback has been invoked - assertTrue(exception.message!!.contains("User-provided callback failed")) + assertContains(exception.message!!, "User-provided callback failed") assertIs(exception.cause) assertEquals( @@ -786,7 +787,7 @@ class SyncClientResetIntegrationTests { exception: ClientResetRequiredException ) { // Notify that this callback has been invoked - assertTrue(exception.message!!.contains("User-provided callback failed")) + assertContains(exception.message!!, "User-provided callback failed") channel.trySendOrFail(ClientResetEvents.ON_MANUAL_RESET_FALLBACK) } @@ -1076,7 +1077,7 @@ class SyncClientResetIntegrationTests { assertNotNull(exception.originalFilePath) assertFalse(fileExists(exception.recoveryFilePath)) assertTrue(fileExists(exception.originalFilePath)) - assertTrue(exception.message!!.contains("Simulate Client Reset")) + assertContains(exception.message!!, "Simulate Client Reset") } } channel.close() @@ -1119,7 +1120,7 @@ class SyncClientResetIntegrationTests { exception: ClientResetRequiredException ) { // Notify that this callback has been invoked - assertTrue(exception.message!!.contains("User-provided callback failed")) + assertContains(exception.message!!, "User-provided callback failed") channel.trySendOrFail(ClientResetEvents.ON_MANUAL_RESET_FALLBACK) } @@ -1188,7 +1189,7 @@ class SyncClientResetIntegrationTests { assertFalse(fileExists(originalFilePath)) assertTrue(fileExists(recoveryFilePath)) println(exception.message) - assertTrue(exception.message!!.contains("User-provided callback failed")) + assertContains(exception.message!!, "User-provided callback failed") channel.trySendOrFail(ClientResetEvents.ON_MANUAL_RESET_FALLBACK) } From d4c9b5dafec42063b2e36d95ace3249db226775b Mon Sep 17 00:00:00 2001 From: Clemente Date: Thu, 11 Jul 2024 10:33:46 +0200 Subject: [PATCH 12/42] Bump gha versions --- .github/workflows/pr.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 7e9c45a8e2..6e9948204a 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -122,7 +122,7 @@ jobs: key: jni-linux-lib-${{ needs.check-cache.outputs.packages-sha }} - name: Setup Java 11 - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: distribution: ${{ vars.VERSION_JAVA_DISTRIBUTION }} java-version: ${{ vars.VERSION_JAVA }} @@ -473,7 +473,7 @@ jobs: echo '#!/bin/bash\nccache clang++ "$@"%"' > /usr/local/bin/ccache-clang++ - name: Setup Android SDK - uses: android-actions/setup-android@v2 + uses: android-actions/setup-android@v3 - name: Install NDK run: sdkmanager --install "ndk;${{ env.NDK_VERSION }}" @@ -602,7 +602,7 @@ jobs: echo '#!/bin/bash\nccache clang++ "$@"%"' > /usr/local/bin/ccache-clang++ - name: Setup Android SDK - uses: android-actions/setup-android@v2 + uses: android-actions/setup-android@v3 - name: Install NDK run: sdkmanager --install "ndk;${{ env.NDK_VERSION }}" From 033d2452e13f6f1ba135df53ed5d8193cec3609f Mon Sep 17 00:00:00 2001 From: Clemente Date: Thu, 11 Jul 2024 10:37:54 +0200 Subject: [PATCH 13/42] Suppress deprecation warnings --- .../kotlin/mongodb/exceptions/SyncExceptions.kt | 1 + .../kotlin/mongodb/internal/RealmSyncUtils.kt | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/exceptions/SyncExceptions.kt b/packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/exceptions/SyncExceptions.kt index 39d88e2e12..5350877d65 100644 --- a/packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/exceptions/SyncExceptions.kt +++ b/packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/exceptions/SyncExceptions.kt @@ -68,6 +68,7 @@ public open class UnrecoverableSyncException internal constructor(message: Strin * Thrown when the type of sync used by the server does not match the one used by the client, i.e. * the server and client disagrees whether to use Partition-based or Flexible Sync. */ +@Suppress("DEPRECATION") public class WrongSyncTypeException internal constructor(message: String) : UnrecoverableSyncException(message) diff --git a/packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/internal/RealmSyncUtils.kt b/packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/internal/RealmSyncUtils.kt index 46fbc13e17..a6f015b9fb 100644 --- a/packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/internal/RealmSyncUtils.kt +++ b/packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/internal/RealmSyncUtils.kt @@ -17,7 +17,6 @@ import io.realm.kotlin.mongodb.exceptions.FunctionExecutionException import io.realm.kotlin.mongodb.exceptions.InvalidCredentialsException import io.realm.kotlin.mongodb.exceptions.ServiceException import io.realm.kotlin.mongodb.exceptions.SyncException -import io.realm.kotlin.mongodb.exceptions.UnrecoverableSyncException import io.realm.kotlin.mongodb.exceptions.UserAlreadyConfirmedException import io.realm.kotlin.mongodb.exceptions.UserAlreadyExistsException import io.realm.kotlin.mongodb.exceptions.UserNotFoundException @@ -91,19 +90,26 @@ internal fun convertSyncError(syncError: SyncError): SyncException { syncError.compensatingWrites, syncError.isFatal ) + ErrorCode.RLM_ERR_SYNC_PROTOCOL_INVARIANT_FAILED, ErrorCode.RLM_ERR_SYNC_PROTOCOL_NEGOTIATION_FAILED, - ErrorCode.RLM_ERR_SYNC_PERMISSION_DENIED -> { + ErrorCode.RLM_ERR_SYNC_PERMISSION_DENIED, + -> { // Permission denied errors should be unrecoverable according to Core, i.e. the // client will disconnect sync and transition to the "inactive" state - UnrecoverableSyncException(message) + @Suppress("DEPRECATION") io.realm.kotlin.mongodb.exceptions.UnrecoverableSyncException( + message + ) } + else -> { // An error happened we are not sure how to handle. Just report as a generic // SyncException. when (syncError.isFatal) { false -> SyncException(message, syncError.isFatal) - true -> UnrecoverableSyncException(message) + true -> @Suppress("DEPRECATION") io.realm.kotlin.mongodb.exceptions.UnrecoverableSyncException( + message + ) } } } From 2dd78e1e25af04ac10f9d1d68b07a6a600892c4d Mon Sep 17 00:00:00 2001 From: Clemente Date: Thu, 11 Jul 2024 12:15:13 +0200 Subject: [PATCH 14/42] use correct java version for android SDK setup --- .github/workflows/pr.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 6e9948204a..e020cfcf54 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -547,7 +547,9 @@ jobs: uses: actions/setup-java@v4 with: distribution: ${{ vars.VERSION_JAVA_DISTRIBUTION }} - java-version: ${{ vars.VERSION_JAVA }} + java-version: | + 17 + ${{ vars.VERSION_JAVA }} - name: Setup Gradle and task/dependency caching uses: gradle/actions/setup-gradle@v3 @@ -602,6 +604,8 @@ jobs: echo '#!/bin/bash\nccache clang++ "$@"%"' > /usr/local/bin/ccache-clang++ - name: Setup Android SDK + env: + JAVA_HOME: ${{ env.JAVA_HOME_17_x64 }} uses: android-actions/setup-android@v3 - name: Install NDK From 1b07d2e876818e28fdffcdf061bc9006a8274ad2 Mon Sep 17 00:00:00 2001 From: Clemente Date: Thu, 11 Jul 2024 12:21:35 +0200 Subject: [PATCH 15/42] fix variable name --- .github/workflows/pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index e020cfcf54..28b0f33d46 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -605,7 +605,7 @@ jobs: - name: Setup Android SDK env: - JAVA_HOME: ${{ env.JAVA_HOME_17_x64 }} + JAVA_HOME: ${{ env.JAVA_HOME_17_X64 }} uses: android-actions/setup-android@v3 - name: Install NDK From 36ff3612d88ba98fe1e266a4d4e402d13916f619 Mon Sep 17 00:00:00 2001 From: Clemente Date: Thu, 11 Jul 2024 12:37:44 +0200 Subject: [PATCH 16/42] set jdk 17 to install ndk step --- .github/workflows/pr.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 28b0f33d46..4ef75fe85f 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -609,6 +609,8 @@ jobs: uses: android-actions/setup-android@v3 - name: Install NDK + env: + JAVA_HOME: ${{ env.JAVA_HOME_17_X64 }} run: sdkmanager --install "ndk;${{ env.NDK_VERSION }}" - name: Build Android Base Test Apk From e825ebf2f3706dee2c9e61b634c3847b2928f038 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus=20R=C3=B8rbech?= Date: Tue, 16 Jul 2024 10:21:19 +0200 Subject: [PATCH 17/42] Upgrade to Core 14.10.4 --- CHANGELOG.md | 3 +-- packages/external/core | 2 +- .../kotlin/test/mongodb/common/FLXProgressListenerTests.kt | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f7ad8ee030..1931706488 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,8 +26,7 @@ ### Internal * Reworked test app initializer framework. -* Updated to Realm Core 14.10.3 commit 3334d3869b8cba9a4ae63247f80f3f1739e32c07. - +* Updated to Realm Core 14.10.4 commit 4f83c590c4340dd7760d5f070e2e81613eb536aa. ## 2.1.0 (2024-07-12) diff --git a/packages/external/core b/packages/external/core index 7c31f5d8fc..4f83c590c4 160000 --- a/packages/external/core +++ b/packages/external/core @@ -1 +1 @@ -Subproject commit 7c31f5d8fc9d76dc9e9274b0caf55144dee855c2 +Subproject commit 4f83c590c4340dd7760d5f070e2e81613eb536aa diff --git a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt index 106d289c5e..b06d69e982 100644 --- a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt +++ b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt @@ -146,7 +146,6 @@ class FLXProgressListenerTests { } @Test - @Ignore // disabled until https://github.com/realm/realm-core/issues/7869 is fixed fun uploadProgressListener_changesOnly() = runBlocking { Realm.open(createSyncConfig(app.createUserAndLogin())).use { realm -> for (i in 0..3) { From 42cc4f5a0cf0e0c4c73e12a799b1e2932511cad6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus=20R=C3=B8rbech?= Date: Tue, 16 Jul 2024 10:23:10 +0200 Subject: [PATCH 18/42] Fix merge error in CHANGELOG --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1931706488..bf899f9b8f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,7 +25,6 @@ * Minimum R8: 8.0.34. ### Internal -* Reworked test app initializer framework. * Updated to Realm Core 14.10.4 commit 4f83c590c4340dd7760d5f070e2e81613eb536aa. ## 2.1.0 (2024-07-12) From 364999a1ddb6d6d9a442378f0c185590a0183e21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus=20R=C3=B8rbech?= Date: Tue, 16 Jul 2024 10:36:33 +0200 Subject: [PATCH 19/42] Another round for linting --- .../realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt index b06d69e982..53728762cf 100644 --- a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt +++ b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt @@ -48,7 +48,6 @@ import kotlinx.coroutines.withTimeout import kotlin.random.Random import kotlin.test.AfterTest import kotlin.test.BeforeTest -import kotlin.test.Ignore import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertFailsWith From a59074f28c18697a4527ff85be16b2ddda85d13b Mon Sep 17 00:00:00 2001 From: Clemente Date: Mon, 10 Jun 2024 23:07:47 +0200 Subject: [PATCH 20/42] Use client config --- .../kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt | 4 +--- .../kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt | 5 ++--- .../kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt | 5 ++--- packages/jni-swig-stub/realm.i | 2 -- .../io/realm/kotlin/mongodb/internal/AppConfigurationImpl.kt | 5 ++++- 5 files changed, 9 insertions(+), 12 deletions(-) diff --git a/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt b/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt index e012f627d4..ce9e60d32c 100644 --- a/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt +++ b/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt @@ -519,7 +519,6 @@ expect object RealmInterop { // App fun realm_app_get( appConfig: RealmAppConfigurationPointer, - syncClientConfig: RealmSyncClientConfigurationPointer, basePath: String, ): RealmAppPointer fun realm_app_get_current_user(app: RealmAppPointer): RealmUserPointer? @@ -599,8 +598,7 @@ expect object RealmInterop { fun realm_user_refresh_custom_data(app: RealmAppPointer, user: RealmUserPointer, callback: AppCallback) // Sync client config - fun realm_sync_client_config_new(): RealmSyncClientConfigurationPointer - + fun realm_app_config_get_sync_client_config(configPointer: RealmAppConfigurationPointer): RealmSyncClientConfigurationPointer fun realm_sync_client_config_set_default_binding_thread_observer( syncClientConfig: RealmSyncClientConfigurationPointer, appId: String diff --git a/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt b/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt index facb5d5814..0bcf8c3cd4 100644 --- a/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt +++ b/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt @@ -1154,7 +1154,6 @@ actual object RealmInterop { actual fun realm_app_get( appConfig: RealmAppConfigurationPointer, - syncClientConfig: RealmSyncClientConfigurationPointer, basePath: String ): RealmAppPointer { return LongPointerWrapper(realmc.realm_app_create(appConfig.cptr()), managed = true) @@ -1310,8 +1309,8 @@ actual object RealmInterop { ) } - actual fun realm_sync_client_config_new(): RealmSyncClientConfigurationPointer { - return LongPointerWrapper(realmc.realm_sync_client_config_new()) + actual fun realm_app_config_get_sync_client_config(configPointer: RealmAppConfigurationPointer): RealmSyncClientConfigurationPointer { + return LongPointerWrapper(realmc.realm_app_config_get_sync_client_config(configPointer.cptr())) } actual fun realm_sync_client_config_set_default_binding_thread_observer(syncClientConfig: RealmSyncClientConfigurationPointer, appId: String) { diff --git a/packages/cinterop/src/nativeDarwin/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt b/packages/cinterop/src/nativeDarwin/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt index da0ae06505..f7179fd4a2 100644 --- a/packages/cinterop/src/nativeDarwin/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt +++ b/packages/cinterop/src/nativeDarwin/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt @@ -2062,7 +2062,6 @@ actual object RealmInterop { actual fun realm_app_get( appConfig: RealmAppConfigurationPointer, - syncClientConfig: RealmSyncClientConfigurationPointer, basePath: String ): RealmAppPointer { return CPointerWrapper(realm_wrapper.realm_app_create(appConfig.cptr()), managed = true) @@ -2465,8 +2464,8 @@ actual object RealmInterop { ) } - actual fun realm_sync_client_config_new(): RealmSyncClientConfigurationPointer { - return CPointerWrapper(realm_wrapper.realm_sync_client_config_new()) + actual fun realm_app_config_get_sync_client_config(configPointer: RealmAppConfigurationPointer): RealmSyncClientConfigurationPointer { + return CPointerWrapper(realm_wrapper.realm_app_config_get_sync_client_config(configPointer.cptr())) } actual fun realm_sync_client_config_set_default_binding_thread_observer( diff --git a/packages/jni-swig-stub/realm.i b/packages/jni-swig-stub/realm.i index 96593c782c..3e8d2af436 100644 --- a/packages/jni-swig-stub/realm.i +++ b/packages/jni-swig-stub/realm.i @@ -533,8 +533,6 @@ $result = SWIG_JavaArrayOutLonglong(jenv, (long long *)result, 2); %ignore "realm_dictionary_add_notification_callback"; %ignore "realm_results_add_notification_callback"; -%ignore "realm_app_config_get_sync_client_config"; - // Swig doesn't understand __attribute__ so eliminate it #define __attribute__(x) diff --git a/packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/internal/AppConfigurationImpl.kt b/packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/internal/AppConfigurationImpl.kt index 1f7a7bdb21..16daa32d9e 100644 --- a/packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/internal/AppConfigurationImpl.kt +++ b/packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/internal/AppConfigurationImpl.kt @@ -89,7 +89,9 @@ public class AppConfigurationImpl @OptIn(ExperimentalKBsonSerializerApi::class) applicationInfo = info.toString() } val sdkInfo = "RealmKotlin/$SDK_VERSION" + val synClientConfig: RealmSyncClientConfigurationPointer = initializeSyncClientConfig( + appConfigPointer, websocketTransport, sdkInfo, applicationInfo.toString() @@ -158,11 +160,12 @@ public class AppConfigurationImpl @OptIn(ExperimentalKBsonSerializerApi::class) } private fun initializeSyncClientConfig( + appConfigPointer: RealmAppConfigurationPointer, webSocketTransport: WebSocketTransport?, sdkInfo: String?, applicationInfo: String? ): RealmSyncClientConfigurationPointer = - RealmInterop.realm_sync_client_config_new() + RealmInterop.realm_app_config_get_sync_client_config(appConfigPointer) .also { syncClientConfig -> // Initialize client configuration first RealmInterop.realm_sync_client_config_set_default_binding_thread_observer(syncClientConfig, appId) From fa54fe0f6130527f1b4902a56d6faa8282229690 Mon Sep 17 00:00:00 2001 From: Clemente Date: Mon, 10 Jun 2024 23:22:37 +0200 Subject: [PATCH 21/42] Remove parameter --- .../io/realm/kotlin/mongodb/internal/AppConfigurationImpl.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/internal/AppConfigurationImpl.kt b/packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/internal/AppConfigurationImpl.kt index 16daa32d9e..fe6ce4d9a2 100644 --- a/packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/internal/AppConfigurationImpl.kt +++ b/packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/internal/AppConfigurationImpl.kt @@ -103,7 +103,6 @@ public class AppConfigurationImpl @OptIn(ExperimentalKBsonSerializerApi::class) websocketTransport, RealmInterop.realm_app_get( appConfigPointer, - synClientConfig, appFilesDirectory() ) ) From 8285baa19c9c6edb43817e429df60cde7088fe17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus=20R=C3=B8rbech?= Date: Wed, 17 Jul 2024 13:51:22 +0200 Subject: [PATCH 22/42] Update core and add platform networking tests --- .../kotlin/internal/interop/RealmInterop.kt | 3 +- .../kotlin/internal/interop/RealmInterop.kt | 3 +- packages/external/core | 2 +- .../mongodb/jvm/PlatformNetworkingTests.kt | 76 +++++++++++++++++++ 4 files changed, 81 insertions(+), 3 deletions(-) create mode 100644 packages/test-sync/src/jvmTest/kotlin/io/realm/kotlin/test/mongodb/jvm/PlatformNetworkingTests.kt diff --git a/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt b/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt index 0bcf8c3cd4..33f29cf9e5 100644 --- a/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt +++ b/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt @@ -1310,7 +1310,8 @@ actual object RealmInterop { } actual fun realm_app_config_get_sync_client_config(configPointer: RealmAppConfigurationPointer): RealmSyncClientConfigurationPointer { - return LongPointerWrapper(realmc.realm_app_config_get_sync_client_config(configPointer.cptr())) + // The configuration is owned by Core so don't track and release it through garbage collection of the NativePointer + return LongPointerWrapper(realmc.realm_app_config_get_sync_client_config(configPointer.cptr()), false) } actual fun realm_sync_client_config_set_default_binding_thread_observer(syncClientConfig: RealmSyncClientConfigurationPointer, appId: String) { diff --git a/packages/cinterop/src/nativeDarwin/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt b/packages/cinterop/src/nativeDarwin/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt index f7179fd4a2..54fc9f530e 100644 --- a/packages/cinterop/src/nativeDarwin/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt +++ b/packages/cinterop/src/nativeDarwin/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt @@ -2465,7 +2465,8 @@ actual object RealmInterop { } actual fun realm_app_config_get_sync_client_config(configPointer: RealmAppConfigurationPointer): RealmSyncClientConfigurationPointer { - return CPointerWrapper(realm_wrapper.realm_app_config_get_sync_client_config(configPointer.cptr())) + // The configuration is owned by Core so don't track and release it through garbage collection of the NativePointer + return CPointerWrapper(realm_wrapper.realm_app_config_get_sync_client_config(configPointer.cptr()), false) } actual fun realm_sync_client_config_set_default_binding_thread_observer( diff --git a/packages/external/core b/packages/external/core index c280bdb175..bc7ff1b0ba 160000 --- a/packages/external/core +++ b/packages/external/core @@ -1 +1 @@ -Subproject commit c280bdb17522323d5c30dc32a2b9efc9dc80ca3b +Subproject commit bc7ff1b0ba48b187757fdfa26bec65bcb6753b98 diff --git a/packages/test-sync/src/jvmTest/kotlin/io/realm/kotlin/test/mongodb/jvm/PlatformNetworkingTests.kt b/packages/test-sync/src/jvmTest/kotlin/io/realm/kotlin/test/mongodb/jvm/PlatformNetworkingTests.kt new file mode 100644 index 0000000000..635e4ee501 --- /dev/null +++ b/packages/test-sync/src/jvmTest/kotlin/io/realm/kotlin/test/mongodb/jvm/PlatformNetworkingTests.kt @@ -0,0 +1,76 @@ +package io.realm.kotlin.test.mongodb.jvm + +import io.realm.kotlin.Realm +import io.realm.kotlin.entities.sync.SyncObjectWithAllTypes +import io.realm.kotlin.ext.query +import io.realm.kotlin.internal.platform.runBlocking +import io.realm.kotlin.log.LogCategory +import io.realm.kotlin.log.LogLevel +import io.realm.kotlin.log.RealmLog +import io.realm.kotlin.mongodb.User +import io.realm.kotlin.mongodb.sync.SyncConfiguration +import io.realm.kotlin.mongodb.syncSession +import io.realm.kotlin.test.mongodb.TestApp +import io.realm.kotlin.test.mongodb.common.FLEXIBLE_SYNC_SCHEMA +import io.realm.kotlin.test.mongodb.common.utils.CustomLogCollector +import io.realm.kotlin.test.mongodb.createUserAndLogIn +import io.realm.kotlin.test.mongodb.use +import io.realm.kotlin.test.mongodb.util.DefaultFlexibleSyncAppInitializer +import io.realm.kotlin.test.util.use +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertTrue +import kotlin.time.Duration.Companion.seconds + +class PlatformNetworkingTests { + + private val TIMEOUT = 10.seconds + + @Test + fun syncRoundTrip() = runBlocking { + setOf(true, false).forEach { platformNetworking -> + TestApp(this::class.simpleName, DefaultFlexibleSyncAppInitializer, builder = { + it.usePlatformNetworking(platformNetworking) + }).use { app -> + val selector = org.mongodb.kbson.ObjectId().toString() + + // Setup logger to capture WebSocketClient log messages + val logger = CustomLogCollector() + RealmLog.add(logger) + RealmLog.setLevel(LogLevel.DEBUG, LogCategory.Realm.Sdk) + + Realm.open(createSyncConfig(app.createUserAndLogIn(), selector)).use { uploadRealm -> + Realm.open(createSyncConfig(app.createUserAndLogIn(), selector)).use { realm -> + uploadRealm.write { + copyToRealm( + SyncObjectWithAllTypes().apply { + stringField = selector + } + ) + } + uploadRealm.syncSession.uploadAllLocalChanges(TIMEOUT) + realm.syncSession.downloadAllServerChanges(TIMEOUT) + assertEquals(1, realm.query().find().size) + } + } + assertTrue( + if (platformNetworking) { + logger.logs.any { it.contains("\\[Websocket.*\\] onOpen".toRegex()) } + } else { + logger.logs.none { it.contains("\\[Websocket.*\\] onOpen".toRegex()) } + }, + "Failed to verify log statements for : platformNetworking=$platformNetworking" + ) + } + } + } + + private fun createSyncConfig( + user: User, + selector: String + ): SyncConfiguration { + return SyncConfiguration.Builder(user, FLEXIBLE_SYNC_SCHEMA).initialSubscriptions { + add(it.query("stringField = $0", selector)) + }.build() + } +} From ff8b587d4c39b54b3814dc2633544c7c51ab2029 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus=20R=C3=B8rbech?= Date: Wed, 17 Jul 2024 13:56:15 +0200 Subject: [PATCH 23/42] Add CHANGELOG entry --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3473190aa2..3dc4468177 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ * None. ### Fixed -* None. +* [Sync] Platform networking was not enabled even if setting `AppConfiguration.Builder.usePlatformNetworking`. (Issue [#1811](https://github.com/realm/realm-kotlin/issues/1811)/[RKOTLIN-1114](https://jira.mongodb.org/browse/RKOTLIN-1114)). ### Compatibility * File format: Generates Realms with file format v24 (reads and upgrades file format v10 or later). From 088eb86c4fb727a410f7b13df44c28ca295b1a37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus=20R=C3=B8rbech?= Date: Wed, 17 Jul 2024 15:04:11 +0200 Subject: [PATCH 24/42] Include CHANGELOG entries from Core --- CHANGELOG.md | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bf899f9b8f..7c33cb63dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,10 +4,28 @@ * None. ### Enhancements -* None. +* Reduce the size of the local transaction log produced by creating objects, improving the performance of insertion-heavy transactions (Core issue [realm/realm-core#7734](https://github.com/realm/realm-core/pull/7734)). +* Performance has been improved for range queries on integers and timestamps. Requires that you use the "BETWEEN" operation in MQL or the Query::between() method when you build the query. (Core issue [realm/realm-core#7785](https://github.com/realm/realm-core/pull/7785)) +* [Sync] Report the originating error that caused a client reset to occur. (Core issue [realm/realm-core#6154](https://github.com/realm/realm-core/issues/6154)). +* [Sync] It is no longer an error to set a base url for an App with a trailing slash - for example, `https://services.cloud.mongodb.com/` instead of `https://services.cloud.mongodb.com` - before this change that would result in a 404 error from the server (Core issue [realm/realm-core#7791](https://github.com/realm/realm-core/pull/7791)). +* [Sync] On Windows devices Device Sync will additionally look up SSL certificates in the Windows Trusted Root Certification Authorities certificate store when establishing a connection. (Core issue [realm/realm-core#7882](https://github.com/realm/realm-core/pull/7882)) ### Fixed -* None. +* Comparing a numeric property with an argument list containing a string would throw. (Core issue [realm/realm-core#7714](https://github.com/realm/realm-core/issues/7714), since v2.0.0). +* After compacting, a file upgrade would be triggered. This could cause loss of data if schema mode is SoftResetFile (Core issue [realm/realm-core#7747](https://github.com/realm/realm-core/issues/7747), since v1.15.0). +* Encrypted files on Windows had a maximum size of 2GB even on x64 due to internal usage of `off_t`, which is a 32-bit type on 64-bit Windows (Core issue [realm/realm-core#7698](https://github.com/realm/realm-core/pull/7698)). +* The encryption code no longer behaves differently depending on the system page size, which should entirely eliminate a recurring source of bugs related to copying encrypted Realm files between platforms with different page sizes. One known outstanding bug was ([RNET-1141](https://github.com/realm/realm-dotnet/issues/3592)), where opening files on a system with a larger page size than the writing system would attempt to read sections of the file which had never been written to (Core issue [realm/realm-core#7698](https://github.com/realm/realm-core/pull/7698)). +* There were several complicated scenarios which could result in stale reads from encrypted files in multiprocess scenarios. These were very difficult to hit and would typically lead to a crash, either due to an assertion failure or DecryptionFailure being thrown (Core issue [realm/realm-core#7698](https://github.com/realm/realm-core/pull/7698), since v1.8.0). +* Encrypted files have some benign data races where we can memcpy a block of memory while another thread is writing to a limited range of it. It is logically impossible to ever read from that range when this happens, but Thread Sanitizer quite reasonably complains about this. We now perform a slower operations when running with TSan which avoids this benign race (Core issue [realm/realm-core#7698](https://github.com/realm/realm-core/pull/7698)). +* Tokenizing strings for full-text search could pass values outside the range [-1, 255] to `isspace()`, which is undefined behavior (Core issue [realm/realm-core#7698](https://github.com/realm/realm-core/pull/7698), since the introduction of FTS). +* Clearing a List of RealmAnys in an upgraded file would lead to an assertion failing (Core issue [realm/realm-core#7771](https://github.com/realm/realm-core/issues/7771), since v1.15.0) +* You could get unexpected merge results when assigning to a nested collection (Core issue [realm/realm-core#7809](https://github.com/realm/realm-core/issues/7809), since v1.15.0) +* Fixed removing backlinks from the wrong objects if the link came from a nested list, nested dictionary, top-level dictionary, or list of mixed, and the source table had more than 256 objects. This could manifest as `array_backlink.cpp:112: Assertion failed: int64_t(value >> 1) == key.value` when removing an object. (Core issue [realm/realm-core#7594](https://github.com/realm/realm-core/issues/7594), since Core v11 for dictionaries) +* Fixed the collapse/rejoin of clusters which contained nested collections with links. This could manifest as `array.cpp:319: Array::move() Assertion failed: begin <= end [2, 1]` when removing an object. (Core issue [realm/realm-core#7839](https://github.com/realm/realm-core/issues/7839), since the introduction of nested collections in v1.15.0) +* [Sync] Fix some client resets (such as migrating to flexible sync) potentially failing with AutoClientResetFailed if a new client reset condition (such as rolling back a flexible sync migration) occurred before the first one completed. (Core issue [realm/realm-core#7542](https://github.com/realm/realm-core/pull/7542), since v1.9.0) +* [Sync] Fixed a change of mode from Strong to All when removing links from an embedded object that links to a tombstone. This affects sync apps that use embedded objects which have a `Lst` that contains a link to another top level object which has been deleted by another sync client (creating a tombstone locally). In this particular case, the switch would cause any remaining link removals to recursively delete the destination object if there were no other links to it. (Core issue [realm/realm-core#7828](https://github.com/realm/realm-core/issues/7828), since v1.15.0) +* [Sync] `SyncSession.uploadAllLocalChanges` was inconsistent in how it handled commits which did not produce any changesets to upload. Previously it would sometimes complete immediately if all commits waiting to be uploaded were empty, and at other times it would wait for a server roundtrip. It will now always complete immediately. (Core issue [realm/realm-core#7796](https://github.com/realm/realm-core/pull/7796)). +* [Sync] Sync client can crash if a session is resumed while the session is being suspended. (Core issue [realm/realm-core#7860](https://github.com/realm/realm-core/issues/7860), since v1.0.0) ### Compatibility * File format: Generates Realms with file format v24 (reads and upgrades file format v10 or later). @@ -27,6 +45,7 @@ ### Internal * Updated to Realm Core 14.10.4 commit 4f83c590c4340dd7760d5f070e2e81613eb536aa. + ## 2.1.0 (2024-07-12) ### Breaking Changes From 56a2b033021567800c6f4dfb1914d4aa456e7c0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus=20R=C3=B8rbech?= Date: Wed, 17 Jul 2024 23:11:07 +0200 Subject: [PATCH 25/42] Bump to latest core --- CHANGELOG.md | 2 +- packages/external/core | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0bda4be16b..92724236bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,7 +44,7 @@ * Minimum R8: 8.0.34. ### Internal -* Updated to Realm Core 14.10.4 commit 4f83c590c4340dd7760d5f070e2e81613eb536aa. +* Updated to Realm Core 14.10.4 commit 1f0378ae53f73d67a309c9499aec512f4cde53f1. ## 2.1.0 (2024-07-12) diff --git a/packages/external/core b/packages/external/core index bc7ff1b0ba..1f0378ae53 160000 --- a/packages/external/core +++ b/packages/external/core @@ -1 +1 @@ -Subproject commit bc7ff1b0ba48b187757fdfa26bec65bcb6753b98 +Subproject commit 1f0378ae53f73d67a309c9499aec512f4cde53f1 From b1534c2b7741330e5d0560e502459c21e02d8ad4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus=20R=C3=B8rbech?= Date: Wed, 17 Jul 2024 23:11:25 +0200 Subject: [PATCH 26/42] Fix platform networking test --- .../kotlin/test/mongodb/jvm/PlatformNetworkingTests.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/test-sync/src/jvmTest/kotlin/io/realm/kotlin/test/mongodb/jvm/PlatformNetworkingTests.kt b/packages/test-sync/src/jvmTest/kotlin/io/realm/kotlin/test/mongodb/jvm/PlatformNetworkingTests.kt index 635e4ee501..ed97a22ea5 100644 --- a/packages/test-sync/src/jvmTest/kotlin/io/realm/kotlin/test/mongodb/jvm/PlatformNetworkingTests.kt +++ b/packages/test-sync/src/jvmTest/kotlin/io/realm/kotlin/test/mongodb/jvm/PlatformNetworkingTests.kt @@ -17,6 +17,8 @@ import io.realm.kotlin.test.mongodb.createUserAndLogIn import io.realm.kotlin.test.mongodb.use import io.realm.kotlin.test.mongodb.util.DefaultFlexibleSyncAppInitializer import io.realm.kotlin.test.util.use +import kotlinx.coroutines.flow.first +import kotlinx.coroutines.withTimeout import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertTrue @@ -49,8 +51,9 @@ class PlatformNetworkingTests { ) } uploadRealm.syncSession.uploadAllLocalChanges(TIMEOUT) - realm.syncSession.downloadAllServerChanges(TIMEOUT) - assertEquals(1, realm.query().find().size) + withTimeout(TIMEOUT) { + realm.query().asFlow().first { it.list.size == 1 } + } } } assertTrue( From fa325a009b8f247b91750af297d34d0936a8ccd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus=20R=C3=B8rbech?= Date: Wed, 17 Jul 2024 23:11:41 +0200 Subject: [PATCH 27/42] Add debug output to flx progress listener test --- .../kotlin/test/mongodb/common/FLXProgressListenerTests.kt | 5 +++++ .../realm/kotlin/test/mongodb/jvm/PlatformNetworkingTests.kt | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt index 53728762cf..833c462e63 100644 --- a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt +++ b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt @@ -20,6 +20,8 @@ import io.realm.kotlin.Realm import io.realm.kotlin.entities.sync.SyncObjectWithAllTypes import io.realm.kotlin.ext.query import io.realm.kotlin.internal.platform.runBlocking +import io.realm.kotlin.log.LogLevel +import io.realm.kotlin.log.RealmLog import io.realm.kotlin.mongodb.User import io.realm.kotlin.mongodb.sync.Direction import io.realm.kotlin.mongodb.sync.Progress @@ -40,6 +42,7 @@ import kotlinx.coroutines.flow.buffer import kotlinx.coroutines.flow.filter import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.last +import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.scan import kotlinx.coroutines.flow.takeWhile import kotlinx.coroutines.supervisorScope @@ -146,10 +149,12 @@ class FLXProgressListenerTests { @Test fun uploadProgressListener_changesOnly() = runBlocking { + RealmLog.setLevel(LogLevel.ALL) Realm.open(createSyncConfig(app.createUserAndLogin())).use { realm -> for (i in 0..3) { realm.writeSampleData(TEST_SIZE, timeout = TIMEOUT) realm.syncSession.progressAsFlow(Direction.UPLOAD, ProgressMode.CURRENT_CHANGES) + .onEach { println("Progress[$i] $it") } .run { withTimeout(TIMEOUT) { last().let { diff --git a/packages/test-sync/src/jvmTest/kotlin/io/realm/kotlin/test/mongodb/jvm/PlatformNetworkingTests.kt b/packages/test-sync/src/jvmTest/kotlin/io/realm/kotlin/test/mongodb/jvm/PlatformNetworkingTests.kt index ed97a22ea5..d33e150447 100644 --- a/packages/test-sync/src/jvmTest/kotlin/io/realm/kotlin/test/mongodb/jvm/PlatformNetworkingTests.kt +++ b/packages/test-sync/src/jvmTest/kotlin/io/realm/kotlin/test/mongodb/jvm/PlatformNetworkingTests.kt @@ -20,7 +20,6 @@ import io.realm.kotlin.test.util.use import kotlinx.coroutines.flow.first import kotlinx.coroutines.withTimeout import kotlin.test.Test -import kotlin.test.assertEquals import kotlin.test.assertTrue import kotlin.time.Duration.Companion.seconds From 91d15bd0b454803d8691417013b0a4d4540d4e63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus=20R=C3=B8rbech?= Date: Thu, 18 Jul 2024 10:00:14 +0200 Subject: [PATCH 28/42] More debug output for flx progress listener test --- .../kotlin/io/realm/kotlin/mongodb/internal/SyncSessionImpl.kt | 1 + .../realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/internal/SyncSessionImpl.kt b/packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/internal/SyncSessionImpl.kt index c7dd207ae4..078e0fe198 100644 --- a/packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/internal/SyncSessionImpl.kt +++ b/packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/internal/SyncSessionImpl.kt @@ -121,6 +121,7 @@ internal open class SyncSessionImpl( }, progressMode == ProgressMode.INDEFINITELY ) { progressEstimate: Double -> + println("PROGRESS-CALLBACK: $progressEstimate") val progress = Progress(progressEstimate) trySendWithBufferOverflowCheck(progress) if (progressMode == ProgressMode.CURRENT_CHANGES && progress.isTransferComplete) { diff --git a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt index 833c462e63..e635d37005 100644 --- a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt +++ b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt @@ -296,6 +296,7 @@ class FLXProgressListenerTests { .initialSubscriptions { add(it.query("stringField = $0", getTestPartitionValue())) } + .waitForInitialRemoteData(TIMEOUT) .build() } From 89c1d84c11bbf7e18c44598c9bdc31fb5a2a6279 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus=20R=C3=B8rbech?= Date: Thu, 18 Jul 2024 12:02:53 +0200 Subject: [PATCH 29/42] Clean up --- .../kotlin/test/mongodb/common/FLXProgressListenerTests.kt | 5 ----- 1 file changed, 5 deletions(-) diff --git a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt index e635d37005..f26e9399b2 100644 --- a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt +++ b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt @@ -20,8 +20,6 @@ import io.realm.kotlin.Realm import io.realm.kotlin.entities.sync.SyncObjectWithAllTypes import io.realm.kotlin.ext.query import io.realm.kotlin.internal.platform.runBlocking -import io.realm.kotlin.log.LogLevel -import io.realm.kotlin.log.RealmLog import io.realm.kotlin.mongodb.User import io.realm.kotlin.mongodb.sync.Direction import io.realm.kotlin.mongodb.sync.Progress @@ -42,7 +40,6 @@ import kotlinx.coroutines.flow.buffer import kotlinx.coroutines.flow.filter import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.last -import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.scan import kotlinx.coroutines.flow.takeWhile import kotlinx.coroutines.supervisorScope @@ -149,12 +146,10 @@ class FLXProgressListenerTests { @Test fun uploadProgressListener_changesOnly() = runBlocking { - RealmLog.setLevel(LogLevel.ALL) Realm.open(createSyncConfig(app.createUserAndLogin())).use { realm -> for (i in 0..3) { realm.writeSampleData(TEST_SIZE, timeout = TIMEOUT) realm.syncSession.progressAsFlow(Direction.UPLOAD, ProgressMode.CURRENT_CHANGES) - .onEach { println("Progress[$i] $it") } .run { withTimeout(TIMEOUT) { last().let { From df59dcc7f55247a3148b492d38d57125a7f87fec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus=20R=C3=B8rbech?= Date: Thu, 18 Jul 2024 13:11:06 +0200 Subject: [PATCH 30/42] Remove debug statements --- .../kotlin/io/realm/kotlin/mongodb/internal/SyncSessionImpl.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/internal/SyncSessionImpl.kt b/packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/internal/SyncSessionImpl.kt index 078e0fe198..c7dd207ae4 100644 --- a/packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/internal/SyncSessionImpl.kt +++ b/packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/internal/SyncSessionImpl.kt @@ -121,7 +121,6 @@ internal open class SyncSessionImpl( }, progressMode == ProgressMode.INDEFINITELY ) { progressEstimate: Double -> - println("PROGRESS-CALLBACK: $progressEstimate") val progress = Progress(progressEstimate) trySendWithBufferOverflowCheck(progress) if (progressMode == ProgressMode.CURRENT_CHANGES && progress.isTransferComplete) { From 7901a14299a4389a3f239f4fe1f587ec465a351a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus=20R=C3=B8rbech?= Date: Thu, 18 Jul 2024 16:16:17 +0200 Subject: [PATCH 31/42] Test updates --- .../kotlin/test/mongodb/common/FLXProgressListenerTests.kt | 2 +- .../kotlin/test/mongodb/jvm/PlatformNetworkingTests.kt | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt index f26e9399b2..a82787fa5e 100644 --- a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt +++ b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt @@ -147,6 +147,7 @@ class FLXProgressListenerTests { @Test fun uploadProgressListener_changesOnly() = runBlocking { Realm.open(createSyncConfig(app.createUserAndLogin())).use { realm -> + realm.syncSession.uploadAllLocalChanges(TIMEOUT) for (i in 0..3) { realm.writeSampleData(TEST_SIZE, timeout = TIMEOUT) realm.syncSession.progressAsFlow(Direction.UPLOAD, ProgressMode.CURRENT_CHANGES) @@ -291,7 +292,6 @@ class FLXProgressListenerTests { .initialSubscriptions { add(it.query("stringField = $0", getTestPartitionValue())) } - .waitForInitialRemoteData(TIMEOUT) .build() } diff --git a/packages/test-sync/src/jvmTest/kotlin/io/realm/kotlin/test/mongodb/jvm/PlatformNetworkingTests.kt b/packages/test-sync/src/jvmTest/kotlin/io/realm/kotlin/test/mongodb/jvm/PlatformNetworkingTests.kt index d33e150447..01ec0acb29 100644 --- a/packages/test-sync/src/jvmTest/kotlin/io/realm/kotlin/test/mongodb/jvm/PlatformNetworkingTests.kt +++ b/packages/test-sync/src/jvmTest/kotlin/io/realm/kotlin/test/mongodb/jvm/PlatformNetworkingTests.kt @@ -20,6 +20,7 @@ import io.realm.kotlin.test.util.use import kotlinx.coroutines.flow.first import kotlinx.coroutines.withTimeout import kotlin.test.Test +import kotlin.test.assertEquals import kotlin.test.assertTrue import kotlin.time.Duration.Companion.seconds @@ -51,7 +52,11 @@ class PlatformNetworkingTests { } uploadRealm.syncSession.uploadAllLocalChanges(TIMEOUT) withTimeout(TIMEOUT) { - realm.query().asFlow().first { it.list.size == 1 } + realm.query().asFlow().first { + it.list.size == 1 + }.list.first().also { + assertEquals(selector, it.stringField) + } } } } From 90e38c2a0289c72c50f368928f3712994d1530b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus=20R=C3=B8rbech?= Date: Thu, 18 Jul 2024 21:08:42 +0200 Subject: [PATCH 32/42] Test udpates --- .../kotlin/test/mongodb/common/FLXProgressListenerTests.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt index a82787fa5e..e80239fd7b 100644 --- a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt +++ b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt @@ -147,7 +147,7 @@ class FLXProgressListenerTests { @Test fun uploadProgressListener_changesOnly() = runBlocking { Realm.open(createSyncConfig(app.createUserAndLogin())).use { realm -> - realm.syncSession.uploadAllLocalChanges(TIMEOUT) + realm.syncSession.downloadAllServerChanges(TIMEOUT) for (i in 0..3) { realm.writeSampleData(TEST_SIZE, timeout = TIMEOUT) realm.syncSession.progressAsFlow(Direction.UPLOAD, ProgressMode.CURRENT_CHANGES) From e2723ee844b2098caaca554fe7147b8305cf82f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus=20R=C3=B8rbech?= Date: Fri, 19 Jul 2024 09:43:57 +0200 Subject: [PATCH 33/42] Debug if sync sessions is actually closed --- .../commonMain/kotlin/io/realm/kotlin/test/mongodb/TestApp.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/test-sync/src/commonMain/kotlin/io/realm/kotlin/test/mongodb/TestApp.kt b/packages/test-sync/src/commonMain/kotlin/io/realm/kotlin/test/mongodb/TestApp.kt index 079ab3b377..6a69c6513e 100644 --- a/packages/test-sync/src/commonMain/kotlin/io/realm/kotlin/test/mongodb/TestApp.kt +++ b/packages/test-sync/src/commonMain/kotlin/io/realm/kotlin/test/mongodb/TestApp.kt @@ -122,7 +122,9 @@ open class TestApp private constructor( return } + println("TERMINATING SESSION") app.sync.waitForSessionsToTerminate() + println("SESSIONS TERMINATED: ${app.sync.hasSyncSessions}") // This is needed to "properly reset" all sessions across tests since deleting users // directly using the REST API doesn't do the trick From ead1fde820272e95075b535aacc729440e3fcef9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus=20R=C3=B8rbech?= Date: Fri, 19 Jul 2024 10:47:35 +0200 Subject: [PATCH 34/42] Immediately terminating sync session --- .../io/realm/kotlin/internal/interop/RealmInterop.kt | 5 ++--- .../io/realm/kotlin/internal/interop/RealmInterop.kt | 6 +++++- .../io/realm/kotlin/internal/interop/RealmInterop.kt | 12 ++++++++---- .../kotlin/io/realm/kotlin/test/mongodb/TestApp.kt | 2 -- .../test/mongodb/common/FLXProgressListenerTests.kt | 1 - 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt b/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt index ce9e60d32c..2d5974fa12 100644 --- a/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt +++ b/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt @@ -649,6 +649,8 @@ expect object RealmInterop { user: RealmUserPointer, partition: String ): RealmSyncConfigurationPointer + // Flexible Sync + fun realm_flx_sync_config_new(user: RealmUserPointer): RealmSyncConfigurationPointer fun realm_sync_config_set_error_handler( syncConfig: RealmSyncConfigurationPointer, errorHandler: SyncErrorCallback @@ -786,9 +788,6 @@ expect object RealmInterop { syncConfiguration: RealmSyncConfigurationPointer ) - // Flexible Sync - fun realm_flx_sync_config_new(user: RealmUserPointer): RealmSyncConfigurationPointer - // Flexible Sync Subscription fun realm_sync_subscription_id(subscription: RealmSubscriptionPointer): ObjectId fun realm_sync_subscription_name(subscription: RealmSubscriptionPointer): String? diff --git a/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt b/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt index 33f29cf9e5..6247ab2409 100644 --- a/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt +++ b/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt @@ -1981,7 +1981,11 @@ actual object RealmInterop { } actual fun realm_flx_sync_config_new(user: RealmUserPointer): RealmSyncConfigurationPointer { - return LongPointerWrapper(realmc.realm_flx_sync_config_new(user.cptr())) + return LongPointerWrapper(realmc.realm_flx_sync_config_new(user.cptr())).also { ptr -> + // Stop the session immediately when the Realm is closed, so the lifecycle of the + // Sync Client thread is manageable. + realmc.realm_sync_config_set_session_stop_policy(ptr.cptr(), realm_sync_session_stop_policy_e.RLM_SYNC_SESSION_STOP_POLICY_IMMEDIATELY) + } } actual fun realm_sync_subscription_id(subscription: RealmSubscriptionPointer): ObjectId { diff --git a/packages/cinterop/src/nativeDarwin/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt b/packages/cinterop/src/nativeDarwin/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt index 54fc9f530e..9c7f35a029 100644 --- a/packages/cinterop/src/nativeDarwin/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt +++ b/packages/cinterop/src/nativeDarwin/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt @@ -3317,6 +3317,14 @@ actual object RealmInterop { } } + actual fun realm_flx_sync_config_new(user: RealmUserPointer): RealmSyncConfigurationPointer { + return CPointerWrapper(realm_wrapper.realm_flx_sync_config_new((user.cptr()))).also { ptr -> + // Stop the session immediately when the Realm is closed, so the lifecycle of the + // Sync Client thread is manageable. + realm_wrapper.realm_sync_config_set_session_stop_policy(ptr.cptr(), realm_sync_session_stop_policy_e.RLM_SYNC_SESSION_STOP_POLICY_IMMEDIATELY) + } + } + actual fun realm_app_sync_client_reconnect(app: RealmAppPointer) { realm_wrapper.realm_app_sync_client_reconnect(app.cptr()) } @@ -3332,10 +3340,6 @@ actual object RealmInterop { realm_wrapper.realm_config_set_sync_config(realmConfiguration.cptr(), syncConfiguration.cptr()) } - actual fun realm_flx_sync_config_new(user: RealmUserPointer): RealmSyncConfigurationPointer { - return CPointerWrapper(realm_wrapper.realm_flx_sync_config_new((user.cptr()))) - } - actual fun realm_sync_subscription_id(subscription: RealmSubscriptionPointer): ObjectId { return ObjectId(realm_wrapper.realm_sync_subscription_id(subscription.cptr()).getBytes()) } diff --git a/packages/test-sync/src/commonMain/kotlin/io/realm/kotlin/test/mongodb/TestApp.kt b/packages/test-sync/src/commonMain/kotlin/io/realm/kotlin/test/mongodb/TestApp.kt index 6a69c6513e..079ab3b377 100644 --- a/packages/test-sync/src/commonMain/kotlin/io/realm/kotlin/test/mongodb/TestApp.kt +++ b/packages/test-sync/src/commonMain/kotlin/io/realm/kotlin/test/mongodb/TestApp.kt @@ -122,9 +122,7 @@ open class TestApp private constructor( return } - println("TERMINATING SESSION") app.sync.waitForSessionsToTerminate() - println("SESSIONS TERMINATED: ${app.sync.hasSyncSessions}") // This is needed to "properly reset" all sessions across tests since deleting users // directly using the REST API doesn't do the trick diff --git a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt index e80239fd7b..53728762cf 100644 --- a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt +++ b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt @@ -147,7 +147,6 @@ class FLXProgressListenerTests { @Test fun uploadProgressListener_changesOnly() = runBlocking { Realm.open(createSyncConfig(app.createUserAndLogin())).use { realm -> - realm.syncSession.downloadAllServerChanges(TIMEOUT) for (i in 0..3) { realm.writeSampleData(TEST_SIZE, timeout = TIMEOUT) realm.syncSession.progressAsFlow(Direction.UPLOAD, ProgressMode.CURRENT_CHANGES) From ae0135f962b90fcba902b3f531ece7111ec5fcec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus=20R=C3=B8rbech?= Date: Fri, 19 Jul 2024 14:43:35 +0200 Subject: [PATCH 35/42] More debug information --- .../io/realm/kotlin/internal/interop/RealmInterop.kt | 12 ++++-------- .../io/realm/kotlin/internal/interop/RealmInterop.kt | 6 +----- .../realm/kotlin/mongodb/internal/SyncSessionImpl.kt | 1 + .../test/mongodb/common/FLXProgressListenerTests.kt | 5 +++++ 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt b/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt index 6247ab2409..d23a72eaab 100644 --- a/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt +++ b/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt @@ -1758,6 +1758,10 @@ actual object RealmInterop { } } + actual fun realm_flx_sync_config_new(user: RealmUserPointer): RealmSyncConfigurationPointer { + return LongPointerWrapper(realmc.realm_flx_sync_config_new(user.cptr())) + } + actual fun realm_config_set_sync_config(realmConfiguration: RealmConfigurationPointer, syncConfiguration: RealmSyncConfigurationPointer) { realmc.realm_config_set_sync_config(realmConfiguration.cptr(), syncConfiguration.cptr()) } @@ -1980,14 +1984,6 @@ actual object RealmInterop { realmc.realm_object_delete(obj.cptr()) } - actual fun realm_flx_sync_config_new(user: RealmUserPointer): RealmSyncConfigurationPointer { - return LongPointerWrapper(realmc.realm_flx_sync_config_new(user.cptr())).also { ptr -> - // Stop the session immediately when the Realm is closed, so the lifecycle of the - // Sync Client thread is manageable. - realmc.realm_sync_config_set_session_stop_policy(ptr.cptr(), realm_sync_session_stop_policy_e.RLM_SYNC_SESSION_STOP_POLICY_IMMEDIATELY) - } - } - actual fun realm_sync_subscription_id(subscription: RealmSubscriptionPointer): ObjectId { val nativeBytes: ShortArray = realmc.realm_sync_subscription_id(subscription.cptr()).bytes val byteArray = ByteArray(nativeBytes.size) diff --git a/packages/cinterop/src/nativeDarwin/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt b/packages/cinterop/src/nativeDarwin/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt index 9c7f35a029..ae04710e18 100644 --- a/packages/cinterop/src/nativeDarwin/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt +++ b/packages/cinterop/src/nativeDarwin/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt @@ -3318,11 +3318,7 @@ actual object RealmInterop { } actual fun realm_flx_sync_config_new(user: RealmUserPointer): RealmSyncConfigurationPointer { - return CPointerWrapper(realm_wrapper.realm_flx_sync_config_new((user.cptr()))).also { ptr -> - // Stop the session immediately when the Realm is closed, so the lifecycle of the - // Sync Client thread is manageable. - realm_wrapper.realm_sync_config_set_session_stop_policy(ptr.cptr(), realm_sync_session_stop_policy_e.RLM_SYNC_SESSION_STOP_POLICY_IMMEDIATELY) - } + return CPointerWrapper(realm_wrapper.realm_flx_sync_config_new((user.cptr()))) } actual fun realm_app_sync_client_reconnect(app: RealmAppPointer) { diff --git a/packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/internal/SyncSessionImpl.kt b/packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/internal/SyncSessionImpl.kt index c7dd207ae4..1846f70928 100644 --- a/packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/internal/SyncSessionImpl.kt +++ b/packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/internal/SyncSessionImpl.kt @@ -121,6 +121,7 @@ internal open class SyncSessionImpl( }, progressMode == ProgressMode.INDEFINITELY ) { progressEstimate: Double -> + realm.log.debug("PROGRESS CALLBACK: $progressEstimate") val progress = Progress(progressEstimate) trySendWithBufferOverflowCheck(progress) if (progressMode == ProgressMode.CURRENT_CHANGES && progress.isTransferComplete) { diff --git a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt index 53728762cf..d68c25c7ce 100644 --- a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt +++ b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt @@ -20,6 +20,8 @@ import io.realm.kotlin.Realm import io.realm.kotlin.entities.sync.SyncObjectWithAllTypes import io.realm.kotlin.ext.query import io.realm.kotlin.internal.platform.runBlocking +import io.realm.kotlin.log.LogLevel +import io.realm.kotlin.log.RealmLog import io.realm.kotlin.mongodb.User import io.realm.kotlin.mongodb.sync.Direction import io.realm.kotlin.mongodb.sync.Progress @@ -40,6 +42,7 @@ import kotlinx.coroutines.flow.buffer import kotlinx.coroutines.flow.filter import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.last +import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.scan import kotlinx.coroutines.flow.takeWhile import kotlinx.coroutines.supervisorScope @@ -146,10 +149,12 @@ class FLXProgressListenerTests { @Test fun uploadProgressListener_changesOnly() = runBlocking { + RealmLog.setLevel(LogLevel.ALL) Realm.open(createSyncConfig(app.createUserAndLogin())).use { realm -> for (i in 0..3) { realm.writeSampleData(TEST_SIZE, timeout = TIMEOUT) realm.syncSession.progressAsFlow(Direction.UPLOAD, ProgressMode.CURRENT_CHANGES) + .onEach { println("PROGRESS LISTENER: $it") } .run { withTimeout(TIMEOUT) { last().let { From e519710639f188aa405b4b7480f67332a3c8fc7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus=20R=C3=B8rbech?= Date: Fri, 19 Jul 2024 15:49:07 +0200 Subject: [PATCH 36/42] Rework flx upload progress listener test and clean up --- .../kotlin/mongodb/internal/SyncSessionImpl.kt | 1 - .../mongodb/common/FLXProgressListenerTests.kt | 18 ++++++++---------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/internal/SyncSessionImpl.kt b/packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/internal/SyncSessionImpl.kt index 1846f70928..c7dd207ae4 100644 --- a/packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/internal/SyncSessionImpl.kt +++ b/packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/internal/SyncSessionImpl.kt @@ -121,7 +121,6 @@ internal open class SyncSessionImpl( }, progressMode == ProgressMode.INDEFINITELY ) { progressEstimate: Double -> - realm.log.debug("PROGRESS CALLBACK: $progressEstimate") val progress = Progress(progressEstimate) trySendWithBufferOverflowCheck(progress) if (progressMode == ProgressMode.CURRENT_CHANGES && progress.isTransferComplete) { diff --git a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt index d68c25c7ce..1ff2992425 100644 --- a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt +++ b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt @@ -20,8 +20,6 @@ import io.realm.kotlin.Realm import io.realm.kotlin.entities.sync.SyncObjectWithAllTypes import io.realm.kotlin.ext.query import io.realm.kotlin.internal.platform.runBlocking -import io.realm.kotlin.log.LogLevel -import io.realm.kotlin.log.RealmLog import io.realm.kotlin.mongodb.User import io.realm.kotlin.mongodb.sync.Direction import io.realm.kotlin.mongodb.sync.Progress @@ -42,7 +40,6 @@ import kotlinx.coroutines.flow.buffer import kotlinx.coroutines.flow.filter import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.last -import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.scan import kotlinx.coroutines.flow.takeWhile import kotlinx.coroutines.supervisorScope @@ -149,20 +146,21 @@ class FLXProgressListenerTests { @Test fun uploadProgressListener_changesOnly() = runBlocking { - RealmLog.setLevel(LogLevel.ALL) Realm.open(createSyncConfig(app.createUserAndLogin())).use { realm -> for (i in 0..3) { - realm.writeSampleData(TEST_SIZE, timeout = TIMEOUT) - realm.syncSession.progressAsFlow(Direction.UPLOAD, ProgressMode.CURRENT_CHANGES) - .onEach { println("PROGRESS LISTENER: $it") } - .run { - withTimeout(TIMEOUT) { + val task = async { + realm.syncSession.progressAsFlow(Direction.UPLOAD, ProgressMode.CURRENT_CHANGES) + .run { last().let { assertTrue(it.isTransferComplete) assertEquals(1.0, it.estimate) } } - } + } + realm.writeSampleData(TEST_SIZE, timeout = TIMEOUT) + withTimeout(TIMEOUT) { + task.await() + } } } } From 1820ad7bac035e2df43648e75e83f09001d9e113 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus=20R=C3=B8rbech?= Date: Fri, 19 Jul 2024 16:40:05 +0200 Subject: [PATCH 37/42] Updates according to review comments --- .github/workflows/pr.yml | 14 ++++++-------- CHANGELOG.md | 2 +- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 4ef75fe85f..4474cf51b9 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -431,11 +431,11 @@ jobs: run: |- echo "::add-matcher::.github/problem-matchers/kotlin.json" - - name: Setup Java 17 + - name: Setup Java 11 uses: actions/setup-java@v4 with: distribution: ${{ vars.VERSION_JAVA_DISTRIBUTION }} - java-version: '17' + java-version: ${{ vars.VERSION_JAVA }} - name: Setup Gradle and task/dependency caching uses: gradle/actions/setup-gradle@v3 @@ -473,6 +473,8 @@ jobs: echo '#!/bin/bash\nccache clang++ "$@"%"' > /usr/local/bin/ccache-clang++ - name: Setup Android SDK + env: + JAVA_HOME: ${{ env.JAVA_HOME_17_X64 }} uses: android-actions/setup-android@v3 - name: Install NDK @@ -547,9 +549,7 @@ jobs: uses: actions/setup-java@v4 with: distribution: ${{ vars.VERSION_JAVA_DISTRIBUTION }} - java-version: | - 17 - ${{ vars.VERSION_JAVA }} + java-version: ${{ vars.VERSION_JAVA }} - name: Setup Gradle and task/dependency caching uses: gradle/actions/setup-gradle@v3 @@ -604,12 +604,10 @@ jobs: echo '#!/bin/bash\nccache clang++ "$@"%"' > /usr/local/bin/ccache-clang++ - name: Setup Android SDK - env: - JAVA_HOME: ${{ env.JAVA_HOME_17_X64 }} uses: android-actions/setup-android@v3 - name: Install NDK - env: + env: JAVA_HOME: ${{ env.JAVA_HOME_17_X64 }} run: sdkmanager --install "ndk;${{ env.NDK_VERSION }}" diff --git a/CHANGELOG.md b/CHANGELOG.md index 92724236bc..5542106567 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ ### Enhancements * Reduce the size of the local transaction log produced by creating objects, improving the performance of insertion-heavy transactions (Core issue [realm/realm-core#7734](https://github.com/realm/realm-core/pull/7734)). -* Performance has been improved for range queries on integers and timestamps. Requires that you use the "BETWEEN" operation in MQL or the Query::between() method when you build the query. (Core issue [realm/realm-core#7785](https://github.com/realm/realm-core/pull/7785)) +* Performance has been improved for range queries on integers and timestamps. Requires that you use the "BETWEEN" operation in RQL or the Query::between() method when you build the query. (Core issue [realm/realm-core#7785](https://github.com/realm/realm-core/pull/7785)) * [Sync] Report the originating error that caused a client reset to occur. (Core issue [realm/realm-core#6154](https://github.com/realm/realm-core/issues/6154)). * [Sync] It is no longer an error to set a base url for an App with a trailing slash - for example, `https://services.cloud.mongodb.com/` instead of `https://services.cloud.mongodb.com` - before this change that would result in a 404 error from the server (Core issue [realm/realm-core#7791](https://github.com/realm/realm-core/pull/7791)). * [Sync] On Windows devices Device Sync will additionally look up SSL certificates in the Windows Trusted Root Certification Authorities certificate store when establishing a connection. (Core issue [realm/realm-core#7882](https://github.com/realm/realm-core/pull/7882)) From 193318b60cb9f45abba3f206b5064936830eb832 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus=20R=C3=B8rbech?= Date: Fri, 19 Jul 2024 22:36:07 +0200 Subject: [PATCH 38/42] Upgrade to Core 14.11.0 --- CHANGELOG.md | 9 ++++++--- packages/external/core | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5542106567..c7953d1f83 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,8 @@ * Performance has been improved for range queries on integers and timestamps. Requires that you use the "BETWEEN" operation in RQL or the Query::between() method when you build the query. (Core issue [realm/realm-core#7785](https://github.com/realm/realm-core/pull/7785)) * [Sync] Report the originating error that caused a client reset to occur. (Core issue [realm/realm-core#6154](https://github.com/realm/realm-core/issues/6154)). * [Sync] It is no longer an error to set a base url for an App with a trailing slash - for example, `https://services.cloud.mongodb.com/` instead of `https://services.cloud.mongodb.com` - before this change that would result in a 404 error from the server (Core issue [realm/realm-core#7791](https://github.com/realm/realm-core/pull/7791)). -* [Sync] On Windows devices Device Sync will additionally look up SSL certificates in the Windows Trusted Root Certification Authorities certificate store when establishing a connection. (Core issue [realm/realm-core#7882](https://github.com/realm/realm-core/pull/7882)) +* [Sync] On Windows devices Device Sync will additionally look up SSL certificates in the Windows Trusted Root Certification Authorities certificate store when establishing a connection. (Core issue [realm/realm-core#7882](https://github.com/realm/realm-core/pull/7882)). +* [Sync] Role and permissions changes no longer require a client reset to update the local realm. (Core issue [realm/realm-core#7440](https://github.com/realm/realm-core/pull/7440)). ### Fixed * Comparing a numeric property with an argument list containing a string would throw. (Core issue [realm/realm-core#7714](https://github.com/realm/realm-core/issues/7714), since v2.0.0). @@ -26,7 +27,8 @@ * [Sync] Fix some client resets (such as migrating to flexible sync) potentially failing with AutoClientResetFailed if a new client reset condition (such as rolling back a flexible sync migration) occurred before the first one completed. (Core issue [realm/realm-core#7542](https://github.com/realm/realm-core/pull/7542), since v1.9.0) * [Sync] Fixed a change of mode from Strong to All when removing links from an embedded object that links to a tombstone. This affects sync apps that use embedded objects which have a `Lst` that contains a link to another top level object which has been deleted by another sync client (creating a tombstone locally). In this particular case, the switch would cause any remaining link removals to recursively delete the destination object if there were no other links to it. (Core issue [realm/realm-core#7828](https://github.com/realm/realm-core/issues/7828), since v1.15.0) * [Sync] `SyncSession.uploadAllLocalChanges` was inconsistent in how it handled commits which did not produce any changesets to upload. Previously it would sometimes complete immediately if all commits waiting to be uploaded were empty, and at other times it would wait for a server roundtrip. It will now always complete immediately. (Core issue [realm/realm-core#7796](https://github.com/realm/realm-core/pull/7796)). -* [Sync] Sync client can crash if a session is resumed while the session is being suspended. (Core issue [realm/realm-core#7860](https://github.com/realm/realm-core/issues/7860), since v1.0.0) +* [Sync] Sync client can crash if a session is resumed while the session is being suspended. (Core issue [realm/realm-core#7860](https://github.com/realm/realm-core/issues/7860), since v1.0.0). +* [Sync] If a sync session is interrupted by a disconnect or restart while downloading a bootstrap, stale data from the previous bootstrap may be included when the session reconnects and downloads the bootstrap. This can lead to objects stored in the database that do not match the actual state of the server and potentially leading to compensating writes. (Core issue [realm/realm-core#7827](https://github.com/realm/realm-core/issues/7827), since v1.0.0). ### Compatibility * File format: Generates Realms with file format v24 (reads and upgrades file format v10 or later). @@ -44,7 +46,8 @@ * Minimum R8: 8.0.34. ### Internal -* Updated to Realm Core 14.10.4 commit 1f0378ae53f73d67a309c9499aec512f4cde53f1. +* Updated to Realm Core 14.11.0 commit 60867846a0aca0c7da5e482282b293236f730216. +* Updated to Sync protocol version 14 to support server intiated bootstraps and role change updates without a client reset. (Core issue [realm/realm-core#7440](https://github.com/realm/realm-core/pull/7440)). ## 2.1.0 (2024-07-12) diff --git a/packages/external/core b/packages/external/core index 1f0378ae53..60867846a0 160000 --- a/packages/external/core +++ b/packages/external/core @@ -1 +1 @@ -Subproject commit 1f0378ae53f73d67a309c9499aec512f4cde53f1 +Subproject commit 60867846a0aca0c7da5e482282b293236f730216 From af8e6c2fac27b2ad6290a1b33256afed57b3af41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus=20R=C3=B8rbech?= Date: Fri, 9 Aug 2024 10:35:58 +0200 Subject: [PATCH 39/42] Upgrade to Core 14.11.2 --- CHANGELOG.md | 4 +++- packages/external/core | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index be5dd9d1be..54f02cc4da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ * [Sync] It is no longer an error to set a base url for an App with a trailing slash - for example, `https://services.cloud.mongodb.com/` instead of `https://services.cloud.mongodb.com` - before this change that would result in a 404 error from the server (Core issue [realm/realm-core#7791](https://github.com/realm/realm-core/pull/7791)). * [Sync] On Windows devices Device Sync will additionally look up SSL certificates in the Windows Trusted Root Certification Authorities certificate store when establishing a connection. (Core issue [realm/realm-core#7882](https://github.com/realm/realm-core/pull/7882)) * [Sync] Role and permissions changes no longer require a client reset to update the local realm. (Core issue [realm/realm-core#7440](https://github.com/realm/realm-core/pull/7440)). +* [Sync] Sync log statements now include the app services connection id in their prefix (e.g `Connection[1:] Session[1]: log message`) to make correlating sync activity to server logs easier during troubleshooting (Core issue [realm/realm-core#7849)](https://github.com/realm/realm-core/pull/7849)). ### Fixed * Comparing a numeric property with an argument list containing a string would throw. (Core issue [realm/realm-core#7714](https://github.com/realm/realm-core/issues/7714), since v2.0.0). @@ -30,6 +31,7 @@ * [Sync] `SyncSession.uploadAllLocalChanges` was inconsistent in how it handled commits which did not produce any changesets to upload. Previously it would sometimes complete immediately if all commits waiting to be uploaded were empty, and at other times it would wait for a server roundtrip. It will now always complete immediately. (Core issue [realm/realm-core#7796](https://github.com/realm/realm-core/pull/7796)). * [Sync] Sync client can crash if a session is resumed while the session is being suspended. (Core issue [realm/realm-core#7860](https://github.com/realm/realm-core/issues/7860), since v1.0.0) * [Sync] If a sync session is interrupted by a disconnect or restart while downloading a bootstrap, stale data from the previous bootstrap may be included when the session reconnects and downloads the bootstrap. This can lead to objects stored in the database that do not match the actual state of the server and potentially leading to compensating writes. (Core issue [realm/realm-core#7827](https://github.com/realm/realm-core/issues/7827), since v1.0.0). +* [Sync] App subscription callback was getting fired before the user profile was retrieved on login, leading to an empty user profile when using the callback. ([#7889](https://github.com/realm/realm-core/issues/7889), since v14.7.0). ### Compatibility * File format: Generates Realms with file format v24 (reads and upgrades file format v10 or later). @@ -47,7 +49,7 @@ * Minimum R8: 8.0.34. ### Internal -* Updated to Realm Core 14.11.0 commit 60867846a0aca0c7da5e482282b293236f730216. +* Updated to Realm Core 14.11.2 commit 117c1cbf2b96eaa1bf51562e4f45d3649b3bdad2. * Updated to Sync protocol version 14 to support server intiated bootstraps and role change updates without a client reset. (Core issue [realm/realm-core#7440](https://github.com/realm/realm-core/pull/7440)). diff --git a/packages/external/core b/packages/external/core index 1f0378ae53..117c1cbf2b 160000 --- a/packages/external/core +++ b/packages/external/core @@ -1 +1 @@ -Subproject commit 1f0378ae53f73d67a309c9499aec512f4cde53f1 +Subproject commit 117c1cbf2b96eaa1bf51562e4f45d3649b3bdad2 From 31a553109536fd29491bd7386e0b18c694a9552c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus=20R=C3=B8rbech?= Date: Fri, 9 Aug 2024 11:56:13 +0200 Subject: [PATCH 40/42] Remove deprecated websocket error codes --- .../io/realm/kotlin/internal/interop/sync/ProtocolErrorCode.kt | 3 --- .../io/realm/kotlin/internal/interop/sync/ProtocolErrorCode.kt | 3 --- .../io/realm/kotlin/internal/interop/sync/ProtocolErrorCode.kt | 3 --- .../kotlin/io/realm/kotlin/test/common/EncryptionTests.kt | 1 - 4 files changed, 10 deletions(-) diff --git a/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/ProtocolErrorCode.kt b/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/ProtocolErrorCode.kt index 1eb7aa437e..5a2483d04d 100644 --- a/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/ProtocolErrorCode.kt +++ b/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/ProtocolErrorCode.kt @@ -110,9 +110,6 @@ expect enum class WebsocketErrorCode : CodeDescription { RLM_ERR_WEBSOCKET_UNAUTHORIZED, RLM_ERR_WEBSOCKET_FORBIDDEN, RLM_ERR_WEBSOCKET_MOVEDPERMANENTLY, - RLM_ERR_WEBSOCKET_CLIENT_TOO_OLD, - RLM_ERR_WEBSOCKET_CLIENT_TOO_NEW, - RLM_ERR_WEBSOCKET_PROTOCOL_MISMATCH, RLM_ERR_WEBSOCKET_RESOLVE_FAILED, RLM_ERR_WEBSOCKET_CONNECTION_FAILED, RLM_ERR_WEBSOCKET_READ_ERROR, diff --git a/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/sync/ProtocolErrorCode.kt b/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/sync/ProtocolErrorCode.kt index 2b4f74131e..452136341e 100644 --- a/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/sync/ProtocolErrorCode.kt +++ b/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/sync/ProtocolErrorCode.kt @@ -120,9 +120,6 @@ actual enum class WebsocketErrorCode( RLM_ERR_WEBSOCKET_UNAUTHORIZED("Unauthorized", realm_web_socket_errno_e.RLM_ERR_WEBSOCKET_UNAUTHORIZED), RLM_ERR_WEBSOCKET_FORBIDDEN("Forbidden", realm_web_socket_errno_e.RLM_ERR_WEBSOCKET_FORBIDDEN), RLM_ERR_WEBSOCKET_MOVEDPERMANENTLY("MovedPermanently", realm_web_socket_errno_e.RLM_ERR_WEBSOCKET_MOVEDPERMANENTLY), - RLM_ERR_WEBSOCKET_CLIENT_TOO_OLD("ClientTooOld", realm_web_socket_errno_e.RLM_ERR_WEBSOCKET_CLIENT_TOO_OLD), - RLM_ERR_WEBSOCKET_CLIENT_TOO_NEW("ClientTooNew", realm_web_socket_errno_e.RLM_ERR_WEBSOCKET_CLIENT_TOO_NEW), - RLM_ERR_WEBSOCKET_PROTOCOL_MISMATCH("ProtocolMismatch", realm_web_socket_errno_e.RLM_ERR_WEBSOCKET_PROTOCOL_MISMATCH), RLM_ERR_WEBSOCKET_RESOLVE_FAILED("ResolveFailed", realm_web_socket_errno_e.RLM_ERR_WEBSOCKET_RESOLVE_FAILED), RLM_ERR_WEBSOCKET_CONNECTION_FAILED("ConnectionFailed", realm_web_socket_errno_e.RLM_ERR_WEBSOCKET_CONNECTION_FAILED), diff --git a/packages/cinterop/src/nativeDarwin/kotlin/io/realm/kotlin/internal/interop/sync/ProtocolErrorCode.kt b/packages/cinterop/src/nativeDarwin/kotlin/io/realm/kotlin/internal/interop/sync/ProtocolErrorCode.kt index 1a42c622c8..cdb56f3669 100644 --- a/packages/cinterop/src/nativeDarwin/kotlin/io/realm/kotlin/internal/interop/sync/ProtocolErrorCode.kt +++ b/packages/cinterop/src/nativeDarwin/kotlin/io/realm/kotlin/internal/interop/sync/ProtocolErrorCode.kt @@ -108,9 +108,6 @@ actual enum class WebsocketErrorCode( RLM_ERR_WEBSOCKET_UNAUTHORIZED("Unauthorized", realm_web_socket_errno.RLM_ERR_WEBSOCKET_UNAUTHORIZED), RLM_ERR_WEBSOCKET_FORBIDDEN("Forbidden", realm_web_socket_errno.RLM_ERR_WEBSOCKET_FORBIDDEN), RLM_ERR_WEBSOCKET_MOVEDPERMANENTLY("MovedPermanently", realm_web_socket_errno.RLM_ERR_WEBSOCKET_MOVEDPERMANENTLY), - RLM_ERR_WEBSOCKET_CLIENT_TOO_OLD("ClientTooOld", realm_web_socket_errno.RLM_ERR_WEBSOCKET_CLIENT_TOO_OLD), - RLM_ERR_WEBSOCKET_CLIENT_TOO_NEW("ClientTooNew", realm_web_socket_errno.RLM_ERR_WEBSOCKET_CLIENT_TOO_NEW), - RLM_ERR_WEBSOCKET_PROTOCOL_MISMATCH("ProtocolMismatch", realm_web_socket_errno.RLM_ERR_WEBSOCKET_PROTOCOL_MISMATCH), RLM_ERR_WEBSOCKET_RESOLVE_FAILED("ResolveFailed", realm_web_socket_errno.RLM_ERR_WEBSOCKET_RESOLVE_FAILED), RLM_ERR_WEBSOCKET_CONNECTION_FAILED("ConnectionFailed", realm_web_socket_errno.RLM_ERR_WEBSOCKET_CONNECTION_FAILED), RLM_ERR_WEBSOCKET_READ_ERROR("ReadError", realm_web_socket_errno.RLM_ERR_WEBSOCKET_READ_ERROR), diff --git a/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/EncryptionTests.kt b/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/EncryptionTests.kt index 02526a98e1..0377f0a106 100644 --- a/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/EncryptionTests.kt +++ b/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/EncryptionTests.kt @@ -69,7 +69,6 @@ class EncryptionTests { // Initialize an encrypted Realm val encryptedConf = RealmConfiguration .Builder( - schema = setOf(Sample::class) ) .directory(tmpDir) From 6151c5ab56986b7b4dc10eaf735340a3abad3c76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus=20R=C3=B8rbech?= Date: Tue, 13 Aug 2024 08:53:43 +0200 Subject: [PATCH 41/42] Update CHANGELOG.md Co-authored-by: Kenneth Geisshirt --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 54f02cc4da..cbfe06a334 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,7 +30,7 @@ * [Sync] Fixed a change of mode from Strong to All when removing links from an embedded object that links to a tombstone. This affects sync apps that use embedded objects which have a `Lst` that contains a link to another top level object which has been deleted by another sync client (creating a tombstone locally). In this particular case, the switch would cause any remaining link removals to recursively delete the destination object if there were no other links to it. (Core issue [realm/realm-core#7828](https://github.com/realm/realm-core/issues/7828), since v1.15.0) * [Sync] `SyncSession.uploadAllLocalChanges` was inconsistent in how it handled commits which did not produce any changesets to upload. Previously it would sometimes complete immediately if all commits waiting to be uploaded were empty, and at other times it would wait for a server roundtrip. It will now always complete immediately. (Core issue [realm/realm-core#7796](https://github.com/realm/realm-core/pull/7796)). * [Sync] Sync client can crash if a session is resumed while the session is being suspended. (Core issue [realm/realm-core#7860](https://github.com/realm/realm-core/issues/7860), since v1.0.0) -* [Sync] If a sync session is interrupted by a disconnect or restart while downloading a bootstrap, stale data from the previous bootstrap may be included when the session reconnects and downloads the bootstrap. This can lead to objects stored in the database that do not match the actual state of the server and potentially leading to compensating writes. (Core issue [realm/realm-core#7827](https://github.com/realm/realm-core/issues/7827), since v1.0.0). +* [Sync] When a sync session is interrupted by a disconnect or restart while downloading a bootstrap, stale data from the previous bootstrap may be included when the session reconnects and downloads the bootstrap. This can lead to objects stored in the database that do not match the actual state of the server and potentially leading to compensating writes. (Core issue [realm/realm-core#7827](https://github.com/realm/realm-core/issues/7827), since v1.0.0). * [Sync] App subscription callback was getting fired before the user profile was retrieved on login, leading to an empty user profile when using the callback. ([#7889](https://github.com/realm/realm-core/issues/7889), since v14.7.0). ### Compatibility From 197621f55836153a8f97b8dd45d6358974720981 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus=20R=C3=B8rbech?= Date: Tue, 13 Aug 2024 11:11:00 +0200 Subject: [PATCH 42/42] Ignore flaky platform networking test --- .../io/realm/kotlin/test/mongodb/jvm/PlatformNetworkingTests.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/test-sync/src/jvmTest/kotlin/io/realm/kotlin/test/mongodb/jvm/PlatformNetworkingTests.kt b/packages/test-sync/src/jvmTest/kotlin/io/realm/kotlin/test/mongodb/jvm/PlatformNetworkingTests.kt index b61ddeaa1d..0ddcd8b6ac 100644 --- a/packages/test-sync/src/jvmTest/kotlin/io/realm/kotlin/test/mongodb/jvm/PlatformNetworkingTests.kt +++ b/packages/test-sync/src/jvmTest/kotlin/io/realm/kotlin/test/mongodb/jvm/PlatformNetworkingTests.kt @@ -19,6 +19,7 @@ import io.realm.kotlin.test.mongodb.util.DefaultFlexibleSyncAppInitializer import io.realm.kotlin.test.util.use import kotlinx.coroutines.flow.first import kotlinx.coroutines.withTimeout +import kotlin.test.Ignore import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertTrue @@ -29,6 +30,7 @@ class PlatformNetworkingTests { private val TIMEOUT = 10.seconds @Test + @Ignore // https://github.com/realm/realm-kotlin/issues/1819 fun syncRoundTrip_coreNetworking() = runBlocking { roundTrip(platformNetworking = false) }