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

Improve error messages from failing tests #8225

Merged
merged 1 commit into from
Nov 4, 2020
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
28 changes: 11 additions & 17 deletions test/e2e/exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,12 @@ var _ = Describe("Podman exec", func() {
session := podmanTest.Podman([]string{"exec", "--env", "FOO=BAR", "test1", "printenv", "FOO"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
match, _ := session.GrepString("BAR")
Expect(match).Should(BeTrue())
Expect(session.OutputToString()).To(Equal("BAR"))

session = podmanTest.Podman([]string{"exec", "--env", "PATH=/bin", "test1", "printenv", "PATH"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
match, _ = session.GrepString("/bin")
Expect(match).Should(BeTrue())
Expect(session.OutputToString()).To(Equal("/bin"))
})

It("podman exec os.Setenv env", func() {
Expand All @@ -107,8 +105,7 @@ var _ = Describe("Podman exec", func() {
session := podmanTest.Podman([]string{"exec", "--env", "FOO", "test1", "printenv", "FOO"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
match, _ := session.GrepString("BAR")
Expect(match).Should(BeTrue())
Expect(session.OutputToString()).To(Equal("BAR"))
os.Unsetenv("FOO")
})

Expand Down Expand Up @@ -142,8 +139,7 @@ var _ = Describe("Podman exec", func() {
session := podmanTest.Podman([]string{"exec", "--interactive", "--tty", "test1", "/usr/bin/stty", "--all"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
match, _ := session.GrepString(" onlcr")
Expect(match).Should(BeTrue())
Expect(session.OutputToString()).To(ContainSubstring(" onlcr"))
})

It("podman exec simple command with user", func() {
Expand Down Expand Up @@ -199,14 +195,12 @@ var _ = Describe("Podman exec", func() {
session := podmanTest.Podman([]string{"exec", "--workdir", "/tmp", "test1", "pwd"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
match, _ := session.GrepString("/tmp")
Expect(match).Should(BeTrue())
Expect(session.OutputToString()).To(Equal("/tmp"))

session = podmanTest.Podman([]string{"exec", "-w", "/tmp", "test1", "pwd"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
match, _ = session.GrepString("/tmp")
Expect(match).Should(BeTrue())
Expect(session.OutputToString()).To(Equal("/tmp"))
})

It("podman exec missing working directory test", func() {
Expand Down Expand Up @@ -280,7 +274,7 @@ var _ = Describe("Podman exec", func() {
exec := podmanTest.Podman([]string{"exec", "-ti", ctrName2, "id"})
exec.WaitWithDefaultTimeout()
Expect(exec.ExitCode()).To(Equal(0))
Expect(strings.Contains(exec.OutputToString(), fmt.Sprintf("%s(%s)", gid, groupName))).To(BeTrue())
Expect(exec.OutputToString()).To(ContainSubstring(fmt.Sprintf("%s(%s)", gid, groupName)))
Copy link
Member

Choose a reason for hiding this comment

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

Should this equal?

Copy link
Member Author

Choose a reason for hiding this comment

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

The output of id would at least also have the UID, so we can't just use Equal without further changes to the test.

Copy link
Member

Choose a reason for hiding this comment

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

I am fine with this, then.

})

It("podman exec preserves container groups with --user and --group-add", func() {
Expand All @@ -300,9 +294,9 @@ RUN useradd -u 1000 auser`
exec.WaitWithDefaultTimeout()
Expect(exec.ExitCode()).To(Equal(0))
output := exec.OutputToString()
Expect(strings.Contains(output, "4000(first)")).To(BeTrue())
Expect(strings.Contains(output, "4001(second)")).To(BeTrue())
Expect(strings.Contains(output, "1000(auser)")).To(BeTrue())
Expect(output).To(ContainSubstring("4000(first)"))
Expect(output).To(ContainSubstring("4001(second)"))
Expect(output).To(ContainSubstring("1000(auser)"))

// Kill the container just so the test does not take 15 seconds to stop.
kill := podmanTest.Podman([]string{"kill", ctrName})
Expand All @@ -323,7 +317,7 @@ RUN useradd -u 1000 auser`
data := podmanTest.InspectContainer(ctrName)
Expect(len(data)).To(Equal(1))
Expect(len(data[0].ExecIDs)).To(Equal(1))
Expect(strings.Contains(exec1.OutputToString(), data[0].ExecIDs[0])).To(BeTrue())
Expect(exec1.OutputToString()).To(ContainSubstring(data[0].ExecIDs[0]))

exec2 := podmanTest.Podman([]string{"exec", "-t", "-i", ctrName, "ps", "-a"})
exec2.WaitWithDefaultTimeout()
Expand Down