Exemplo n.º 1
0
        public void TestMaxConnections()
        {
            var dbName = "test";
            var tableName = "CreateClientPerRequest";

            // make sure the db and table exists
            Assert.IsNotNull(Utils.GetOrCreateTableAndDatabase(new Client(Utils.GetConfigNodes()), dbName, tableName));

            Client.SetMaxConnections(10);

            for (var i = 0; i < 11; i++)
            {
                Client client = new Client(Utils.GetConfigNodes());
                client.SetGlobalTimeout(15000);
                client.SetMasterTimeout(10000);
                Database db = client.GetDatabase(dbName);
                Table table = db.GetTable(tableName);
                try
                {
                    table.Set("" + i, "" + i);
                    client.Submit();
                }
                catch (SDBPException e)
                {
                    Assert.IsTrue(i == 10 && e.Status == Status.SDBP_FAILURE);
                }
            }
        }
Exemplo n.º 2
0
        public void TestNoMasterException()
        {
            // This test is not working, because it always throws Status.SDBP_NOCONNECTION
            try
            {
                // ensure that there is no master
                Client client = new Client(new string[] { "192.168.2.118:7080", "192.168.2.119:7080", "192.168.2.120:7080" });
                client.SetMasterTimeout(5 * 1000);
                client.SetGlobalTimeout(10 * 1000);
                string configState = client.GetJSONConfigState();
            }
            catch (SDBPException e)
            {
                Assert.IsTrue(e.Status == Status.SDBP_NOMASTER);
                return;
            }

            Assert.Fail();
        }
Exemplo n.º 3
0
        public void TestNoPrimaryException()
        {
            try
            {
                // ensure that there is no master
                Client client = new Client(new string[] { "192.168.2.118:7080", "192.168.2.119:7080", "192.168.2.120:7080" });
                client.SetMasterTimeout(5 * 1000);
                client.SetGlobalTimeout(10 * 1000);
                Client.SetTrace(true);
                string configState = client.GetJSONConfigState();
                Database db = client.GetDatabase("test_db");
                Table table = db.GetTable("test_table");
                for (int i = 0; i < 100; i++)
                {
                    table.Set("a", "1");
                    client.Submit();
                    Thread.Sleep(500);
                }
            }
            catch (SDBPException e)
            {
                Assert.IsTrue(e.Status == Status.SDBP_FAILURE);
                return;
            }

            Assert.Fail();
        }
Exemplo n.º 4
0
        public void TestNoConnectionException()
        {
            try
            {
                // bad port
                Client client = new Client(new string[] { "127.0.0.1:1" });
                client.SetMasterTimeout(5 * 1000);
                client.SetGlobalTimeout(10 * 1000);
                string configState = client.GetJSONConfigState();
            }
            catch (SDBPException e)
            {
                Assert.IsTrue(e.Status == Status.SDBP_NOCONNECTION);
                return;
            }

            Assert.Fail();
        }