Couchbase
  • Why NoSQL?
  • Couchbase Server
  • Download
  • Resources
  • Careers
Home | Forums | Couchbase | Couchbase Server 1.8.x

Item doesn't expire in integration test

6 replies [Last post]
  • Login or register to post comments
Tue, 11/27/2012 - 09:08
simonthorogood
Offline
Joined: 01/14/2011
Groups: None

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.

Top
  • Login or register to post comments
Tue, 11/27/2012 - 09:23
simonthorogood
Offline
Joined: 01/14/2011
Groups: None

Just realised that I'm running the 1.1.6 client against a Couchbase 2.0 Beta instance - possibly relevant?

Top
  • Login or register to post comments
Tue, 11/27/2012 - 10:03
simonthorogood
Offline
Joined: 01/14/2011
Groups: None

Same issue with Couchbase 1.8

Top
  • Login or register to post comments
Thu, 11/29/2012 - 08:24
simonthorogood
Offline
Joined: 01/14/2011
Groups: None

I seem to have got this working now using higher sleep periods (>1000ms).

Top
  • Login or register to post comments
Wed, 01/16/2013 - 02:35
simonthorogood
Offline
Joined: 01/14/2011
Groups: None

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.

Top
  • Login or register to post comments
Wed, 01/23/2013 - 14:48
robbygregory
Offline
Joined: 01/21/2013
Groups: None

simonthorogood wrote:
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.

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?

Top
  • Login or register to post comments
Thu, 01/31/2013 - 14:02
robbygregory
Offline
Joined: 01/21/2013
Groups: None

robbygregory wrote:
simonthorogood wrote:
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.

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.

Top
  • Login or register to post comments
  • Login or register to post comments
  • Login
  • Register

Company

  • About Us
  • Leadership
  • Customers
  • Partners
  • Contact Us

Product

  • Couchbase Server
  • Couchbase SDKs
  • Use Cases
  • Documentation
  • Forums

Open Source

  • Couchbase Project
  • Couchbase vs. CouchDB

Commercial

  • Subscriptions & Support
  • Training & Services

News

  • Blog
  • Newsletter
  • Press Releases
  • Buzz

Follow Us

    
  • Customer Login
  • Terms of Service
  • Privacy Policy
  • Trademark Policy
  • Site Map

© 2013 COUCHBASE All rights reserved.

Sign in to Couchbase Community

close
  • Create new account
  • Request new password
You are logging into the Forums, Wiki and Issue Tracker