forked from kata-containers/ci
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request kata-containers#78 from chavafg/topic/top_terminal…
…_tests tests: Add terminal and top tests
- Loading branch information
Showing
2 changed files
with
91 additions
and
0 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
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:]]`)) | ||
}) | ||
}) | ||
}) | ||
}) |
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 |
---|---|---|
@@ -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)) | ||
}) | ||
}) | ||
}) |