public void When_Connecting_To_Good_IP_Connection_Succeeds_Before_ConnectTimeout() { const int connectionTimedOut = 10060; string ipThatDoesExist = ConfigurationManager.AppSettings["OperationTestAddress"]; var ipEndpoint = UriExtensions.GetEndPoint(ipThatDoesExist); var connectionPoolConfig = new PoolConfiguration { ConnectTimeout = 5000 //set really low for test }; var connectionPool = new ConnectionPool <Connection>(connectionPoolConfig, ipEndpoint); IConnection connection = null; var stopWatch = new Stopwatch(); try { stopWatch.Start(); connection = connectionPool.Acquire(); } catch (SocketException e) { Assert.AreEqual(connectionTimedOut, e.ErrorCode); } finally { stopWatch.Stop(); Assert.IsNotNull(connection); Assert.IsTrue(connection.Socket.Connected); connection.Dispose(); } }
public void TestFixtureSetUp() { var ipEndpoint = UriExtensions.GetEndPoint(_address); var connectionPoolConfig = new PoolConfiguration(); _connectionPool = new ConnectionPool <Connection>(connectionPoolConfig, ipEndpoint); }
public void When_Connecting_To_Dead_IP_Connection_Fails_After_n_Seconds() { const int connectionTimedOut = 10060; const string ipThatDoesNotExist = "198.0.0.1:11210"; var ipEndpoint = UriExtensions.GetEndPoint(ipThatDoesNotExist); var connectionPoolConfig = new PoolConfiguration { ConnectTimeout = 1000 //set really low for test }; var connectionPool = new ConnectionPool <Connection>(connectionPoolConfig, ipEndpoint); var stopWatch = new Stopwatch(); try { stopWatch.Start(); var connection = connectionPool.Acquire(); } catch (SocketException e) { Assert.AreEqual(connectionTimedOut, e.ErrorCode); } finally { stopWatch.Stop(); Assert.AreEqual(1.0d, Math.Round((double)stopWatch.Elapsed.Seconds)); } }
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 = 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 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> { { "beer-sample", new BucketConfiguration { BucketName = "beer-sample", 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 ioStrategy = new FakeIOStrategy(UriExtensions.GetEndPoint(node.Hostname + ":" + node.KeyValue), new FakeConnectionPool(), false); using (var server = new Server(ioStrategy, node, configuration, config, new FakeTranscoder())) { var uri = server.GetBaseViewUri("beer-sample"); Assert.AreEqual(uri, "https://192.168.109.104:18092/beer-sample"); } }
public void When_Authentication_Fails_AuthenticationException_Or_ConnectionUnavailableException_Is_Thrown() { var authenticator = new CramMd5Mechanism(_ioStrategy, "authenticated", "secretw", new AutoByteConverter()); _ioStrategy.SaslMechanism = authenticator; //The first two iterations will throw auth exceptions and then a CUE; //you will never find yourself in an infinite loop waiting for connections that don't exist. int count = 0; while (count < 3) { count++; try { var config = new Config(new AutoByteConverter(), UriExtensions.GetEndPoint(Address)); var result = _ioStrategy.Execute(config); Console.WriteLine(result.Success); } catch (Exception e) { Console.WriteLine(e); var type = e.GetType(); if (type == typeof(AuthenticationException) || type == typeof(ConnectionUnavailableException)) { continue; } Assert.Fail(); } } Assert.Pass(); }
public void When_GetBaseViewUri_Is_Called_With_EncryptTraffic_False_Uri_Is_Not_SSL_URI() { 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.104")); var ioStrategy = new FakeIOStrategy(UriExtensions.GetEndPoint(node.Hostname + ":" + node.KeyValue), new FakeConnectionPool(), false); using (var server = new Server(ioStrategy, node, configuration, config, new FakeTranscoder())) { var uri = server.GetBaseViewUri("default"); Assert.AreEqual(uri, "http://192.168.109.104:8092/default"); } }
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_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 TestFixtureSetUp() { var ipEndpoint = UriExtensions.GetEndPoint(Address); var connectionPoolConfig = new PoolConfiguration(); _connectionPool = new ConnectionPool <Connection>(connectionPoolConfig, ipEndpoint); _ioStrategy = new DefaultIOStrategy(_connectionPool); }
public void TestGetEndpoint() { const string address = "192.168.56.101:11210"; var endpoint = UriExtensions.GetEndPoint(address); Assert.AreEqual(endpoint.Address.ToString(), "192.168.56.101"); Assert.AreEqual(endpoint.Port, 11210); }
public void OneTimeSetUp() { var ipEndpoint = UriExtensions.GetEndPoint(_address); var connectionPoolConfig = new PoolConfiguration(); _connectionPool = new ConnectionPool <Connection>(connectionPoolConfig, ipEndpoint); _ioService = new PooledIOService(_connectionPool); }
public void TestFixtureSetUp() { _endPoint = UriExtensions.GetEndPoint(Address); var connectionPoolConfig = new PoolConfiguration(); _connectionPool = new DefaultConnectionPool(connectionPoolConfig, _endPoint); _ioStrategy = new AwaitableIOStrategy(_connectionPool); }
public void SetUp() { _endPoint = UriExtensions.GetEndPoint(_address); CouchbaseClientSection section = (CouchbaseClientSection)ConfigurationManager.GetSection("couchbaseClients/couchbase"); _clientConfig = new ClientConfiguration(section); _clusterManager = new ClusterController(_clientConfig); }
public virtual void TestFixtureSetUp() { EndPoint = UriExtensions.GetEndPoint(Address); var connectionPoolConfig = new PoolConfiguration(); _connectionPool = new ConnectionPool <EapConnection>(connectionPoolConfig, EndPoint); _ioStrategy = new DefaultIOStrategy(_connectionPool); Transcoder = new DefaultTranscoder(Converter); }
public void SetUp() { var ipEndpoint = UriExtensions.GetEndPoint(_address); var factory = DefaultConnectionFactory.GetGeneric <Connection>(); _configuration = new PoolConfiguration(MaxSize, MinSize, WaitTimeout, RecieveTimeout, ShutdownTimeout, SendTimeout, ConnectTimeout, MaxConnectionAcquireCount, BucketName); _connectionPool = new ConnectionPool <Connection>(_configuration, ipEndpoint, factory, new DefaultConverter()); _connectionPool.Initialize(); }
public void TestFixtureSetUp() { var ipEndpoint = UriExtensions.GetEndPoint(Address); var connectionPoolConfig = new PoolConfiguration(); _connectionPool = new ConnectionPool <Connection>(connectionPoolConfig, ipEndpoint); _connectionPool.Initialize(); _ioService = new PooledIOService(_connectionPool, null); }
public void TestFixtureSetup() { _endPoint = UriExtensions.GetEndPoint(Address); var configuration = new ClientConfiguration(); var connectionPool = new ConnectionPool <EapConnection>(new PoolConfiguration(), UriExtensions.GetEndPoint(Address)); var ioStrategy = new DefaultIOStrategy(connectionPool); _server = new Server(ioStrategy, new Node(), configuration); }
public void OneTimeSetUp() { var ipEndpoint = UriExtensions.GetEndPoint(_address); var connectionPoolConfig = new PoolConfiguration { UseSsl = false }; _connectionPool = new ConnectionPool <Connection>(connectionPoolConfig, ipEndpoint); }
public void SetUp() { var ipEndpoint = UriExtensions.GetEndPoint(Address); var factory = DefaultConnectionFactory.GetDefault(); _configuration = new PoolConfiguration(MaxSize, MinSize, WaitTimeout, RecieveTimeout, ShutdownTimeout, SendTimeout); _connectionPool = new DefaultConnectionPool(_configuration, ipEndpoint, factory); _connectionPool.Initialize(); }
public virtual void TestFixtureSetUp() { EndPoint = UriExtensions.GetEndPoint(Address); var connectionPoolConfig = new PoolConfiguration(); _connectionPool = new ConnectionPool <Connection>(connectionPoolConfig, EndPoint); _ioService = new PooledIOService(_connectionPool); Transcoder = new DefaultTranscoder(); }
/// <summary> /// Gets an <see cref="IPEndPoint"/> instance for a given Node and <see cref="IBucketConfig"/> /// </summary> /// <param name="node"></param> /// <param name="bucketConfig"></param> /// <returns></returns> protected IPEndPoint GetEndPoint(Node node, IBucketConfig bucketConfig) { const string couchbasePort = "8091"; const string blah = "$HOST"; var address = node.Hostname.Replace(blah, bucketConfig.SurrogateHost); address = address.Replace(couchbasePort, node.Ports.Direct.ToString(CultureInfo.InvariantCulture)); return(UriExtensions.GetEndPoint(address)); }
public void TestFixtureSetUp() { var ipEndpoint = UriExtensions.GetEndPoint(_address); var connectionPoolConfig = new PoolConfiguration { UseSsl = false }; _connectionPool = new ConnectionPool <Connection>(connectionPoolConfig, ipEndpoint); _ioService = new PooledIOService(_connectionPool); }
public void TestFixtureSetup() { _endPoint = UriExtensions.GetEndPoint(_address); var configuration = new ClientConfiguration(); var connectionPool = new ConnectionPool <Connection>(new PoolConfiguration(), UriExtensions.GetEndPoint(_address)); var ioStrategy = new DefaultIOStrategy(connectionPool); _server = new Server(ioStrategy, new NodeAdapter(new Node(), new NodeExt()), configuration, new BucketConfig { Name = "default" }); }
public void TestFixtureSetUp() { var ipEndpoint = UriExtensions.GetEndPoint(Address); var connectionPoolConfig = new PoolConfiguration { UseSsl = true }; _connectionPool = new ConnectionPool <SslConnection>(connectionPoolConfig, ipEndpoint); _connectionPool.Initialize(); _ioStrategy = new DefaultIOStrategy(_connectionPool, null); }
public void TestFixtureSetUp() { var ipEndpoint = UriExtensions.GetEndPoint(_address.Replace("11210", "11207")); var connectionPoolConfig = new PoolConfiguration { UseSsl = true }; _connectionPool = new ConnectionPool <SslConnection>(connectionPoolConfig, ipEndpoint); _connectionPool.Initialize(); _ioService = new PooledIOService(_connectionPool, null); }
public void OneTimeSetUp() { var ipEndpoint = UriExtensions.GetEndPoint(_address.Replace("11210", "11207")); var connectionPoolConfig = new PoolConfiguration { UseSsl = true, Uri = new Uri(ConfigurationManager.AppSettings["bootstrapUrl"]) }; _connectionPool = new ConnectionPool <SslConnection>(connectionPoolConfig, ipEndpoint); _connectionPool.Initialize(); _ioService = new PooledIOService(_connectionPool, null); }
public void TestFixtureSetUp() { _endPoint = UriExtensions.GetEndPoint(_address); var connectionPoolConfig = new PoolConfiguration { MinSize = 1, MaxSize = 1 }; _connectionPool = new ConnectionPool <Connection>(connectionPoolConfig, _endPoint); _ioStrategy = new DefaultIOStrategy(_connectionPool); }