Beispiel #1
0
 public void SSHRecoverNullConnection()
 {
     using (var c = new SSHRecoveringConnection(() => (ISSHConnection)null))
     {
         c.ExecuteLinuxCommand("ls");
     }
 }
Beispiel #2
0
 public void SSHRecoverUsername()
 {
     using (var c = new SSHRecoveringConnection(() => new dummyConnection()))
     {
         Assert.AreEqual("myname", c.UserName);
     }
 }
Beispiel #3
0
        public void SSHRecoverFailsConnectionSSHConnectionDroppedException()
        {
            var maker = new dummyConnectionMaker(failExecuteCommandForNTimes: 1, genException: () => new SSHConnectionDroppedException());

            using (var c = new SSHRecoveringConnection(() => maker.Execute()))
            {
                c.RetryWaitPeriod = TimeSpan.FromMilliseconds(5);
                c.ExecuteLinuxCommand("ls");
                Assert.AreEqual(3, dummyConnection.CalledExecuteLinuxCommand);
            }
            Assert.AreEqual(2, dummyConnection.DisposedCalled);
        }
Beispiel #4
0
        public void SSHRecoverRegularConnection()
        {
            var maker = new dummyConnectionMaker();

            using (var c = new SSHRecoveringConnection(() => maker.Execute()))
            {
                Assert.AreEqual(0, dummyConnection.DisposedCalled);
                c.ExecuteLinuxCommand("ls");
                Assert.AreEqual(2, dummyConnection.CalledExecuteLinuxCommand);
            }
            Assert.AreEqual(1, dummyConnection.DisposedCalled);
        }
Beispiel #5
0
        public void SSHRecoverNoRecover()
        {
            var maker = new dummyConnectionMaker(failExecuteCommandForNTimes: 1);

            using (var c = new SSHRecoveringConnection(() => maker.Execute()))
            {
                c.RetryWaitPeriod = TimeSpan.FromMilliseconds(1);
                using (var blocker = c.EnterNoRecoverRegion())
                {
                    c.ExecuteLinuxCommand("ls");
                }
            }
            Assert.AreEqual(1, dummyConnection.DisposedCalled);
            Assert.AreEqual(1, dummyConnection.CTorCalls);
        }
Beispiel #6
0
        public void SSHRecoverMakeSureCommandRetriedOnException()
        {
            var maker = new dummyConnectionMaker(failExecuteCommandForNTimes: 1);

            using (var c = new SSHRecoveringConnection(() => maker.Execute()))
            {
                c.RetryWaitPeriod = TimeSpan.FromMilliseconds(5);
                try
                {
                    c.ExecuteLinuxCommand("ls");
                }
                catch { }
                Assert.AreEqual(2, dummyConnection.ListOfCommands.Count());
                Assert.AreEqual("ls", dummyConnection.ListOfCommands[0]);
            }
            Assert.AreEqual(2, dummyConnection.DisposedCalled);
        }