public void When_GetBaseViewUri_Is_Called_With_EncryptTraffic_True_Uri_Is_SSL_URI() { var configuration = new ClientConfiguration { UseSsl = true }; configuration.Initialize(); var json = ResourceHelper.ReadResource(@"Data\Configuration\cb4-config-4-nodes.json"); var config = JsonConvert.DeserializeObject <BucketConfig>(json); var nodes = config.GetNodes(); var node = nodes.Find(x => x.Hostname.Equals("192.168.109.104")); var ioService = new FakeIOService(UriExtensions.GetEndPoint(node.Hostname + ":" + node.KeyValue), new FakeConnectionPool(), false); using (var server = new Server(ioService, node, configuration, config, new FakeTranscoder())) { var uri = server.CachedViewBaseUri; Assert.AreEqual("https://192.168.109.104:18092/default/", uri.ToString()); } }
public void When_UseSsl_Is_True_Use_HTTP_Protocol() { var configuration = new ClientConfiguration { BucketConfigs = new Dictionary <string, BucketConfiguration> { { "default", new BucketConfiguration { BucketName = "default", UseSsl = true, Port = 18092 } } } }; var json = ResourceHelper.ReadResource(@"Data\Configuration\cb4-config-4-nodes.json"); var config = JsonConvert.DeserializeObject <BucketConfig>(json); var nodes = config.GetNodes(); var node = nodes.Find(x => x.Hostname.Equals("192.168.109.104")); var ioService = new FakeIOService(UriExtensions.GetEndPoint(node.Hostname + ":" + node.KeyValue), new FakeConnectionPool(), false); using (var server = new Server(ioService, node, configuration, config, new FakeTranscoder())) { var uri = server.CachedViewBaseUri; Assert.AreEqual("https://192.168.109.104:18092/default/", uri.ToString()); } }
public void When_IOErrorThreshold_Is_Met_By_IOErrorInterval_IsDead_Returns_True() { var json = ResourceHelper.ReadResource(@"Data\Configuration\nodesext-cb-beta-4.json"); var config = JsonConvert.DeserializeObject <BucketConfig>(json); var node = config.GetNodes().First(); var endPoint = UriExtensions.GetEndPoint(_address); var configuration = new ClientConfiguration { IOErrorThreshold = 10, IOErrorCheckInterval = 100 }; var connectionPool = new FakeConnectionPool(); var ioService = new FakeIOService(endPoint, connectionPool, false); var server = new Server(ioService, node, configuration, config, new FakeTranscoder()); Assert.IsFalse(server.IsDown); var stopWatch = new Stopwatch(); stopWatch.Start(); for (int i = 0; i < 11; i++) { server.CheckOnline(true); Console.WriteLine("{0}=>{1}", server.IsDown, server.IOErrorCount); Thread.Sleep(10); } Console.WriteLine(stopWatch.ElapsedMilliseconds); Assert.IsTrue(server.IsDown); Assert.AreEqual(0, server.IOErrorCount); }
public void SetUp() { var configuration = new ClientConfiguration { UseSsl = true }; configuration.Initialize(); var json = ResourceHelper.ReadResource(@"Data\Configuration\cb4-config-4-nodes.json"); var config = JsonConvert.DeserializeObject<BucketConfig>(json); var nodes = config.GetNodes(); var node = nodes.Find(x => x.Hostname.Equals("192.168.109.104")); var ioService = new FakeIOService(UriExtensions.GetEndPoint(node.Hostname + ":" + node.KeyValue), new FakeConnectionPool(), false); _configContext = new CouchbaseConfigContext(config, configuration, pool => ioService, (c, e) => new FakeConnectionPool(), SaslFactory.GetFactory(), new DefaultTranscoder(new DefaultConverter())); _configContext.LoadConfig(); }
public void When_Node_Supports_Index_Queries_IsIndexNode_Is_True() { var configuration = new ClientConfiguration { UseSsl = false }; configuration.Initialize(); var json = ResourceHelper.ReadResource(@"Data\Configuration\cb4-config-4-nodes.json"); var config = JsonConvert.DeserializeObject <BucketConfig>(json); var nodes = config.GetNodes(); var node = nodes.Find(x => x.Hostname.Equals("192.168.109.102")); var ioService = new FakeIOService(UriExtensions.GetEndPoint(node.Hostname + ":" + node.KeyValue), new FakeConnectionPool(), false); var server = new Server(ioService, node, configuration, config, new FakeTranscoder()); Assert.IsFalse(server.IsQueryNode); Assert.IsTrue(server.IsMgmtNode); Assert.IsTrue(server.IsIndexNode); Assert.IsFalse(server.IsDataNode); Assert.IsFalse(server.IsViewNode); }
public void When_GetBaseViewUri_Is_Called_With_EncryptTraffic_True_Uri_Is_SSL_URI() { var configuration = new ClientConfiguration { UseSsl = true }; configuration.Initialize(); var json = File.ReadAllText(@"Data\\Configuration\\cb4-config-4-nodes.json"); var config = JsonConvert.DeserializeObject<BucketConfig>(json); var nodes = config.GetNodes(); var node = nodes.Find(x => x.Hostname.Equals("192.168.109.104")); var ioService = new FakeIOService(UriExtensions.GetEndPoint(node.Hostname + ":" + node.KeyValue), new FakeConnectionPool(), false); using (var server = new Server(ioService, node, configuration, config, new FakeTranscoder())) { var uri = server.CachedViewBaseUri; Assert.AreEqual("https://192.168.109.104:18092/default/", uri.ToString()); } }
public void SetUp() { var configuration = new ClientConfiguration { UseSsl = true }; configuration.Initialize(); var json = File.ReadAllText(@"Data\\Configuration\\cb4-config-4-nodes.json"); var config = JsonConvert.DeserializeObject <BucketConfig>(json); var nodes = config.GetNodes(); var node = nodes.Find(x => x.Hostname.Equals("192.168.109.104")); var ioService = new FakeIOService(UriExtensions.GetEndPoint(node.Hostname + ":" + node.KeyValue), new FakeConnectionPool(), false); _configContext = new CouchbaseConfigContext(config, configuration, pool => ioService, (c, e) => new FakeConnectionPool(), SaslFactory.GetFactory(), new DefaultTranscoder(new DefaultConverter())); _configContext.LoadConfig(); }
public void OneTimeSetUp() { var json = ResourceHelper.ReadResource(@"Data\Configuration\nodesext-cb-beta-4.json"); var bucketConfig = JsonConvert.DeserializeObject <BucketConfig>(json); var node = bucketConfig.GetNodes().First(); _endPoint = UriExtensions.GetEndPoint(_address); var connectionPool = new FakeConnectionPool(); var ioService = new FakeIOService(_endPoint, connectionPool, false); _server = new Server(ioService, node, new FakeTranscoder(), ContextFactory.GetCouchbaseContext(bucketConfig)); }
public void TestFixtureSetup() { var json = File.ReadAllText(@"Data\\Configuration\\nodesext-cb-beta-4.json"); var config = JsonConvert.DeserializeObject<BucketConfig>(json); var node = config.GetNodes().First(); _endPoint = UriExtensions.GetEndPoint(_address); var configuration = new ClientConfiguration(); var connectionPool = new FakeConnectionPool(); var ioService = new FakeIOService(_endPoint, connectionPool, false); _server = new Server(ioService, node, configuration, config, new FakeTranscoder()); }
public void TestFixtureSetup() { var json = File.ReadAllText(@"Data\\Configuration\\nodesext-cb-beta-4.json"); var config = JsonConvert.DeserializeObject <BucketConfig>(json); var node = config.GetNodes().First(); _endPoint = UriExtensions.GetEndPoint(_address); var configuration = new ClientConfiguration(); var connectionPool = new FakeConnectionPool(); var ioService = new FakeIOService(_endPoint, connectionPool, false); _server = new Server(ioService, node, configuration, config, new FakeTranscoder()); }
public void When_IOErrorThreshold_IsNot_Met_By_IOErrorInterval_NodeUnavailableException_Is_Thrown() { var json = ResourceHelper.ReadResource(@"Data\Configuration\nodesext-cb-beta-4.json"); var config = JsonConvert.DeserializeObject <BucketConfig>(json); var node = config.GetNodes().First(); var endPoint = UriExtensions.GetEndPoint(_address); var configuration = new ClientConfiguration { IOErrorThreshold = 10, IOErrorCheckInterval = 100 }; var connectionPool = new FakeConnectionPool(); var ioService = new FakeIOService(endPoint, connectionPool, false); var server = new Server(ioService, node, configuration, config, new FakeTranscoder()); Assert.IsFalse(server.IsDown); var stopWatch = new Stopwatch(); stopWatch.Start(); for (int i = 0; i < 11; i++) { server.CheckOnline(true); Console.WriteLine("{0}=>{1}", server.IsDown, server.IOErrorCount); Thread.Sleep(10); } // ReSharper disable once ThrowingSystemException Assert.Throws <NodeUnavailableException>(() => { var operation = new FakeOperation(new DefaultTranscoder()); server.Send(operation); throw operation.Exception; }); }
public void When_UseSsl_Is_True_Use_HTTP_Protocol() { var configuration = new ClientConfiguration { BucketConfigs = new Dictionary<string, BucketConfiguration> { {"default", new BucketConfiguration{BucketName = "default", UseSsl = true, Port = 18092}} } }; var json = File.ReadAllText(@"Data\\Configuration\\cb4-config-4-nodes.json"); var config = JsonConvert.DeserializeObject<BucketConfig>(json); var nodes = config.GetNodes(); var node = nodes.Find(x => x.Hostname.Equals("192.168.109.104")); var ioService = new FakeIOService(UriExtensions.GetEndPoint(node.Hostname + ":" + node.KeyValue), new FakeConnectionPool(), false); using (var server = new Server(ioService, node, configuration, config, new FakeTranscoder())) { var uri = server.CachedViewBaseUri; Assert.AreEqual("https://192.168.109.104:18092/default/", uri.ToString()); } }
public void When_IOErrorThreshold_IsNot_Met_By_IOErrorInterval_NodeUnavailableException_Is_Thrown() { var json = File.ReadAllText(@"Data\\Configuration\\nodesext-cb-beta-4.json"); var config = JsonConvert.DeserializeObject<BucketConfig>(json); var node = config.GetNodes().First(); var endPoint = UriExtensions.GetEndPoint(_address); var configuration = new ClientConfiguration { IOErrorThreshold = 10, IOErrorCheckInterval = 100 }; var connectionPool = new FakeConnectionPool(); var ioService = new FakeIOService(endPoint, connectionPool, false); var server = new Server(ioService, node, configuration, config, new FakeTranscoder()); Assert.IsFalse(server.IsDown); var stopWatch = new Stopwatch(); stopWatch.Start(); for (int i = 0; i < 11; i++) { server.CheckOnline(true); Console.WriteLine("{0}=>{1}", server.IsDown, server.IOErrorCount); Thread.Sleep(10); } // ReSharper disable once ThrowingSystemException Assert.Throws<NodeUnavailableException>(() => { var operation = new FakeOperation(new DefaultTranscoder()); server.Send(operation); throw operation.Exception; }); }
public void When_IOErrorThreshold_IsNot_Met_Within_IOErrorInterval_IsDead_Returns_False() { var json = File.ReadAllText(@"Data\\Configuration\\nodesext-cb-beta-4.json"); var config = JsonConvert.DeserializeObject<BucketConfig>(json); var node = config.GetNodes().First(); var endPoint = UriExtensions.GetEndPoint(_address); var configuration = new ClientConfiguration { IOErrorThreshold = 10, IOErrorCheckInterval = 10 }; var connectionPool = new FakeConnectionPool(); var ioService = new FakeIOService(endPoint, connectionPool, false); var server = new Server(ioService, node, configuration, config, new FakeTranscoder()); Assert.IsFalse(server.IsDown); var stopWatch = new Stopwatch(); stopWatch.Start(); for (int i = 0; i < 11; i++) { server.CheckOnline(true); Console.WriteLine("{0}=>{1}", server.IsDown, server.IOErrorCount); } Console.WriteLine("Time elapsed {0}", stopWatch.ElapsedMilliseconds); stopWatch.Restart(); Assert.IsFalse(server.IsDown); Assert.AreEqual(0, server.IOErrorCount); }
public void When_Node_Supports_Index_Queries_IsIndexNode_Is_True() { var configuration = new ClientConfiguration { UseSsl = false }; configuration.Initialize(); var json = File.ReadAllText(@"Data\\Configuration\\cb4-config-4-nodes.json"); var config = JsonConvert.DeserializeObject<BucketConfig>(json); var nodes = config.GetNodes(); var node = nodes.Find(x => x.Hostname.Equals("192.168.109.102")); var ioService = new FakeIOService(UriExtensions.GetEndPoint(node.Hostname + ":" + node.KeyValue), new FakeConnectionPool(), false); var server = new Server(ioService, node, configuration, config, new FakeTranscoder()); Assert.IsFalse(server.IsQueryNode); Assert.IsTrue(server.IsMgmtNode); Assert.IsTrue(server.IsIndexNode); Assert.IsFalse(server.IsDataNode); Assert.IsFalse(server.IsViewNode); }