Skip to content

integration test timing issues #306

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

Merged
merged 5 commits into from
Feb 7, 2023
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
12 changes: 6 additions & 6 deletions test/Redis.OM.Unit.Tests/CoreTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public async Task SimpleHashInsertWhenAsync()
res = await collection.InsertAsync(obj, WhenKey.NotExists, TimeSpan.FromMilliseconds(5000));
Assert.Null(res);
var expiration = (long)await connection.ExecuteAsync("PTTL", key);
Assert.True(expiration < 4000, $"Expiration is {expiration}");
Assert.True(expiration < 4050, $"Expiration is {expiration}");
res = await collection.InsertAsync(obj, WhenKey.Exists, TimeSpan.FromMilliseconds(5000));
Assert.NotNull(res);

Expand Down Expand Up @@ -303,7 +303,7 @@ public void SimpleHashInsertWhen()
res = collection.Insert(obj, WhenKey.NotExists, TimeSpan.FromMilliseconds(5000));
Assert.Null(res);
var expiration = (long)connection.Execute("PTTL", key);
Assert.True(expiration < 4000);
Assert.True(expiration <= 4050);
res = collection.Insert(obj, WhenKey.Exists, TimeSpan.FromMilliseconds(5000));
Assert.NotNull(res);

Expand Down Expand Up @@ -348,15 +348,15 @@ public async Task SimpleJsonInsertWhenAsync()
res = await collection.InsertAsync(obj, WhenKey.NotExists, TimeSpan.FromMilliseconds(5000));
Assert.Null(res);
var expiration = (long)await connection.ExecuteAsync("PTTL", key);
Assert.True(expiration < 4000);
Assert.True(expiration <= 4050, $"Actual: {expiration}");
res = await collection.InsertAsync(obj, WhenKey.Exists, TimeSpan.FromMilliseconds(5000));
expiration = (long)await connection.ExecuteAsync("PTTL", key);
Assert.NotNull(res);
Assert.True(expiration > 4000);
Assert.True(expiration >= 4000, $"Actual: {expiration}");
res = collection.Insert(obj, WhenKey.Always, TimeSpan.FromMilliseconds(6000));
expiration = (long)connection.Execute("PTTL", key);
Assert.NotNull(res);
Assert.True(expiration>5000);
Assert.True(expiration>=5000);
res = collection.Insert(obj, WhenKey.Always);
expiration = (long)connection.Execute("PTTL", key);
Assert.NotNull(res);
Expand Down Expand Up @@ -396,7 +396,7 @@ public void SimpleJsonInsertWhen()
res = collection.Insert(obj, WhenKey.NotExists, TimeSpan.FromMilliseconds(5000));
Assert.Null(res);
var expiration = (long)connection.Execute("PTTL", key);
Assert.True(expiration < 4000, $"Expiration: {expiration}");
Assert.True(expiration <= 4050, $"Expiration: {expiration}");
res = collection.Insert(obj, WhenKey.Exists, TimeSpan.FromMilliseconds(5000));
Assert.NotNull(res);
res = collection.Insert(obj, WhenKey.Always, TimeSpan.FromMilliseconds(6000));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,12 @@ public void TestSave()
var count = collection.Count();
foreach (var person in collection)
{
person.Name = "Steve";
person.Name = "TestSave";
person.Mother = new Person {Name = "Diane"};
}

collection.Save();
var steves = collection.Where(x => x.Name == "Steve");
var steves = collection.Where(x => x.Name == "TestSave");
Assert.Equal(count, steves.Count());
}

Expand All @@ -171,12 +171,12 @@ public async Task TestSaveAsync()
await foreach (var person in collection.Where(x=>x.Name == "Chris"))
{
count++;
person.Name = "Augustine";
person.Name = "TestSaveAsync";
person.Mother = new Person {Name = "Monica"};
person.IsEngineer = true;
}
await collection.SaveAsync();
var augustines = collection.Where(x => x.Name == "Augustine");
var augustines = collection.Where(x => x.Name == "TestSaveAsync");
var numSteves = augustines.Count();
Assert.Equal(count, augustines.Count());
}
Expand All @@ -191,11 +191,11 @@ public async Task TestSaveAsyncSecondEnumeration()
await foreach (var person in collection.Where(x => x.Name == "Chris"))
{
count++;
person.Name = "Thomas";
person.Name = "TestSaveAsyncSecondEnumeration";
}

await collection.SaveAsync();
var augustines = collection.Where(x => x.Name == "Thomas");
var augustines = collection.Where(x => x.Name == "TestSaveAsyncSecondEnumeration");
Assert.Equal(count, augustines.Count());

}
Expand All @@ -207,11 +207,11 @@ public async Task TestSaveHashAsync()
var count = collection.Count();
await foreach (var person in collection)
{
person.Name = "Steve";
person.Name = "TestSaveHashAsync";
person.Mother = new HashPerson {Name = "Diane"};
}
await collection.SaveAsync();
var steves = collection.Where(x => x.Name == "Steve");
var steves = collection.Where(x => x.Name == "TestSaveHashAsync");
Assert.Equal(count, steves.Count());
}

Expand Down
4 changes: 2 additions & 2 deletions test/Redis.OM.Unit.Tests/RediSearchTests/SearchTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ public async Task TestUpdateJsonUnloadedScriptAsync()
var steve = collection.First(x => x.Name == "Steve");
steve.Age = 33;
await collection.UpdateAsync(steve);
_mock.Verify(x => x.ExecuteAsync("EVALSHA", "cbbf1c4fab5064f419e469cc51c563f8bf51e6fb", "1", "Redis.OM.Unit.Tests.RediSearchTests.Person:01FVN836BNQGYMT80V7RCVY73N", "SET", "$.Age", "33"));
_mock.Verify(x => x.ExecuteAsync("EVALSHA", It.IsAny<string>(), "1", "Redis.OM.Unit.Tests.RediSearchTests.Person:01FVN836BNQGYMT80V7RCVY73N", "SET", "$.Age", "33"));
_mock.Verify(x => x.ExecuteAsync("EVAL",Scripts.JsonDiffResolution, "1", "Redis.OM.Unit.Tests.RediSearchTests.Person:01FVN836BNQGYMT80V7RCVY73N", "SET", "$.Age", "33"));
Scripts.ShaCollection.Clear();
}
Expand Down Expand Up @@ -865,7 +865,7 @@ public async Task TestUpdateJsonWithDouble()
steve.Age = 33;
steve.Height = 71.5;
await collection.UpdateAsync(steve);
_mock.Verify(x => x.ExecuteAsync("EVALSHA", "42", "1", "Redis.OM.Unit.Tests.RediSearchTests.Person:01FVN836BNQGYMT80V7RCVY73N", "SET", "$.Age", "33", "SET", "$.Height", "71.5"));
_mock.Verify(x => x.ExecuteAsync("EVALSHA", It.IsAny<string>(), "1", "Redis.OM.Unit.Tests.RediSearchTests.Person:01FVN836BNQGYMT80V7RCVY73N", "SET", "$.Age", "33", "SET", "$.Height", "71.5"));
Scripts.ShaCollection.Clear();
}

Expand Down