Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: --pid=host tests #8

Merged
merged 2 commits into from
Nov 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions tests/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,16 @@ func Run(o *option.Option) {
})

ginkgo.It("should share PID namespace with host with --pid=host", func() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe that's (partly) addressed by #8 (comment)?

command.Run(o, "run", "-d", "--name", testContainerName, "--pid", "host", defaultImage, "sleep", "infinity")
processes := command.StdoutStr(o, "top", testContainerName)
pid := strings.Fields(processes)[9]
output := command.StdOutAsLines(o, "exec", "-d", testContainerName, "ps", "-o", "pid")
gomega.Expect(output).Should(gomega.ContainElement(pid))
command.Run(o, "run", "-d", "--name", testContainerName, "--pid=host", defaultImage, "sleep", "infinity")
pid := command.StdoutStr(o, "inspect", "--format", "{{.State.Pid}}", testContainerName)
command.Run(o, "exec", testContainerName, "sh", "-c", fmt.Sprintf("ps -o pid,comm | grep '%s sleep'", pid))
})

ginkgo.It("should share PID namespace with a container with --pid=container:<container>", func() {
command.Run(o, "run", "-d", "--name", testContainerName, defaultImage, "sleep", "infinity")
// We are joining the pid namespace that was "created" by testContainerName,
// so the pid=1 process will be the main process of testContainerName, which is `sleep`.
command.Run(o, "exec", testContainerName, "sh", "-c", "ps -o pid,comm | grep '1 sleep'")
})

ginkgo.When("running a container with network related flags", func() {
Expand Down