Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix various failing CI tests #3535

Merged
merged 6 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Tests/Realm.Tests/Sync/SessionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1328,7 +1328,7 @@ public void Session_WaitForUpload_CanBeCancelled()

sw.Stop();

Assert.That(sw.ElapsedMilliseconds, Is.LessThan(5));
Copy link
Contributor Author

@papafe papafe Feb 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even locally these two tests didn't pass all the time

Assert.That(sw.ElapsedMilliseconds, Is.LessThan(30));
});
}

Expand Down Expand Up @@ -1377,7 +1377,7 @@ public void Session_WaitForDownload_CanBeCancelled()

sw.Stop();

Assert.That(sw.ElapsedMilliseconds, Is.LessThan(5));
Assert.That(sw.ElapsedMilliseconds, Is.LessThan(30));
Assert.That(readerRealm.All<SyncAllTypesObject>().Count(), Is.Zero);

await GetSession(readerRealm).WaitForDownloadAsync();
Expand Down
8 changes: 4 additions & 4 deletions Tests/Realm.Tests/Sync/StaticQueriesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ public void RealmObjectAPI_Links_AtlasToRealm(TestCaseData<LinksObject> testCase
var linkObjs = await realm.All<LinksObject>().SubscribeAsync();

await realm.SyncSession.WaitForDownloadAsync();
await linkObjs.WaitForEventAsync((sender, _) => sender.Count >= totalCount);
await linkObjs.WaitForEventAsync((sender, _) => sender.Count >= totalCount && realm.Find<LinksObject>(obj.Id) != null);

var linkObj = realm.Find<LinksObject>(obj.Id);

Expand Down Expand Up @@ -752,7 +752,7 @@ public void RealmObjectAPI_RealmValueLinks_AtlasToRealm(TestCaseData<RealmValueO
var realmObjs = await realm.All<RealmValueObject>().SubscribeAsync();

await intObjs.WaitForEventAsync((sender, _) => sender.Count >= totalCount);
await realmObjs.WaitForEventAsync((sender, _) => sender.Count >= 1);
await realmObjs.WaitForEventAsync((sender, _) => sender.Count == 1 && realm.Find<RealmValueObject>(obj.Id) != null);

var realmValObj = realm.Find<RealmValueObject>(obj.Id);

Expand Down Expand Up @@ -1257,7 +1257,7 @@ public void RealmObjectAPI_MissingField_GetsDefaultValueWhenDeserialized()

SyncConfigurationBase config = appConfigType == AppConfigType.FlexibleSync ? GetFLXIntegrationConfig(user) : GetIntegrationConfig(user);

using var realm = await GetRealmAsync(config);
using var realm = await GetRealmAsync(config, true);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to wait for the schema to be synchronized, otherwise the call to the backends without the database name could raise an exception

var client = user.GetMongoClient(ServiceName);
var collection = client.GetCollection<T>();
await collection.DeleteManyAsync(new object());
Expand All @@ -1272,7 +1272,7 @@ public void RealmObjectAPI_MissingField_GetsDefaultValueWhenDeserialized()

SyncConfigurationBase config = appConfigType == AppConfigType.FlexibleSync ? GetFLXIntegrationConfig(user) : GetIntegrationConfig(user);

using var realm = await GetRealmAsync(config);
using var realm = await GetRealmAsync(config, true);
var client = user.GetMongoClient(ServiceName);
var db = client.GetDatabase(SyncTestHelpers.SyncMongoDBName(appConfigType));

Expand Down
4 changes: 2 additions & 2 deletions Tests/Realm.Tests/Sync/UserManagementTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1166,11 +1166,11 @@ public void UserCustomDataChange_RaisesChanged()

await tcs.Task;

tcs = new();

// Unsubscribe and verify that it no longer raises user changed
user.Changed -= OnUserChanged;

tcs = new();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sometimes no TimeoutException was raised at the end of the method on CI. I verified that actually we get two Changed notifications, one for the custom data, and one for the user token refresh.
I suspect that sometimes the second notification was being raised after the new token completion source was created but before the unsubscription, that's why the timeout had no effect.


var filter = BsonDocument.Parse(@"{
user_id: { $eq: """ + user.Id + @""" }
}");
Expand Down
Loading