Beispiel #1
0
        public void TestDefaultLoginTimeout()
        {
            using (IDbConnection conn = new MockSnowflakeDbConnection())
            {
                conn.ConnectionString = ConnectionString;

                // Default timeout is 15 min
                Assert.AreEqual(15 * 60, conn.ConnectionTimeout);

                Assert.AreEqual(conn.State, ConnectionState.Closed);
                try
                {
                    Stopwatch stopwatch = Stopwatch.StartNew();
                    conn.Open();
                    stopwatch.Stop();
                    //Should timeout after the default timeout (15min)
                    Assert.GreaterOrEqual(stopwatch.ElapsedMilliseconds, 15 * 60 * 1000);
                    Assert.Fail();
                }
                catch (AggregateException e)
                {
                    Assert.AreEqual(SFError.REQUEST_TIMEOUT.GetAttribute <SFErrorAttr>().errorCode,
                                    ((SnowflakeDbException)e.InnerException).ErrorCode);
                }
            }
        }
Beispiel #2
0
        public void TestLoginTimeout()
        {
            using (IDbConnection conn = new MockSnowflakeDbConnection())
            {
                int    timeoutSec       = 5;
                string loginTimeOut5sec = String.Format(ConnectionString + "connection_timeout={0}",
                                                        timeoutSec);

                conn.ConnectionString = loginTimeOut5sec;

                Assert.AreEqual(conn.State, ConnectionState.Closed);
                try
                {
                    Stopwatch stopwatch = Stopwatch.StartNew();
                    conn.Open();
                    stopwatch.Stop();
                    Assert.Fail();
                    //Should timeout before the default timeout (15min) * 60 * 1000
                    Assert.Less(stopwatch.ElapsedMilliseconds, 15 * 60 * 1000);
                    // Should timeout after the defined connection timeout
                    Assert.GreaterOrEqual(stopwatch.ElapsedMilliseconds, timeoutSec * 1000);
                }
                catch (AggregateException e)
                {
                    Assert.AreEqual(SFError.REQUEST_TIMEOUT.GetAttribute <SFErrorAttr>().errorCode,
                                    ((SnowflakeDbException)e.InnerException).ErrorCode);
                }
                Assert.AreEqual(5, conn.ConnectionTimeout);
            }
        }
Beispiel #3
0
        public void TestDefaultLoginTimeout()
        {
            using (IDbConnection conn = new MockSnowflakeDbConnection())
            {
                conn.ConnectionString = ConnectionString;

                // Default timeout is 120 sec
                Assert.AreEqual(120, conn.ConnectionTimeout);

                Assert.AreEqual(conn.State, ConnectionState.Closed);
                Stopwatch stopwatch = Stopwatch.StartNew();
                try
                {
                    conn.Open();
                    Assert.Fail();
                }
                catch (AggregateException e)
                {
                    Assert.AreEqual(SFError.REQUEST_TIMEOUT.GetAttribute <SFErrorAttr>().errorCode,
                                    ((SnowflakeDbException)e.InnerException).ErrorCode);
                }
                stopwatch.Stop();
                // Should timeout after the default timeout (120 sec)
                Assert.GreaterOrEqual(stopwatch.ElapsedMilliseconds, 120 * 1000);
                // But never more than 16 sec (max backoff) after the default timeout
                Assert.LessOrEqual(stopwatch.ElapsedMilliseconds, (120 + 16) * 1000);
            }
        }