-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Keep Alive for non-interactive sessions
[#101789464] Signed-off-by: Andrew Edgar <[email protected]>
- Loading branch information
1 parent
b5ed976
commit b88aead
Showing
3 changed files
with
49 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1159,6 +1159,7 @@ var _ = Describe("Diego SSH Plugin", func() { | |
|
||
Describe("Wait", func() { | ||
var opts *options.SSHOptions | ||
var waitErr error | ||
|
||
BeforeEach(func() { | ||
opts = &options.SSHOptions{ | ||
|
@@ -1176,14 +1177,52 @@ var _ = Describe("Diego SSH Plugin", func() { | |
JustBeforeEach(func() { | ||
connectErr := secureShell.Connect(opts) | ||
Expect(connectErr).NotTo(HaveOccurred()) | ||
}) | ||
|
||
It("calls close on the secureClient", func() { | ||
err := secureShell.Wait() | ||
Expect(err).NotTo(HaveOccurred()) | ||
waitErr = secureShell.Wait() | ||
}) | ||
|
||
It("calls wait on the secureClient", func() { | ||
Expect(waitErr).NotTo(HaveOccurred()) | ||
Expect(fakeSecureClient.WaitCallCount()).To(Equal(1)) | ||
}) | ||
|
||
Describe("keep alive messages", func() { | ||
var times []time.Time | ||
var timesCh chan []time.Time | ||
var done chan struct{} | ||
|
||
BeforeEach(func() { | ||
keepAliveDuration = 100 * time.Millisecond | ||
|
||
times = []time.Time{} | ||
timesCh = make(chan []time.Time, 1) | ||
done = make(chan struct{}, 1) | ||
|
||
fakeConnection.SendRequestStub = func(reqName string, wantReply bool, message []byte) (bool, []byte, error) { | ||
Expect(reqName).To(Equal("[email protected]")) | ||
Expect(wantReply).To(BeTrue()) | ||
Expect(message).To(BeNil()) | ||
|
||
times = append(times, time.Now()) | ||
if len(times) == 3 { | ||
timesCh <- times | ||
close(done) | ||
} | ||
return true, nil, nil | ||
} | ||
|
||
fakeSecureClient.WaitStub = func() error { | ||
Eventually(done).Should(BeClosed()) | ||
return nil | ||
} | ||
}) | ||
|
||
It("sends keep alive messages at the expected interval", func() { | ||
Expect(waitErr).NotTo(HaveOccurred()) | ||
times := <-timesCh | ||
Expect(times[2]).To(BeTemporally("~", times[0].Add(200*time.Millisecond), 100*time.Millisecond)) | ||
}) | ||
}) | ||
}) | ||
|
||
Describe("Close", func() { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters