Permalink
Browse files

NCBC-190: Support bucket flushing

Change-Id: Ie945e6c36ad9936684d78b67e0eb260997f33014
Reviewed-on: http://review.couchbase.org/23660
Tested-by: Saakshi Manocha <saakshi.manocha@globallogic.com>
Reviewed-by: Saakshi Manocha <saakshi.manocha@globallogic.com>
  • Loading branch information...
1 parent 99fe073 commit 6d932ab001ea883294556c66773e81a1f72410a4 @johnzablocki johnzablocki committed with saakshimanocha Jan 2, 2013
@@ -13,6 +13,7 @@
using System.Text.RegularExpressions;
using Couchbase.Tests.Factories;
using Couchbase.Operations;
+using System.Configuration;
namespace Couchbase.Tests
{
@@ -235,28 +236,55 @@ public void When_Try_Getting_Invalid_Bucket_Web_Exception_Is_Not_Thrown()
}
- [Ignore("Restful flush has been delayed")]
[Test]
public void When_Flushing_Bucket_Data_Are_Removed()
{
+ var storedConfig = ConfigurationManager.GetSection("couchbase") as ICouchbaseClientConfiguration;
var config = new CouchbaseClientConfiguration();
- config.Urls.Add(new Uri("http://localhost:8091/pools/default"));
- config.Bucket = "default";
+ config.Bucket = "Bucket-" + DateTime.Now.Ticks;
+ config.Username = storedConfig.Username;
+ config.Password = storedConfig.Password;
+ config.Urls.Add(storedConfig.Urls[0]);
+
+ var cluster = new CouchbaseCluster(config);
+ cluster.CreateBucket(new Bucket
+ {
+ Name = config.Bucket,
+ AuthType = AuthTypes.Sasl,
+ BucketType = BucketTypes.Membase,
+ Quota = new Quota { RAM = 100 },
+ ReplicaNumber = ReplicaNumbers.Zero,
+ FlushOption = FlushOptions.Enabled
+ }
+ );
+
+ Bucket bucket = null;
+ for (int i = 0; i < 10; i++) //wait for bucket to be ready to accept ops
+ {
+ bucket = waitForBucket(config.Bucket);
+ if (bucket.Nodes.First().Status == "healthy") break;
+ Thread.Sleep(1000);
+ }
+
+ Assert.That(bucket, Is.Not.Null);
var client = new CouchbaseClient(config);
- var storeResult = client.ExecuteStore(StoreMode.Set, "SomeKey", "SomeValue");
- Assert.That(storeResult.Success, Is.True);
+ var storeResult = client.ExecuteStore(StoreMode.Set, "SomeKey", "SomeValue");
+ Assert.That(storeResult.Success, Is.True, "Message: " + storeResult.Message);
var getResult = client.ExecuteGet<string>("SomeKey");
Assert.That(getResult.Success, Is.True);
Assert.That(getResult.Value, Is.StringMatching("SomeValue"));
- _Cluster.FlushBucket("default");
+ cluster.FlushBucket(config.Bucket);
getResult = client.ExecuteGet<string>("SomeKey");
Assert.That(getResult.Success, Is.False);
Assert.That(getResult.Value, Is.Null);
+
+ _Cluster.DeleteBucket(config.Bucket);
+
}
/// <summary>
@@ -15,6 +15,8 @@ public class Bucket
public AuthTypes AuthType { get; set; }
+ public FlushOptions FlushOption { get; set; }
+
public int ProxyPort { get; set; }
public string Password { get; set; }
@@ -27,6 +27,12 @@ public enum ReplicaNumbers
Two,
Three
}
+
+ public enum FlushOptions
+ {
+ Disabled,
+ Enabled
+ }
}
#region [ License information ]
@@ -169,6 +169,7 @@ private string getCreateBucketQueryString(Bucket bucket, bool includeName = true
sb.AppendFormat("&authType={0}", Enum.GetName(typeof(AuthTypes), bucket.AuthType).ToLower()); ;
sb.AppendFormat("&bucketType={0}", Enum.GetName(typeof(BucketTypes), bucket.BucketType).ToLower());
sb.AppendFormat("&replicaNumber={0}", (short)bucket.ReplicaNumber);
+ sb.AppendFormat("&flushEnabled={0}", (short)bucket.FlushOption);
return sb.ToString();
}

0 comments on commit 6d932ab

Please sign in to comment.