From bc7650ca62d1b17e9fabe736041c52921c5e775e Mon Sep 17 00:00:00 2001 From: blagoev Date: Fri, 4 Aug 2023 14:30:11 +0300 Subject: [PATCH 01/50] realm open async --- lib/src/native/realm_bindings.dart | 34 ++++++++++ lib/src/native/realm_core.dart | 100 ++++++++++++++++++++++++----- lib/src/realm_class.dart | 93 ++++++++++++++++++++++----- lib/src/session.dart | 24 ++++--- src/realm_dart_sync.cpp | 8 +++ src/realm_dart_sync.h | 4 +- 6 files changed, 220 insertions(+), 43 deletions(-) diff --git a/lib/src/native/realm_bindings.dart b/lib/src/native/realm_bindings.dart index 2a85e3f2e..47d313712 100644 --- a/lib/src/native/realm_bindings.dart +++ b/lib/src/native/realm_bindings.dart @@ -3129,6 +3129,32 @@ class RealmLibrary { ffi.Pointer Function( ffi.Pointer)>(); + void realm_dart_async_open_task_callback( + ffi.Pointer userdata, + ffi.Pointer realm, + ffi.Pointer error, + ) { + return _realm_dart_async_open_task_callback( + userdata, + realm, + error, + ); + } + + late final _realm_dart_async_open_task_callbackPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>( + 'realm_dart_async_open_task_callback'); + late final _realm_dart_async_open_task_callback = + _realm_dart_async_open_task_callbackPtr.asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); + ffi.Pointer realm_dart_create_scheduler( int isolateId, int port, @@ -10819,6 +10845,14 @@ class RealmLibrary { class _SymbolAddresses { final RealmLibrary _library; _SymbolAddresses(this._library); + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>> + get realm_dart_async_open_task_callback => + _library._realm_dart_async_open_task_callbackPtr; ffi.Pointer< ffi.NativeFunction< ffi.Pointer Function(ffi.Uint64, Dart_Port)>> diff --git a/lib/src/native/realm_core.dart b/lib/src/native/realm_core.dart index 5f7e21bd5..aa2352a18 100644 --- a/lib/src/native/realm_core.dart +++ b/lib/src/native/realm_core.dart @@ -143,14 +143,7 @@ class _RealmCore { return null; } - final message = error.ref.message.cast().toRealmDartString(); - Object? userError; - if (error.ref.usercode_error != nullptr) { - userError = error.ref.usercode_error.toObject(isPersistent: true); - _realmLib.realm_dart_delete_persistent_handle(error.ref.usercode_error); - } - - return LastError(error.ref.error, message, userError); + return error.ref.toLastError(); } void throwLastError([String? errorMessage]) { @@ -626,8 +619,8 @@ class _RealmCore { } final beforeRealm = RealmInternal.getUnowned(syncConfig, RealmHandle._unowned(beforeHandle)); - final afterRealm = - RealmInternal.getUnowned(syncConfig, RealmHandle._unowned(_realmLib.realm_from_thread_safe_reference(afterReference, scheduler.handle._pointer))); + final realmPtr = _realmLib.invokeGetPointer(() => _realmLib.realm_from_thread_safe_reference(afterReference, scheduler.handle._pointer)); + final afterRealm = RealmInternal.getUnowned(syncConfig, RealmHandle._unowned(realmPtr)); try { return await afterResetCallback(beforeRealm, afterRealm); @@ -664,6 +657,59 @@ class _RealmCore { return RealmHandle._(realmPtr); } + RealmAsyncOpenTaskHandle createRealmAsyncOpenTask(FlexibleSyncConfiguration config) { + final configHandle = _createConfig(config); + final asyncOpenTaskPtr = + _realmLib.invokeGetPointer(() => _realmLib.realm_open_synchronized(configHandle._pointer), "Error opening realm at path ${config.path}"); + return RealmAsyncOpenTaskHandle._(asyncOpenTaskPtr); + } + + Future openRealmAsync(RealmAsyncOpenTaskHandle handle) { + final completer = Completer(); + final callback = + Pointer.fromFunction realm, Pointer error)>(_openRealmAsyncCallback); + final userData = _realmLib.realm_dart_userdata_async_new(completer, callback.cast(), scheduler.handle._pointer); + _realmLib.realm_async_open_task_start( + handle._pointer, + _realmLib.addresses.realm_dart_async_open_task_callback, + userData.cast(), + _realmLib.addresses.realm_dart_userdata_async_free, + ); + return completer.future; + } + + static void _openRealmAsyncCallback(Object userData, Pointer realmSafePtr, Pointer error) { + return using((Arena arena) { + final completer = userData as Completer; + + if (error != nullptr) { + final err = arena(); + _realmLib.realm_get_async_error(error, err); + completer.completeError(RealmException("Failed to open realm ${err.ref.toLastError().toString()}")); + } + + final realmPtr = _realmLib.invokeGetPointer(() => _realmLib.realm_from_thread_safe_reference(realmSafePtr, scheduler.handle._pointer)); + completer.complete(RealmHandle._(realmPtr)); + }); + } + + void cancelOpenRealmAsync(RealmAsyncOpenTaskHandle handle) { + _realmLib.realm_async_open_task_cancel(handle._pointer); + } + + RealmAsyncOpenTaskProgressNotificationTokenHandle realmAsyncOpenRegisterAsyncOpenProgressNotifier( + RealmAsyncOpenTaskHandle handle, RealmAsyncOpenProgressNotificationsController controller) { + final callback = Pointer.fromFunction(_syncProgressCallback); + final userdata = _realmLib.realm_dart_userdata_async_new(controller, callback.cast(), scheduler.handle._pointer); + final tokenPtr = _realmLib.invokeGetPointer(() => _realmLib.realm_async_open_task_register_download_progress_notifier( + handle._pointer, + _realmLib.addresses.realm_dart_sync_progress_callback, + userdata.cast(), + _realmLib.addresses.realm_dart_userdata_async_free, + )); + return RealmAsyncOpenTaskProgressNotificationTokenHandle._(tokenPtr); + } + RealmSchema readSchema(Realm realm) { return using((Arena arena) { return _readSchema(realm, arena); @@ -2207,20 +2253,20 @@ class _RealmCore { RealmSyncSessionConnectionStateNotificationTokenHandle sessionRegisterProgressNotifier( Session session, ProgressDirection direction, ProgressMode mode, SessionProgressNotificationsController controller) { final isStreaming = mode == ProgressMode.reportIndefinitely; - final callback = Pointer.fromFunction(_progressCallback); + final callback = Pointer.fromFunction(_syncProgressCallback); final userdata = _realmLib.realm_dart_userdata_async_new(controller, callback.cast(), scheduler.handle._pointer); - final notification_token = _realmLib.realm_sync_session_register_progress_notifier( + final tokenPtr = _realmLib.invokeGetPointer(() => _realmLib.realm_sync_session_register_progress_notifier( session.handle._pointer, _realmLib.addresses.realm_dart_sync_progress_callback, direction.index, isStreaming, userdata.cast(), - _realmLib.addresses.realm_dart_userdata_async_free); - return RealmSyncSessionConnectionStateNotificationTokenHandle._(notification_token); + _realmLib.addresses.realm_dart_userdata_async_free)); + return RealmSyncSessionConnectionStateNotificationTokenHandle._(tokenPtr); } - static void _progressCallback(Object userdata, int transferred, int transferable) { - final controller = userdata as SessionProgressNotificationsController; + static void _syncProgressCallback(Object userdata, int transferred, int transferable) { + final controller = userdata as ProgressNotificationsController; controller.onProgress(transferred, transferable); } @@ -2824,6 +2870,15 @@ class SubscriptionHandle extends HandleBase { SubscriptionHandle._(Pointer pointer) : super(pointer, 184); } +class RealmAsyncOpenTaskHandle extends HandleBase { + RealmAsyncOpenTaskHandle._(Pointer pointer) : super(pointer, 16); //TODO: fix size +} + +class RealmAsyncOpenTaskProgressNotificationTokenHandle extends HandleBase { + RealmAsyncOpenTaskProgressNotificationTokenHandle._(Pointer pointer) + : super(pointer, 32); //TODO: fix size +} + class SubscriptionSetHandle extends RootedHandleBase { @override bool get shouldRoot => true; @@ -3318,3 +3373,16 @@ class SyncErrorDetails { this.compensatingWrites, }); } + +extension on realm_error { + LastError toLastError() { + final message = this.message.cast().toRealmDartString(); + Object? userError; + if (usercode_error != nullptr) { + userError = usercode_error.toObject(isPersistent: true); + _realmLib.realm_dart_delete_persistent_handle(usercode_error); + } + + return LastError(error, message, userError); + } +} diff --git a/lib/src/realm_class.dart b/lib/src/realm_class.dart index 552988808..3d46d70e7 100644 --- a/lib/src/realm_class.dart +++ b/lib/src/realm_class.dart @@ -173,31 +173,58 @@ class Realm implements Finalizable { if (cancellationToken != null && cancellationToken.isCancelled) { throw cancellationToken.exception!; } - final realm = Realm(config); - StreamSubscription? subscription; - try { - if (config is FlexibleSyncConfiguration) { - final session = realm.syncSession; - if (onProgressCallback != null) { - subscription = session.getProgressStream(ProgressDirection.download, ProgressMode.forCurrentlyOutstandingWork).listen(onProgressCallback); - } - await session.waitForDownload(cancellationToken); - await subscription?.cancel(); - } - } catch (_) { - await subscription?.cancel(); - realm.close(); - rethrow; + + if (config is! FlexibleSyncConfiguration) { + final realm = Realm(config); + return await CancellableFuture.value(realm, cancellationToken); } - return await CancellableFuture.value(realm, cancellationToken); + + _ensureDirectory(config); + + final asyncOpenHandle = realmCore.createRealmAsyncOpenTask(config); + + return CancellableFuture.from(() async { + StreamSubscription? progressSubscription; + if (onProgressCallback != null) { + final progressController = RealmAsyncOpenProgressNotificationsController._(asyncOpenHandle); + realmCore.realmAsyncOpenRegisterAsyncOpenProgressNotifier(asyncOpenHandle, progressController); + final progressStream = progressController.createStream(); + progressSubscription = progressStream.listen(onProgressCallback); + } + + final realmHandle = await realmCore.openRealmAsync(asyncOpenHandle); + await progressSubscription?.cancel(); + + return Realm._(config, realmHandle); + }, cancellationToken, onCancel: () => realmCore.cancelOpenRealmAsync(asyncOpenHandle)); + + // final realm = Realm(config); + // StreamSubscription? subscription; + // try { + // final session = realm.syncSession; + // if (onProgressCallback != null) { + // subscription = session.getProgressStream(ProgressDirection.download, ProgressMode.forCurrentlyOutstandingWork).listen(onProgressCallback); + // } + // await session.waitForDownload(cancellationToken); + // await subscription?.cancel(); + // } catch (_) { + // await subscription?.cancel(); + // realm.close(); + // rethrow; + // } + // return await CancellableFuture.value(realm, cancellationToken); } static RealmHandle _openRealm(Configuration config) { + _ensureDirectory(config); + return realmCore.openRealm(config); + } + + static void _ensureDirectory(Configuration config) { var dir = File(config.path).parent; if (!dir.existsSync()) { dir.createSync(recursive: true); } - return realmCore.openRealm(config); } void _populateMetadata() { @@ -959,3 +986,35 @@ class MigrationRealm extends DynamicRealm { /// * syncProgress - an object of [SyncProgress] that contains `transferredBytes` and `transferableBytes`. /// {@category Realm} typedef ProgressCallback = void Function(SyncProgress syncProgress); + +/// @nodoc +class RealmAsyncOpenProgressNotificationsController implements ProgressNotificationsController { + final RealmAsyncOpenTaskHandle _handle; + RealmAsyncOpenTaskProgressNotificationTokenHandle? _tokenHandle; + late final StreamController _streamController; + + RealmAsyncOpenProgressNotificationsController._(this._handle); + + Stream createStream() { + _streamController = StreamController.broadcast(onListen: _start, onCancel: _stop); + return _streamController.stream; + } + + @override + void onProgress(int transferredBytes, int transferableBytes) { + _streamController.add(SessionInternal.createSyncProgress(transferredBytes, transferableBytes)); + } + + void _start() { + if (_tokenHandle != null) { + throw RealmStateError("Progress subscription already started."); + } + + _tokenHandle = realmCore.realmAsyncOpenRegisterAsyncOpenProgressNotifier(_handle, this); + } + + void _stop() { + _tokenHandle?.release(); + _tokenHandle = null; + } +} diff --git a/lib/src/session.dart b/lib/src/session.dart index e8e123e9d..84adaddf7 100644 --- a/lib/src/session.dart +++ b/lib/src/session.dart @@ -91,7 +91,7 @@ class SyncProgress { /// successfully transferred. final int transferableBytes; - SyncProgress._(this.transferredBytes, this.transferableBytes); + const SyncProgress._(this.transferredBytes, this.transferableBytes); } /// A type containing information about the transition of a connection state from one value to another. @@ -124,15 +124,21 @@ extension SessionInternal on Session { void raiseError(SyncErrorCategory category, int errorCode, bool isFatal) { realmCore.raiseError(this, category, errorCode, isFatal); } + + static SyncProgress createSyncProgress(int transferredBytes, int transferableBytes) => SyncProgress._(transferredBytes, transferableBytes); +} + +abstract interface class ProgressNotificationsController { + void onProgress(int transferredBytes, int transferableBytes); } /// @nodoc -class SessionProgressNotificationsController { +class SessionProgressNotificationsController implements ProgressNotificationsController { final Session _session; final ProgressDirection _direction; final ProgressMode _mode; - RealmSyncSessionConnectionStateNotificationTokenHandle? _token; + RealmSyncSessionConnectionStateNotificationTokenHandle? _tokenHandle; late final StreamController _streamController; SessionProgressNotificationsController(this._session, this._direction, this._mode); @@ -142,6 +148,7 @@ class SessionProgressNotificationsController { return _streamController.stream; } + @override void onProgress(int transferredBytes, int transferableBytes) { _streamController.add(SyncProgress._(transferredBytes, transferableBytes)); @@ -151,15 +158,15 @@ class SessionProgressNotificationsController { } void _start() { - if (_token != null) { - throw RealmStateError("Session progress subscription already started"); + if (_tokenHandle != null) { + throw RealmStateError("Session progress subscription already started."); } - _token = realmCore.sessionRegisterProgressNotifier(_session, _direction, _mode, this); + _tokenHandle = realmCore.sessionRegisterProgressNotifier(_session, _direction, _mode, this); } void _stop() { - _token?.release(); - _token = null; + _tokenHandle?.release(); + _tokenHandle = null; } } @@ -591,7 +598,6 @@ enum SyncResolveErrorCode { /// /// These errors will be reported via the error handlers of the affected sessions. enum SyncWebSocketErrorCode { - /// Web socket resolution failed websocketResolveFailed(4400), diff --git a/src/realm_dart_sync.cpp b/src/realm_dart_sync.cpp index d2867cf9d..8846e3aae 100644 --- a/src/realm_dart_sync.cpp +++ b/src/realm_dart_sync.cpp @@ -218,3 +218,11 @@ RLM_API bool realm_dart_sync_after_reset_handler_callback(realm_userdata_t userd }; return invoke_dart_and_await_result(&userCallback); } + +RLM_API void realm_dart_async_open_task_callback(realm_userdata_t userdata, realm_thread_safe_reference_t* realm, const realm_async_error_t* error) +{ + auto ud = reinterpret_cast(userdata); + ud->scheduler->invoke([ud, realm, error]() { + (reinterpret_cast(ud->dart_callback))(ud->handle, realm, error); + }); +} diff --git a/src/realm_dart_sync.h b/src/realm_dart_sync.h index ba354b89b..8d1f9f412 100644 --- a/src/realm_dart_sync.h +++ b/src/realm_dart_sync.h @@ -41,4 +41,6 @@ RLM_API void realm_dart_sync_on_subscription_state_changed_callback(realm_userda RLM_API bool realm_dart_sync_before_reset_handler_callback(realm_userdata_t userdata, realm_t* realm); -RLM_API bool realm_dart_sync_after_reset_handler_callback(realm_userdata_t userdata, realm_t* before_realm, realm_thread_safe_reference_t* after_realm, bool did_recover); \ No newline at end of file +RLM_API bool realm_dart_sync_after_reset_handler_callback(realm_userdata_t userdata, realm_t* before_realm, realm_thread_safe_reference_t* after_realm, bool did_recover); + +RLM_API void realm_dart_async_open_task_callback(realm_userdata_t userdata, realm_thread_safe_reference_t* realm, const realm_async_error_t* error); From d68effee941e7263467600c59369e5d9383c9c61 Mon Sep 17 00:00:00 2001 From: blagoev Date: Fri, 4 Aug 2023 16:57:43 +0300 Subject: [PATCH 02/50] don't subscribe twice --- lib/src/realm_class.dart | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/lib/src/realm_class.dart b/lib/src/realm_class.dart index 3d46d70e7..30c5b591a 100644 --- a/lib/src/realm_class.dart +++ b/lib/src/realm_class.dart @@ -187,7 +187,6 @@ class Realm implements Finalizable { StreamSubscription? progressSubscription; if (onProgressCallback != null) { final progressController = RealmAsyncOpenProgressNotificationsController._(asyncOpenHandle); - realmCore.realmAsyncOpenRegisterAsyncOpenProgressNotifier(asyncOpenHandle, progressController); final progressStream = progressController.createStream(); progressSubscription = progressStream.listen(onProgressCallback); } @@ -197,22 +196,6 @@ class Realm implements Finalizable { return Realm._(config, realmHandle); }, cancellationToken, onCancel: () => realmCore.cancelOpenRealmAsync(asyncOpenHandle)); - - // final realm = Realm(config); - // StreamSubscription? subscription; - // try { - // final session = realm.syncSession; - // if (onProgressCallback != null) { - // subscription = session.getProgressStream(ProgressDirection.download, ProgressMode.forCurrentlyOutstandingWork).listen(onProgressCallback); - // } - // await session.waitForDownload(cancellationToken); - // await subscription?.cancel(); - // } catch (_) { - // await subscription?.cancel(); - // realm.close(); - // rethrow; - // } - // return await CancellableFuture.value(realm, cancellationToken); } static RealmHandle _openRealm(Configuration config) { From 97db98cbf63fafc34efc85fdb2766609db444473 Mon Sep 17 00:00:00 2001 From: blagoev Date: Tue, 8 Aug 2023 14:51:45 +0300 Subject: [PATCH 03/50] filter tests on CI --- .github/workflows/flutter-desktop-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/flutter-desktop-tests.yml b/.github/workflows/flutter-desktop-tests.yml index 0650c5ccf..dcd6fbcb2 100644 --- a/.github/workflows/flutter-desktop-tests.yml +++ b/.github/workflows/flutter-desktop-tests.yml @@ -87,5 +87,5 @@ jobs: clusterName: ${{ env.BAAS_CLUSTER }} - name: Run tests - run: ${{ inputs.os == 'linux' && 'xvfb-run' || '' }} flutter drive -d ${{ inputs.os }} --target=test_driver/app.dart --suppress-analytics --dart-entrypoint-args="" --debug # -a="Some test name" + run: ${{ inputs.os == 'linux' && 'xvfb-run' || '' }} flutter drive -d ${{ inputs.os }} --target=test_driver/app.dart --suppress-analytics --dart-entrypoint-args="RecoverOrDiscardUnsyncedChangesHandler check data in beforeResetRealm realm and after realm when recover or discard" --debug # -a="Some test name" working-directory: ./flutter/realm_flutter/tests From b8c37eafca1dcb534667cc907f6adb68820c71fe Mon Sep 17 00:00:00 2001 From: blagoev Date: Wed, 9 Aug 2023 17:25:04 +0300 Subject: [PATCH 04/50] add changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bc006fd0f..12c81f68a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,7 @@ * Dart ^3.0.2 and Flutter ^3.10.2 ### Internal +* Synced realms will use async open to prevent overloading the server with schema updates. [#1369](https://github.com/realm/realm-dart/pull/1369)) * Using Core 13.15.1 ## 1.2.0 (2023-06-08) From 3b85c77c30709c7bfa7d6fbd7f5b60269718c93e Mon Sep 17 00:00:00 2001 From: blagoev Date: Wed, 9 Aug 2023 17:37:37 +0300 Subject: [PATCH 05/50] fix native struct sizes enable multiplexing --- lib/src/native/realm_core.dart | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/src/native/realm_core.dart b/lib/src/native/realm_core.dart index fd1c584ee..7874ed3f5 100644 --- a/lib/src/native/realm_core.dart +++ b/lib/src/native/realm_core.dart @@ -1823,10 +1823,6 @@ class _RealmCore { return using((arena) { final handle = SyncClientConfigHandle._(_realmLib.realm_sync_client_config_new()); - // TODO: Remove later - // Disable multiplexing for now due to: https://github.com/realm/realm-core/issues/6656 - _realmLib.realm_sync_client_config_set_multiplex_sessions(handle._pointer, false); - // <-- end _realmLib.realm_sync_client_config_set_base_file_path(handle._pointer, configuration.baseFilePath.path.toCharPtr(arena)); _realmLib.realm_sync_client_config_set_metadata_mode(handle._pointer, configuration.metadataPersistenceMode.index); _realmLib.realm_sync_client_config_set_connect_timeout(handle._pointer, configuration.maxConnectionTimeout.inMilliseconds); @@ -2892,12 +2888,12 @@ class SubscriptionHandle extends HandleBase { } class RealmAsyncOpenTaskHandle extends HandleBase { - RealmAsyncOpenTaskHandle._(Pointer pointer) : super(pointer, 16); //TODO: fix size + RealmAsyncOpenTaskHandle._(Pointer pointer) : super(pointer, 32); } class RealmAsyncOpenTaskProgressNotificationTokenHandle extends HandleBase { RealmAsyncOpenTaskProgressNotificationTokenHandle._(Pointer pointer) - : super(pointer, 32); //TODO: fix size + : super(pointer, 40); } class SubscriptionSetHandle extends RootedHandleBase { From 4df83a5ef5d22717ad4535879698e7f0f5d3ff02 Mon Sep 17 00:00:00 2001 From: blagoev Date: Thu, 10 Aug 2023 12:46:13 +0300 Subject: [PATCH 06/50] revert test filter --- .github/workflows/flutter-desktop-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/flutter-desktop-tests.yml b/.github/workflows/flutter-desktop-tests.yml index dcd6fbcb2..0650c5ccf 100644 --- a/.github/workflows/flutter-desktop-tests.yml +++ b/.github/workflows/flutter-desktop-tests.yml @@ -87,5 +87,5 @@ jobs: clusterName: ${{ env.BAAS_CLUSTER }} - name: Run tests - run: ${{ inputs.os == 'linux' && 'xvfb-run' || '' }} flutter drive -d ${{ inputs.os }} --target=test_driver/app.dart --suppress-analytics --dart-entrypoint-args="RecoverOrDiscardUnsyncedChangesHandler check data in beforeResetRealm realm and after realm when recover or discard" --debug # -a="Some test name" + run: ${{ inputs.os == 'linux' && 'xvfb-run' || '' }} flutter drive -d ${{ inputs.os }} --target=test_driver/app.dart --suppress-analytics --dart-entrypoint-args="" --debug # -a="Some test name" working-directory: ./flutter/realm_flutter/tests From df11bdc4b62a0e605f9fa94cdf7d95f31491968b Mon Sep 17 00:00:00 2001 From: blagoev Date: Thu, 10 Aug 2023 13:21:38 +0300 Subject: [PATCH 07/50] remove null check --- lib/src/realm_class.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/realm_class.dart b/lib/src/realm_class.dart index d5416f291..a07215703 100644 --- a/lib/src/realm_class.dart +++ b/lib/src/realm_class.dart @@ -171,7 +171,7 @@ class Realm implements Finalizable { /// Using [Realm.open] for opening a local Realm is equivalent to using the constructor of [Realm]. static Future open(Configuration config, {CancellationToken? cancellationToken, ProgressCallback? onProgressCallback}) async { if (cancellationToken != null && cancellationToken.isCancelled) { - throw cancellationToken.exception!; + throw cancellationToken.exception; } if (config is! FlexibleSyncConfiguration) { From 6ef613c540e3caa89ef83df41a49cf4270e3844c Mon Sep 17 00:00:00 2001 From: blagoev Date: Thu, 10 Aug 2023 13:36:24 +0300 Subject: [PATCH 08/50] revert null check. (fooled by the analyzer) --- lib/src/realm_class.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/realm_class.dart b/lib/src/realm_class.dart index a07215703..d5416f291 100644 --- a/lib/src/realm_class.dart +++ b/lib/src/realm_class.dart @@ -171,7 +171,7 @@ class Realm implements Finalizable { /// Using [Realm.open] for opening a local Realm is equivalent to using the constructor of [Realm]. static Future open(Configuration config, {CancellationToken? cancellationToken, ProgressCallback? onProgressCallback}) async { if (cancellationToken != null && cancellationToken.isCancelled) { - throw cancellationToken.exception; + throw cancellationToken.exception!; } if (config is! FlexibleSyncConfiguration) { From 7dd5ac186a7bce2e2874192cb0ba65b3f79c4a5d Mon Sep 17 00:00:00 2001 From: blagoev Date: Thu, 10 Aug 2023 13:48:20 +0300 Subject: [PATCH 09/50] don't use broadcast --- lib/src/realm_class.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/realm_class.dart b/lib/src/realm_class.dart index d5416f291..04410f46e 100644 --- a/lib/src/realm_class.dart +++ b/lib/src/realm_class.dart @@ -992,7 +992,7 @@ class RealmAsyncOpenProgressNotificationsController implements ProgressNotificat RealmAsyncOpenProgressNotificationsController._(this._handle); Stream createStream() { - _streamController = StreamController.broadcast(onListen: _start, onCancel: _stop); + _streamController = StreamController(onListen: _start, onCancel: _stop); return _streamController.stream; } From 94a81d188a9871a7521b3f062fffeb82a5d70d5c Mon Sep 17 00:00:00 2001 From: blagoev Date: Thu, 10 Aug 2023 18:16:41 +0300 Subject: [PATCH 10/50] check token isCancelled inside CancellableFuture callback use try finally for pgoress subscription cancelations Use CancellableCompleter for openRealmAsync. Core does not invoke the callback on cancellation. --- lib/src/native/realm_core.dart | 5 +++-- lib/src/realm_class.dart | 12 ++++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/src/native/realm_core.dart b/lib/src/native/realm_core.dart index 7874ed3f5..ac085106a 100644 --- a/lib/src/native/realm_core.dart +++ b/lib/src/native/realm_core.dart @@ -664,8 +664,8 @@ class _RealmCore { return RealmAsyncOpenTaskHandle._(asyncOpenTaskPtr); } - Future openRealmAsync(RealmAsyncOpenTaskHandle handle) { - final completer = Completer(); + Future openRealmAsync(RealmAsyncOpenTaskHandle handle, CancellationToken? cancellationToken) { + final completer = CancellableCompleter(cancellationToken); final callback = Pointer.fromFunction realm, Pointer error)>(_openRealmAsyncCallback); final userData = _realmLib.realm_dart_userdata_async_new(completer, callback.cast(), scheduler.handle._pointer); @@ -675,6 +675,7 @@ class _RealmCore { userData.cast(), _realmLib.addresses.realm_dart_userdata_async_free, ); + return completer.future; } diff --git a/lib/src/realm_class.dart b/lib/src/realm_class.dart index 04410f46e..879ca69bb 100644 --- a/lib/src/realm_class.dart +++ b/lib/src/realm_class.dart @@ -184,6 +184,10 @@ class Realm implements Finalizable { final asyncOpenHandle = realmCore.createRealmAsyncOpenTask(config); return CancellableFuture.from(() async { + if (cancellationToken != null && cancellationToken.isCancelled) { + throw cancellationToken.exception!; + } + StreamSubscription? progressSubscription; if (onProgressCallback != null) { final progressController = RealmAsyncOpenProgressNotificationsController._(asyncOpenHandle); @@ -191,8 +195,12 @@ class Realm implements Finalizable { progressSubscription = progressStream.listen(onProgressCallback); } - final realmHandle = await realmCore.openRealmAsync(asyncOpenHandle); - await progressSubscription?.cancel(); + late final RealmHandle realmHandle; + try { + realmHandle = await realmCore.openRealmAsync(asyncOpenHandle, cancellationToken); + } finally { + await progressSubscription?.cancel(); + } return Realm._(config, realmHandle); }, cancellationToken, onCancel: () => realmCore.cancelOpenRealmAsync(asyncOpenHandle)); From 897f971029be4d1428bf4c5dd9b65e076abd4498 Mon Sep 17 00:00:00 2001 From: blagoev Date: Thu, 10 Aug 2023 23:29:46 +0300 Subject: [PATCH 11/50] force rebuild --- .github/workflows/build-native.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-native.yml b/.github/workflows/build-native.yml index df56e587f..8ba0023e1 100644 --- a/.github/workflows/build-native.yml +++ b/.github/workflows/build-native.yml @@ -37,7 +37,7 @@ jobs: uses: actions/cache@v3 with: path: ./binary/** - key: binaries-${{ matrix.build }}-{{ inputs.runner }}-${{hashFiles('./src/**')}} + key: binaries-1-${{ matrix.build }}-{{ inputs.runner }}-${{hashFiles('./src/**')}} - name: Setup Ninja if: contains(github.head_ref, 'release/') || steps.check-cache.outputs.cache-hit != 'true' From 15916ebf4d193e6d5a340889c0d50d60385bfb12 Mon Sep 17 00:00:00 2001 From: blagoev Date: Thu, 10 Aug 2023 23:48:08 +0300 Subject: [PATCH 12/50] revert cache. filter tests --- .github/workflows/build-native.yml | 2 +- .github/workflows/flutter-desktop-tests.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-native.yml b/.github/workflows/build-native.yml index 8ba0023e1..df56e587f 100644 --- a/.github/workflows/build-native.yml +++ b/.github/workflows/build-native.yml @@ -37,7 +37,7 @@ jobs: uses: actions/cache@v3 with: path: ./binary/** - key: binaries-1-${{ matrix.build }}-{{ inputs.runner }}-${{hashFiles('./src/**')}} + key: binaries-${{ matrix.build }}-{{ inputs.runner }}-${{hashFiles('./src/**')}} - name: Setup Ninja if: contains(github.head_ref, 'release/') || steps.check-cache.outputs.cache-hit != 'true' diff --git a/.github/workflows/flutter-desktop-tests.yml b/.github/workflows/flutter-desktop-tests.yml index 0650c5ccf..437cafbd5 100644 --- a/.github/workflows/flutter-desktop-tests.yml +++ b/.github/workflows/flutter-desktop-tests.yml @@ -87,5 +87,5 @@ jobs: clusterName: ${{ env.BAAS_CLUSTER }} - name: Run tests - run: ${{ inputs.os == 'linux' && 'xvfb-run' || '' }} flutter drive -d ${{ inputs.os }} --target=test_driver/app.dart --suppress-analytics --dart-entrypoint-args="" --debug # -a="Some test name" + run: ${{ inputs.os == 'linux' && 'xvfb-run' || '' }} flutter drive -d ${{ inputs.os }} --target=test_driver/app.dart --suppress-analytics --dart-entrypoint-args="Realm.open" --debug # -a="Some test name" working-directory: ./flutter/realm_flutter/tests From bc9f4f992b47c2353b1b2a27c31644525fb46178 Mon Sep 17 00:00:00 2001 From: blagoev Date: Thu, 10 Aug 2023 23:58:37 +0300 Subject: [PATCH 13/50] force release --- lib/src/realm_class.dart | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/src/realm_class.dart b/lib/src/realm_class.dart index 879ca69bb..81bcfc6e5 100644 --- a/lib/src/realm_class.dart +++ b/lib/src/realm_class.dart @@ -182,7 +182,6 @@ class Realm implements Finalizable { _ensureDirectory(config); final asyncOpenHandle = realmCore.createRealmAsyncOpenTask(config); - return CancellableFuture.from(() async { if (cancellationToken != null && cancellationToken.isCancelled) { throw cancellationToken.exception!; @@ -203,7 +202,7 @@ class Realm implements Finalizable { } return Realm._(config, realmHandle); - }, cancellationToken, onCancel: () => realmCore.cancelOpenRealmAsync(asyncOpenHandle)); + }, cancellationToken, onCancel: () => realmCore.cancelOpenRealmAsync(asyncOpenHandle)).whenComplete(() => asyncOpenHandle.release()); } static RealmHandle _openRealm(Configuration config) { From 6c4b6766a855c445745add49974a2e3ee0798939 Mon Sep 17 00:00:00 2001 From: blagoev Date: Fri, 11 Aug 2023 11:34:45 +0300 Subject: [PATCH 14/50] only linux ci --- .github/workflows/ci.yml | 1026 +++++++++++++++++++------------------- 1 file changed, 513 insertions(+), 513 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f97d840a7..8b17287c7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,12 +17,12 @@ concurrency: cancel-in-progress: true jobs: - deploy-dart-cluster: - name: Deploy Dart cluster - secrets: inherit - uses: ./.github/workflows/create-cluster.yml - with: - prefix: d + # deploy-dart-cluster: + # name: Deploy Dart cluster + # secrets: inherit + # uses: ./.github/workflows/create-cluster.yml + # with: + # prefix: d deploy-flutter-cluster: name: Deploy Flutter cluster @@ -31,15 +31,15 @@ jobs: with: prefix: f - create-dart-shared-apps: - name: Create Dart shared Apps - secrets: inherit - needs: - - deploy-dart-cluster - uses: ./.github/workflows/shared-apps.yml - with: - cluster: ${{ needs.deploy-dart-cluster.outputs.clusterName }} - env: Dart + # create-dart-shared-apps: + # name: Create Dart shared Apps + # secrets: inherit + # needs: + # - deploy-dart-cluster + # uses: ./.github/workflows/shared-apps.yml + # with: + # cluster: ${{ needs.deploy-dart-cluster.outputs.clusterName }} + # env: Dart create-flutter-shared-apps: name: Create Flutter shared Apps @@ -51,28 +51,28 @@ jobs: cluster: ${{ needs.deploy-flutter-cluster.outputs.clusterName }} env: Flutter - delete-dart-cluster: - runs-on: ubuntu-latest - name: Delete Dart Cluster - timeout-minutes: 5 - continue-on-error: true - needs: - - deploy-dart-cluster - - dart-tests-windows - - dart-tests-macos - - dart-tests-macos-arm - - dart-tests-linux - - dart-tests-linux-ubuntu-20 - - steps: - - uses: realm/ci-actions/mdb-realm/cleanup@338bf3e7575015a28faec8b67614385d122aece7 - with: - realmUrl: ${{ env.BAAS_URL }} - atlasUrl: ${{ secrets.ATLAS_QA_URL }} - projectId: ${{ env.BAAS_PROJECT_ID }} - apiKey: ${{ env.BAAS_API_KEY }} - privateApiKey: ${{ env.BAAS_PRIVATE_API_KEY }} - clusterName: ${{ needs.deploy-dart-cluster.outputs.clusterName }} + # delete-dart-cluster: + # runs-on: ubuntu-latest + # name: Delete Dart Cluster + # timeout-minutes: 5 + # continue-on-error: true + # needs: + # - deploy-dart-cluster + # - dart-tests-windows + # - dart-tests-macos + # - dart-tests-macos-arm + # - dart-tests-linux + # - dart-tests-linux-ubuntu-20 + + # steps: + # - uses: realm/ci-actions/mdb-realm/cleanup@338bf3e7575015a28faec8b67614385d122aece7 + # with: + # realmUrl: ${{ env.BAAS_URL }} + # atlasUrl: ${{ secrets.ATLAS_QA_URL }} + # projectId: ${{ env.BAAS_PROJECT_ID }} + # apiKey: ${{ env.BAAS_API_KEY }} + # privateApiKey: ${{ env.BAAS_PRIVATE_API_KEY }} + # clusterName: ${{ needs.deploy-dart-cluster.outputs.clusterName }} delete-flutter-cluster: runs-on: ubuntu-latest @@ -97,22 +97,22 @@ jobs: privateApiKey: ${{ env.BAAS_PRIVATE_API_KEY }} clusterName: ${{ needs.deploy-flutter-cluster.outputs.clusterName }} - cleanup-dart-shared-apps: - name: Delete Dart shared Apps - secrets: inherit - needs: - - deploy-dart-cluster - - dart-tests-windows - - dart-tests-macos - - dart-tests-macos-arm - - dart-tests-linux - - dart-tests-linux-ubuntu-20 - uses: ./.github/workflows/shared-apps.yml - if: always() - with: - cleanup: true - cluster: ${{ needs.deploy-dart-cluster.outputs.clusterName }} - env: Dart + # cleanup-dart-shared-apps: + # name: Delete Dart shared Apps + # secrets: inherit + # needs: + # - deploy-dart-cluster + # - dart-tests-windows + # - dart-tests-macos + # - dart-tests-macos-arm + # - dart-tests-linux + # - dart-tests-linux-ubuntu-20 + # uses: ./.github/workflows/shared-apps.yml + # if: always() + # with: + # cleanup: true + # cluster: ${{ needs.deploy-dart-cluster.outputs.clusterName }} + # env: Dart cleanup-flutter-shared-apps: name: Delete Flutter shared Apps @@ -132,55 +132,55 @@ jobs: cluster: ${{ needs.deploy-flutter-cluster.outputs.clusterName }} env: Flutter - cleanup-dart-matrix: - needs: - - deploy-dart-cluster - - dart-tests-windows - - dart-tests-macos - - dart-tests-macos-arm - - dart-tests-linux - - dart-tests-linux-ubuntu-20 - strategy: - fail-fast: false - matrix: - include: - - app: dm - description: dart macos - - app: dma - description: dart macos-arm - - app: dl - description: dart linux - - app: dl2 - description: dart linux (ubuntu 20) - - app: dw - description: dart windows - runs-on: ubuntu-latest - name: Cleanup apps for ${{ matrix.description }} - timeout-minutes: 20 - if: always() - env: - BAAS_CLUSTER: ${{ needs.deploy-dart-cluster.outputs.clusterName }} - BAAS_DIFFERENTIATOR: ${{ matrix.app }}${{ github.run_id }}${{ github.run_attempt }} - steps: - - name: Checkout - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 - with: - submodules: false - - - name : Setup Dart SDK - uses: dart-lang/setup-dart@main - with: - sdk: stable - - - name: Cleanup Dart apps - run: | - dart run realm_dart delete-apps \ - --baas-url ${{ env.BAAS_URL }} \ - --atlas-cluster ${{ env.BAAS_CLUSTER }} \ - --api-key ${{ env.BAAS_API_KEY }} \ - --private-api-key ${{ env.BAAS_PRIVATE_API_KEY }} \ - --project-id ${{ env.BAAS_PROJECT_ID }} \ - --differentiator '${{ env.BAAS_DIFFERENTIATOR }}' + # cleanup-dart-matrix: + # needs: + # - deploy-dart-cluster + # - dart-tests-windows + # - dart-tests-macos + # - dart-tests-macos-arm + # - dart-tests-linux + # - dart-tests-linux-ubuntu-20 + # strategy: + # fail-fast: false + # matrix: + # include: + # - app: dm + # description: dart macos + # - app: dma + # description: dart macos-arm + # - app: dl + # description: dart linux + # - app: dl2 + # description: dart linux (ubuntu 20) + # - app: dw + # description: dart windows + # runs-on: ubuntu-latest + # name: Cleanup apps for ${{ matrix.description }} + # timeout-minutes: 20 + # if: always() + # env: + # BAAS_CLUSTER: ${{ needs.deploy-dart-cluster.outputs.clusterName }} + # BAAS_DIFFERENTIATOR: ${{ matrix.app }}${{ github.run_id }}${{ github.run_attempt }} + # steps: + # - name: Checkout + # uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + # with: + # submodules: false + + # - name : Setup Dart SDK + # uses: dart-lang/setup-dart@main + # with: + # sdk: stable + + # - name: Cleanup Dart apps + # run: | + # dart run realm_dart delete-apps \ + # --baas-url ${{ env.BAAS_URL }} \ + # --atlas-cluster ${{ env.BAAS_CLUSTER }} \ + # --api-key ${{ env.BAAS_API_KEY }} \ + # --private-api-key ${{ env.BAAS_PRIVATE_API_KEY }} \ + # --project-id ${{ env.BAAS_PROJECT_ID }} \ + # --differentiator '${{ env.BAAS_DIFFERENTIATOR }}' cleanup-flutter-matrix: needs: @@ -235,21 +235,21 @@ jobs: --project-id ${{ env.BAAS_PROJECT_ID }} \ --differentiator '${{ env.BAAS_DIFFERENTIATOR }}' - build-windows: - name: Build Windows - uses: ./.github/workflows/build-native.yml - with: - runner: windows-latest - binary: windows - build: '["windows"]' - - build-macos: - name: Build MacOS - uses: ./.github/workflows/build-native.yml - with: - runner: macos-latest - binary: macos - build: '["macos"]' + # build-windows: + # name: Build Windows + # uses: ./.github/workflows/build-native.yml + # with: + # runner: windows-latest + # binary: windows + # build: '["windows"]' + + # build-macos: + # name: Build MacOS + # uses: ./.github/workflows/build-native.yml + # with: + # runner: macos-latest + # binary: macos + # build: '["macos"]' build-linux: name: Build Linux @@ -259,134 +259,134 @@ jobs: binary: linux build: '["linux"]' - build-android: - name: Build Android - uses: ./.github/workflows/build-native.yml - with: - runner: ubuntu-20.04 - binary: android - build: '["android-x86", "android-x86_64", "android-armeabi-v7a", "android-arm64-v8a"]' - - build-ios: - name: Build IOS - uses: ./.github/workflows/build-native.yml - with: - runner: macos-latest - binary: ios - build: '["ios-device", "ios-simulator", "ios-catalyst"]' - - build-android-combined: - name: Android binaries combine - needs: build-android - uses: ./.github/workflows/binary-combine-android.yml - - build-ios-xcframework: - name: IOS binaries combine - needs: build-ios - uses: ./.github/workflows/binary-combine-ios.yml + # build-android: + # name: Build Android + # uses: ./.github/workflows/build-native.yml + # with: + # runner: ubuntu-20.04 + # binary: android + # build: '["android-x86", "android-x86_64", "android-armeabi-v7a", "android-arm64-v8a"]' + + # build-ios: + # name: Build IOS + # uses: ./.github/workflows/build-native.yml + # with: + # runner: macos-latest + # binary: ios + # build: '["ios-device", "ios-simulator", "ios-catalyst"]' + + # build-android-combined: + # name: Android binaries combine + # needs: build-android + # uses: ./.github/workflows/binary-combine-android.yml + + # build-ios-xcframework: + # name: IOS binaries combine + # needs: build-ios + # uses: ./.github/workflows/binary-combine-ios.yml # Dart jobs - dart-tests-windows: - name: Windows Dart Tests - uses: ./.github/workflows/dart-desktop-tests.yml - needs: - - build-windows - - deploy-dart-cluster - - create-dart-shared-apps - secrets: inherit - with: - os: windows - runner: windows-latest - app: dw - cluster: ${{ needs.deploy-dart-cluster.outputs.clusterName }} - - dart-tests-macos: - name: MacOS Dart Tests - uses: ./.github/workflows/dart-desktop-tests.yml - needs: - - build-macos - - deploy-dart-cluster - - create-dart-shared-apps - secrets: inherit - with: - os: macos - runner: macos-latest - app: dm - cluster: ${{ needs.deploy-dart-cluster.outputs.clusterName }} - - dart-tests-macos-arm: - name: MacOS Arm Dart Tests - uses: ./.github/workflows/dart-desktop-tests.yml - needs: - - build-macos - - deploy-dart-cluster - - create-dart-shared-apps - secrets: inherit - with: - os: macos - runner: macos-arm - architecture: arm - app: dma - cluster: ${{ needs.deploy-dart-cluster.outputs.clusterName }} - - dart-tests-linux: - name: Linux Dart Tests - uses: ./.github/workflows/dart-desktop-tests.yml - needs: - - build-linux - - deploy-dart-cluster - - create-dart-shared-apps - secrets: inherit - with: - os: linux - runner: ubuntu-latest - app: dl - cluster: ${{ needs.deploy-dart-cluster.outputs.clusterName }} - - dart-tests-linux-ubuntu-20: - name: Linux Dart Tests (ubuntu 20) - uses: ./.github/workflows/dart-desktop-tests.yml - needs: - - build-linux - - deploy-dart-cluster - - create-dart-shared-apps - secrets: inherit - with: - os: linux - runner: ubuntu-20.04 - app: dl2 - cluster: ${{ needs.deploy-dart-cluster.outputs.clusterName }} + # dart-tests-windows: + # name: Windows Dart Tests + # uses: ./.github/workflows/dart-desktop-tests.yml + # needs: + # - build-windows + # - deploy-dart-cluster + # - create-dart-shared-apps + # secrets: inherit + # with: + # os: windows + # runner: windows-latest + # app: dw + # cluster: ${{ needs.deploy-dart-cluster.outputs.clusterName }} + + # dart-tests-macos: + # name: MacOS Dart Tests + # uses: ./.github/workflows/dart-desktop-tests.yml + # needs: + # - build-macos + # - deploy-dart-cluster + # - create-dart-shared-apps + # secrets: inherit + # with: + # os: macos + # runner: macos-latest + # app: dm + # cluster: ${{ needs.deploy-dart-cluster.outputs.clusterName }} + + # dart-tests-macos-arm: + # name: MacOS Arm Dart Tests + # uses: ./.github/workflows/dart-desktop-tests.yml + # needs: + # - build-macos + # - deploy-dart-cluster + # - create-dart-shared-apps + # secrets: inherit + # with: + # os: macos + # runner: macos-arm + # architecture: arm + # app: dma + # cluster: ${{ needs.deploy-dart-cluster.outputs.clusterName }} + + # dart-tests-linux: + # name: Linux Dart Tests + # uses: ./.github/workflows/dart-desktop-tests.yml + # needs: + # - build-linux + # - deploy-dart-cluster + # - create-dart-shared-apps + # secrets: inherit + # with: + # os: linux + # runner: ubuntu-latest + # app: dl + # cluster: ${{ needs.deploy-dart-cluster.outputs.clusterName }} + + # dart-tests-linux-ubuntu-20: + # name: Linux Dart Tests (ubuntu 20) + # uses: ./.github/workflows/dart-desktop-tests.yml + # needs: + # - build-linux + # - deploy-dart-cluster + # - create-dart-shared-apps + # secrets: inherit + # with: + # os: linux + # runner: ubuntu-20.04 + # app: dl2 + # cluster: ${{ needs.deploy-dart-cluster.outputs.clusterName }} # Flutter jobs - flutter-desktop-tests-windows: - name: Windows Flutter Tests - uses: ./.github/workflows/flutter-desktop-tests.yml - needs: - - build-windows - - deploy-flutter-cluster - - create-flutter-shared-apps - secrets: inherit - with: - os: windows - runner: windows-latest - app: fw - cluster: ${{ needs.deploy-flutter-cluster.outputs.clusterName }} - - flutter-desktop-tests-macos: - name: MacOS Flutter Tests - uses: ./.github/workflows/flutter-desktop-tests.yml - needs: - - build-macos - - deploy-flutter-cluster - - create-flutter-shared-apps - secrets: inherit - with: - os: macos - runner: macos-13 # workaround to: https://github.com/flutter/flutter/issues/118469 latest is still macos-12 ¯\_(ツ)_/¯ - app: fm - cluster: ${{ needs.deploy-flutter-cluster.outputs.clusterName }} + # flutter-desktop-tests-windows: + # name: Windows Flutter Tests + # uses: ./.github/workflows/flutter-desktop-tests.yml + # needs: + # - build-windows + # - deploy-flutter-cluster + # - create-flutter-shared-apps + # secrets: inherit + # with: + # os: windows + # runner: windows-latest + # app: fw + # cluster: ${{ needs.deploy-flutter-cluster.outputs.clusterName }} + + # flutter-desktop-tests-macos: + # name: MacOS Flutter Tests + # uses: ./.github/workflows/flutter-desktop-tests.yml + # needs: + # - build-macos + # - deploy-flutter-cluster + # - create-flutter-shared-apps + # secrets: inherit + # with: + # os: macos + # runner: macos-13 # workaround to: https://github.com/flutter/flutter/issues/118469 latest is still macos-12 ¯\_(ツ)_/¯ + # app: fm + # cluster: ${{ needs.deploy-flutter-cluster.outputs.clusterName }} flutter-desktop-tests-linux: name: Linux Flutter Tests @@ -416,281 +416,281 @@ jobs: app: fl2 cluster: ${{ needs.deploy-flutter-cluster.outputs.clusterName }} - flutter-ios: - runs-on: macos-latest - name: IOS Flutter Tests - timeout-minutes: 45 - needs: - - deploy-flutter-cluster - - build-ios-xcframework - - create-flutter-shared-apps - env: - BAAS_CLUSTER: ${{ needs.deploy-flutter-cluster.outputs.clusterName }} - BAAS_DIFFERENTIATOR: fi${{ github.run_id }}${{ github.run_attempt }} - - steps: - - - name: Checkout - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 - with: - submodules: 'recursive' - - - name: Enable ccache - run: echo "PATH=/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" >> $GITHUB_ENV - - - name: Fetch artifacts - uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7 - with: - name: librealm-ios - path: binary/ios - - - name: Setup Flutter - uses: subosito/flutter-action@v2 - with: - channel: 'stable' - - - name: Install dependencies - run: dart pub get - - - name: Launch Simulator - uses: futureware-tech/simulator-action@v2 - with: - model: 'iPhone 8' - os: 'iOS' - os_version: '>= 14.0' - - # This will be a no-op under normal circumstances since the cluster would have been deployed - # in deploy-cluster. It is needed in case we want to re-run the job after the cluster has been reaped. - - name: Create cluster - uses: realm/ci-actions/mdb-realm/deploy@338bf3e7575015a28faec8b67614385d122aece7 - with: - realmUrl: ${{ env.BAAS_URL }} - atlasUrl: ${{ secrets.ATLAS_QA_URL }} - projectId: ${{ env.BAAS_PROJECT_ID }} - apiKey: ${{ env.BAAS_API_KEY }} - privateApiKey: ${{ env.BAAS_PRIVATE_API_KEY }} - clusterName: ${{ env.BAAS_CLUSTER }} - - - name: Run tests on iOS Simulator - run: | - flutter drive --target=test_driver/app.dart --dart-define=testName="" --suppress-analytics --debug - working-directory: ./flutter/realm_flutter/tests - - flutter-android: - runs-on: macos-latest - name: Android Flutter Tests - timeout-minutes: 45 - needs: - - deploy-flutter-cluster - - build-android-combined - - create-flutter-shared-apps - env: - BAAS_CLUSTER: ${{ needs.deploy-flutter-cluster.outputs.clusterName }} - BAAS_DIFFERENTIATOR: fa${{ github.run_id }}${{ github.run_attempt }} - steps: - - - name: Checkout - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 - with: - submodules: 'recursive' - - - name: Set up Java - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: 11 - - - name: Fetch artifacts - uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7 - with: - name: librealm-android - path: binary/android - - - name: Setup Flutter - uses: subosito/flutter-action@v2 - with: - channel: 'stable' - - - name: Install dependencies - run: dart pub get - - # TODO: Move CI run tests on Android Emulator into device farm https://github.com/realm/realm-dart/issues/691 - - name: Setup Android Emulator cache - uses: actions/cache@v3 - id: avd-cache - with: - path: | - ~/.android/avd/* - ~/.android/adb* - key: avd-29 - - - name: Create Android Emulator and generate snapshot for caching - if: ${{ steps.avd-cache.outputs.cache-hit != 'true' }} - uses: reactivecircus/android-emulator-runner@v2 - with: - api-level: 29 - force-avd-creation: false - emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none - disable-animations: true - arch: x86 - ndk: 21.0.6113669 - cmake: 3.10.2.4988404 - script: echo "Generated Emulator snapshot for caching." - - # This will be a no-op under normal circumstances since the cluster would have been deployed - # in deploy-cluster. It is needed in case we want to re-run the job after the cluster has been reaped. - - name: Create cluster - uses: realm/ci-actions/mdb-realm/deploy@338bf3e7575015a28faec8b67614385d122aece7 - with: - realmUrl: ${{ env.BAAS_URL }} - atlasUrl: ${{ secrets.ATLAS_QA_URL }} - projectId: ${{ env.BAAS_PROJECT_ID }} - apiKey: ${{ env.BAAS_API_KEY }} - privateApiKey: ${{ env.BAAS_PRIVATE_API_KEY }} - clusterName: ${{ env.BAAS_CLUSTER }} - - - name: Run tests on Android Emulator - uses: reactivecircus/android-emulator-runner@v2 - with: - force-avd-creation: false - disable-animations: true - emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none - api-level: 29 - ndk: 21.0.6113669 - arch: x86 - cmake: 3.10.2.4988404 - script: flutter build apk --debug --target=test_driver/app.dart && flutter install --debug && flutter drive --target=test_driver/app.dart --dart-define=testName="" --suppress-analytics --debug - working-directory: ./flutter/realm_flutter/tests + # flutter-ios: + # runs-on: macos-latest + # name: IOS Flutter Tests + # timeout-minutes: 45 + # needs: + # - deploy-flutter-cluster + # - build-ios-xcframework + # - create-flutter-shared-apps + # env: + # BAAS_CLUSTER: ${{ needs.deploy-flutter-cluster.outputs.clusterName }} + # BAAS_DIFFERENTIATOR: fi${{ github.run_id }}${{ github.run_attempt }} + + # steps: + + # - name: Checkout + # uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + # with: + # submodules: 'recursive' + + # - name: Enable ccache + # run: echo "PATH=/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" >> $GITHUB_ENV + + # - name: Fetch artifacts + # uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7 + # with: + # name: librealm-ios + # path: binary/ios + + # - name: Setup Flutter + # uses: subosito/flutter-action@v2 + # with: + # channel: 'stable' + + # - name: Install dependencies + # run: dart pub get + + # - name: Launch Simulator + # uses: futureware-tech/simulator-action@v2 + # with: + # model: 'iPhone 8' + # os: 'iOS' + # os_version: '>= 14.0' + + # # This will be a no-op under normal circumstances since the cluster would have been deployed + # # in deploy-cluster. It is needed in case we want to re-run the job after the cluster has been reaped. + # - name: Create cluster + # uses: realm/ci-actions/mdb-realm/deploy@338bf3e7575015a28faec8b67614385d122aece7 + # with: + # realmUrl: ${{ env.BAAS_URL }} + # atlasUrl: ${{ secrets.ATLAS_QA_URL }} + # projectId: ${{ env.BAAS_PROJECT_ID }} + # apiKey: ${{ env.BAAS_API_KEY }} + # privateApiKey: ${{ env.BAAS_PRIVATE_API_KEY }} + # clusterName: ${{ env.BAAS_CLUSTER }} + + # - name: Run tests on iOS Simulator + # run: | + # flutter drive --target=test_driver/app.dart --dart-define=testName="" --suppress-analytics --debug + # working-directory: ./flutter/realm_flutter/tests + + # flutter-android: + # runs-on: macos-latest + # name: Android Flutter Tests + # timeout-minutes: 45 + # needs: + # - deploy-flutter-cluster + # - build-android-combined + # - create-flutter-shared-apps + # env: + # BAAS_CLUSTER: ${{ needs.deploy-flutter-cluster.outputs.clusterName }} + # BAAS_DIFFERENTIATOR: fa${{ github.run_id }}${{ github.run_attempt }} + # steps: + + # - name: Checkout + # uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + # with: + # submodules: 'recursive' + + # - name: Set up Java + # uses: actions/setup-java@v3 + # with: + # distribution: 'temurin' + # java-version: 11 + + # - name: Fetch artifacts + # uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7 + # with: + # name: librealm-android + # path: binary/android + + # - name: Setup Flutter + # uses: subosito/flutter-action@v2 + # with: + # channel: 'stable' + + # - name: Install dependencies + # run: dart pub get + + # # TODO: Move CI run tests on Android Emulator into device farm https://github.com/realm/realm-dart/issues/691 + # - name: Setup Android Emulator cache + # uses: actions/cache@v3 + # id: avd-cache + # with: + # path: | + # ~/.android/avd/* + # ~/.android/adb* + # key: avd-29 + + # - name: Create Android Emulator and generate snapshot for caching + # if: ${{ steps.avd-cache.outputs.cache-hit != 'true' }} + # uses: reactivecircus/android-emulator-runner@v2 + # with: + # api-level: 29 + # force-avd-creation: false + # emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none + # disable-animations: true + # arch: x86 + # ndk: 21.0.6113669 + # cmake: 3.10.2.4988404 + # script: echo "Generated Emulator snapshot for caching." + + # # This will be a no-op under normal circumstances since the cluster would have been deployed + # # in deploy-cluster. It is needed in case we want to re-run the job after the cluster has been reaped. + # - name: Create cluster + # uses: realm/ci-actions/mdb-realm/deploy@338bf3e7575015a28faec8b67614385d122aece7 + # with: + # realmUrl: ${{ env.BAAS_URL }} + # atlasUrl: ${{ secrets.ATLAS_QA_URL }} + # projectId: ${{ env.BAAS_PROJECT_ID }} + # apiKey: ${{ env.BAAS_API_KEY }} + # privateApiKey: ${{ env.BAAS_PRIVATE_API_KEY }} + # clusterName: ${{ env.BAAS_CLUSTER }} + + # - name: Run tests on Android Emulator + # uses: reactivecircus/android-emulator-runner@v2 + # with: + # force-avd-creation: false + # disable-animations: true + # emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none + # api-level: 29 + # ndk: 21.0.6113669 + # arch: x86 + # cmake: 3.10.2.4988404 + # script: flutter build apk --debug --target=test_driver/app.dart && flutter install --debug && flutter drive --target=test_driver/app.dart --dart-define=testName="" --suppress-analytics --debug + # working-directory: ./flutter/realm_flutter/tests # Generator jobs - generator: - strategy: - fail-fast: false - matrix: - os: [ubuntu, macos, windows] - - runs-on: ${{ matrix.os }}-latest - name: Generator Tests - timeout-minutes: 30 - steps: - - name: Checkout - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 - with: - submodules: 'recursive' - - - name: Setup Flutter - uses: subosito/flutter-action@v2 - with: - channel: 'stable' - - - name: Delete generated files - run: find . -name "*.g.dart" -not -path "./generator/*" -delete - shell: bash - - - name: Run generator in realm-dart repo - run: | - dart pub get - dart run build_runner build --delete-conflicting-outputs - - - name: Run generator in realm-dart/example - run: | - dart pub get - dart run build_runner build --delete-conflicting-outputs - working-directory: ./example/ - - - name: Run generator in realm_flutter/example - run: | - dart pub get - dart run build_runner build --delete-conflicting-outputs - working-directory: ./flutter/realm_flutter/example/ - - - name: Install LLVM - run: sudo apt update && sudo apt-get install -y libclang-dev - if: ${{ matrix.os == 'ubuntu' }} - - - name: Run ffigen - run: dart run ffigen --config config.yaml - working-directory: ./ffigen - - - name: Validate there are no uncommitted changes - run: | - changedFiles=$(git --no-pager diff -w) - if [ "$changedFiles" ]; then - git --no-pager diff -w - exit 1 - fi - shell: bash - - - name: Run generator tests - run: | - dart pub get - dart test -r expanded --coverage ./coverage/ --test-randomize-ordering-seed random - working-directory: ./generator/ - - - name: Generate generator coverage report - if: matrix.os == 'ubuntu' - run: | - dart run coverage:format_coverage \ - --in coverage/ \ - --out ./coverage/lcov.info \ - --check-ignore \ - --lcov \ - --packages .dart_tool/package_config.json \ - --report-on lib - working-directory: ./generator/ - - - name: Publish Generator Coverage - if: matrix.os == 'ubuntu' - id: publish-coverage - uses: coverallsapp/github-action@f350da2c033043742f89e8c0b7b5145a1616da6d - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - flag-name: generator - path-to-lcov: ./generator/coverage/lcov.info - parallel: true - - - name: Output Coveralls response - if: matrix.os == 'ubuntu' - run: echo ${{ steps.publish-coverage.outputs.coveralls-api-result }} - - coverage-finished: - needs: - - generator - - dart-tests-linux - runs-on: ubuntu-latest - steps: - - - name: Coveralls Finished - id: publish-coverage - uses: coverallsapp/github-action@f350da2c033043742f89e8c0b7b5145a1616da6d - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - parallel-finished: true - - - name: Output Coveralls response - run: echo ${{ steps.publish-coverage.outputs.coveralls-api-result }} - - slack-on-failure: - name: Report failure in main branch - needs: - - cleanup-dart-matrix - - cleanup-flutter-matrix - runs-on: ubuntu-latest - if: always() - steps: - # Run this action to set env.WORKFLOW_CONCLUSION - - uses: technote-space/workflow-conclusion-action@45ce8e0eb155657ab8ccf346ade734257fd196a5 - - - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - if: ${{ github.ref == 'refs/heads/main' && env.WORKFLOW_CONCLUSION == 'FAILURE' }} - # Statuses: neutral, success, skipped, cancelled, timed_out, action_required, failure - with: - status: ${{ env.WORKFLOW_CONCLUSION }} - webhook-url: ${{ secrets.SLACK_DART_WEBHOOK }} - channel: '#realm-github-dart' - message: | - ** - <{{refUrl}}|`{{ref}}` - {{description}}> - {{#if description}}<{{diffUrl}}|branch: `{{diffRef}}`>{{/if}} + # generator: + # strategy: + # fail-fast: false + # matrix: + # os: [ubuntu, macos, windows] + + # runs-on: ${{ matrix.os }}-latest + # name: Generator Tests + # timeout-minutes: 30 + # steps: + # - name: Checkout + # uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + # with: + # submodules: 'recursive' + + # - name: Setup Flutter + # uses: subosito/flutter-action@v2 + # with: + # channel: 'stable' + + # - name: Delete generated files + # run: find . -name "*.g.dart" -not -path "./generator/*" -delete + # shell: bash + + # - name: Run generator in realm-dart repo + # run: | + # dart pub get + # dart run build_runner build --delete-conflicting-outputs + + # - name: Run generator in realm-dart/example + # run: | + # dart pub get + # dart run build_runner build --delete-conflicting-outputs + # working-directory: ./example/ + + # - name: Run generator in realm_flutter/example + # run: | + # dart pub get + # dart run build_runner build --delete-conflicting-outputs + # working-directory: ./flutter/realm_flutter/example/ + + # - name: Install LLVM + # run: sudo apt update && sudo apt-get install -y libclang-dev + # if: ${{ matrix.os == 'ubuntu' }} + + # - name: Run ffigen + # run: dart run ffigen --config config.yaml + # working-directory: ./ffigen + + # - name: Validate there are no uncommitted changes + # run: | + # changedFiles=$(git --no-pager diff -w) + # if [ "$changedFiles" ]; then + # git --no-pager diff -w + # exit 1 + # fi + # shell: bash + + # - name: Run generator tests + # run: | + # dart pub get + # dart test -r expanded --coverage ./coverage/ --test-randomize-ordering-seed random + # working-directory: ./generator/ + + # - name: Generate generator coverage report + # if: matrix.os == 'ubuntu' + # run: | + # dart run coverage:format_coverage \ + # --in coverage/ \ + # --out ./coverage/lcov.info \ + # --check-ignore \ + # --lcov \ + # --packages .dart_tool/package_config.json \ + # --report-on lib + # working-directory: ./generator/ + + # - name: Publish Generator Coverage + # if: matrix.os == 'ubuntu' + # id: publish-coverage + # uses: coverallsapp/github-action@f350da2c033043742f89e8c0b7b5145a1616da6d + # with: + # github-token: ${{ secrets.GITHUB_TOKEN }} + # flag-name: generator + # path-to-lcov: ./generator/coverage/lcov.info + # parallel: true + + # - name: Output Coveralls response + # if: matrix.os == 'ubuntu' + # run: echo ${{ steps.publish-coverage.outputs.coveralls-api-result }} + + # coverage-finished: + # needs: + # - generator + # - dart-tests-linux + # runs-on: ubuntu-latest + # steps: + + # - name: Coveralls Finished + # id: publish-coverage + # uses: coverallsapp/github-action@f350da2c033043742f89e8c0b7b5145a1616da6d + # with: + # github-token: ${{ secrets.GITHUB_TOKEN }} + # parallel-finished: true + + # - name: Output Coveralls response + # run: echo ${{ steps.publish-coverage.outputs.coveralls-api-result }} + + # slack-on-failure: + # name: Report failure in main branch + # needs: + # - cleanup-dart-matrix + # - cleanup-flutter-matrix + # runs-on: ubuntu-latest + # if: always() + # steps: + # # Run this action to set env.WORKFLOW_CONCLUSION + # - uses: technote-space/workflow-conclusion-action@45ce8e0eb155657ab8ccf346ade734257fd196a5 + + # - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f + # if: ${{ github.ref == 'refs/heads/main' && env.WORKFLOW_CONCLUSION == 'FAILURE' }} + # # Statuses: neutral, success, skipped, cancelled, timed_out, action_required, failure + # with: + # status: ${{ env.WORKFLOW_CONCLUSION }} + # webhook-url: ${{ secrets.SLACK_DART_WEBHOOK }} + # channel: '#realm-github-dart' + # message: | + # ** + # <{{refUrl}}|`{{ref}}` - {{description}}> + # {{#if description}}<{{diffUrl}}|branch: `{{diffRef}}`>{{/if}} \ No newline at end of file From 3b71a4872fc35c1108bbcb701421e5be0858f92a Mon Sep 17 00:00:00 2001 From: blagoev Date: Fri, 11 Aug 2023 11:37:59 +0300 Subject: [PATCH 15/50] filter tests --- test/realm_test.dart | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/test/realm_test.dart b/test/realm_test.dart index 09c17a3cc..a9e217fcb 100644 --- a/test/realm_test.dart +++ b/test/realm_test.dart @@ -1227,7 +1227,7 @@ Future main([List? args]) async { expect(realm.isInTransaction, true); }); - baasTest('Realm.open (flexibleSync)', (appConfiguration) async { + baasTest('Realm._open (flexibleSync)', (appConfiguration) async { final app = App(appConfiguration); final credentials = Credentials.anonymous(); final user = await app.logIn(credentials); @@ -1237,20 +1237,20 @@ Future main([List? args]) async { expect(realm.isClosed, false); }); - test('Realm.open (local)', () async { + test('Realm._open (local)', () async { final configuration = Configuration.local([Car.schema]); final realm = await getRealmAsync(configuration); expect(realm.isClosed, false); }); - test('Realm.open (local) - cancel before open', () async { + test('Realm._open (local) - cancel before open', () async { final configuration = Configuration.local([Car.schema]); final cancellationToken = CancellationToken(); cancellationToken.cancel(); await expectLater(getRealmAsync(configuration, cancellationToken: cancellationToken), throwsA(isA())); }); - baasTest('Realm.open (flexibleSync) - cancel before open', (appConfiguration) async { + baasTest('Realm._open (flexibleSync) - cancel before open', (appConfiguration) async { final app = App(appConfiguration); final credentials = Credentials.anonymous(); final user = await app.logIn(credentials); @@ -1261,7 +1261,7 @@ Future main([List? args]) async { await expectLater(getRealmAsync(configuration, cancellationToken: cancellationToken), throwsA(isA())); }); - baasTest('Realm.open (flexibleSync) - cancel right after open', (appConfiguration) async { + baasTest('Realm._open (flexibleSync) - cancel right after open', (appConfiguration) async { final app = App(appConfiguration); final credentials = Credentials.anonymous(); final user = await app.logIn(credentials); @@ -1288,7 +1288,7 @@ Future main([List? args]) async { expect(await isRealm2Cancelled, isTrue); }); - baasTest('Realm.open (flexibleSync) - open the same realm twice and only cancel the first call', (appConfiguration) async { + baasTest('Realm._open (flexibleSync) - open the same realm twice and only cancel the first call', (appConfiguration) async { final app = App(appConfiguration); final credentials = Credentials.anonymous(); final user = await app.logIn(credentials); @@ -1304,7 +1304,7 @@ Future main([List? args]) async { expect(await isRealm2Cancelled, isFalse); }); - baasTest('Realm.open (flexibleSync) - open two different Realms for two different users and cancel only the second call', (appConfiguration) async { + baasTest('Realm._open (flexibleSync) - open two different Realms for two different users and cancel only the second call', (appConfiguration) async { final app = App(appConfiguration); final user1 = await app.logIn(Credentials.anonymous()); @@ -1322,7 +1322,7 @@ Future main([List? args]) async { expect(await isRealm1Cancelled, isFalse); }); - baasTest('Realm.open (flexibleSync) - cancel after realm is returned is no-op', (appConfiguration) async { + baasTest('Realm._open (flexibleSync) - cancel after realm is returned is no-op', (appConfiguration) async { final app = App(appConfiguration); final credentials = Credentials.anonymous(); final user = await app.logIn(credentials); @@ -1338,7 +1338,7 @@ Future main([List? args]) async { expect(realm.isClosed, false); }); - baasTest('Realm.open (flexibleSync) - listen for download progress on an empty realm', (appConfiguration) async { + baasTest('Realm._open (flexibleSync) - listen for download progress on an empty realm', (appConfiguration) async { final app = App(appConfiguration); final credentials = Credentials.anonymous(); final user = await app.logIn(credentials); @@ -1357,7 +1357,7 @@ Future main([List? args]) async { expect(transferredBytes, greaterThan(-1)); }); - baasTest('Realm.open (flexibleSync) - download a populated realm', (appConfiguration) async { + baasTest('Realm._open (flexibleSync) - download a populated realm', (appConfiguration) async { final app = App(appConfiguration); final queryDifferentiator = generateRandomString(10); const itemsCount = 200; @@ -1368,7 +1368,7 @@ Future main([List? args]) async { expect(data.length, itemsCount); }); - baasTest('Realm.open (flexibleSync) - listen for download progress of a populated realm', (appConfiguration) async { + baasTest('Realm._open (flexibleSync) - listen for download progress of a populated realm', (appConfiguration) async { final app = App(appConfiguration); final config = await _subscribeForAtlasAddedData(app); @@ -1385,7 +1385,7 @@ Future main([List? args]) async { expect(transferredBytes, greaterThan(19)); //19 bytes is the empty realm }); - baasTest('Realm.open (flexibleSync) - listen and cancel download progress of a populated realm', (appConfiguration) async { + baasTest('Realm._open (flexibleSync) - listen and cancel download progress of a populated realm', (appConfiguration) async { final app = App(appConfiguration); final config = await _subscribeForAtlasAddedData(app); From 8246a111b2cda079d23fc73456a14ae394bad9e1 Mon Sep 17 00:00:00 2001 From: blagoev Date: Fri, 11 Aug 2023 11:40:00 +0300 Subject: [PATCH 16/50] only linux --- .github/workflows/ci.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8b17287c7..121b075fa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -81,12 +81,12 @@ jobs: continue-on-error: true needs: - deploy-flutter-cluster - - flutter-desktop-tests-windows - - flutter-desktop-tests-macos + # - flutter-desktop-tests-windows + # - flutter-desktop-tests-macos - flutter-desktop-tests-linux - flutter-desktop-tests-linux-ubuntu-20 - - flutter-ios - - flutter-android + # - flutter-ios + # - flutter-android steps: - uses: realm/ci-actions/mdb-realm/cleanup@338bf3e7575015a28faec8b67614385d122aece7 with: @@ -119,12 +119,12 @@ jobs: secrets: inherit needs: - deploy-flutter-cluster - - flutter-desktop-tests-windows - - flutter-desktop-tests-macos + # - flutter-desktop-tests-windows + # - flutter-desktop-tests-macos - flutter-desktop-tests-linux - flutter-desktop-tests-linux-ubuntu-20 - - flutter-ios - - flutter-android + # - flutter-ios + # - flutter-android uses: ./.github/workflows/shared-apps.yml if: always() with: @@ -185,12 +185,12 @@ jobs: cleanup-flutter-matrix: needs: - deploy-flutter-cluster - - flutter-desktop-tests-windows - - flutter-desktop-tests-macos + # - flutter-desktop-tests-windows + # - flutter-desktop-tests-macos - flutter-desktop-tests-linux - flutter-desktop-tests-linux-ubuntu-20 - - flutter-ios - - flutter-android + # - flutter-ios + # - flutter-android strategy: fail-fast: false matrix: From c009104f90fb68d6976d141acc6b57984e85e931 Mon Sep 17 00:00:00 2001 From: blagoev Date: Fri, 11 Aug 2023 11:44:11 +0300 Subject: [PATCH 17/50] 1 --- test/realm_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/realm_test.dart b/test/realm_test.dart index a9e217fcb..b087108d7 100644 --- a/test/realm_test.dart +++ b/test/realm_test.dart @@ -1261,7 +1261,7 @@ Future main([List? args]) async { await expectLater(getRealmAsync(configuration, cancellationToken: cancellationToken), throwsA(isA())); }); - baasTest('Realm._open (flexibleSync) - cancel right after open', (appConfiguration) async { + baasTest('Realm.open (flexibleSync) - cancel right after open', (appConfiguration) async { final app = App(appConfiguration); final credentials = Credentials.anonymous(); final user = await app.logIn(credentials); From abe4351d661d902a024cdb3481ebf119feb39b4e Mon Sep 17 00:00:00 2001 From: blagoev Date: Fri, 11 Aug 2023 11:46:48 +0300 Subject: [PATCH 18/50] only linux --- .github/workflows/ci.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 121b075fa..0d7d55056 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -195,18 +195,18 @@ jobs: fail-fast: false matrix: include: - - app: fm - description: flutter macos + # - app: fm + # description: flutter macos - app: fl description: flutter linux - app: fl2 description: flutter linux (ubuntu 20) - - app: fw - description: flutter windows - - app: fa - description: flutter android - - app: fi - description: flutter iOS + # - app: fw + # description: flutter windows + # - app: fa + # description: flutter android + # - app: fi + # description: flutter iOS runs-on: ubuntu-latest name: Cleanup apps for ${{ matrix.description }} timeout-minutes: 20 From 7a978987c6de1c409ca79d5246b9731f406db1af Mon Sep 17 00:00:00 2001 From: blagoev Date: Fri, 11 Aug 2023 11:52:18 +0300 Subject: [PATCH 19/50] 2 --- test/realm_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/realm_test.dart b/test/realm_test.dart index b087108d7..717161262 100644 --- a/test/realm_test.dart +++ b/test/realm_test.dart @@ -1273,7 +1273,7 @@ Future main([List? args]) async { expect(await isRealmCancelled, isTrue); }); - baasTest('Realm.open (flexibleSync) - open twice the same realm with the same CancelationToken cancels all', (appConfiguration) async { + baasTest('Realm._open (flexibleSync) - open twice the same realm with the same CancelationToken cancels all', (appConfiguration) async { final app = App(appConfiguration); final credentials = Credentials.anonymous(); final user = await app.logIn(credentials); From 6f23cd5fc7a2713c0a8edd46fdfcda9bdf5d9c2b Mon Sep 17 00:00:00 2001 From: blagoev Date: Fri, 11 Aug 2023 11:57:43 +0300 Subject: [PATCH 20/50] 3 --- test/realm_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/realm_test.dart b/test/realm_test.dart index 717161262..5fd74e440 100644 --- a/test/realm_test.dart +++ b/test/realm_test.dart @@ -1250,7 +1250,7 @@ Future main([List? args]) async { await expectLater(getRealmAsync(configuration, cancellationToken: cancellationToken), throwsA(isA())); }); - baasTest('Realm._open (flexibleSync) - cancel before open', (appConfiguration) async { + baasTest('Realm.open (flexibleSync) - cancel before open', (appConfiguration) async { final app = App(appConfiguration); final credentials = Credentials.anonymous(); final user = await app.logIn(credentials); From 53178adf0195702da16bfe2acb7eee9ea71c8fe6 Mon Sep 17 00:00:00 2001 From: blagoev Date: Fri, 11 Aug 2023 12:03:38 +0300 Subject: [PATCH 21/50] 3 --- test/realm_test.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/realm_test.dart b/test/realm_test.dart index 5fd74e440..7608ac06f 100644 --- a/test/realm_test.dart +++ b/test/realm_test.dart @@ -1250,7 +1250,7 @@ Future main([List? args]) async { await expectLater(getRealmAsync(configuration, cancellationToken: cancellationToken), throwsA(isA())); }); - baasTest('Realm.open (flexibleSync) - cancel before open', (appConfiguration) async { + baasTest('Realm._open (flexibleSync) - cancel before open', (appConfiguration) async { final app = App(appConfiguration); final credentials = Credentials.anonymous(); final user = await app.logIn(credentials); @@ -1288,7 +1288,7 @@ Future main([List? args]) async { expect(await isRealm2Cancelled, isTrue); }); - baasTest('Realm._open (flexibleSync) - open the same realm twice and only cancel the first call', (appConfiguration) async { + baasTest('Realm.open (flexibleSync) - open the same realm twice and only cancel the first call', (appConfiguration) async { final app = App(appConfiguration); final credentials = Credentials.anonymous(); final user = await app.logIn(credentials); From ae389bb15d9c4408276d4b4b6fd5bfad0d552eda Mon Sep 17 00:00:00 2001 From: blagoev Date: Fri, 11 Aug 2023 12:08:31 +0300 Subject: [PATCH 22/50] 4 --- test/realm_test.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/realm_test.dart b/test/realm_test.dart index 7608ac06f..402c95e78 100644 --- a/test/realm_test.dart +++ b/test/realm_test.dart @@ -1250,7 +1250,7 @@ Future main([List? args]) async { await expectLater(getRealmAsync(configuration, cancellationToken: cancellationToken), throwsA(isA())); }); - baasTest('Realm._open (flexibleSync) - cancel before open', (appConfiguration) async { + baasTest('Realm.open (flexibleSync) - cancel before open', (appConfiguration) async { final app = App(appConfiguration); final credentials = Credentials.anonymous(); final user = await app.logIn(credentials); @@ -1261,7 +1261,7 @@ Future main([List? args]) async { await expectLater(getRealmAsync(configuration, cancellationToken: cancellationToken), throwsA(isA())); }); - baasTest('Realm.open (flexibleSync) - cancel right after open', (appConfiguration) async { + baasTest('Realm._open (flexibleSync) - cancel right after open', (appConfiguration) async { final app = App(appConfiguration); final credentials = Credentials.anonymous(); final user = await app.logIn(credentials); @@ -1273,7 +1273,7 @@ Future main([List? args]) async { expect(await isRealmCancelled, isTrue); }); - baasTest('Realm._open (flexibleSync) - open twice the same realm with the same CancelationToken cancels all', (appConfiguration) async { + baasTest('Realm.open (flexibleSync) - open twice the same realm with the same CancelationToken cancels all', (appConfiguration) async { final app = App(appConfiguration); final credentials = Credentials.anonymous(); final user = await app.logIn(credentials); @@ -1288,7 +1288,7 @@ Future main([List? args]) async { expect(await isRealm2Cancelled, isTrue); }); - baasTest('Realm.open (flexibleSync) - open the same realm twice and only cancel the first call', (appConfiguration) async { + baasTest('Realm._open (flexibleSync) - open the same realm twice and only cancel the first call', (appConfiguration) async { final app = App(appConfiguration); final credentials = Credentials.anonymous(); final user = await app.logIn(credentials); From 1eef8b82aca1f91a801afba8312caf3367c28724 Mon Sep 17 00:00:00 2001 From: blagoev Date: Fri, 11 Aug 2023 12:12:54 +0300 Subject: [PATCH 23/50] 5 --- test/realm_test.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/realm_test.dart b/test/realm_test.dart index 402c95e78..e5223075b 100644 --- a/test/realm_test.dart +++ b/test/realm_test.dart @@ -1250,7 +1250,7 @@ Future main([List? args]) async { await expectLater(getRealmAsync(configuration, cancellationToken: cancellationToken), throwsA(isA())); }); - baasTest('Realm.open (flexibleSync) - cancel before open', (appConfiguration) async { + baasTest('Realm._open (flexibleSync) - cancel before open', (appConfiguration) async { final app = App(appConfiguration); final credentials = Credentials.anonymous(); final user = await app.logIn(credentials); @@ -1304,7 +1304,7 @@ Future main([List? args]) async { expect(await isRealm2Cancelled, isFalse); }); - baasTest('Realm._open (flexibleSync) - open two different Realms for two different users and cancel only the second call', (appConfiguration) async { + baasTest('Realm.open (flexibleSync) - open two different Realms for two different users and cancel only the second call', (appConfiguration) async { final app = App(appConfiguration); final user1 = await app.logIn(Credentials.anonymous()); From ab67fca89d12fc665c6f05acf596d3e592837d5d Mon Sep 17 00:00:00 2001 From: blagoev Date: Fri, 11 Aug 2023 12:19:24 +0300 Subject: [PATCH 24/50] 6 --- test/realm_test.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/realm_test.dart b/test/realm_test.dart index e5223075b..b087108d7 100644 --- a/test/realm_test.dart +++ b/test/realm_test.dart @@ -1261,7 +1261,7 @@ Future main([List? args]) async { await expectLater(getRealmAsync(configuration, cancellationToken: cancellationToken), throwsA(isA())); }); - baasTest('Realm._open (flexibleSync) - cancel right after open', (appConfiguration) async { + baasTest('Realm.open (flexibleSync) - cancel right after open', (appConfiguration) async { final app = App(appConfiguration); final credentials = Credentials.anonymous(); final user = await app.logIn(credentials); @@ -1304,7 +1304,7 @@ Future main([List? args]) async { expect(await isRealm2Cancelled, isFalse); }); - baasTest('Realm.open (flexibleSync) - open two different Realms for two different users and cancel only the second call', (appConfiguration) async { + baasTest('Realm._open (flexibleSync) - open two different Realms for two different users and cancel only the second call', (appConfiguration) async { final app = App(appConfiguration); final user1 = await app.logIn(Credentials.anonymous()); From d9e46a7114080247d57dcfc396f51541e8422183 Mon Sep 17 00:00:00 2001 From: blagoev Date: Fri, 11 Aug 2023 12:33:50 +0300 Subject: [PATCH 25/50] 1 --- lib/src/realm_class.dart | 2 +- test/realm_test.dart | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/src/realm_class.dart b/lib/src/realm_class.dart index 81bcfc6e5..d027e9063 100644 --- a/lib/src/realm_class.dart +++ b/lib/src/realm_class.dart @@ -202,7 +202,7 @@ class Realm implements Finalizable { } return Realm._(config, realmHandle); - }, cancellationToken, onCancel: () => realmCore.cancelOpenRealmAsync(asyncOpenHandle)).whenComplete(() => asyncOpenHandle.release()); + }, cancellationToken, onCancel: () => realmCore.cancelOpenRealmAsync(asyncOpenHandle)); } static RealmHandle _openRealm(Configuration config) { diff --git a/test/realm_test.dart b/test/realm_test.dart index b087108d7..e1d0a6e7d 100644 --- a/test/realm_test.dart +++ b/test/realm_test.dart @@ -1262,6 +1262,7 @@ Future main([List? args]) async { }); baasTest('Realm.open (flexibleSync) - cancel right after open', (appConfiguration) async { + print("test 1: started"); final app = App(appConfiguration); final credentials = Credentials.anonymous(); final user = await app.logIn(credentials); @@ -1271,9 +1272,11 @@ Future main([List? args]) async { final isRealmCancelled = getRealmAsync(configuration, cancellationToken: cancellationToken).isCancelled(); cancellationToken.cancel(); expect(await isRealmCancelled, isTrue); + print("test 1: finished"); }); baasTest('Realm.open (flexibleSync) - open twice the same realm with the same CancelationToken cancels all', (appConfiguration) async { + print("test 2: started"); final app = App(appConfiguration); final credentials = Credentials.anonymous(); final user = await app.logIn(credentials); @@ -1286,6 +1289,7 @@ Future main([List? args]) async { final isRealm2Cancelled = getRealmAsync(configuration, cancellationToken: cancellationToken).isCancelled(); expect(await isRealm1Cancelled, isTrue); expect(await isRealm2Cancelled, isTrue); + print("test 2: finished"); }); baasTest('Realm._open (flexibleSync) - open the same realm twice and only cancel the first call', (appConfiguration) async { From 249beac7a9e6a1de27166ea6f2209657033abcee Mon Sep 17 00:00:00 2001 From: blagoev Date: Fri, 11 Aug 2023 13:39:23 +0300 Subject: [PATCH 26/50] 7 --- lib/src/realm_class.dart | 8 +++++++- src/realm_dart.cpp | 1 + test/test.dart | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/src/realm_class.dart b/lib/src/realm_class.dart index d027e9063..4282baec9 100644 --- a/lib/src/realm_class.dart +++ b/lib/src/realm_class.dart @@ -182,6 +182,7 @@ class Realm implements Finalizable { _ensureDirectory(config); final asyncOpenHandle = realmCore.createRealmAsyncOpenTask(config); + print("asyncOpenHandle ptr: ${asyncOpenHandle.toString()}"); return CancellableFuture.from(() async { if (cancellationToken != null && cancellationToken.isCancelled) { throw cancellationToken.exception!; @@ -189,6 +190,7 @@ class Realm implements Finalizable { StreamSubscription? progressSubscription; if (onProgressCallback != null) { + print("attaching progress callback"); final progressController = RealmAsyncOpenProgressNotificationsController._(asyncOpenHandle); final progressStream = progressController.createStream(); progressSubscription = progressStream.listen(onProgressCallback); @@ -198,11 +200,15 @@ class Realm implements Finalizable { try { realmHandle = await realmCore.openRealmAsync(asyncOpenHandle, cancellationToken); } finally { + print("cancelling progress callback"); await progressSubscription?.cancel(); } return Realm._(config, realmHandle); - }, cancellationToken, onCancel: () => realmCore.cancelOpenRealmAsync(asyncOpenHandle)); + }, cancellationToken, onCancel: () { + print("onCancel callback. calling cancelOpenRealmAsync"); + realmCore.cancelOpenRealmAsync(asyncOpenHandle); + }); } static RealmHandle _openRealm(Configuration config) { diff --git a/src/realm_dart.cpp b/src/realm_dart.cpp index 0625cd92e..544cad9b4 100644 --- a/src/realm_dart.cpp +++ b/src/realm_dart.cpp @@ -126,6 +126,7 @@ RLM_API const char* realm_dart_library_version() { return "1.3.0"; } // } void handle_finalizer(void* isolate_callback_data, void* realmPtr) { + printf("releasing ptr %p", realmPtr); realm_release(realmPtr); } diff --git a/test/test.dart b/test/test.dart index bbe16b44f..73663b415 100644 --- a/test/test.dart +++ b/test/test.dart @@ -407,6 +407,7 @@ Future setupTests(List? args) async { while (_openRealms.isNotEmpty) { final realm = _openRealms.removeFirst(); paths.add(realm.config.path); + print("closing realm at path ${realm.config.path}"); realm.close(); } From 3bbb86a390132bee71ff5bcf15184595fda067c5 Mon Sep 17 00:00:00 2001 From: blagoev Date: Fri, 11 Aug 2023 16:58:50 +0300 Subject: [PATCH 27/50] 8 --- lib/src/realm_class.dart | 3 +++ test/test.dart | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/src/realm_class.dart b/lib/src/realm_class.dart index 4282baec9..6459f7a22 100644 --- a/lib/src/realm_class.dart +++ b/lib/src/realm_class.dart @@ -153,6 +153,7 @@ class Realm implements Finalizable { Realm(Configuration config) : this._(config); Realm._(this.config, [RealmHandle? handle, this._isInMigration = false]) : _handle = handle ?? _openRealm(config) { + print("Realm._: calling populateMetadata. Realm handle ${_handle.toString()}"); _populateMetadata(); } @@ -204,6 +205,7 @@ class Realm implements Finalizable { await progressSubscription?.cancel(); } + print("creating Realm instance with handle ${realmHandle.toString()}"); return Realm._(config, realmHandle); }, cancellationToken, onCancel: () { print("onCancel callback. calling cancelOpenRealmAsync"); @@ -212,6 +214,7 @@ class Realm implements Finalizable { } static RealmHandle _openRealm(Configuration config) { + print("_openRealm called"); _ensureDirectory(config); return realmCore.openRealm(config); } diff --git a/test/test.dart b/test/test.dart index 73663b415..1c4f01c1c 100644 --- a/test/test.dart +++ b/test/test.dart @@ -399,9 +399,11 @@ Future setupTests(List? args) async { Configuration.defaultRealmPath = path; addTearDown(() async { + print("Test teardown called"); final paths = HashSet(); paths.add(path); - + + print("tearddown: Clearing cached apps"); realmCore.clearCachedApps(); while (_openRealms.isNotEmpty) { From 986ce1cfed3ed59508bea746f20e80ea97858f32 Mon Sep 17 00:00:00 2001 From: blagoev Date: Fri, 11 Aug 2023 17:00:08 +0300 Subject: [PATCH 28/50] 9 --- lib/src/native/realm_core.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/src/native/realm_core.dart b/lib/src/native/realm_core.dart index ac085106a..563f6658e 100644 --- a/lib/src/native/realm_core.dart +++ b/lib/src/native/realm_core.dart @@ -652,7 +652,9 @@ class _RealmCore { } RealmHandle openRealm(Configuration config) { + print("realm_core: openRealm called. Creating config"); final configHandle = _createConfig(config); + print("realm_core: calling realm_open"); final realmPtr = _realmLib.invokeGetPointer(() => _realmLib.realm_open(configHandle._pointer), "Error opening realm at path ${config.path}"); return RealmHandle._(realmPtr); } From 64ddc2aef1229a7aaaec50986b1986ce53a3cbd3 Mon Sep 17 00:00:00 2001 From: blagoev Date: Fri, 11 Aug 2023 19:06:12 +0300 Subject: [PATCH 29/50] 10 --- lib/src/native/realm_core.dart | 2 ++ src/realm_dart.cpp | 1 + 2 files changed, 3 insertions(+) diff --git a/lib/src/native/realm_core.dart b/lib/src/native/realm_core.dart index 563f6658e..f48a9ec9d 100644 --- a/lib/src/native/realm_core.dart +++ b/lib/src/native/realm_core.dart @@ -671,6 +671,7 @@ class _RealmCore { final callback = Pointer.fromFunction realm, Pointer error)>(_openRealmAsyncCallback); final userData = _realmLib.realm_dart_userdata_async_new(completer, callback.cast(), scheduler.handle._pointer); + print("realm_dart_userdata_async_new userData ptr: ${userData.address.toString()}"); _realmLib.realm_async_open_task_start( handle._pointer, _realmLib.addresses.realm_dart_async_open_task_callback, @@ -683,6 +684,7 @@ class _RealmCore { static void _openRealmAsyncCallback(Object userData, Pointer realmSafePtr, Pointer error) { return using((Arena arena) { + print("_openRealmAsyncCallback called"); final completer = userData as Completer; if (error != nullptr) { diff --git a/src/realm_dart.cpp b/src/realm_dart.cpp index 544cad9b4..999581650 100644 --- a/src/realm_dart.cpp +++ b/src/realm_dart.cpp @@ -104,6 +104,7 @@ RLM_API realm_dart_userdata_async_t realm_dart_userdata_async_new(Dart_Handle ha } RLM_API void realm_dart_userdata_async_free(void* userdata) { + printf("realm_dart_userdata_async_free userdata ptr: %p", userdata); auto async_userdata = reinterpret_cast(userdata); async_userdata->scheduler->invoke([async_userdata]() { delete async_userdata; From 9647c2e0df6a7f0ae6c90071517869fcb412cea3 Mon Sep 17 00:00:00 2001 From: blagoev Date: Fri, 11 Aug 2023 19:18:49 +0300 Subject: [PATCH 30/50] 1 --- lib/src/native/realm_core.dart | 38 +++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/lib/src/native/realm_core.dart b/lib/src/native/realm_core.dart index f48a9ec9d..c752e6e9d 100644 --- a/lib/src/native/realm_core.dart +++ b/lib/src/native/realm_core.dart @@ -683,19 +683,30 @@ class _RealmCore { } static void _openRealmAsyncCallback(Object userData, Pointer realmSafePtr, Pointer error) { - return using((Arena arena) { - print("_openRealmAsyncCallback called"); - final completer = userData as Completer; - - if (error != nullptr) { - final err = arena(); - _realmLib.realm_get_async_error(error, err); - completer.completeError(RealmException("Failed to open realm ${err.ref.toLastError().toString()}")); - } + try { + return using((Arena arena) { + print("_openRealmAsyncCallback called"); + final completer = userData as Completer; + + if (error != nullptr) { + print("_openRealmAsyncCallback error detected"); + final err = arena(); + print("_openRealmAsyncCallback geting last async error"); + _realmLib.realm_get_async_error(error, err); + print("_openRealmAsyncCallback completing with error"); + completer.completeError(RealmException("Failed to open realm ${err.ref.toLastError().toString()}")); + } - final realmPtr = _realmLib.invokeGetPointer(() => _realmLib.realm_from_thread_safe_reference(realmSafePtr, scheduler.handle._pointer)); - completer.complete(RealmHandle._(realmPtr)); - }); + print("_openRealmAsyncCallback calling realm_from_thread_safe_reference"); + final realmPtr = _realmLib.invokeGetPointer(() => _realmLib.realm_from_thread_safe_reference(realmSafePtr, scheduler.handle._pointer)); + print("_openRealmAsyncCallback completing with a realm handle"); + completer.complete(RealmHandle._(realmPtr)); + }); + } on Exception catch (e) { + print("Error"); + print(e); + rethrow; + } } void cancelOpenRealmAsync(RealmAsyncOpenTaskHandle handle) { @@ -2897,8 +2908,7 @@ class RealmAsyncOpenTaskHandle extends HandleBase { } class RealmAsyncOpenTaskProgressNotificationTokenHandle extends HandleBase { - RealmAsyncOpenTaskProgressNotificationTokenHandle._(Pointer pointer) - : super(pointer, 40); + RealmAsyncOpenTaskProgressNotificationTokenHandle._(Pointer pointer) : super(pointer, 40); } class SubscriptionSetHandle extends RootedHandleBase { From 07b3289c8131044c65338a4d0f59562182c35986 Mon Sep 17 00:00:00 2001 From: blagoev Date: Fri, 11 Aug 2023 19:25:51 +0300 Subject: [PATCH 31/50] 12 --- lib/src/native/realm_core.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/native/realm_core.dart b/lib/src/native/realm_core.dart index c752e6e9d..f63ddcd10 100644 --- a/lib/src/native/realm_core.dart +++ b/lib/src/native/realm_core.dart @@ -693,7 +693,7 @@ class _RealmCore { final err = arena(); print("_openRealmAsyncCallback geting last async error"); _realmLib.realm_get_async_error(error, err); - print("_openRealmAsyncCallback completing with error"); + print("_openRealmAsyncCallback completing with error ${err.ref.toLastError().toString()}"); completer.completeError(RealmException("Failed to open realm ${err.ref.toLastError().toString()}")); } From 1c91f9a85c1812e826fb83d29f3c36415e04257a Mon Sep 17 00:00:00 2001 From: blagoev Date: Fri, 11 Aug 2023 19:35:07 +0300 Subject: [PATCH 32/50] 11 --- lib/src/native/realm_core.dart | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/src/native/realm_core.dart b/lib/src/native/realm_core.dart index f63ddcd10..26f6c05d3 100644 --- a/lib/src/native/realm_core.dart +++ b/lib/src/native/realm_core.dart @@ -690,10 +690,11 @@ class _RealmCore { if (error != nullptr) { print("_openRealmAsyncCallback error detected"); - final err = arena(); + final err = arena(); print("_openRealmAsyncCallback geting last async error"); _realmLib.realm_get_async_error(error, err); - print("_openRealmAsyncCallback completing with error ${err.ref.toLastError().toString()}"); + print("_openRealmAsyncCallback completing with error"); + print("error ${err.ref.toLastError().toString()}"); completer.completeError(RealmException("Failed to open realm ${err.ref.toLastError().toString()}")); } From 0db6613a66f60edf44f8db8f40ca24d2fd1520d6 Mon Sep 17 00:00:00 2001 From: blagoev Date: Fri, 11 Aug 2023 19:41:16 +0300 Subject: [PATCH 33/50] 124 --- lib/src/native/realm_core.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/src/native/realm_core.dart b/lib/src/native/realm_core.dart index 26f6c05d3..384ec4c6d 100644 --- a/lib/src/native/realm_core.dart +++ b/lib/src/native/realm_core.dart @@ -694,6 +694,9 @@ class _RealmCore { print("_openRealmAsyncCallback geting last async error"); _realmLib.realm_get_async_error(error, err); print("_openRealmAsyncCallback completing with error"); + if (err == nullptr) { + print("err is nullptr"); + } print("error ${err.ref.toLastError().toString()}"); completer.completeError(RealmException("Failed to open realm ${err.ref.toLastError().toString()}")); } From ba1f6fd715be5e5f6ef3c3dec765c03d8386ba20 Mon Sep 17 00:00:00 2001 From: blagoev Date: Fri, 11 Aug 2023 19:47:14 +0300 Subject: [PATCH 34/50] 1 --- lib/src/native/realm_core.dart | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/src/native/realm_core.dart b/lib/src/native/realm_core.dart index 384ec4c6d..92ea5d10e 100644 --- a/lib/src/native/realm_core.dart +++ b/lib/src/native/realm_core.dart @@ -3423,13 +3423,18 @@ class SyncErrorDetails { extension on realm_error { LastError toLastError() { + print("getting last error message"); final message = this.message.cast().toRealmDartString(); + print("getting usercode error"); Object? userError; if (usercode_error != nullptr) { + print("usercode error to object"); userError = usercode_error.toObject(isPersistent: true); + print("usercode error delete persistent handle"); _realmLib.realm_dart_delete_persistent_handle(usercode_error); } + print("usercode error creating last error"); return LastError(error, message, userError); } } From a6902fc59c31b05a3d0783f8386349a7bf4135ad Mon Sep 17 00:00:00 2001 From: blagoev Date: Fri, 11 Aug 2023 19:59:20 +0300 Subject: [PATCH 35/50] 12 + custom realm-core --- lib/src/native/realm_core.dart | 1 + src/realm-core | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/src/native/realm_core.dart b/lib/src/native/realm_core.dart index 92ea5d10e..edb198f9b 100644 --- a/lib/src/native/realm_core.dart +++ b/lib/src/native/realm_core.dart @@ -588,6 +588,7 @@ class _RealmCore { await callback(); } catch (error) { success = false; + print("_guardSynchronousCallback setting user code callback error"); _realmLib.realm_register_user_code_callback_error(error.toPersistentHandle()); } finally { _realmLib.realm_dart_invoke_unlock_callback(success, unlockCallbackFunc); diff --git a/src/realm-core b/src/realm-core index c04f5e401..2643323a0 160000 --- a/src/realm-core +++ b/src/realm-core @@ -1 +1 @@ -Subproject commit c04f5e401a1ec682e6b08b1ee157e19a0f834a5f +Subproject commit 2643323a0143b66338ba13d747aa2d2c27b98daf From 142747207699b16aeeddc26d8ec82afe94b7508c Mon Sep 17 00:00:00 2001 From: blagoev Date: Fri, 11 Aug 2023 20:45:08 +0300 Subject: [PATCH 36/50] 23 --- src/realm-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/realm-core b/src/realm-core index 2643323a0..a23014b23 160000 --- a/src/realm-core +++ b/src/realm-core @@ -1 +1 @@ -Subproject commit 2643323a0143b66338ba13d747aa2d2c27b98daf +Subproject commit a23014b23dc4b98f155d1770da1674459a47d3f6 From c00b503b61279e70189df0dd070c0e9fe79a52ed Mon Sep 17 00:00:00 2001 From: blagoev Date: Fri, 11 Aug 2023 21:02:33 +0300 Subject: [PATCH 37/50] 34564 --- src/realm-core | 2 +- src/realm_dart.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/realm-core b/src/realm-core index a23014b23..3dc310560 160000 --- a/src/realm-core +++ b/src/realm-core @@ -1 +1 @@ -Subproject commit a23014b23dc4b98f155d1770da1674459a47d3f6 +Subproject commit 3dc310560f14b3ab4162a00fb4e83b4ebf1fc34f diff --git a/src/realm_dart.cpp b/src/realm_dart.cpp index 999581650..1702f2ffc 100644 --- a/src/realm_dart.cpp +++ b/src/realm_dart.cpp @@ -104,7 +104,7 @@ RLM_API realm_dart_userdata_async_t realm_dart_userdata_async_new(Dart_Handle ha } RLM_API void realm_dart_userdata_async_free(void* userdata) { - printf("realm_dart_userdata_async_free userdata ptr: %p", userdata); + printf("realm_dart_userdata_async_free userdata ptr: %p\n", userdata); auto async_userdata = reinterpret_cast(userdata); async_userdata->scheduler->invoke([async_userdata]() { delete async_userdata; @@ -127,7 +127,7 @@ RLM_API const char* realm_dart_library_version() { return "1.3.0"; } // } void handle_finalizer(void* isolate_callback_data, void* realmPtr) { - printf("releasing ptr %p", realmPtr); + printf("releasing ptr %p\n", realmPtr); realm_release(realmPtr); } From 3738379f9aa7c7178d2767bec0ed5131e9e0a2f4 Mon Sep 17 00:00:00 2001 From: blagoev Date: Fri, 11 Aug 2023 21:25:44 +0300 Subject: [PATCH 38/50] fixed core --- src/realm-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/realm-core b/src/realm-core index 3dc310560..6f227cd96 160000 --- a/src/realm-core +++ b/src/realm-core @@ -1 +1 @@ -Subproject commit 3dc310560f14b3ab4162a00fb4e83b4ebf1fc34f +Subproject commit 6f227cd96c169d051e5fc03d5e1807dc11a8046e From 04d98c5a1a831beb7c408e28902381bd6dcd1ce7 Mon Sep 17 00:00:00 2001 From: blagoev Date: Fri, 11 Aug 2023 21:42:38 +0300 Subject: [PATCH 39/50] 345 --- src/realm-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/realm-core b/src/realm-core index 6f227cd96..351eec617 160000 --- a/src/realm-core +++ b/src/realm-core @@ -1 +1 @@ -Subproject commit 6f227cd96c169d051e5fc03d5e1807dc11a8046e +Subproject commit 351eec617db832b3aded2669d4b2d2363b2a3167 From b960065c96a42c8e24fd64193da6390cfb3a845c Mon Sep 17 00:00:00 2001 From: blagoev Date: Fri, 11 Aug 2023 22:17:23 +0300 Subject: [PATCH 40/50] 334344 --- src/realm-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/realm-core b/src/realm-core index 351eec617..01d288524 160000 --- a/src/realm-core +++ b/src/realm-core @@ -1 +1 @@ -Subproject commit 351eec617db832b3aded2669d4b2d2363b2a3167 +Subproject commit 01d288524bde4b21834c69b07e4281b906c23bde From 3a0360f516fdcbaf6e41c7c2db4037d7911a5bb8 Mon Sep 17 00:00:00 2001 From: blagoev Date: Fri, 11 Aug 2023 22:52:30 +0300 Subject: [PATCH 41/50] 23 --- lib/src/native/realm_core.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/native/realm_core.dart b/lib/src/native/realm_core.dart index edb198f9b..2cb18adc1 100644 --- a/lib/src/native/realm_core.dart +++ b/lib/src/native/realm_core.dart @@ -3428,7 +3428,7 @@ extension on realm_error { final message = this.message.cast().toRealmDartString(); print("getting usercode error"); Object? userError; - if (usercode_error != nullptr) { + if (error == realm_errno.RLM_ERR_CALLBACK && usercode_error != nullptr) { print("usercode error to object"); userError = usercode_error.toObject(isPersistent: true); print("usercode error delete persistent handle"); From eaf0d45c43fad8de5172e1fe5eedcf17e9ff33bd Mon Sep 17 00:00:00 2001 From: blagoev Date: Fri, 11 Aug 2023 23:01:14 +0300 Subject: [PATCH 42/50] fix open asyn callback --- lib/src/native/realm_core.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/src/native/realm_core.dart b/lib/src/native/realm_core.dart index 2cb18adc1..7b0d3d774 100644 --- a/lib/src/native/realm_core.dart +++ b/lib/src/native/realm_core.dart @@ -700,6 +700,7 @@ class _RealmCore { } print("error ${err.ref.toLastError().toString()}"); completer.completeError(RealmException("Failed to open realm ${err.ref.toLastError().toString()}")); + return; } print("_openRealmAsyncCallback calling realm_from_thread_safe_reference"); From 94d7fb0c193847d40e7b0c2f293b8ae62797fe35 Mon Sep 17 00:00:00 2001 From: blagoev Date: Fri, 11 Aug 2023 23:12:06 +0300 Subject: [PATCH 43/50] 3434 --- lib/src/native/realm_core.dart | 1 + test/test.dart | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/src/native/realm_core.dart b/lib/src/native/realm_core.dart index 7b0d3d774..da040084a 100644 --- a/lib/src/native/realm_core.dart +++ b/lib/src/native/realm_core.dart @@ -716,6 +716,7 @@ class _RealmCore { } void cancelOpenRealmAsync(RealmAsyncOpenTaskHandle handle) { + print("realm_core.cancelOpenRealmAsync asyncOpenHandle ${handle.toString()}"); _realmLib.realm_async_open_task_cancel(handle._pointer); } diff --git a/test/test.dart b/test/test.dart index 1c4f01c1c..35ef653c6 100644 --- a/test/test.dart +++ b/test/test.dart @@ -403,7 +403,6 @@ Future setupTests(List? args) async { final paths = HashSet(); paths.add(path); - print("tearddown: Clearing cached apps"); realmCore.clearCachedApps(); while (_openRealms.isNotEmpty) { @@ -414,6 +413,7 @@ Future setupTests(List? args) async { } for (final path in paths) { + print("deleting realm at path $path"); await tryDeleteRealm(path); } }); From c0e9465e40d42e4f0c8247a60f2ef2bbc5228405 Mon Sep 17 00:00:00 2001 From: blagoev Date: Fri, 11 Aug 2023 23:21:32 +0300 Subject: [PATCH 44/50] 234234 --- lib/src/realm_class.dart | 2 ++ test/test.dart | 2 ++ 2 files changed, 4 insertions(+) diff --git a/lib/src/realm_class.dart b/lib/src/realm_class.dart index 6459f7a22..553677433 100644 --- a/lib/src/realm_class.dart +++ b/lib/src/realm_class.dart @@ -182,6 +182,8 @@ class Realm implements Finalizable { _ensureDirectory(config); + print("async opening realm at path: ${config.path}"); + final asyncOpenHandle = realmCore.createRealmAsyncOpenTask(config); print("asyncOpenHandle ptr: ${asyncOpenHandle.toString()}"); return CancellableFuture.from(() async { diff --git a/test/test.dart b/test/test.dart index 35ef653c6..170b3a657 100644 --- a/test/test.dart +++ b/test/test.dart @@ -388,6 +388,8 @@ Future setupTests(List? args) async { setUpAll(() async => await (_baasSetupResult ??= setupBaas())); + tearDownAll(() async => await Future.delayed(Duration(seconds: 30))); + setUp(() { Realm.logger = Logger.detached('test run') ..level = Level.INFO From 51941d68852b1df2070c4c259dd48eb02def1fdc Mon Sep 17 00:00:00 2001 From: blagoev Date: Fri, 11 Aug 2023 23:29:52 +0300 Subject: [PATCH 45/50] await inside --- lib/src/realm_class.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/realm_class.dart b/lib/src/realm_class.dart index 553677433..8bfb80670 100644 --- a/lib/src/realm_class.dart +++ b/lib/src/realm_class.dart @@ -186,7 +186,7 @@ class Realm implements Finalizable { final asyncOpenHandle = realmCore.createRealmAsyncOpenTask(config); print("asyncOpenHandle ptr: ${asyncOpenHandle.toString()}"); - return CancellableFuture.from(() async { + return await CancellableFuture.from(() async { if (cancellationToken != null && cancellationToken.isCancelled) { throw cancellationToken.exception!; } From 1f554570982bf2c291823c7c880240a4e9f3c351 Mon Sep 17 00:00:00 2001 From: blagoev Date: Fri, 11 Aug 2023 23:44:10 +0300 Subject: [PATCH 46/50] remove debug statements --- lib/src/native/realm_core.dart | 50 ++++++++-------------------------- lib/src/realm_class.dart | 16 ++--------- test/realm_test.dart | 4 --- test/test.dart | 3 -- 4 files changed, 14 insertions(+), 59 deletions(-) diff --git a/lib/src/native/realm_core.dart b/lib/src/native/realm_core.dart index da040084a..2081e40a2 100644 --- a/lib/src/native/realm_core.dart +++ b/lib/src/native/realm_core.dart @@ -588,7 +588,6 @@ class _RealmCore { await callback(); } catch (error) { success = false; - print("_guardSynchronousCallback setting user code callback error"); _realmLib.realm_register_user_code_callback_error(error.toPersistentHandle()); } finally { _realmLib.realm_dart_invoke_unlock_callback(success, unlockCallbackFunc); @@ -653,9 +652,7 @@ class _RealmCore { } RealmHandle openRealm(Configuration config) { - print("realm_core: openRealm called. Creating config"); final configHandle = _createConfig(config); - print("realm_core: calling realm_open"); final realmPtr = _realmLib.invokeGetPointer(() => _realmLib.realm_open(configHandle._pointer), "Error opening realm at path ${config.path}"); return RealmHandle._(realmPtr); } @@ -672,7 +669,6 @@ class _RealmCore { final callback = Pointer.fromFunction realm, Pointer error)>(_openRealmAsyncCallback); final userData = _realmLib.realm_dart_userdata_async_new(completer, callback.cast(), scheduler.handle._pointer); - print("realm_dart_userdata_async_new userData ptr: ${userData.address.toString()}"); _realmLib.realm_async_open_task_start( handle._pointer, _realmLib.addresses.realm_dart_async_open_task_callback, @@ -684,39 +680,22 @@ class _RealmCore { } static void _openRealmAsyncCallback(Object userData, Pointer realmSafePtr, Pointer error) { - try { - return using((Arena arena) { - print("_openRealmAsyncCallback called"); - final completer = userData as Completer; - - if (error != nullptr) { - print("_openRealmAsyncCallback error detected"); - final err = arena(); - print("_openRealmAsyncCallback geting last async error"); - _realmLib.realm_get_async_error(error, err); - print("_openRealmAsyncCallback completing with error"); - if (err == nullptr) { - print("err is nullptr"); - } - print("error ${err.ref.toLastError().toString()}"); - completer.completeError(RealmException("Failed to open realm ${err.ref.toLastError().toString()}")); - return; - } + return using((Arena arena) { + final completer = userData as Completer; - print("_openRealmAsyncCallback calling realm_from_thread_safe_reference"); - final realmPtr = _realmLib.invokeGetPointer(() => _realmLib.realm_from_thread_safe_reference(realmSafePtr, scheduler.handle._pointer)); - print("_openRealmAsyncCallback completing with a realm handle"); - completer.complete(RealmHandle._(realmPtr)); - }); - } on Exception catch (e) { - print("Error"); - print(e); - rethrow; - } + if (error != nullptr) { + final err = arena(); + _realmLib.realm_get_async_error(error, err); + completer.completeError(RealmException("Failed to open realm ${err.ref.toLastError().toString()}")); + return; + } + + final realmPtr = _realmLib.invokeGetPointer(() => _realmLib.realm_from_thread_safe_reference(realmSafePtr, scheduler.handle._pointer)); + completer.complete(RealmHandle._(realmPtr)); + }); } void cancelOpenRealmAsync(RealmAsyncOpenTaskHandle handle) { - print("realm_core.cancelOpenRealmAsync asyncOpenHandle ${handle.toString()}"); _realmLib.realm_async_open_task_cancel(handle._pointer); } @@ -3426,18 +3405,13 @@ class SyncErrorDetails { extension on realm_error { LastError toLastError() { - print("getting last error message"); final message = this.message.cast().toRealmDartString(); - print("getting usercode error"); Object? userError; if (error == realm_errno.RLM_ERR_CALLBACK && usercode_error != nullptr) { - print("usercode error to object"); userError = usercode_error.toObject(isPersistent: true); - print("usercode error delete persistent handle"); _realmLib.realm_dart_delete_persistent_handle(usercode_error); } - print("usercode error creating last error"); return LastError(error, message, userError); } } diff --git a/lib/src/realm_class.dart b/lib/src/realm_class.dart index 8bfb80670..675e2007e 100644 --- a/lib/src/realm_class.dart +++ b/lib/src/realm_class.dart @@ -153,7 +153,6 @@ class Realm implements Finalizable { Realm(Configuration config) : this._(config); Realm._(this.config, [RealmHandle? handle, this._isInMigration = false]) : _handle = handle ?? _openRealm(config) { - print("Realm._: calling populateMetadata. Realm handle ${_handle.toString()}"); _populateMetadata(); } @@ -182,10 +181,7 @@ class Realm implements Finalizable { _ensureDirectory(config); - print("async opening realm at path: ${config.path}"); - final asyncOpenHandle = realmCore.createRealmAsyncOpenTask(config); - print("asyncOpenHandle ptr: ${asyncOpenHandle.toString()}"); return await CancellableFuture.from(() async { if (cancellationToken != null && cancellationToken.isCancelled) { throw cancellationToken.exception!; @@ -193,7 +189,6 @@ class Realm implements Finalizable { StreamSubscription? progressSubscription; if (onProgressCallback != null) { - print("attaching progress callback"); final progressController = RealmAsyncOpenProgressNotificationsController._(asyncOpenHandle); final progressStream = progressController.createStream(); progressSubscription = progressStream.listen(onProgressCallback); @@ -202,21 +197,14 @@ class Realm implements Finalizable { late final RealmHandle realmHandle; try { realmHandle = await realmCore.openRealmAsync(asyncOpenHandle, cancellationToken); + return Realm._(config, realmHandle); } finally { - print("cancelling progress callback"); await progressSubscription?.cancel(); } - - print("creating Realm instance with handle ${realmHandle.toString()}"); - return Realm._(config, realmHandle); - }, cancellationToken, onCancel: () { - print("onCancel callback. calling cancelOpenRealmAsync"); - realmCore.cancelOpenRealmAsync(asyncOpenHandle); - }); + }, cancellationToken, onCancel: () => realmCore.cancelOpenRealmAsync(asyncOpenHandle)); } static RealmHandle _openRealm(Configuration config) { - print("_openRealm called"); _ensureDirectory(config); return realmCore.openRealm(config); } diff --git a/test/realm_test.dart b/test/realm_test.dart index e1d0a6e7d..b087108d7 100644 --- a/test/realm_test.dart +++ b/test/realm_test.dart @@ -1262,7 +1262,6 @@ Future main([List? args]) async { }); baasTest('Realm.open (flexibleSync) - cancel right after open', (appConfiguration) async { - print("test 1: started"); final app = App(appConfiguration); final credentials = Credentials.anonymous(); final user = await app.logIn(credentials); @@ -1272,11 +1271,9 @@ Future main([List? args]) async { final isRealmCancelled = getRealmAsync(configuration, cancellationToken: cancellationToken).isCancelled(); cancellationToken.cancel(); expect(await isRealmCancelled, isTrue); - print("test 1: finished"); }); baasTest('Realm.open (flexibleSync) - open twice the same realm with the same CancelationToken cancels all', (appConfiguration) async { - print("test 2: started"); final app = App(appConfiguration); final credentials = Credentials.anonymous(); final user = await app.logIn(credentials); @@ -1289,7 +1286,6 @@ Future main([List? args]) async { final isRealm2Cancelled = getRealmAsync(configuration, cancellationToken: cancellationToken).isCancelled(); expect(await isRealm1Cancelled, isTrue); expect(await isRealm2Cancelled, isTrue); - print("test 2: finished"); }); baasTest('Realm._open (flexibleSync) - open the same realm twice and only cancel the first call', (appConfiguration) async { diff --git a/test/test.dart b/test/test.dart index 170b3a657..d5537963a 100644 --- a/test/test.dart +++ b/test/test.dart @@ -401,7 +401,6 @@ Future setupTests(List? args) async { Configuration.defaultRealmPath = path; addTearDown(() async { - print("Test teardown called"); final paths = HashSet(); paths.add(path); @@ -410,12 +409,10 @@ Future setupTests(List? args) async { while (_openRealms.isNotEmpty) { final realm = _openRealms.removeFirst(); paths.add(realm.config.path); - print("closing realm at path ${realm.config.path}"); realm.close(); } for (final path in paths) { - print("deleting realm at path $path"); await tryDeleteRealm(path); } }); From 3fc0e9a7bb2f9ddcd0909b4bddffbc55436e7801 Mon Sep 17 00:00:00 2001 From: blagoev Date: Fri, 11 Aug 2023 23:46:19 +0300 Subject: [PATCH 47/50] revert debug stms --- src/realm_dart.cpp | 2 -- test/realm_test.dart | 22 +++++++++++----------- test/test.dart | 2 -- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/realm_dart.cpp b/src/realm_dart.cpp index 1702f2ffc..0625cd92e 100644 --- a/src/realm_dart.cpp +++ b/src/realm_dart.cpp @@ -104,7 +104,6 @@ RLM_API realm_dart_userdata_async_t realm_dart_userdata_async_new(Dart_Handle ha } RLM_API void realm_dart_userdata_async_free(void* userdata) { - printf("realm_dart_userdata_async_free userdata ptr: %p\n", userdata); auto async_userdata = reinterpret_cast(userdata); async_userdata->scheduler->invoke([async_userdata]() { delete async_userdata; @@ -127,7 +126,6 @@ RLM_API const char* realm_dart_library_version() { return "1.3.0"; } // } void handle_finalizer(void* isolate_callback_data, void* realmPtr) { - printf("releasing ptr %p\n", realmPtr); realm_release(realmPtr); } diff --git a/test/realm_test.dart b/test/realm_test.dart index b087108d7..09c17a3cc 100644 --- a/test/realm_test.dart +++ b/test/realm_test.dart @@ -1227,7 +1227,7 @@ Future main([List? args]) async { expect(realm.isInTransaction, true); }); - baasTest('Realm._open (flexibleSync)', (appConfiguration) async { + baasTest('Realm.open (flexibleSync)', (appConfiguration) async { final app = App(appConfiguration); final credentials = Credentials.anonymous(); final user = await app.logIn(credentials); @@ -1237,20 +1237,20 @@ Future main([List? args]) async { expect(realm.isClosed, false); }); - test('Realm._open (local)', () async { + test('Realm.open (local)', () async { final configuration = Configuration.local([Car.schema]); final realm = await getRealmAsync(configuration); expect(realm.isClosed, false); }); - test('Realm._open (local) - cancel before open', () async { + test('Realm.open (local) - cancel before open', () async { final configuration = Configuration.local([Car.schema]); final cancellationToken = CancellationToken(); cancellationToken.cancel(); await expectLater(getRealmAsync(configuration, cancellationToken: cancellationToken), throwsA(isA())); }); - baasTest('Realm._open (flexibleSync) - cancel before open', (appConfiguration) async { + baasTest('Realm.open (flexibleSync) - cancel before open', (appConfiguration) async { final app = App(appConfiguration); final credentials = Credentials.anonymous(); final user = await app.logIn(credentials); @@ -1288,7 +1288,7 @@ Future main([List? args]) async { expect(await isRealm2Cancelled, isTrue); }); - baasTest('Realm._open (flexibleSync) - open the same realm twice and only cancel the first call', (appConfiguration) async { + baasTest('Realm.open (flexibleSync) - open the same realm twice and only cancel the first call', (appConfiguration) async { final app = App(appConfiguration); final credentials = Credentials.anonymous(); final user = await app.logIn(credentials); @@ -1304,7 +1304,7 @@ Future main([List? args]) async { expect(await isRealm2Cancelled, isFalse); }); - baasTest('Realm._open (flexibleSync) - open two different Realms for two different users and cancel only the second call', (appConfiguration) async { + baasTest('Realm.open (flexibleSync) - open two different Realms for two different users and cancel only the second call', (appConfiguration) async { final app = App(appConfiguration); final user1 = await app.logIn(Credentials.anonymous()); @@ -1322,7 +1322,7 @@ Future main([List? args]) async { expect(await isRealm1Cancelled, isFalse); }); - baasTest('Realm._open (flexibleSync) - cancel after realm is returned is no-op', (appConfiguration) async { + baasTest('Realm.open (flexibleSync) - cancel after realm is returned is no-op', (appConfiguration) async { final app = App(appConfiguration); final credentials = Credentials.anonymous(); final user = await app.logIn(credentials); @@ -1338,7 +1338,7 @@ Future main([List? args]) async { expect(realm.isClosed, false); }); - baasTest('Realm._open (flexibleSync) - listen for download progress on an empty realm', (appConfiguration) async { + baasTest('Realm.open (flexibleSync) - listen for download progress on an empty realm', (appConfiguration) async { final app = App(appConfiguration); final credentials = Credentials.anonymous(); final user = await app.logIn(credentials); @@ -1357,7 +1357,7 @@ Future main([List? args]) async { expect(transferredBytes, greaterThan(-1)); }); - baasTest('Realm._open (flexibleSync) - download a populated realm', (appConfiguration) async { + baasTest('Realm.open (flexibleSync) - download a populated realm', (appConfiguration) async { final app = App(appConfiguration); final queryDifferentiator = generateRandomString(10); const itemsCount = 200; @@ -1368,7 +1368,7 @@ Future main([List? args]) async { expect(data.length, itemsCount); }); - baasTest('Realm._open (flexibleSync) - listen for download progress of a populated realm', (appConfiguration) async { + baasTest('Realm.open (flexibleSync) - listen for download progress of a populated realm', (appConfiguration) async { final app = App(appConfiguration); final config = await _subscribeForAtlasAddedData(app); @@ -1385,7 +1385,7 @@ Future main([List? args]) async { expect(transferredBytes, greaterThan(19)); //19 bytes is the empty realm }); - baasTest('Realm._open (flexibleSync) - listen and cancel download progress of a populated realm', (appConfiguration) async { + baasTest('Realm.open (flexibleSync) - listen and cancel download progress of a populated realm', (appConfiguration) async { final app = App(appConfiguration); final config = await _subscribeForAtlasAddedData(app); diff --git a/test/test.dart b/test/test.dart index d5537963a..ea05fbedb 100644 --- a/test/test.dart +++ b/test/test.dart @@ -388,8 +388,6 @@ Future setupTests(List? args) async { setUpAll(() async => await (_baasSetupResult ??= setupBaas())); - tearDownAll(() async => await Future.delayed(Duration(seconds: 30))); - setUp(() { Realm.logger = Logger.detached('test run') ..level = Level.INFO From 1130bc2854c3b83515bf9b21c9dd7c459984a5e1 Mon Sep 17 00:00:00 2001 From: blagoev Date: Fri, 11 Aug 2023 23:49:51 +0300 Subject: [PATCH 48/50] revert CI --- .github/workflows/ci.yml | 1066 +++++++++++++++++++------------------- 1 file changed, 533 insertions(+), 533 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0d7d55056..f97d840a7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,12 +17,12 @@ concurrency: cancel-in-progress: true jobs: - # deploy-dart-cluster: - # name: Deploy Dart cluster - # secrets: inherit - # uses: ./.github/workflows/create-cluster.yml - # with: - # prefix: d + deploy-dart-cluster: + name: Deploy Dart cluster + secrets: inherit + uses: ./.github/workflows/create-cluster.yml + with: + prefix: d deploy-flutter-cluster: name: Deploy Flutter cluster @@ -31,15 +31,15 @@ jobs: with: prefix: f - # create-dart-shared-apps: - # name: Create Dart shared Apps - # secrets: inherit - # needs: - # - deploy-dart-cluster - # uses: ./.github/workflows/shared-apps.yml - # with: - # cluster: ${{ needs.deploy-dart-cluster.outputs.clusterName }} - # env: Dart + create-dart-shared-apps: + name: Create Dart shared Apps + secrets: inherit + needs: + - deploy-dart-cluster + uses: ./.github/workflows/shared-apps.yml + with: + cluster: ${{ needs.deploy-dart-cluster.outputs.clusterName }} + env: Dart create-flutter-shared-apps: name: Create Flutter shared Apps @@ -51,28 +51,28 @@ jobs: cluster: ${{ needs.deploy-flutter-cluster.outputs.clusterName }} env: Flutter - # delete-dart-cluster: - # runs-on: ubuntu-latest - # name: Delete Dart Cluster - # timeout-minutes: 5 - # continue-on-error: true - # needs: - # - deploy-dart-cluster - # - dart-tests-windows - # - dart-tests-macos - # - dart-tests-macos-arm - # - dart-tests-linux - # - dart-tests-linux-ubuntu-20 - - # steps: - # - uses: realm/ci-actions/mdb-realm/cleanup@338bf3e7575015a28faec8b67614385d122aece7 - # with: - # realmUrl: ${{ env.BAAS_URL }} - # atlasUrl: ${{ secrets.ATLAS_QA_URL }} - # projectId: ${{ env.BAAS_PROJECT_ID }} - # apiKey: ${{ env.BAAS_API_KEY }} - # privateApiKey: ${{ env.BAAS_PRIVATE_API_KEY }} - # clusterName: ${{ needs.deploy-dart-cluster.outputs.clusterName }} + delete-dart-cluster: + runs-on: ubuntu-latest + name: Delete Dart Cluster + timeout-minutes: 5 + continue-on-error: true + needs: + - deploy-dart-cluster + - dart-tests-windows + - dart-tests-macos + - dart-tests-macos-arm + - dart-tests-linux + - dart-tests-linux-ubuntu-20 + + steps: + - uses: realm/ci-actions/mdb-realm/cleanup@338bf3e7575015a28faec8b67614385d122aece7 + with: + realmUrl: ${{ env.BAAS_URL }} + atlasUrl: ${{ secrets.ATLAS_QA_URL }} + projectId: ${{ env.BAAS_PROJECT_ID }} + apiKey: ${{ env.BAAS_API_KEY }} + privateApiKey: ${{ env.BAAS_PRIVATE_API_KEY }} + clusterName: ${{ needs.deploy-dart-cluster.outputs.clusterName }} delete-flutter-cluster: runs-on: ubuntu-latest @@ -81,12 +81,12 @@ jobs: continue-on-error: true needs: - deploy-flutter-cluster - # - flutter-desktop-tests-windows - # - flutter-desktop-tests-macos + - flutter-desktop-tests-windows + - flutter-desktop-tests-macos - flutter-desktop-tests-linux - flutter-desktop-tests-linux-ubuntu-20 - # - flutter-ios - # - flutter-android + - flutter-ios + - flutter-android steps: - uses: realm/ci-actions/mdb-realm/cleanup@338bf3e7575015a28faec8b67614385d122aece7 with: @@ -97,34 +97,34 @@ jobs: privateApiKey: ${{ env.BAAS_PRIVATE_API_KEY }} clusterName: ${{ needs.deploy-flutter-cluster.outputs.clusterName }} - # cleanup-dart-shared-apps: - # name: Delete Dart shared Apps - # secrets: inherit - # needs: - # - deploy-dart-cluster - # - dart-tests-windows - # - dart-tests-macos - # - dart-tests-macos-arm - # - dart-tests-linux - # - dart-tests-linux-ubuntu-20 - # uses: ./.github/workflows/shared-apps.yml - # if: always() - # with: - # cleanup: true - # cluster: ${{ needs.deploy-dart-cluster.outputs.clusterName }} - # env: Dart + cleanup-dart-shared-apps: + name: Delete Dart shared Apps + secrets: inherit + needs: + - deploy-dart-cluster + - dart-tests-windows + - dart-tests-macos + - dart-tests-macos-arm + - dart-tests-linux + - dart-tests-linux-ubuntu-20 + uses: ./.github/workflows/shared-apps.yml + if: always() + with: + cleanup: true + cluster: ${{ needs.deploy-dart-cluster.outputs.clusterName }} + env: Dart cleanup-flutter-shared-apps: name: Delete Flutter shared Apps secrets: inherit needs: - deploy-flutter-cluster - # - flutter-desktop-tests-windows - # - flutter-desktop-tests-macos + - flutter-desktop-tests-windows + - flutter-desktop-tests-macos - flutter-desktop-tests-linux - flutter-desktop-tests-linux-ubuntu-20 - # - flutter-ios - # - flutter-android + - flutter-ios + - flutter-android uses: ./.github/workflows/shared-apps.yml if: always() with: @@ -132,81 +132,81 @@ jobs: cluster: ${{ needs.deploy-flutter-cluster.outputs.clusterName }} env: Flutter - # cleanup-dart-matrix: - # needs: - # - deploy-dart-cluster - # - dart-tests-windows - # - dart-tests-macos - # - dart-tests-macos-arm - # - dart-tests-linux - # - dart-tests-linux-ubuntu-20 - # strategy: - # fail-fast: false - # matrix: - # include: - # - app: dm - # description: dart macos - # - app: dma - # description: dart macos-arm - # - app: dl - # description: dart linux - # - app: dl2 - # description: dart linux (ubuntu 20) - # - app: dw - # description: dart windows - # runs-on: ubuntu-latest - # name: Cleanup apps for ${{ matrix.description }} - # timeout-minutes: 20 - # if: always() - # env: - # BAAS_CLUSTER: ${{ needs.deploy-dart-cluster.outputs.clusterName }} - # BAAS_DIFFERENTIATOR: ${{ matrix.app }}${{ github.run_id }}${{ github.run_attempt }} - # steps: - # - name: Checkout - # uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 - # with: - # submodules: false - - # - name : Setup Dart SDK - # uses: dart-lang/setup-dart@main - # with: - # sdk: stable - - # - name: Cleanup Dart apps - # run: | - # dart run realm_dart delete-apps \ - # --baas-url ${{ env.BAAS_URL }} \ - # --atlas-cluster ${{ env.BAAS_CLUSTER }} \ - # --api-key ${{ env.BAAS_API_KEY }} \ - # --private-api-key ${{ env.BAAS_PRIVATE_API_KEY }} \ - # --project-id ${{ env.BAAS_PROJECT_ID }} \ - # --differentiator '${{ env.BAAS_DIFFERENTIATOR }}' + cleanup-dart-matrix: + needs: + - deploy-dart-cluster + - dart-tests-windows + - dart-tests-macos + - dart-tests-macos-arm + - dart-tests-linux + - dart-tests-linux-ubuntu-20 + strategy: + fail-fast: false + matrix: + include: + - app: dm + description: dart macos + - app: dma + description: dart macos-arm + - app: dl + description: dart linux + - app: dl2 + description: dart linux (ubuntu 20) + - app: dw + description: dart windows + runs-on: ubuntu-latest + name: Cleanup apps for ${{ matrix.description }} + timeout-minutes: 20 + if: always() + env: + BAAS_CLUSTER: ${{ needs.deploy-dart-cluster.outputs.clusterName }} + BAAS_DIFFERENTIATOR: ${{ matrix.app }}${{ github.run_id }}${{ github.run_attempt }} + steps: + - name: Checkout + uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + with: + submodules: false + + - name : Setup Dart SDK + uses: dart-lang/setup-dart@main + with: + sdk: stable + + - name: Cleanup Dart apps + run: | + dart run realm_dart delete-apps \ + --baas-url ${{ env.BAAS_URL }} \ + --atlas-cluster ${{ env.BAAS_CLUSTER }} \ + --api-key ${{ env.BAAS_API_KEY }} \ + --private-api-key ${{ env.BAAS_PRIVATE_API_KEY }} \ + --project-id ${{ env.BAAS_PROJECT_ID }} \ + --differentiator '${{ env.BAAS_DIFFERENTIATOR }}' cleanup-flutter-matrix: needs: - deploy-flutter-cluster - # - flutter-desktop-tests-windows - # - flutter-desktop-tests-macos + - flutter-desktop-tests-windows + - flutter-desktop-tests-macos - flutter-desktop-tests-linux - flutter-desktop-tests-linux-ubuntu-20 - # - flutter-ios - # - flutter-android + - flutter-ios + - flutter-android strategy: fail-fast: false matrix: include: - # - app: fm - # description: flutter macos + - app: fm + description: flutter macos - app: fl description: flutter linux - app: fl2 description: flutter linux (ubuntu 20) - # - app: fw - # description: flutter windows - # - app: fa - # description: flutter android - # - app: fi - # description: flutter iOS + - app: fw + description: flutter windows + - app: fa + description: flutter android + - app: fi + description: flutter iOS runs-on: ubuntu-latest name: Cleanup apps for ${{ matrix.description }} timeout-minutes: 20 @@ -235,21 +235,21 @@ jobs: --project-id ${{ env.BAAS_PROJECT_ID }} \ --differentiator '${{ env.BAAS_DIFFERENTIATOR }}' - # build-windows: - # name: Build Windows - # uses: ./.github/workflows/build-native.yml - # with: - # runner: windows-latest - # binary: windows - # build: '["windows"]' - - # build-macos: - # name: Build MacOS - # uses: ./.github/workflows/build-native.yml - # with: - # runner: macos-latest - # binary: macos - # build: '["macos"]' + build-windows: + name: Build Windows + uses: ./.github/workflows/build-native.yml + with: + runner: windows-latest + binary: windows + build: '["windows"]' + + build-macos: + name: Build MacOS + uses: ./.github/workflows/build-native.yml + with: + runner: macos-latest + binary: macos + build: '["macos"]' build-linux: name: Build Linux @@ -259,134 +259,134 @@ jobs: binary: linux build: '["linux"]' - # build-android: - # name: Build Android - # uses: ./.github/workflows/build-native.yml - # with: - # runner: ubuntu-20.04 - # binary: android - # build: '["android-x86", "android-x86_64", "android-armeabi-v7a", "android-arm64-v8a"]' - - # build-ios: - # name: Build IOS - # uses: ./.github/workflows/build-native.yml - # with: - # runner: macos-latest - # binary: ios - # build: '["ios-device", "ios-simulator", "ios-catalyst"]' - - # build-android-combined: - # name: Android binaries combine - # needs: build-android - # uses: ./.github/workflows/binary-combine-android.yml - - # build-ios-xcframework: - # name: IOS binaries combine - # needs: build-ios - # uses: ./.github/workflows/binary-combine-ios.yml + build-android: + name: Build Android + uses: ./.github/workflows/build-native.yml + with: + runner: ubuntu-20.04 + binary: android + build: '["android-x86", "android-x86_64", "android-armeabi-v7a", "android-arm64-v8a"]' + + build-ios: + name: Build IOS + uses: ./.github/workflows/build-native.yml + with: + runner: macos-latest + binary: ios + build: '["ios-device", "ios-simulator", "ios-catalyst"]' + + build-android-combined: + name: Android binaries combine + needs: build-android + uses: ./.github/workflows/binary-combine-android.yml + + build-ios-xcframework: + name: IOS binaries combine + needs: build-ios + uses: ./.github/workflows/binary-combine-ios.yml # Dart jobs - # dart-tests-windows: - # name: Windows Dart Tests - # uses: ./.github/workflows/dart-desktop-tests.yml - # needs: - # - build-windows - # - deploy-dart-cluster - # - create-dart-shared-apps - # secrets: inherit - # with: - # os: windows - # runner: windows-latest - # app: dw - # cluster: ${{ needs.deploy-dart-cluster.outputs.clusterName }} - - # dart-tests-macos: - # name: MacOS Dart Tests - # uses: ./.github/workflows/dart-desktop-tests.yml - # needs: - # - build-macos - # - deploy-dart-cluster - # - create-dart-shared-apps - # secrets: inherit - # with: - # os: macos - # runner: macos-latest - # app: dm - # cluster: ${{ needs.deploy-dart-cluster.outputs.clusterName }} - - # dart-tests-macos-arm: - # name: MacOS Arm Dart Tests - # uses: ./.github/workflows/dart-desktop-tests.yml - # needs: - # - build-macos - # - deploy-dart-cluster - # - create-dart-shared-apps - # secrets: inherit - # with: - # os: macos - # runner: macos-arm - # architecture: arm - # app: dma - # cluster: ${{ needs.deploy-dart-cluster.outputs.clusterName }} - - # dart-tests-linux: - # name: Linux Dart Tests - # uses: ./.github/workflows/dart-desktop-tests.yml - # needs: - # - build-linux - # - deploy-dart-cluster - # - create-dart-shared-apps - # secrets: inherit - # with: - # os: linux - # runner: ubuntu-latest - # app: dl - # cluster: ${{ needs.deploy-dart-cluster.outputs.clusterName }} - - # dart-tests-linux-ubuntu-20: - # name: Linux Dart Tests (ubuntu 20) - # uses: ./.github/workflows/dart-desktop-tests.yml - # needs: - # - build-linux - # - deploy-dart-cluster - # - create-dart-shared-apps - # secrets: inherit - # with: - # os: linux - # runner: ubuntu-20.04 - # app: dl2 - # cluster: ${{ needs.deploy-dart-cluster.outputs.clusterName }} + dart-tests-windows: + name: Windows Dart Tests + uses: ./.github/workflows/dart-desktop-tests.yml + needs: + - build-windows + - deploy-dart-cluster + - create-dart-shared-apps + secrets: inherit + with: + os: windows + runner: windows-latest + app: dw + cluster: ${{ needs.deploy-dart-cluster.outputs.clusterName }} + + dart-tests-macos: + name: MacOS Dart Tests + uses: ./.github/workflows/dart-desktop-tests.yml + needs: + - build-macos + - deploy-dart-cluster + - create-dart-shared-apps + secrets: inherit + with: + os: macos + runner: macos-latest + app: dm + cluster: ${{ needs.deploy-dart-cluster.outputs.clusterName }} + + dart-tests-macos-arm: + name: MacOS Arm Dart Tests + uses: ./.github/workflows/dart-desktop-tests.yml + needs: + - build-macos + - deploy-dart-cluster + - create-dart-shared-apps + secrets: inherit + with: + os: macos + runner: macos-arm + architecture: arm + app: dma + cluster: ${{ needs.deploy-dart-cluster.outputs.clusterName }} + + dart-tests-linux: + name: Linux Dart Tests + uses: ./.github/workflows/dart-desktop-tests.yml + needs: + - build-linux + - deploy-dart-cluster + - create-dart-shared-apps + secrets: inherit + with: + os: linux + runner: ubuntu-latest + app: dl + cluster: ${{ needs.deploy-dart-cluster.outputs.clusterName }} + + dart-tests-linux-ubuntu-20: + name: Linux Dart Tests (ubuntu 20) + uses: ./.github/workflows/dart-desktop-tests.yml + needs: + - build-linux + - deploy-dart-cluster + - create-dart-shared-apps + secrets: inherit + with: + os: linux + runner: ubuntu-20.04 + app: dl2 + cluster: ${{ needs.deploy-dart-cluster.outputs.clusterName }} # Flutter jobs - # flutter-desktop-tests-windows: - # name: Windows Flutter Tests - # uses: ./.github/workflows/flutter-desktop-tests.yml - # needs: - # - build-windows - # - deploy-flutter-cluster - # - create-flutter-shared-apps - # secrets: inherit - # with: - # os: windows - # runner: windows-latest - # app: fw - # cluster: ${{ needs.deploy-flutter-cluster.outputs.clusterName }} - - # flutter-desktop-tests-macos: - # name: MacOS Flutter Tests - # uses: ./.github/workflows/flutter-desktop-tests.yml - # needs: - # - build-macos - # - deploy-flutter-cluster - # - create-flutter-shared-apps - # secrets: inherit - # with: - # os: macos - # runner: macos-13 # workaround to: https://github.com/flutter/flutter/issues/118469 latest is still macos-12 ¯\_(ツ)_/¯ - # app: fm - # cluster: ${{ needs.deploy-flutter-cluster.outputs.clusterName }} + flutter-desktop-tests-windows: + name: Windows Flutter Tests + uses: ./.github/workflows/flutter-desktop-tests.yml + needs: + - build-windows + - deploy-flutter-cluster + - create-flutter-shared-apps + secrets: inherit + with: + os: windows + runner: windows-latest + app: fw + cluster: ${{ needs.deploy-flutter-cluster.outputs.clusterName }} + + flutter-desktop-tests-macos: + name: MacOS Flutter Tests + uses: ./.github/workflows/flutter-desktop-tests.yml + needs: + - build-macos + - deploy-flutter-cluster + - create-flutter-shared-apps + secrets: inherit + with: + os: macos + runner: macos-13 # workaround to: https://github.com/flutter/flutter/issues/118469 latest is still macos-12 ¯\_(ツ)_/¯ + app: fm + cluster: ${{ needs.deploy-flutter-cluster.outputs.clusterName }} flutter-desktop-tests-linux: name: Linux Flutter Tests @@ -416,281 +416,281 @@ jobs: app: fl2 cluster: ${{ needs.deploy-flutter-cluster.outputs.clusterName }} - # flutter-ios: - # runs-on: macos-latest - # name: IOS Flutter Tests - # timeout-minutes: 45 - # needs: - # - deploy-flutter-cluster - # - build-ios-xcframework - # - create-flutter-shared-apps - # env: - # BAAS_CLUSTER: ${{ needs.deploy-flutter-cluster.outputs.clusterName }} - # BAAS_DIFFERENTIATOR: fi${{ github.run_id }}${{ github.run_attempt }} - - # steps: - - # - name: Checkout - # uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 - # with: - # submodules: 'recursive' - - # - name: Enable ccache - # run: echo "PATH=/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" >> $GITHUB_ENV - - # - name: Fetch artifacts - # uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7 - # with: - # name: librealm-ios - # path: binary/ios - - # - name: Setup Flutter - # uses: subosito/flutter-action@v2 - # with: - # channel: 'stable' - - # - name: Install dependencies - # run: dart pub get - - # - name: Launch Simulator - # uses: futureware-tech/simulator-action@v2 - # with: - # model: 'iPhone 8' - # os: 'iOS' - # os_version: '>= 14.0' - - # # This will be a no-op under normal circumstances since the cluster would have been deployed - # # in deploy-cluster. It is needed in case we want to re-run the job after the cluster has been reaped. - # - name: Create cluster - # uses: realm/ci-actions/mdb-realm/deploy@338bf3e7575015a28faec8b67614385d122aece7 - # with: - # realmUrl: ${{ env.BAAS_URL }} - # atlasUrl: ${{ secrets.ATLAS_QA_URL }} - # projectId: ${{ env.BAAS_PROJECT_ID }} - # apiKey: ${{ env.BAAS_API_KEY }} - # privateApiKey: ${{ env.BAAS_PRIVATE_API_KEY }} - # clusterName: ${{ env.BAAS_CLUSTER }} - - # - name: Run tests on iOS Simulator - # run: | - # flutter drive --target=test_driver/app.dart --dart-define=testName="" --suppress-analytics --debug - # working-directory: ./flutter/realm_flutter/tests - - # flutter-android: - # runs-on: macos-latest - # name: Android Flutter Tests - # timeout-minutes: 45 - # needs: - # - deploy-flutter-cluster - # - build-android-combined - # - create-flutter-shared-apps - # env: - # BAAS_CLUSTER: ${{ needs.deploy-flutter-cluster.outputs.clusterName }} - # BAAS_DIFFERENTIATOR: fa${{ github.run_id }}${{ github.run_attempt }} - # steps: - - # - name: Checkout - # uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 - # with: - # submodules: 'recursive' - - # - name: Set up Java - # uses: actions/setup-java@v3 - # with: - # distribution: 'temurin' - # java-version: 11 - - # - name: Fetch artifacts - # uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7 - # with: - # name: librealm-android - # path: binary/android - - # - name: Setup Flutter - # uses: subosito/flutter-action@v2 - # with: - # channel: 'stable' - - # - name: Install dependencies - # run: dart pub get - - # # TODO: Move CI run tests on Android Emulator into device farm https://github.com/realm/realm-dart/issues/691 - # - name: Setup Android Emulator cache - # uses: actions/cache@v3 - # id: avd-cache - # with: - # path: | - # ~/.android/avd/* - # ~/.android/adb* - # key: avd-29 - - # - name: Create Android Emulator and generate snapshot for caching - # if: ${{ steps.avd-cache.outputs.cache-hit != 'true' }} - # uses: reactivecircus/android-emulator-runner@v2 - # with: - # api-level: 29 - # force-avd-creation: false - # emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none - # disable-animations: true - # arch: x86 - # ndk: 21.0.6113669 - # cmake: 3.10.2.4988404 - # script: echo "Generated Emulator snapshot for caching." - - # # This will be a no-op under normal circumstances since the cluster would have been deployed - # # in deploy-cluster. It is needed in case we want to re-run the job after the cluster has been reaped. - # - name: Create cluster - # uses: realm/ci-actions/mdb-realm/deploy@338bf3e7575015a28faec8b67614385d122aece7 - # with: - # realmUrl: ${{ env.BAAS_URL }} - # atlasUrl: ${{ secrets.ATLAS_QA_URL }} - # projectId: ${{ env.BAAS_PROJECT_ID }} - # apiKey: ${{ env.BAAS_API_KEY }} - # privateApiKey: ${{ env.BAAS_PRIVATE_API_KEY }} - # clusterName: ${{ env.BAAS_CLUSTER }} - - # - name: Run tests on Android Emulator - # uses: reactivecircus/android-emulator-runner@v2 - # with: - # force-avd-creation: false - # disable-animations: true - # emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none - # api-level: 29 - # ndk: 21.0.6113669 - # arch: x86 - # cmake: 3.10.2.4988404 - # script: flutter build apk --debug --target=test_driver/app.dart && flutter install --debug && flutter drive --target=test_driver/app.dart --dart-define=testName="" --suppress-analytics --debug - # working-directory: ./flutter/realm_flutter/tests + flutter-ios: + runs-on: macos-latest + name: IOS Flutter Tests + timeout-minutes: 45 + needs: + - deploy-flutter-cluster + - build-ios-xcframework + - create-flutter-shared-apps + env: + BAAS_CLUSTER: ${{ needs.deploy-flutter-cluster.outputs.clusterName }} + BAAS_DIFFERENTIATOR: fi${{ github.run_id }}${{ github.run_attempt }} + + steps: + + - name: Checkout + uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + with: + submodules: 'recursive' + + - name: Enable ccache + run: echo "PATH=/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" >> $GITHUB_ENV + + - name: Fetch artifacts + uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7 + with: + name: librealm-ios + path: binary/ios + + - name: Setup Flutter + uses: subosito/flutter-action@v2 + with: + channel: 'stable' + + - name: Install dependencies + run: dart pub get + + - name: Launch Simulator + uses: futureware-tech/simulator-action@v2 + with: + model: 'iPhone 8' + os: 'iOS' + os_version: '>= 14.0' + + # This will be a no-op under normal circumstances since the cluster would have been deployed + # in deploy-cluster. It is needed in case we want to re-run the job after the cluster has been reaped. + - name: Create cluster + uses: realm/ci-actions/mdb-realm/deploy@338bf3e7575015a28faec8b67614385d122aece7 + with: + realmUrl: ${{ env.BAAS_URL }} + atlasUrl: ${{ secrets.ATLAS_QA_URL }} + projectId: ${{ env.BAAS_PROJECT_ID }} + apiKey: ${{ env.BAAS_API_KEY }} + privateApiKey: ${{ env.BAAS_PRIVATE_API_KEY }} + clusterName: ${{ env.BAAS_CLUSTER }} + + - name: Run tests on iOS Simulator + run: | + flutter drive --target=test_driver/app.dart --dart-define=testName="" --suppress-analytics --debug + working-directory: ./flutter/realm_flutter/tests + + flutter-android: + runs-on: macos-latest + name: Android Flutter Tests + timeout-minutes: 45 + needs: + - deploy-flutter-cluster + - build-android-combined + - create-flutter-shared-apps + env: + BAAS_CLUSTER: ${{ needs.deploy-flutter-cluster.outputs.clusterName }} + BAAS_DIFFERENTIATOR: fa${{ github.run_id }}${{ github.run_attempt }} + steps: + + - name: Checkout + uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + with: + submodules: 'recursive' + + - name: Set up Java + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: 11 + + - name: Fetch artifacts + uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7 + with: + name: librealm-android + path: binary/android + + - name: Setup Flutter + uses: subosito/flutter-action@v2 + with: + channel: 'stable' + + - name: Install dependencies + run: dart pub get + + # TODO: Move CI run tests on Android Emulator into device farm https://github.com/realm/realm-dart/issues/691 + - name: Setup Android Emulator cache + uses: actions/cache@v3 + id: avd-cache + with: + path: | + ~/.android/avd/* + ~/.android/adb* + key: avd-29 + + - name: Create Android Emulator and generate snapshot for caching + if: ${{ steps.avd-cache.outputs.cache-hit != 'true' }} + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: 29 + force-avd-creation: false + emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none + disable-animations: true + arch: x86 + ndk: 21.0.6113669 + cmake: 3.10.2.4988404 + script: echo "Generated Emulator snapshot for caching." + + # This will be a no-op under normal circumstances since the cluster would have been deployed + # in deploy-cluster. It is needed in case we want to re-run the job after the cluster has been reaped. + - name: Create cluster + uses: realm/ci-actions/mdb-realm/deploy@338bf3e7575015a28faec8b67614385d122aece7 + with: + realmUrl: ${{ env.BAAS_URL }} + atlasUrl: ${{ secrets.ATLAS_QA_URL }} + projectId: ${{ env.BAAS_PROJECT_ID }} + apiKey: ${{ env.BAAS_API_KEY }} + privateApiKey: ${{ env.BAAS_PRIVATE_API_KEY }} + clusterName: ${{ env.BAAS_CLUSTER }} + + - name: Run tests on Android Emulator + uses: reactivecircus/android-emulator-runner@v2 + with: + force-avd-creation: false + disable-animations: true + emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none + api-level: 29 + ndk: 21.0.6113669 + arch: x86 + cmake: 3.10.2.4988404 + script: flutter build apk --debug --target=test_driver/app.dart && flutter install --debug && flutter drive --target=test_driver/app.dart --dart-define=testName="" --suppress-analytics --debug + working-directory: ./flutter/realm_flutter/tests # Generator jobs - # generator: - # strategy: - # fail-fast: false - # matrix: - # os: [ubuntu, macos, windows] - - # runs-on: ${{ matrix.os }}-latest - # name: Generator Tests - # timeout-minutes: 30 - # steps: - # - name: Checkout - # uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 - # with: - # submodules: 'recursive' - - # - name: Setup Flutter - # uses: subosito/flutter-action@v2 - # with: - # channel: 'stable' - - # - name: Delete generated files - # run: find . -name "*.g.dart" -not -path "./generator/*" -delete - # shell: bash - - # - name: Run generator in realm-dart repo - # run: | - # dart pub get - # dart run build_runner build --delete-conflicting-outputs - - # - name: Run generator in realm-dart/example - # run: | - # dart pub get - # dart run build_runner build --delete-conflicting-outputs - # working-directory: ./example/ - - # - name: Run generator in realm_flutter/example - # run: | - # dart pub get - # dart run build_runner build --delete-conflicting-outputs - # working-directory: ./flutter/realm_flutter/example/ - - # - name: Install LLVM - # run: sudo apt update && sudo apt-get install -y libclang-dev - # if: ${{ matrix.os == 'ubuntu' }} - - # - name: Run ffigen - # run: dart run ffigen --config config.yaml - # working-directory: ./ffigen - - # - name: Validate there are no uncommitted changes - # run: | - # changedFiles=$(git --no-pager diff -w) - # if [ "$changedFiles" ]; then - # git --no-pager diff -w - # exit 1 - # fi - # shell: bash - - # - name: Run generator tests - # run: | - # dart pub get - # dart test -r expanded --coverage ./coverage/ --test-randomize-ordering-seed random - # working-directory: ./generator/ - - # - name: Generate generator coverage report - # if: matrix.os == 'ubuntu' - # run: | - # dart run coverage:format_coverage \ - # --in coverage/ \ - # --out ./coverage/lcov.info \ - # --check-ignore \ - # --lcov \ - # --packages .dart_tool/package_config.json \ - # --report-on lib - # working-directory: ./generator/ - - # - name: Publish Generator Coverage - # if: matrix.os == 'ubuntu' - # id: publish-coverage - # uses: coverallsapp/github-action@f350da2c033043742f89e8c0b7b5145a1616da6d - # with: - # github-token: ${{ secrets.GITHUB_TOKEN }} - # flag-name: generator - # path-to-lcov: ./generator/coverage/lcov.info - # parallel: true - - # - name: Output Coveralls response - # if: matrix.os == 'ubuntu' - # run: echo ${{ steps.publish-coverage.outputs.coveralls-api-result }} - - # coverage-finished: - # needs: - # - generator - # - dart-tests-linux - # runs-on: ubuntu-latest - # steps: - - # - name: Coveralls Finished - # id: publish-coverage - # uses: coverallsapp/github-action@f350da2c033043742f89e8c0b7b5145a1616da6d - # with: - # github-token: ${{ secrets.GITHUB_TOKEN }} - # parallel-finished: true - - # - name: Output Coveralls response - # run: echo ${{ steps.publish-coverage.outputs.coveralls-api-result }} - - # slack-on-failure: - # name: Report failure in main branch - # needs: - # - cleanup-dart-matrix - # - cleanup-flutter-matrix - # runs-on: ubuntu-latest - # if: always() - # steps: - # # Run this action to set env.WORKFLOW_CONCLUSION - # - uses: technote-space/workflow-conclusion-action@45ce8e0eb155657ab8ccf346ade734257fd196a5 - - # - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - # if: ${{ github.ref == 'refs/heads/main' && env.WORKFLOW_CONCLUSION == 'FAILURE' }} - # # Statuses: neutral, success, skipped, cancelled, timed_out, action_required, failure - # with: - # status: ${{ env.WORKFLOW_CONCLUSION }} - # webhook-url: ${{ secrets.SLACK_DART_WEBHOOK }} - # channel: '#realm-github-dart' - # message: | - # ** - # <{{refUrl}}|`{{ref}}` - {{description}}> - # {{#if description}}<{{diffUrl}}|branch: `{{diffRef}}`>{{/if}} + generator: + strategy: + fail-fast: false + matrix: + os: [ubuntu, macos, windows] + + runs-on: ${{ matrix.os }}-latest + name: Generator Tests + timeout-minutes: 30 + steps: + - name: Checkout + uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + with: + submodules: 'recursive' + + - name: Setup Flutter + uses: subosito/flutter-action@v2 + with: + channel: 'stable' + + - name: Delete generated files + run: find . -name "*.g.dart" -not -path "./generator/*" -delete + shell: bash + + - name: Run generator in realm-dart repo + run: | + dart pub get + dart run build_runner build --delete-conflicting-outputs + + - name: Run generator in realm-dart/example + run: | + dart pub get + dart run build_runner build --delete-conflicting-outputs + working-directory: ./example/ + + - name: Run generator in realm_flutter/example + run: | + dart pub get + dart run build_runner build --delete-conflicting-outputs + working-directory: ./flutter/realm_flutter/example/ + + - name: Install LLVM + run: sudo apt update && sudo apt-get install -y libclang-dev + if: ${{ matrix.os == 'ubuntu' }} + + - name: Run ffigen + run: dart run ffigen --config config.yaml + working-directory: ./ffigen + + - name: Validate there are no uncommitted changes + run: | + changedFiles=$(git --no-pager diff -w) + if [ "$changedFiles" ]; then + git --no-pager diff -w + exit 1 + fi + shell: bash + + - name: Run generator tests + run: | + dart pub get + dart test -r expanded --coverage ./coverage/ --test-randomize-ordering-seed random + working-directory: ./generator/ + + - name: Generate generator coverage report + if: matrix.os == 'ubuntu' + run: | + dart run coverage:format_coverage \ + --in coverage/ \ + --out ./coverage/lcov.info \ + --check-ignore \ + --lcov \ + --packages .dart_tool/package_config.json \ + --report-on lib + working-directory: ./generator/ + + - name: Publish Generator Coverage + if: matrix.os == 'ubuntu' + id: publish-coverage + uses: coverallsapp/github-action@f350da2c033043742f89e8c0b7b5145a1616da6d + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + flag-name: generator + path-to-lcov: ./generator/coverage/lcov.info + parallel: true + + - name: Output Coveralls response + if: matrix.os == 'ubuntu' + run: echo ${{ steps.publish-coverage.outputs.coveralls-api-result }} + + coverage-finished: + needs: + - generator + - dart-tests-linux + runs-on: ubuntu-latest + steps: + + - name: Coveralls Finished + id: publish-coverage + uses: coverallsapp/github-action@f350da2c033043742f89e8c0b7b5145a1616da6d + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + parallel-finished: true + + - name: Output Coveralls response + run: echo ${{ steps.publish-coverage.outputs.coveralls-api-result }} + + slack-on-failure: + name: Report failure in main branch + needs: + - cleanup-dart-matrix + - cleanup-flutter-matrix + runs-on: ubuntu-latest + if: always() + steps: + # Run this action to set env.WORKFLOW_CONCLUSION + - uses: technote-space/workflow-conclusion-action@45ce8e0eb155657ab8ccf346ade734257fd196a5 + + - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f + if: ${{ github.ref == 'refs/heads/main' && env.WORKFLOW_CONCLUSION == 'FAILURE' }} + # Statuses: neutral, success, skipped, cancelled, timed_out, action_required, failure + with: + status: ${{ env.WORKFLOW_CONCLUSION }} + webhook-url: ${{ secrets.SLACK_DART_WEBHOOK }} + channel: '#realm-github-dart' + message: | + ** + <{{refUrl}}|`{{ref}}` - {{description}}> + {{#if description}}<{{diffUrl}}|branch: `{{diffRef}}`>{{/if}} \ No newline at end of file From 37c37326809cd3644c71e9b236a5524c58ead02c Mon Sep 17 00:00:00 2001 From: blagoev Date: Fri, 11 Aug 2023 23:50:26 +0300 Subject: [PATCH 49/50] revert CI --- .github/workflows/flutter-desktop-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/flutter-desktop-tests.yml b/.github/workflows/flutter-desktop-tests.yml index 437cafbd5..0650c5ccf 100644 --- a/.github/workflows/flutter-desktop-tests.yml +++ b/.github/workflows/flutter-desktop-tests.yml @@ -87,5 +87,5 @@ jobs: clusterName: ${{ env.BAAS_CLUSTER }} - name: Run tests - run: ${{ inputs.os == 'linux' && 'xvfb-run' || '' }} flutter drive -d ${{ inputs.os }} --target=test_driver/app.dart --suppress-analytics --dart-entrypoint-args="Realm.open" --debug # -a="Some test name" + run: ${{ inputs.os == 'linux' && 'xvfb-run' || '' }} flutter drive -d ${{ inputs.os }} --target=test_driver/app.dart --suppress-analytics --dart-entrypoint-args="" --debug # -a="Some test name" working-directory: ./flutter/realm_flutter/tests From fee69be2a0884bb66077752e54983aa0dd702b51 Mon Sep 17 00:00:00 2001 From: blagoev Date: Sat, 12 Aug 2023 00:12:15 +0300 Subject: [PATCH 50/50] revert Core --- src/realm-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/realm-core b/src/realm-core index 01d288524..c04f5e401 160000 --- a/src/realm-core +++ b/src/realm-core @@ -1 +1 @@ -Subproject commit 01d288524bde4b21834c69b07e4281b906c23bde +Subproject commit c04f5e401a1ec682e6b08b1ee157e19a0f834a5f