Example #1
0
        public void ForceServerTCPTimeoutSlowClient()
        {
            string[] domains = TestStore.Default.Domains.ToArray();

            s_failureServer.Counters.InitWait(domains.Length);

            s_failureStore.SuccessInterval = 1; // Always succeed
            SetTimeout(100, false);

            foreach (string domain in domains)
            {
                using (BadTcpClient client = s_failureServer.CreateBadTcpClient())
                {
                    try
                    {
                        client.Connect();
                        client.SendLength(100);
                        client.SendSlowGarbage(100, 10);
                    }
                    catch
                    {
                    }
                }
            }

            Assert.DoesNotThrow(() => s_failureServer.Counters.Wait.WaitOne(20 * 1000));
            Assert.True(s_failureServer.Counters.IsConnectionBalanced);
        }
Example #2
0
        public void ConnectSendLengthAndDrop()
        {
            TestServer.Default.Counters.InitWait(DefaultIterations);
            Random rand = new Random();

            for (int i = 0; i < DefaultIterations; ++i)
            {
                BadTcpClient client = TestServer.Default.CreateBadTcpClient();
                client.Connect();
                client.SendLength((ushort)rand.Next(10, 60));
                client.Close();
            }

            Assert.Null(Record.Exception(() => TestServer.Default.Counters.Wait.WaitOne(DefaultWaitMs)));
            Assert.True(TestServer.Default.Counters.IsConnectionBalanced);
            Assert.True(TestServer.Default.AreMaxTcpAcceptsOutstanding());
        }
Example #3
0
        public void SendWrongSize()
        {
            TestServer.Default.Counters.InitWait(DefaultIterations);
            Random rand = new Random();

            for (int i = 0; i < DefaultIterations; ++i)
            {
                BadTcpClient client = TestServer.Default.CreateBadTcpClient();
                client.Connect();

                ushort length = (ushort)rand.Next(1, 60);
                client.SendLength(length);
                client.SendGarbage(rand.Next(1, 60));

                client.Close();
            }

            Assert.DoesNotThrow(() => TestServer.Default.Counters.Wait.WaitOne(DefaultWaitMs));
            Assert.True(TestServer.Default.Counters.IsConnectionBalanced);
            Assert.True(TestServer.Default.AreMaxTcpAcceptsOutstanding());
        }