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: update int test ttls to be more lenient #441

Merged
merged 6 commits into from
May 15, 2023
Merged
Show file tree
Hide file tree
Changes from 5 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
72 changes: 36 additions & 36 deletions tests/Integration/Momento.Sdk.Tests/DictionaryTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ public async Task DictionarySetGetAsync_FieldIsByteArrayValueIsByteArray_NoRefre
var field = Utils.NewGuidByteArray();
var value = Utils.NewGuidByteArray();

CacheDictionarySetFieldResponse setResponse = await client.DictionarySetFieldAsync(cacheName, dictionaryName, field, value, CollectionTtl.Of(TimeSpan.FromSeconds(5)).WithNoRefreshTtlOnUpdates());
CacheDictionarySetFieldResponse setResponse = await client.DictionarySetFieldAsync(cacheName, dictionaryName, field, value, CollectionTtl.Of(TimeSpan.FromSeconds(Utils.initialRefreshTtl)).WithNoRefreshTtlOnUpdates());
Assert.True(setResponse is CacheDictionarySetFieldResponse.Success, $"Unexpected response: {setResponse}");
await Task.Delay(100);
await Task.Delay(Utils.waitForItemToBeSet);

setResponse = await client.DictionarySetFieldAsync(cacheName, dictionaryName, field, value, CollectionTtl.Of(TimeSpan.FromSeconds(10)).WithNoRefreshTtlOnUpdates());
setResponse = await client.DictionarySetFieldAsync(cacheName, dictionaryName, field, value, CollectionTtl.Of(TimeSpan.FromSeconds(Utils.updatedRefreshTtl)).WithNoRefreshTtlOnUpdates());
Assert.True(setResponse is CacheDictionarySetFieldResponse.Success, $"Unexpected response: {setResponse}");
await Task.Delay(4900);
await Task.Delay(Utils.waitForInitialItemToExpire);

CacheDictionaryGetFieldResponse response = await client.DictionaryGetFieldAsync(cacheName, dictionaryName, field);
Assert.True(response is CacheDictionaryGetFieldResponse.Miss, $"Unexpected response: {response}");
Expand All @@ -106,7 +106,7 @@ public async Task DictionarySetGetAsync_FieldIsByteArrayValueIsByteArray_Refresh

CacheDictionarySetFieldResponse setResponse = await client.DictionarySetFieldAsync(cacheName, dictionaryName, field, value, CollectionTtl.Of(TimeSpan.FromSeconds(2)));
Assert.True(setResponse is CacheDictionarySetFieldResponse.Success, $"Unexpected response: {setResponse}");
setResponse = await client.DictionarySetFieldAsync(cacheName, dictionaryName, field, value, CollectionTtl.Of(TimeSpan.FromSeconds(10)));
setResponse = await client.DictionarySetFieldAsync(cacheName, dictionaryName, field, value, CollectionTtl.Of(TimeSpan.FromSeconds(Utils.updatedRefreshTtl)));
Assert.True(setResponse is CacheDictionarySetFieldResponse.Success, $"Unexpected response: {setResponse}");
await Task.Delay(2000);

Expand Down Expand Up @@ -162,7 +162,7 @@ public async Task DictionaryIncrementAsync_IncrementFromZero_RefreshTtl()

CacheDictionaryIncrementResponse resp = await client.DictionaryIncrementAsync(cacheName, dictionaryName, field, ttl: CollectionTtl.Of(TimeSpan.FromSeconds(2)));
Assert.True(resp is CacheDictionaryIncrementResponse.Success, $"Unexpected response: {resp}");
resp = await client.DictionaryIncrementAsync(cacheName, dictionaryName, field, ttl: CollectionTtl.Of(TimeSpan.FromSeconds(10)));
resp = await client.DictionaryIncrementAsync(cacheName, dictionaryName, field, ttl: CollectionTtl.Of(TimeSpan.FromSeconds(Utils.updatedRefreshTtl)));
Assert.True(resp is CacheDictionaryIncrementResponse.Success, $"Unexpected response: {resp}");
await Task.Delay(2000);

Expand All @@ -177,13 +177,13 @@ public async Task DictionaryIncrementAsync_IncrementFromZero_NoRefreshTtl()
var dictionaryName = Utils.NewGuidString();
var field = Utils.NewGuidString();

CacheDictionaryIncrementResponse resp = await client.DictionaryIncrementAsync(cacheName, dictionaryName, field, ttl: CollectionTtl.Of(TimeSpan.FromSeconds(5)));
CacheDictionaryIncrementResponse resp = await client.DictionaryIncrementAsync(cacheName, dictionaryName, field, ttl: CollectionTtl.Of(TimeSpan.FromSeconds(Utils.initialRefreshTtl)));
Assert.True(resp is CacheDictionaryIncrementResponse.Success, $"Unexpected response: {resp}");
await Task.Delay(101);
await Task.Delay(Utils.waitForItemToBeSet);

resp = await client.DictionaryIncrementAsync(cacheName, dictionaryName, field, ttl: CollectionTtl.Of(TimeSpan.FromSeconds(10)).WithNoRefreshTtlOnUpdates());
resp = await client.DictionaryIncrementAsync(cacheName, dictionaryName, field, ttl: CollectionTtl.Of(TimeSpan.FromSeconds(Utils.updatedRefreshTtl)).WithNoRefreshTtlOnUpdates());
Assert.True(resp is CacheDictionaryIncrementResponse.Success, $"Unexpected response: {resp}");
await Task.Delay(4900);
await Task.Delay(Utils.waitForInitialItemToExpire);

CacheDictionaryGetFieldResponse response = await client.DictionaryGetFieldAsync(cacheName, dictionaryName, field);
Assert.True(response is CacheDictionaryGetFieldResponse.Miss, $"Unexpected response: {response}");
Expand Down Expand Up @@ -316,13 +316,13 @@ public async Task DictionarySetGetAsync_FieldIsStringValueIsString_NoRefreshTtl(
var field = Utils.NewGuidString();
var value = Utils.NewGuidString();

CacheDictionarySetFieldResponse setResponse = await client.DictionarySetFieldAsync(cacheName, dictionaryName, field, value, ttl: CollectionTtl.Of(TimeSpan.FromSeconds(5)));
CacheDictionarySetFieldResponse setResponse = await client.DictionarySetFieldAsync(cacheName, dictionaryName, field, value, ttl: CollectionTtl.Of(TimeSpan.FromSeconds(Utils.initialRefreshTtl)));
Assert.True(setResponse is CacheDictionarySetFieldResponse.Success, $"Unexpected response: {setResponse}");
await Task.Delay(100);
await Task.Delay(Utils.waitForItemToBeSet);

setResponse = await client.DictionarySetFieldAsync(cacheName, dictionaryName, field, value, ttl: CollectionTtl.Of(TimeSpan.FromSeconds(10)).WithNoRefreshTtlOnUpdates());
setResponse = await client.DictionarySetFieldAsync(cacheName, dictionaryName, field, value, ttl: CollectionTtl.Of(TimeSpan.FromSeconds(Utils.updatedRefreshTtl)).WithNoRefreshTtlOnUpdates());
Assert.True(setResponse is CacheDictionarySetFieldResponse.Success, $"Unexpected response: {setResponse}");
await Task.Delay(4900);
await Task.Delay(Utils.waitForInitialItemToExpire);

CacheDictionaryGetFieldResponse response = await client.DictionaryGetFieldAsync(cacheName, dictionaryName, field);
Assert.True(response is CacheDictionaryGetFieldResponse.Miss, $"Unexpected response: {response}");
Expand All @@ -337,7 +337,7 @@ public async Task DictionarySetGetAsync_FieldIsStringValueIsString_RefreshTtl()

CacheDictionarySetFieldResponse setResponse = await client.DictionarySetFieldAsync(cacheName, dictionaryName, field, value, ttl: CollectionTtl.Of(TimeSpan.FromSeconds(2)));
Assert.True(setResponse is CacheDictionarySetFieldResponse.Success, $"Unexpected response: {setResponse}");
setResponse = await client.DictionarySetFieldAsync(cacheName, dictionaryName, field, value, ttl: CollectionTtl.Of(TimeSpan.FromSeconds(10)));
setResponse = await client.DictionarySetFieldAsync(cacheName, dictionaryName, field, value, ttl: CollectionTtl.Of(TimeSpan.FromSeconds(Utils.updatedRefreshTtl)));
Assert.True(setResponse is CacheDictionarySetFieldResponse.Success, $"Unexpected response: {setResponse}");
await Task.Delay(2000);

Expand Down Expand Up @@ -379,13 +379,13 @@ public async Task DictionarySetGetAsync_FieldIsStringValueIsByteArray_NoRefreshT
var field = Utils.NewGuidString();
var value = Utils.NewGuidByteArray();

CacheDictionarySetFieldResponse setResponse = await client.DictionarySetFieldAsync(cacheName, dictionaryName, field, value, ttl: CollectionTtl.Of(TimeSpan.FromSeconds(5)));
CacheDictionarySetFieldResponse setResponse = await client.DictionarySetFieldAsync(cacheName, dictionaryName, field, value, ttl: CollectionTtl.Of(TimeSpan.FromSeconds(Utils.initialRefreshTtl)));
Assert.True(setResponse is CacheDictionarySetFieldResponse.Success, $"Unexpected response: {setResponse}");
await Task.Delay(100);
await Task.Delay(Utils.waitForItemToBeSet);

setResponse = await client.DictionarySetFieldAsync(cacheName, dictionaryName, field, value, ttl: CollectionTtl.Of(TimeSpan.FromSeconds(10)).WithNoRefreshTtlOnUpdates());
setResponse = await client.DictionarySetFieldAsync(cacheName, dictionaryName, field, value, ttl: CollectionTtl.Of(TimeSpan.FromSeconds(Utils.updatedRefreshTtl)).WithNoRefreshTtlOnUpdates());
Assert.True(setResponse is CacheDictionarySetFieldResponse.Success, $"Unexpected response: {setResponse}");
await Task.Delay(4900);
await Task.Delay(Utils.waitForInitialItemToExpire);

CacheDictionaryGetFieldResponse response = await client.DictionaryGetFieldAsync(cacheName, dictionaryName, field);
Assert.True(response is CacheDictionaryGetFieldResponse.Miss, $"Unexpected response: {response}");
Expand All @@ -400,7 +400,7 @@ public async Task DictionarySetGetAsync_FieldIsStringValueIsByteArray_RefreshTtl

CacheDictionarySetFieldResponse setResponse = await client.DictionarySetFieldAsync(cacheName, dictionaryName, field, value, ttl: CollectionTtl.Of(TimeSpan.FromSeconds(2)));
Assert.True(setResponse is CacheDictionarySetFieldResponse.Success, $"Unexpected response: {setResponse}");
setResponse = await client.DictionarySetFieldAsync(cacheName, dictionaryName, field, value, ttl: CollectionTtl.Of(TimeSpan.FromSeconds(10)));
setResponse = await client.DictionarySetFieldAsync(cacheName, dictionaryName, field, value, ttl: CollectionTtl.Of(TimeSpan.FromSeconds(Utils.updatedRefreshTtl)));
Assert.True(setResponse is CacheDictionarySetFieldResponse.Success, $"Unexpected response: {setResponse}");
await Task.Delay(2000);

Expand Down Expand Up @@ -441,7 +441,7 @@ public async Task DictionarySetFieldsAsync_FieldsAreByteArrayValuesAreByteArray_

var items = new Dictionary<byte[], byte[]>() { { field1, value1 }, { field2, value2 } };

await client.DictionarySetFieldsAsync(cacheName, dictionaryName, items, CollectionTtl.Of(TimeSpan.FromSeconds(10)));
await client.DictionarySetFieldsAsync(cacheName, dictionaryName, items, CollectionTtl.Of(TimeSpan.FromSeconds(Utils.updatedRefreshTtl)));

CacheDictionaryGetFieldResponse getResponse = await client.DictionaryGetFieldAsync(cacheName, dictionaryName, field1);
Assert.True(getResponse is CacheDictionaryGetFieldResponse.Hit, $"Unexpected response: {getResponse}");
Expand All @@ -460,11 +460,11 @@ public async Task DictionarySetFieldsAsync_FieldsAreByteArrayValuesAreByteArray_
var value = Utils.NewGuidByteArray();
var content = new Dictionary<byte[], byte[]>() { { field, value } };

await client.DictionarySetFieldsAsync(cacheName, dictionaryName, content, ttl: CollectionTtl.Of(TimeSpan.FromSeconds(5)));
await Task.Delay(100);
await client.DictionarySetFieldsAsync(cacheName, dictionaryName, content, ttl: CollectionTtl.Of(TimeSpan.FromSeconds(Utils.initialRefreshTtl)));
await Task.Delay(Utils.waitForItemToBeSet);

await client.DictionarySetFieldsAsync(cacheName, dictionaryName, content, ttl: CollectionTtl.Of(TimeSpan.FromSeconds(10)).WithNoRefreshTtlOnUpdates());
await Task.Delay(4900);
await client.DictionarySetFieldsAsync(cacheName, dictionaryName, content, ttl: CollectionTtl.Of(TimeSpan.FromSeconds(Utils.updatedRefreshTtl)).WithNoRefreshTtlOnUpdates());
await Task.Delay(Utils.waitForInitialItemToExpire);

CacheDictionaryGetFieldResponse response = await client.DictionaryGetFieldAsync(cacheName, dictionaryName, field);
Assert.True(response is CacheDictionaryGetFieldResponse.Miss, $"Unexpected response: {response}");
Expand All @@ -479,7 +479,7 @@ public async Task DictionarySetFieldsAsync_FieldsAreByteArrayValuesAreByteArray_
var content = new Dictionary<byte[], byte[]>() { { field, value } };

await client.DictionarySetFieldsAsync(cacheName, dictionaryName, content, ttl: CollectionTtl.Of(TimeSpan.FromSeconds(2)));
await client.DictionarySetFieldsAsync(cacheName, dictionaryName, content, ttl: CollectionTtl.Of(TimeSpan.FromSeconds(10)));
await client.DictionarySetFieldsAsync(cacheName, dictionaryName, content, ttl: CollectionTtl.Of(TimeSpan.FromSeconds(Utils.updatedRefreshTtl)));
await Task.Delay(2000);

CacheDictionaryGetFieldResponse response = await client.DictionaryGetFieldAsync(cacheName, dictionaryName, field);
Expand Down Expand Up @@ -538,11 +538,11 @@ public async Task DictionarySetFieldsAsync_FieldsAreStringValuesAreString_NoRefr
var value = Utils.NewGuidString();
var content = new Dictionary<string, string>() { { field, value } };

await client.DictionarySetFieldsAsync(cacheName, dictionaryName, content, ttl: CollectionTtl.Of(TimeSpan.FromSeconds(5)));
await Task.Delay(100);
await client.DictionarySetFieldsAsync(cacheName, dictionaryName, content, ttl: CollectionTtl.Of(TimeSpan.FromSeconds(Utils.initialRefreshTtl)));
await Task.Delay(Utils.waitForItemToBeSet);

await client.DictionarySetFieldsAsync(cacheName, dictionaryName, content, ttl: CollectionTtl.Of(TimeSpan.FromSeconds(10)).WithNoRefreshTtlOnUpdates());
await Task.Delay(4900);
await client.DictionarySetFieldsAsync(cacheName, dictionaryName, content, ttl: CollectionTtl.Of(TimeSpan.FromSeconds(Utils.updatedRefreshTtl)).WithNoRefreshTtlOnUpdates());
await Task.Delay(Utils.waitForInitialItemToExpire);

CacheDictionaryGetFieldResponse response = await client.DictionaryGetFieldAsync(cacheName, dictionaryName, field);
Assert.True(response is CacheDictionaryGetFieldResponse.Miss, $"Unexpected response: {response}");
Expand All @@ -557,7 +557,7 @@ public async Task DictionarySetFieldsAsync_FieldsAreStringValuesAreString_Refres
var content = new Dictionary<string, string>() { { field, value } };

await client.DictionarySetFieldsAsync(cacheName, dictionaryName, content, ttl: CollectionTtl.Of(TimeSpan.FromSeconds(2)));
await client.DictionarySetFieldsAsync(cacheName, dictionaryName, content, ttl: CollectionTtl.Of(TimeSpan.FromSeconds(10)));
await client.DictionarySetFieldsAsync(cacheName, dictionaryName, content, ttl: CollectionTtl.Of(TimeSpan.FromSeconds(Utils.updatedRefreshTtl)));
await Task.Delay(2000);

CacheDictionaryGetFieldResponse response = await client.DictionaryGetFieldAsync(cacheName, dictionaryName, field);
Expand Down Expand Up @@ -616,11 +616,11 @@ public async Task DictionarySetFieldsAsync_FieldsAreStringValuesAreByteArray_NoR
var value = Utils.NewGuidByteArray();
var content = new Dictionary<string, byte[]>() { { field, value } };

await client.DictionarySetFieldsAsync(cacheName, dictionaryName, content, ttl: CollectionTtl.Of(TimeSpan.FromSeconds(5)).WithNoRefreshTtlOnUpdates());
await Task.Delay(100);
await client.DictionarySetFieldsAsync(cacheName, dictionaryName, content, ttl: CollectionTtl.Of(TimeSpan.FromSeconds(Utils.initialRefreshTtl)).WithNoRefreshTtlOnUpdates());
await Task.Delay(Utils.waitForItemToBeSet);

await client.DictionarySetFieldsAsync(cacheName, dictionaryName, content, ttl: CollectionTtl.Of(TimeSpan.FromSeconds(10)).WithNoRefreshTtlOnUpdates());
await Task.Delay(4900);
await client.DictionarySetFieldsAsync(cacheName, dictionaryName, content, ttl: CollectionTtl.Of(TimeSpan.FromSeconds(Utils.updatedRefreshTtl)).WithNoRefreshTtlOnUpdates());
await Task.Delay(Utils.waitForInitialItemToExpire);

CacheDictionaryGetFieldResponse response = await client.DictionaryGetFieldAsync(cacheName, dictionaryName, field);
Assert.True(response is CacheDictionaryGetFieldResponse.Miss, $"Unexpected response: {response}");
Expand All @@ -635,7 +635,7 @@ public async Task DictionarySetFieldsAsync_FieldsAreStringValuesAreByteArray_Ref
var content = new Dictionary<string, byte[]>() { { field, value } };

await client.DictionarySetFieldsAsync(cacheName, dictionaryName, content, ttl: CollectionTtl.Of(TimeSpan.FromSeconds(2)));
await client.DictionarySetFieldsAsync(cacheName, dictionaryName, content, ttl: CollectionTtl.Of(TimeSpan.FromSeconds(10)));
await client.DictionarySetFieldsAsync(cacheName, dictionaryName, content, ttl: CollectionTtl.Of(TimeSpan.FromSeconds(Utils.updatedRefreshTtl)));
await Task.Delay(2000);

CacheDictionaryGetFieldResponse response = await client.DictionaryGetFieldAsync(cacheName, dictionaryName, field);
Expand Down
Loading