Item doesn't expire in integration test
I'm trying to write integration tests for a wrapper we are developing around the v1.1.6 .NET client, but I am unable to get items to expire. Here is an example failing test using the raw CouchbaseClient
[Test]
public void DoesntExpire()
{
var client = new CouchbaseClient(_defaultConfig);
var key = Guid.NewGuid().ToString();
client.Store(StoreMode.Add, key, "test", DateTime.UtcNow.AddMilliseconds(10));
var value1 = client.Get(key);
Assert.That(value1, Is.EqualTo("test"));
Thread.Sleep(200); // Wait for expiration?
var value2 = client.Get(key);
Assert.That(value2, Is.Null);
}The second assert fails because the value returned is 'test' not null. Same problem for TimeSpan-based expiration.
Same issue with Couchbase 1.8
I seem to have got this working now using higher sleep periods (>1000ms).
We are still seeing this issue intermittently. The test stores an item with expiration set to 100ms in the future. We then wait for 2000ms and still in some cases the item is retrieved from Couchbase - example
[Test]
public void CanExpireSliding()
{
var key = Guid.NewGuid().ToString();
_client.Store(StoreMode.Add, key, "test", new TimeSpan(0, 0, 0, 0, 100));
var value = _client.Get(key);
Assert.That(value, Is.EqualTo("test"));
Thread.Sleep(2000);
value = _client.Get(key);
Assert.That(value, Is.Null);
}Can anybody comment on what the issue might be here? Even if the item hasn't been 'garbage-collected' internally (i.e. deleted from memory and/or disk), I wouldn't expect it to be returned by a Get operation after expiration has passed.
[Test]
public void CanExpireSliding()
{
var key = Guid.NewGuid().ToString();
_client.Store(StoreMode.Add, key, "test", new TimeSpan(0, 0, 0, 0, 100));
var value = _client.Get(key);
Assert.That(value, Is.EqualTo("test"));
Thread.Sleep(2000);
value = _client.Get(key);
Assert.That(value, Is.Null);
}Can anybody comment on what the issue might be here? Even if the item hasn't been 'garbage-collected' internally (i.e. deleted from memory and/or disk), I wouldn't expect it to be returned by a Get operation after expiration has passed.
I am having the same issue as above when using the 1.2.0 version of the client from NuGet. I have bumped up the sleep time and the tests fail 100% of the time.
I am currently running CouchBase Server 1.8.1. According to this page version 1.8.1 of CouchBase Server is compatible with version 1.2.0 of the .Net Client.
EDIT: Still having the same issue after updateing to Couchbase Server 2.0...
Additionally, I see that the NuGet package uses a baked in version of Enyim.Memcache instead of relying on a dependency (like it does for Hammock and Json.Net). Is there a specific reason for this?
[Test]
public void CanExpireSliding()
{
var key = Guid.NewGuid().ToString();
_client.Store(StoreMode.Add, key, "test", new TimeSpan(0, 0, 0, 0, 100));
var value = _client.Get(key);
Assert.That(value, Is.EqualTo("test"));
Thread.Sleep(2000);
value = _client.Get(key);
Assert.That(value, Is.Null);
}Can anybody comment on what the issue might be here? Even if the item hasn't been 'garbage-collected' internally (i.e. deleted from memory and/or disk), I wouldn't expect it to be returned by a Get operation after expiration has passed.
I am having the same issue as above when using the 1.2.0 version of the client from NuGet. I have bumped up the sleep time and the tests fail 100% of the time.
I am currently running CouchBase Server 1.8.1. According to this page version 1.8.1 of CouchBase Server is compatible with version 1.2.0 of the .Net Client.
EDIT: Still having the same issue after updateing to Couchbase Server 2.0...
Additionally, I see that the NuGet package uses a baked in version of Enyim.Memcache instead of relying on a dependency (like it does for Hammock and Json.Net). Is there a specific reason for this?
For what it's worth, I have resolved my issue, it was on my side. I had made the assumption that the two servers that I am running Couchbase Server had the correct time set which they did not. After setting the correct time on these servers, I re-ran the tests and they were successful.
Just realised that I'm running the 1.1.6 client against a Couchbase 2.0 Beta instance - possibly relevant?