mirror of
https://github.com/containers/podman.git
synced 2025-06-20 00:51:16 +08:00
Merge pull request #8225 from debarshiray/wip/rishi/exec_test-use-containsubstring
Improve error messages from failing tests
This commit is contained in:
@ -87,14 +87,12 @@ var _ = Describe("Podman exec", func() {
|
|||||||
session := podmanTest.Podman([]string{"exec", "--env", "FOO=BAR", "test1", "printenv", "FOO"})
|
session := podmanTest.Podman([]string{"exec", "--env", "FOO=BAR", "test1", "printenv", "FOO"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session.ExitCode()).To(Equal(0))
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
match, _ := session.GrepString("BAR")
|
Expect(session.OutputToString()).To(Equal("BAR"))
|
||||||
Expect(match).Should(BeTrue())
|
|
||||||
|
|
||||||
session = podmanTest.Podman([]string{"exec", "--env", "PATH=/bin", "test1", "printenv", "PATH"})
|
session = podmanTest.Podman([]string{"exec", "--env", "PATH=/bin", "test1", "printenv", "PATH"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session.ExitCode()).To(Equal(0))
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
match, _ = session.GrepString("/bin")
|
Expect(session.OutputToString()).To(Equal("/bin"))
|
||||||
Expect(match).Should(BeTrue())
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman exec os.Setenv env", func() {
|
It("podman exec os.Setenv env", func() {
|
||||||
@ -107,8 +105,7 @@ var _ = Describe("Podman exec", func() {
|
|||||||
session := podmanTest.Podman([]string{"exec", "--env", "FOO", "test1", "printenv", "FOO"})
|
session := podmanTest.Podman([]string{"exec", "--env", "FOO", "test1", "printenv", "FOO"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session.ExitCode()).To(Equal(0))
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
match, _ := session.GrepString("BAR")
|
Expect(session.OutputToString()).To(Equal("BAR"))
|
||||||
Expect(match).Should(BeTrue())
|
|
||||||
os.Unsetenv("FOO")
|
os.Unsetenv("FOO")
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -142,8 +139,7 @@ var _ = Describe("Podman exec", func() {
|
|||||||
session := podmanTest.Podman([]string{"exec", "--interactive", "--tty", "test1", "/usr/bin/stty", "--all"})
|
session := podmanTest.Podman([]string{"exec", "--interactive", "--tty", "test1", "/usr/bin/stty", "--all"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session.ExitCode()).To(Equal(0))
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
match, _ := session.GrepString(" onlcr")
|
Expect(session.OutputToString()).To(ContainSubstring(" onlcr"))
|
||||||
Expect(match).Should(BeTrue())
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman exec simple command with user", func() {
|
It("podman exec simple command with user", func() {
|
||||||
@ -199,14 +195,12 @@ var _ = Describe("Podman exec", func() {
|
|||||||
session := podmanTest.Podman([]string{"exec", "--workdir", "/tmp", "test1", "pwd"})
|
session := podmanTest.Podman([]string{"exec", "--workdir", "/tmp", "test1", "pwd"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session.ExitCode()).To(Equal(0))
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
match, _ := session.GrepString("/tmp")
|
Expect(session.OutputToString()).To(Equal("/tmp"))
|
||||||
Expect(match).Should(BeTrue())
|
|
||||||
|
|
||||||
session = podmanTest.Podman([]string{"exec", "-w", "/tmp", "test1", "pwd"})
|
session = podmanTest.Podman([]string{"exec", "-w", "/tmp", "test1", "pwd"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session.ExitCode()).To(Equal(0))
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
match, _ = session.GrepString("/tmp")
|
Expect(session.OutputToString()).To(Equal("/tmp"))
|
||||||
Expect(match).Should(BeTrue())
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman exec missing working directory test", func() {
|
It("podman exec missing working directory test", func() {
|
||||||
@ -280,7 +274,7 @@ var _ = Describe("Podman exec", func() {
|
|||||||
exec := podmanTest.Podman([]string{"exec", "-ti", ctrName2, "id"})
|
exec := podmanTest.Podman([]string{"exec", "-ti", ctrName2, "id"})
|
||||||
exec.WaitWithDefaultTimeout()
|
exec.WaitWithDefaultTimeout()
|
||||||
Expect(exec.ExitCode()).To(Equal(0))
|
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)))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman exec preserves container groups with --user and --group-add", func() {
|
It("podman exec preserves container groups with --user and --group-add", func() {
|
||||||
@ -300,9 +294,9 @@ RUN useradd -u 1000 auser`
|
|||||||
exec.WaitWithDefaultTimeout()
|
exec.WaitWithDefaultTimeout()
|
||||||
Expect(exec.ExitCode()).To(Equal(0))
|
Expect(exec.ExitCode()).To(Equal(0))
|
||||||
output := exec.OutputToString()
|
output := exec.OutputToString()
|
||||||
Expect(strings.Contains(output, "4000(first)")).To(BeTrue())
|
Expect(output).To(ContainSubstring("4000(first)"))
|
||||||
Expect(strings.Contains(output, "4001(second)")).To(BeTrue())
|
Expect(output).To(ContainSubstring("4001(second)"))
|
||||||
Expect(strings.Contains(output, "1000(auser)")).To(BeTrue())
|
Expect(output).To(ContainSubstring("1000(auser)"))
|
||||||
|
|
||||||
// Kill the container just so the test does not take 15 seconds to stop.
|
// Kill the container just so the test does not take 15 seconds to stop.
|
||||||
kill := podmanTest.Podman([]string{"kill", ctrName})
|
kill := podmanTest.Podman([]string{"kill", ctrName})
|
||||||
@ -323,7 +317,7 @@ RUN useradd -u 1000 auser`
|
|||||||
data := podmanTest.InspectContainer(ctrName)
|
data := podmanTest.InspectContainer(ctrName)
|
||||||
Expect(len(data)).To(Equal(1))
|
Expect(len(data)).To(Equal(1))
|
||||||
Expect(len(data[0].ExecIDs)).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 := podmanTest.Podman([]string{"exec", "-t", "-i", ctrName, "ps", "-a"})
|
||||||
exec2.WaitWithDefaultTimeout()
|
exec2.WaitWithDefaultTimeout()
|
||||||
|
Reference in New Issue
Block a user