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); }
protected virtual void RefreshClickedThreaded(object state) { DatabaseConnectionSettings settings = state as DatabaseConnectionSettings; DatabaseConnectionContext context = new DatabaseConnectionContext(settings); IDbFactory fac = DbFactoryService.GetDbFactory(settings.ProviderIdentifier); FakeConnectionPool pool = null; try { pool = new FakeConnectionPool(fac, fac.ConnectionProvider, context); pool.Initialize(); if (pool.HasErrors) { MessageService.ShowError(pool.Error); return; } ISchemaProvider prov = fac.CreateSchemaProvider(pool); DatabaseSchemaCollection databases = prov.GetDatabases(); DispatchService.GuiDispatch(delegate() { foreach (DatabaseSchema db in databases) { storeDatabases.AppendValues(db.Name); } }); isDatabaseListEmpty = databases.Count == 0; } catch { } finally { if (pool != null) { pool.Close(); } } if (isDatabaseListEmpty) { DispatchService.GuiDispatch(delegate() { storeDatabases.AppendValues(AddinCatalog.GetString("No databases found!")); }); } else { DispatchService.GuiDispatch(delegate() { TreeIter iter; if (storeDatabases.GetIterFirst(out iter)) { comboDatabase.SetActiveIter(iter); } }); } }
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()); }
protected virtual void TestClickedThreaded(object state) { DatabaseConnectionSettings settings = state as DatabaseConnectionSettings; DatabaseConnectionContext context = new DatabaseConnectionContext(settings); IDbFactory fac = DbFactoryService.GetDbFactory(settings.ProviderIdentifier); bool success = false; string error = null; FakeConnectionPool pool = null; IPooledDbConnection conn = null; try { pool = new FakeConnectionPool(fac, fac.ConnectionProvider, context); success = pool.Initialize(); error = pool.Error; } catch (System.Data.DataException ex) { error = ex.Message; success = false; } finally { if (conn != null) { conn.Release(); conn.Dispose(); } if (pool != null) { pool.Close(); } } DispatchService.GuiDispatch(delegate() { buttonTest.Sensitive = true; if (success) { labelTest.Text = AddinCatalog.GetString("Test Succeeded."); } else { labelTest.Text = AddinCatalog.GetString("Test Failed: {0}.", error); } }); }
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_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 ioStrategy = new FakeIOStrategy(endPoint, connectionPool, false); var server = new Server(ioStrategy, 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); }