public void Test_Insert_String() { using (var bucket = _cluster.OpenBucket("default")) { var response = bucket.Upsert(TestKeys.KeyWithStringValue.Key, TestKeys.KeyWithStringValue.Value); Assert.IsTrue(response.Success); } }
public void Test_Get_String() { using (var bucket = _cluster.OpenBucket("default")) { var response = bucket.Get <string>(TestKeys.KeyWithStringValue.Key); Assert.IsTrue(response.Success); Assert.AreEqual(TestKeys.KeyWithStringValue.Value, response.Value); } }
public void When_Observing_Key_During_Add_Durability_Constraint_Is_Reached() { var configuration = new ClientConfiguration { Servers = new List<Uri> { new Uri(ConfigurationManager.AppSettings["bootstrapUrl"]) } }; configuration.Initialize(); var provider = new CarrierPublicationProvider( configuration, (pool) => new DefaultIOStrategy(pool), (config, endpoint) => new ConnectionPool<EapConnection>(config, endpoint), SaslFactory.GetFactory3(), new AutoByteConverter(), new TypeSerializer(new AutoByteConverter())); var configInfo = provider.GetConfig("default"); ulong cas = 0; using (var cluster = new CouchbaseCluster(configuration)) { using (var bucket = cluster.OpenBucket()) { bucket.Remove("Test_Timeout_Add"); bucket.Insert("Test_Timeout_Add", ""); cas = bucket.Upsert("Test_Timeout_Add", "").Cas; } } var observer = new KeyObserver(configInfo, 10, 500); var constraintReached = observer.ObserveAdd("Test_Timeout_Add", cas, ReplicateTo.One, PersistTo.One); Assert.IsTrue(constraintReached); }
public void When_UseSsl_Is_False_At_Bucket_Level_Ssl_Is_Not_Used() { var remoteHost = ConfigurationManager.AppSettings["bootstrapUrl"]; var config = new ClientConfiguration { BucketConfigs = new Dictionary <string, BucketConfiguration> { { "beer-sample", new BucketConfiguration { UseSsl = false } } }, Servers = new List <Uri> { new Uri(remoteHost) } }; var cluster = new CouchbaseCluster(config); using (var bucket = cluster.OpenBucket("beer-sample")) { //only the customers bucket will not use SSL Assert.IsFalse(bucket.IsSecure); } }
public void Test_Timed_Execution_Parallel_Client() { var options = new ParallelOptions { MaxDegreeOfParallelism = 4 }; var n = 1000;//set to a higher # if needed using (var cluster = new CouchbaseCluster()) { using (var bucket = cluster.OpenBucket()) { using (new OperationTimer()) { var temp = bucket; Parallel.For(0, n, options, i => { var key = string.Format("key{0}", i); var result = temp.Upsert(key, i); Assert.IsTrue(result.Success); var result1 = temp.Get <int>(key); Assert.IsTrue(result1.Success); Assert.AreEqual(i, result1.Value); }); } } } }
static void Main(string[] args) { File.Delete(@"C:\temp\log.txt"); var config = new ClientConfiguration { Servers = new List <Uri> { new Uri("http://127.0.0.1:8091/pools") }, PoolConfiguration = new PoolConfiguration { MaxSize = 2, MinSize = 1 }, UseSsl = false }; using (_cluster = new CouchbaseCluster(config)) { using (var bucket = _cluster.OpenBucket("default")) { const int n = 100000; using (var timer = new OperationTimer()) { //ThreadPoolInsert(bucket, n); //ThreadPoolInsert(bucket, n); //SynchronousInsert(bucket, n); //ParallerInsert(bucket, n); MultiThreaded(8, n, bucket); } } } Console.Read(); }
public void TestFixtureSetUp() { _cluster = new CouchbaseCluster(); using (var bucket = _cluster.OpenBucket()) { bucket.Upsert(TestKeys.KeyWithInt32Value.Key, TestKeys.KeyWithInt32Value.Value); } }
public void TestFixtureSetUp() { _cluster = new CouchbaseCluster(); using (var bucket = _cluster.OpenBucket()) { bucket.Upsert(TestKeys.KeyWithInt32Value.Key, TestKeys.KeyWithInt32Value.Value); } }
public void When_Disposing_StreamingProvider_Worker_Thread_Does_Not_Hang_With_Bucket_Open() { //remove CCCP provider because we want to bootstrap off of the StreamingProvider var cccp = _clusterManager.ConfigProviders.Find(x => x is CarrierPublicationProvider); _clusterManager.ConfigProviders.Remove(cccp); var cluster = new CouchbaseCluster(_clientConfig, _clusterManager); var bucket = cluster.OpenBucket(); bucket.Dispose(); cluster.Dispose(); }
public void Get() { using (var cluster = new CouchbaseCluster()) { using (var bucket = cluster.OpenBucket()) { var key = string.Format("key{0}", 1); var result = bucket.Get<int>(key); Console.WriteLine(result.Value); } } }
public void Set() { using (var cluster = new CouchbaseCluster()) { using (var bucket = cluster.OpenBucket()) { var key = string.Format("key{0}", 1); var result = bucket.Upsert(key, 12); Console.WriteLine(result.Value); } } }
public void Test_UseSsl2() { var config = new ClientConfiguration { UseSsl = true }; var cluster = new CouchbaseCluster(config); using (var bucket = cluster.OpenBucket()) { //all buckets opened with this configuration will use SSL } }
public void When_Disposing_StreamingProvider_Worker_Thread_Does_Not_Hang_With_Bucket_Open_And_Closed() { //remove CCCP provider because we want to bootstrap off of the StreamingProvider var cccp = _clusterManager.ConfigProviders.Find(x => x is CarrierPublicationProvider); _clusterManager.ConfigProviders.Remove(cccp); var cluster = new CouchbaseCluster(_clientConfig, _clusterManager); var bucket = cluster.OpenBucket(); cluster.CloseBucket(bucket); cluster.Dispose(); }
public void When_Initialize_Called_With_AppConfig_Settings_Bucket_Can_Be_Opened() { using (var cluster = new CouchbaseCluster("couchbaseClients/couchbase")) { var bucket = cluster.OpenBucket(); Assert.AreEqual("default", bucket.Name); var result = bucket.Upsert("testkey", "testvalue"); Assert.IsTrue(result.Success); Assert.AreEqual(ResponseStatus.Success, result.Status); var result2 = bucket.Get <string>("testkey"); Assert.IsTrue(result2.Success); Assert.AreEqual(ResponseStatus.Success, result2.Status); Assert.AreEqual("testvalue", result2.Value); } }
public void Test_ClientConnection_With_Ssl() { var bootstrapUrl = ConfigurationManager.AppSettings["bootstrapUrl"]; var config = new ClientConfiguration { UseSsl = true, Servers = new List<Uri> { new Uri(bootstrapUrl) }}; config.Initialize(); var cluster = new CouchbaseCluster(config); using (var bucket = cluster.OpenBucket()) { Assert.IsNotNull(bucket); } }
public void Test_UseSsl3() { var config = new ClientConfiguration { BucketConfigs = new Dictionary <string, BucketConfiguration> { { "customers", new BucketConfiguration { UseSsl = true } } } }; var cluster = new CouchbaseCluster(config); using (var bucket = cluster.OpenBucket("customers")) { //only the customers bucket will use SSL } }
public void When_UseSsl_Is_False_At_Config_Level_Ssl_Is_Not_Used() { var remoteHost = ConfigurationManager.AppSettings["bootstrapUrl"]; var config = new ClientConfiguration() { UseSsl = false, Servers = new List <Uri> { new Uri(remoteHost) } }; var cluster = new CouchbaseCluster(config); using (var bucket = cluster.OpenBucket()) { //all buckets opened with this configuration will not use SSL Assert.IsFalse(bucket.IsSecure); } }
public void Test_ClientConnection_With_Ssl() { var config = new ClientConfiguration { UseSsl = true, Servers = new List <Uri> { new Uri("http://localhost:8091/pools") } }; config.Initialize(); var cluster = new CouchbaseCluster(config); using (var bucket = cluster.OpenBucket()) { Assert.IsNotNull(bucket); } }
public void Test_ClientConnection_With_Ssl() { var bootstrapUrl = ConfigurationManager.AppSettings["bootstrapUrl"]; var config = new ClientConfiguration { UseSsl = true, Servers = new List <Uri> { new Uri(bootstrapUrl) } }; config.Initialize(); var cluster = new CouchbaseCluster(config); using (var bucket = cluster.OpenBucket()) { Assert.IsNotNull(bucket); } }
public void When_InValid_Credentials_Provided_Bucket_Created_UnSuccesfully() { var config = new ClientConfiguration { Servers = new List<Uri> { new Uri("http://127.0.0.1:8091") }, BucketConfigs = new Dictionary<string, BucketConfiguration> { { "authenticated", new BucketConfiguration { BucketName = "authenticated" } } } }; var cluster = new CouchbaseCluster(config); var bucket = cluster.OpenBucket("authenticated", "secretw"); cluster.CloseBucket(bucket); Assert.IsNotNull(bucket); }
public void Test_Dispose_On_Many_Threads() { using (var cluster = new CouchbaseCluster()) { Random random = new Random(100); int n = 100; var options = new ParallelOptions { MaxDegreeOfParallelism = 4 }; Parallel.For(0, n, options, i => { try { using (IBucket bucket = cluster.OpenBucket()) { var key = "key_" + i; var set = bucket.Upsert(key, i); Console.WriteLine("Inserted {0}: {1} Thread: {2}", key, set.Success, Thread.CurrentThread.ManagedThreadId); var get = bucket.Get <int>(key); Console.WriteLine("Getting {0} - {1}: {2} Thread: {3}", key, get.Value, get.Success, Thread.CurrentThread.ManagedThreadId); var sleep = random.Next(0, 100); Console.WriteLine("Sleep for {0}ms", sleep); Thread.Sleep(sleep); } } catch (AggregateException ae) { ae.Flatten().Handle(e => { Console.WriteLine(e); return(true); }); } }); } }
public void When_Valid_Credentials_Provided_Bucket_Created_Succesfully() { var config = new ClientConfiguration { BucketConfigs = new Dictionary<string, BucketConfiguration> { { "authenticated", new BucketConfiguration { BucketName = "authenticated" } } } }; var cluster = new CouchbaseCluster(config); var bucket = cluster.OpenBucket("authenticated", "secret"); cluster.CloseBucket(bucket); Assert.IsNotNull(bucket); cluster.CloseBucket(bucket); }
public void When_Mutation_Happens_Observe_Fails() { var configuration = new ClientConfiguration { Servers = new List <Uri> { new Uri(ConfigurationManager.AppSettings["bootstrapUrl"]) } }; configuration.Initialize(); var provider = new CarrierPublicationProvider( configuration, (pool) => new DefaultIOStrategy(pool), (config, endpoint) => new ConnectionPool <EapConnection>(config, endpoint), SaslFactory.GetFactory3(), new AutoByteConverter(), new TypeSerializer(new AutoByteConverter())); var configInfo = provider.GetConfig("default"); ulong cas = 0; using (var cluster = new CouchbaseCluster(configuration)) { using (var bucket = cluster.OpenBucket()) { bucket.Remove("When_Mutation_Happens_Observe_Fails"); cas = bucket.Insert("When_Mutation_Happens_Observe_Fails", "").Cas; bucket.Upsert("When_Mutation_Happens_Observe_Fails", ""); } } var observer = new KeyObserver(configInfo, 10, 500); var constraintReached = observer.ObserveAdd("When_Mutation_Happens_Observe_Fails", cas, ReplicateTo.One, PersistTo.One); Assert.IsFalse(constraintReached); }
public void When_Valid_Credentials_Provided_Bucket_Created_Succesfully() { var config = new ClientConfiguration { BucketConfigs = new Dictionary <string, BucketConfiguration> { { "authenticated", new BucketConfiguration { BucketName = "authenticated" } } } }; var cluster = new CouchbaseCluster(config); var bucket = cluster.OpenBucket("authenticated", "secret"); cluster.CloseBucket(bucket); Assert.IsNotNull(bucket); cluster.CloseBucket(bucket); }
public void Test_Timeout_Add_PersistTo_Master() { var configuration = new ClientConfiguration { Servers = new List <Uri> { new Uri(ConfigurationManager.AppSettings["bootstrapUrl"]) } }; configuration.Initialize(); var provider = new CarrierPublicationProvider( configuration, (pool) => new DefaultIOStrategy(pool), (config, endpoint) => new ConnectionPool <EapConnection>(config, endpoint), SaslFactory.GetFactory3(), new AutoByteConverter(), new TypeSerializer(new AutoByteConverter())); var configInfo = provider.GetConfig("default"); using (var cluster = new CouchbaseCluster(configuration)) { using (var bucket = cluster.OpenBucket()) { bucket.Remove("Test_Timeout_Add_PersistTo_Master"); bucket.Insert("Test_Timeout_Add_PersistTo_Master", ""); } } var observer = new KeyObserver(configInfo, 10, 500); var constraintReached = observer.ObserveAdd("Test_Timeout_Add_PersistTo_Master", 0, ReplicateTo.Zero, PersistTo.Zero); Assert.IsTrue(constraintReached); }
public void When_InValid_Credentials_Provided_Bucket_Created_UnSuccesfully() { var config = new ClientConfiguration { Servers = new List <Uri> { new Uri("http://127.0.0.1:8091") }, BucketConfigs = new Dictionary <string, BucketConfiguration> { { "authenticated", new BucketConfiguration { BucketName = "authenticated" } } } }; var cluster = new CouchbaseCluster(config); var bucket = cluster.OpenBucket("authenticated", "secretw"); cluster.CloseBucket(bucket); Assert.IsNotNull(bucket); }
public void When_UseSsl_Is_False_At_Config_Level_Ssl_Is_Not_Used() { var remoteHost = ConfigurationManager.AppSettings["bootstrapUrl"]; var config = new ClientConfiguration() { UseSsl = false, Servers = new List<Uri> { new Uri(remoteHost) } }; var cluster = new CouchbaseCluster(config); using (var bucket = cluster.OpenBucket()) { //all buckets opened with this configuration will not use SSL Assert.IsFalse(bucket.IsSecure); } }
public void When_UseSsl_Is_False_At_Bucket_Level_Ssl_Is_Not_Used() { var remoteHost = ConfigurationManager.AppSettings["bootstrapUrl"]; var config = new ClientConfiguration { BucketConfigs = new Dictionary<string, BucketConfiguration> { {"beer-sample", new BucketConfiguration { UseSsl = false }} }, Servers = new List<Uri> { new Uri(remoteHost) } }; var cluster = new CouchbaseCluster(config); using (var bucket = cluster.OpenBucket("beer-sample")) { //only the customers bucket will not use SSL Assert.IsFalse(bucket.IsSecure); } }
public void Test_Timed_Execution_Parallel_Client() { var options = new ParallelOptions { MaxDegreeOfParallelism = 4 }; var n = 1000;//set to a higher # if needed using (var cluster = new CouchbaseCluster()) { using (var bucket = cluster.OpenBucket()) { using (new OperationTimer()) { var temp = bucket; Parallel.For(0, n, options, i => { var key = string.Format("key{0}", i); var result = temp.Upsert(key, i); Assert.IsTrue(result.Success); var result1 = temp.Get<int>(key); Assert.IsTrue(result1.Success); Assert.AreEqual(i, result1.Value); }); } } } }
public void Test_Dispose_On_Many_Threads() { using (var cluster = new CouchbaseCluster()) { Random random = new Random(100); int n = 100; var options = new ParallelOptions {MaxDegreeOfParallelism = 4}; Parallel.For(0, n, options, i => { try { using (IBucket bucket = cluster.OpenBucket()) { var key = "key_" + i; var set = bucket.Upsert(key, i); Console.WriteLine("Inserted {0}: {1} Thread: {2}", key, set.Success, Thread.CurrentThread.ManagedThreadId); var get = bucket.Get<int>(key); Console.WriteLine("Getting {0} - {1}: {2} Thread: {3}", key, get.Value, get.Success, Thread.CurrentThread.ManagedThreadId); var sleep = random.Next(0, 100); Console.WriteLine("Sleep for {0}ms", sleep); Thread.Sleep(sleep); } } catch (AggregateException ae) { ae.Flatten().Handle(e => { Console.WriteLine(e); return true; }); } }); } }
public void When_Initialize_Called_With_AppConfig_Settings_Bucket_Can_Be_Opened() { using (var cluster = new CouchbaseCluster("couchbaseClients/couchbase")) { var bucket = cluster.OpenBucket(); Assert.AreEqual("default", bucket.Name); var result = bucket.Upsert("testkey", "testvalue"); Assert.IsTrue(result.Success); Assert.AreEqual(ResponseStatus.Success, result.Status); var result2 = bucket.Get<string>("testkey"); Assert.IsTrue(result2.Success); Assert.AreEqual(ResponseStatus.Success, result2.Status); Assert.AreEqual("testvalue", result2.Value); } }