Skip to content

Commit

Permalink
Merge pull request kata-containers#78 from chavafg/topic/top_terminal…
Browse files Browse the repository at this point in the history
…_tests

tests: Add terminal and top tests
  • Loading branch information
GabyCT authored Feb 16, 2018
2 parents e71d23d + a578b22 commit a3de611
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 0 deletions.
51 changes: 51 additions & 0 deletions integration/docker/terminal_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright (c) 2018 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0

package docker

import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)

var _ = Describe("terminal", func() {
var (
id string
)

BeforeEach(func() {
id = randomDockerName()
})

AfterEach(func() {
Expect(RemoveDockerContainer(id)).To(BeTrue())
Expect(ExistDockerContainer(id)).NotTo(BeTrue())
})

Describe("terminal with docker", func() {
Context("TERM env variable is set when allocating a tty", func() {
It("should display the terminal's name", func() {
stdout, _, exitCode := dockerRun("--name", id, "-t", Image, "env")
Expect(exitCode).To(Equal(0))
Expect(stdout).To(MatchRegexp("TERM=" + `[[:alnum:]]`))
})
})

Context("TERM env variable is not set when not allocating a tty", func() {
It("should not display the terminal's name", func() {
stdout, _, exitCode := dockerRun("--name", id, Image, "env")
Expect(exitCode).To(Equal(0))
Expect(stdout).NotTo(ContainSubstring("TERM"))
})
})

Context("Check that pseudo tty is setup properly when allocating a tty", func() {
It("should display the pseudo tty's name", func() {
stdout, _, exitCode := dockerRun("--name", id, "-t", Image, "tty")
Expect(exitCode).To(Equal(0))
Expect(stdout).To(MatchRegexp("/dev/pts/" + `[[:alnum:]]`))
})
})
})
})
40 changes: 40 additions & 0 deletions integration/docker/top_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright (c) 2018 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0

package docker

import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)

var _ = Describe("docker top", func() {
var (
id string
stdout string
workload string
exitCode int
)

BeforeEach(func() {
id = randomDockerName()
workload = "sleep 10"
_, _, exitCode = dockerRun("--name", id, "-d", Image, "sh", "-c", workload)
Expect(exitCode).To(Equal(0))
})

AfterEach(func() {
Expect(RemoveDockerContainer(id)).To(BeTrue())
Expect(ExistDockerContainer(id)).NotTo(BeTrue())
})

Context("check docker top functionality", func() {
It("should print usage statement", func() {
Skip("Issue: https://github.com/clearcontainers/runtime/issues/876")
stdout, _, exitCode = dockerTop(id, "-x")
Expect(exitCode).To(Equal(0))
Expect(stdout).To(ContainSubstring(workload))
})
})
})

0 comments on commit a3de611

Please sign in to comment.