Skip to content

Commit

Permalink
Improved console test
Browse files Browse the repository at this point in the history
Ensure that a console connection is closed as soon as a new one is opened

Signed-off-by: Marc Sluiter <msluiter@redhat.com>
  • Loading branch information
slintes committed Oct 25, 2018
1 parent 6b4443c commit 2ac2b3d
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/console_test.go
Expand Up @@ -69,6 +69,13 @@ var _ = Describe("Console", func() {
Expect(err).ToNot(HaveOccurred())
}

OpenConsole := func(vmi *v1.VirtualMachineInstance) (expect.Expecter, <-chan error) {
By("Expecting the VirtualMachineInstance console")
expecter, errChan, err := tests.NewConsoleExpecter(virtClient, vmi, 30*time.Second)
Expect(err).ToNot(HaveOccurred())
return expecter, errChan
}

Describe("A new VirtualMachineInstance", func() {
Context("with a serial console", func() {
Context("with a cirros image", func() {
Expand Down Expand Up @@ -103,6 +110,31 @@ var _ = Describe("Console", func() {
}
}, 220)

It("should close console connection when new console connection is opened", func() {
vmi := tests.NewRandomVMIWithEphemeralDisk(tests.RegistryDiskFor(tests.RegistryDiskAlpine))

RunVMIAndWaitForStart(vmi)

By("opening 1st console connection")
expecter, errChan := OpenConsole(vmi)
defer expecter.Close()

By("expecting error on 1st console connection")
go func() {
defer GinkgoRecover()
select {
case receivedErr := <-errChan:
Expect(receivedErr.Error()).To(ContainSubstring("closed"))
case <-time.After(60 * time.Second):
Fail("timed out waiting for closed 1st connection")
}
}()

By("opening 2nd console connection")
ExpectConsoleOutput(vmi, "login")

}, 220)

It("should wait until the virtual machine is in running state and return a stream interface", func() {
vmi := tests.NewRandomVMIWithEphemeralDisk(tests.RegistryDiskFor(tests.RegistryDiskAlpine))
By("Creating a new VirtualMachineInstance")
Expand Down

0 comments on commit 2ac2b3d

Please sign in to comment.