Skip to content

Commit

Permalink
e2e: remove "-it" from podman run & exec
Browse files Browse the repository at this point in the history
...at least as many as possible. "run/exec -it" make no sense
in a CI environment; I believe the vast majority of these are
the result of fingers typing on autopilot, then copy/pasting
cascades from those. This PR gets rid of as many -it/-ti as
possible. Some are still needed for testing purposes.

Y'all have no idea how much I hate #10927 (the "no logs from conmon"
flake). This does not fix the underlying problem, nor does it even
eliminate the flake (The "exec terminal doesn't hang" test needs
to keep the -ti flag, and that's one of the most popular flakers).
But this at least reduces the scope of the problem. It also removes
a ton of nasty orange "input device is not a TTY" warnings from logs.

Signed-off-by: Ed Santiago <santiago@redhat.com>
  • Loading branch information
edsantiago committed Apr 26, 2023
1 parent 846e7aa commit eeb210b
Show file tree
Hide file tree
Showing 24 changed files with 132 additions and 133 deletions.
1 change: 0 additions & 1 deletion test/e2e/checkpoint_image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ var _ = Describe("Podman checkpoint", func() {

localRunString := []string{
"run",
"-it",
"-d",
"--ip", GetRandomIPAddress(),
"--name", containerName,
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/commit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ var _ = Describe("Podman commit", func() {
})

It("podman commit container check env variables", func() {
s := podmanTest.Podman([]string{"run", "--name", "test1", "-e", "TEST=1=1-01=9.01", "-it", "alpine", "true"})
s := podmanTest.Podman([]string{"run", "--name", "test1", "-e", "TEST=1=1-01=9.01", "alpine", "true"})
s.WaitWithDefaultTimeout()
Expect(s).Should(Exit(0))

Expand Down
2 changes: 1 addition & 1 deletion test/e2e/cp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ var _ = Describe("Podman cp", func() {
Expect(session).Should(Exit(0))

// owner of the file copied to a container is the root user
session = podmanTest.Podman([]string{"exec", "-it", "testctr", "ls", "-l", "testfile2"})
session = podmanTest.Podman([]string{"exec", "testctr", "ls", "-l", "testfile2"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session.OutputToString()).To(ContainSubstring("root"))
Expand Down
16 changes: 8 additions & 8 deletions test/e2e/exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ var _ = Describe("Podman exec", func() {
groupName := "group1"
gid := "4444"
ctrName1 := "ctr1"
ctr1 := podmanTest.Podman([]string{"run", "-ti", "--name", ctrName1, fedoraMinimal, "groupadd", "-g", gid, groupName})
ctr1 := podmanTest.Podman([]string{"run", "--name", ctrName1, fedoraMinimal, "groupadd", "-g", gid, groupName})
ctr1.WaitWithDefaultTimeout()
Expect(ctr1).Should(Exit(0))

Expand All @@ -481,7 +481,7 @@ var _ = Describe("Podman exec", func() {
ctr2.WaitWithDefaultTimeout()
Expect(ctr2).Should(Exit(0))

exec := podmanTest.Podman([]string{"exec", "-ti", ctrName2, "id"})
exec := podmanTest.Podman([]string{"exec", ctrName2, "id"})
exec.WaitWithDefaultTimeout()
Expect(exec).Should(Exit(0))
Expect(exec.OutputToString()).To(ContainSubstring(fmt.Sprintf("%s(%s)", gid, groupName)))
Expand All @@ -496,11 +496,11 @@ RUN useradd -u 1000 auser`, fedoraMinimal)
podmanTest.BuildImage(dockerfile, imgName, "false")

ctrName := "testctr"
ctr := podmanTest.Podman([]string{"run", "-t", "-i", "-d", "--name", ctrName, "--user", "auser:first", "--group-add", "second", imgName, "sleep", "300"})
ctr := podmanTest.Podman([]string{"run", "-d", "--name", ctrName, "--user", "auser:first", "--group-add", "second", imgName, "sleep", "300"})
ctr.WaitWithDefaultTimeout()
Expect(ctr).Should(Exit(0))

exec := podmanTest.Podman([]string{"exec", "-t", ctrName, "id"})
exec := podmanTest.Podman([]string{"exec", ctrName, "id"})
exec.WaitWithDefaultTimeout()
Expect(exec).Should(Exit(0))
output := exec.OutputToString()
Expand All @@ -516,11 +516,11 @@ RUN useradd -u 1000 auser`, fedoraMinimal)

It("podman exec --detach", func() {
ctrName := "testctr"
ctr := podmanTest.Podman([]string{"run", "-t", "-i", "-d", "--name", ctrName, ALPINE, "top"})
ctr := podmanTest.Podman([]string{"run", "-d", "--name", ctrName, ALPINE, "top"})
ctr.WaitWithDefaultTimeout()
Expect(ctr).Should(Exit(0))

exec1 := podmanTest.Podman([]string{"exec", "-t", "-i", "-d", ctrName, "top"})
exec1 := podmanTest.Podman([]string{"exec", "-d", ctrName, "top"})
exec1.WaitWithDefaultTimeout()
Expect(ctr).Should(Exit(0))

Expand All @@ -529,7 +529,7 @@ RUN useradd -u 1000 auser`, fedoraMinimal)
Expect(data[0].ExecIDs).To(HaveLen(1))
Expect(exec1.OutputToString()).To(ContainSubstring(data[0].ExecIDs[0]))

exec2 := podmanTest.Podman([]string{"exec", "-t", "-i", ctrName, "ps", "-a"})
exec2 := podmanTest.Podman([]string{"exec", ctrName, "ps", "-a"})
exec2.WaitWithDefaultTimeout()
Expect(ctr).Should(Exit(0))
Expect(strings.Count(exec2.OutputToString(), "top")).To(Equal(2))
Expand All @@ -551,7 +551,7 @@ RUN useradd -u 1000 auser`, fedoraMinimal)
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))

session = podmanTest.Podman([]string{"run", "-t", "-i", "-d", "--secret", "source=mysecret,type=env", "--name", "secr", ALPINE, "top"})
session = podmanTest.Podman([]string{"run", "-d", "--secret", "source=mysecret,type=env", "--name", "secr", ALPINE, "top"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))

Expand Down
8 changes: 4 additions & 4 deletions test/e2e/logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ var _ = Describe("Podman logs", func() {
It("podman logs on a created container should result in 0 exit code: "+log, func() {
skipIfJournaldInContainer()

session := podmanTest.Podman([]string{"create", "--log-driver", log, "-t", "--name", "log", ALPINE})
session := podmanTest.Podman([]string{"create", "--log-driver", log, "--name", "log", ALPINE})
session.WaitWithDefaultTimeout()
Expect(session).To(Exit(0))

Expand Down Expand Up @@ -382,7 +382,7 @@ var _ = Describe("Podman logs", func() {
It("Make sure logs match expected length: "+log, func() {
skipIfJournaldInContainer()

logc := podmanTest.Podman([]string{"run", "--log-driver", log, "-t", "--name", "test", ALPINE, "sh", "-c", "echo 1; echo 2"})
logc := podmanTest.Podman([]string{"run", "--log-driver", log, "--name", "test", ALPINE, "sh", "-c", "echo 1; echo 2"})
logc.WaitWithDefaultTimeout()
Expect(logc).To(Exit(0))

Expand All @@ -395,8 +395,8 @@ var _ = Describe("Podman logs", func() {
Expect(results).To(Exit(0))
outlines := results.OutputToStringArray()
Expect(outlines).To(HaveLen(2))
Expect(outlines[0]).To(Equal("1\r"))
Expect(outlines[1]).To(Equal("2\r"))
Expect(outlines[0]).To(Equal("1"))
Expect(outlines[1]).To(Equal("2"))
})

It("podman logs test stdout and stderr: "+log, func() {
Expand Down
32 changes: 16 additions & 16 deletions test/e2e/network_connect_disconnect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ var _ = Describe("Podman network connect and disconnect", func() {
ctr.WaitWithDefaultTimeout()
Expect(ctr).Should(Exit(0))

exec := podmanTest.Podman([]string{"exec", "-it", "test", "ip", "addr", "show", "eth0"})
exec := podmanTest.Podman([]string{"exec", "test", "ip", "addr", "show", "eth0"})
exec.WaitWithDefaultTimeout()
Expect(exec).Should(Exit(0))

exec2 := podmanTest.Podman([]string{"exec", "-it", "test", "cat", "/etc/resolv.conf"})
exec2 := podmanTest.Podman([]string{"exec", "test", "cat", "/etc/resolv.conf"})
exec2.WaitWithDefaultTimeout()
Expect(exec2).Should(Exit(0))
Expect(exec2.OutputToString()).To(ContainSubstring(ns))
Expand All @@ -106,11 +106,11 @@ var _ = Describe("Podman network connect and disconnect", func() {
Expect(inspect).Should(Exit(0))
Expect(inspect.OutputToString()).To(Equal("0"))

exec = podmanTest.Podman([]string{"exec", "-it", "test", "ip", "addr", "show", "eth0"})
exec = podmanTest.Podman([]string{"exec", "test", "ip", "addr", "show", "eth0"})
exec.WaitWithDefaultTimeout()
Expect(exec).Should(ExitWithError())

exec3 := podmanTest.Podman([]string{"exec", "-it", "test", "cat", "/etc/resolv.conf"})
exec3 := podmanTest.Podman([]string{"exec", "test", "cat", "/etc/resolv.conf"})
exec3.WaitWithDefaultTimeout()
Expect(exec3).Should(Exit(0))
Expect(exec3.OutputToString()).ToNot(ContainSubstring(ns))
Expand Down Expand Up @@ -201,7 +201,7 @@ var _ = Describe("Podman network connect and disconnect", func() {
Expect(ctr).Should(Exit(0))
cid := ctr.OutputToString()

exec := podmanTest.Podman([]string{"exec", "-it", "test", "ip", "addr", "show", "eth0"})
exec := podmanTest.Podman([]string{"exec", "test", "ip", "addr", "show", "eth0"})
exec.WaitWithDefaultTimeout()
Expect(exec).Should(Exit(0))

Expand All @@ -217,7 +217,7 @@ var _ = Describe("Podman network connect and disconnect", func() {
Expect(gw).Should(Exit(0))
ns := gw.OutputToString()

exec2 := podmanTest.Podman([]string{"exec", "-it", "test", "cat", "/etc/resolv.conf"})
exec2 := podmanTest.Podman([]string{"exec", "test", "cat", "/etc/resolv.conf"})
exec2.WaitWithDefaultTimeout()
Expect(exec2).Should(Exit(0))
Expect(exec2.OutputToString()).ToNot(ContainSubstring(ns))
Expand All @@ -240,13 +240,13 @@ var _ = Describe("Podman network connect and disconnect", func() {
Expect(inspect).Should(Exit(0))
Expect(inspect.OutputToString()).To(Equal("[" + cid[0:12] + "]"))

exec = podmanTest.Podman([]string{"exec", "-it", "test", "ip", "addr", "show", "eth1"})
exec = podmanTest.Podman([]string{"exec", "test", "ip", "addr", "show", "eth1"})
exec.WaitWithDefaultTimeout()
Expect(exec).Should(Exit(0))
Expect(exec.OutputToString()).Should(ContainSubstring(ip))
Expect(exec.OutputToString()).Should(ContainSubstring(mac))

exec3 := podmanTest.Podman([]string{"exec", "-it", "test", "cat", "/etc/resolv.conf"})
exec3 := podmanTest.Podman([]string{"exec", "test", "cat", "/etc/resolv.conf"})
exec3.WaitWithDefaultTimeout()
Expect(exec3).Should(Exit(0))
Expect(exec3.OutputToString()).To(ContainSubstring(ns))
Expand Down Expand Up @@ -293,11 +293,11 @@ var _ = Describe("Podman network connect and disconnect", func() {
start.WaitWithDefaultTimeout()
Expect(start).Should(Exit(0))

exec := podmanTest.Podman([]string{"exec", "-it", "test", "ip", "addr", "show", "eth0"})
exec := podmanTest.Podman([]string{"exec", "test", "ip", "addr", "show", "eth0"})
exec.WaitWithDefaultTimeout()
Expect(exec).Should(Exit(0))

exec = podmanTest.Podman([]string{"exec", "-it", "test", "ip", "addr", "show", "eth1"})
exec = podmanTest.Podman([]string{"exec", "test", "ip", "addr", "show", "eth1"})
exec.WaitWithDefaultTimeout()
Expect(exec).Should(Exit(0))
})
Expand All @@ -318,7 +318,7 @@ var _ = Describe("Podman network connect and disconnect", func() {
ctr.WaitWithDefaultTimeout()
Expect(ctr).Should(Exit(0))

exec := podmanTest.Podman([]string{"exec", "-it", "test", "ip", "addr", "show", "eth0"})
exec := podmanTest.Podman([]string{"exec", "test", "ip", "addr", "show", "eth0"})
exec.WaitWithDefaultTimeout()
Expect(exec).Should(Exit(0))

Expand All @@ -344,7 +344,7 @@ var _ = Describe("Podman network connect and disconnect", func() {
Expect(inspect.OutputToString()).To(ContainSubstring(netName))
Expect(inspect.OutputToString()).To(ContainSubstring(newNetName))

exec = podmanTest.Podman([]string{"exec", "-it", "test", "ip", "addr", "show", "eth1"})
exec = podmanTest.Podman([]string{"exec", "test", "ip", "addr", "show", "eth1"})
exec.WaitWithDefaultTimeout()
Expect(exec).Should(Exit(0))
})
Expand Down Expand Up @@ -379,7 +379,7 @@ var _ = Describe("Podman network connect and disconnect", func() {
start.WaitWithDefaultTimeout()
Expect(start).Should(Exit(0))

exec := podmanTest.Podman([]string{"exec", "-it", "test", "ip", "addr", "show", "eth0"})
exec := podmanTest.Podman([]string{"exec", "test", "ip", "addr", "show", "eth0"})
exec.WaitWithDefaultTimeout()

// because the network interface order is not guaranteed to be the same we have to check both eth0 and eth1
Expand All @@ -389,7 +389,7 @@ var _ = Describe("Podman network connect and disconnect", func() {
exitMatcher = Exit(0)
}

exec = podmanTest.Podman([]string{"exec", "-it", "test", "ip", "addr", "show", "eth1"})
exec = podmanTest.Podman([]string{"exec", "test", "ip", "addr", "show", "eth1"})
exec.WaitWithDefaultTimeout()
Expect(exec).Should(exitMatcher)
})
Expand All @@ -410,7 +410,7 @@ var _ = Describe("Podman network connect and disconnect", func() {
ctr.WaitWithDefaultTimeout()
Expect(ctr).Should(Exit(0))

exec := podmanTest.Podman([]string{"exec", "-it", "test", "ip", "addr", "show", "eth0"})
exec := podmanTest.Podman([]string{"exec", "test", "ip", "addr", "show", "eth0"})
exec.WaitWithDefaultTimeout()
Expect(exec).Should(Exit(0))

Expand All @@ -423,7 +423,7 @@ var _ = Describe("Podman network connect and disconnect", func() {
Expect(inspect).Should(Exit(0))
Expect(inspect.OutputToString()).To(Equal("0"))

exec = podmanTest.Podman([]string{"exec", "-it", "test", "ip", "addr", "show", "eth0"})
exec = podmanTest.Podman([]string{"exec", "test", "ip", "addr", "show", "eth0"})
exec.WaitWithDefaultTimeout()
Expect(exec).Should(ExitWithError())
})
Expand Down
8 changes: 4 additions & 4 deletions test/e2e/network_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ var _ = Describe("Podman network create", func() {
// best we can
defer removeNetworkDevice(result.NetworkInterface)

try := podmanTest.Podman([]string{"run", "-it", "--rm", "--network", netName, ALPINE, "sh", "-c", "ip addr show eth0 | awk ' /inet / {print $2}'"})
try := podmanTest.Podman([]string{"run", "--rm", "--network", netName, ALPINE, "sh", "-c", "ip addr show eth0 | awk ' /inet / {print $2}'"})
try.WaitWithDefaultTimeout()
Expect(try).To(Exit(0))

Expand Down Expand Up @@ -110,7 +110,7 @@ var _ = Describe("Podman network create", func() {
// best we can
defer removeNetworkDevice(result.NetworkInterface)

try := podmanTest.Podman([]string{"run", "-it", "--rm", "--network", netName, ALPINE, "sh", "-c", "ip addr show eth0 | grep global | awk ' /inet6 / {print $2}'"})
try := podmanTest.Podman([]string{"run", "--rm", "--network", netName, ALPINE, "sh", "-c", "ip addr show eth0 | grep global | awk ' /inet6 / {print $2}'"})
try.WaitWithDefaultTimeout()
Expect(try).To(Exit(0))

Expand Down Expand Up @@ -186,7 +186,7 @@ var _ = Describe("Podman network create", func() {
Expect(subnet11.Contains(subnet21.IP)).To(BeFalse())
Expect(subnet12.Contains(subnet22.IP)).To(BeFalse())

try := podmanTest.Podman([]string{"run", "-it", "--rm", "--network", netName, ALPINE, "sh", "-c", "ip addr show eth0 | grep global | awk ' /inet6 / {print $2}'"})
try := podmanTest.Podman([]string{"run", "--rm", "--network", netName, ALPINE, "sh", "-c", "ip addr show eth0 | grep global | awk ' /inet6 / {print $2}'"})
try.WaitWithDefaultTimeout()

_, subnet, err := net.ParseCIDR("fd00:4:3:2:1::/64")
Expand All @@ -196,7 +196,7 @@ var _ = Describe("Podman network create", func() {
// Ensure that the IP the container got is within the subnet the user asked for
Expect(subnet.Contains(containerIP)).To(BeTrue())
// verify the container has an IPv4 address too (the IPv4 subnet is autogenerated)
try = podmanTest.Podman([]string{"run", "-it", "--rm", "--network", netName, ALPINE, "sh", "-c", "ip addr show eth0 | awk ' /inet / {print $2}'"})
try = podmanTest.Podman([]string{"run", "--rm", "--network", netName, ALPINE, "sh", "-c", "ip addr show eth0 | awk ' /inet / {print $2}'"})
try.WaitWithDefaultTimeout()
containerIP, _, err = net.ParseCIDR(try.OutputToString())
Expect(err).ToNot(HaveOccurred())
Expand Down
14 changes: 7 additions & 7 deletions test/e2e/play_kube_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1794,7 +1794,7 @@ func testPodWithSecret(podmanTest *PodmanTestIntegration, podYamlString, fileNam
}
Expect(kube).Should(Exit(0))

exec := podmanTest.Podman([]string{"exec", "-it", "mypod-myctr", "cat", "/etc/foo/username"})
exec := podmanTest.Podman([]string{"exec", "mypod-myctr", "cat", "/etc/foo/username"})
exec.WaitWithDefaultTimeout()
if exists {
Expect(exec).Should(Exit(0))
Expand Down Expand Up @@ -4783,19 +4783,19 @@ ENV OPENJ9_JAVA_OPTIONS=%q
kube.WaitWithDefaultTimeout()
Expect(kube).Should(Exit(0))

exec := podmanTest.Podman([]string{"exec", "-it", "mypod2-myctr", "cat", "/etc/foo/username"})
exec := podmanTest.Podman([]string{"exec", "mypod2-myctr", "cat", "/etc/foo/username"})
exec.WaitWithDefaultTimeout()
Expect(exec).Should(Exit(0))
username, _ := base64.StdEncoding.DecodeString("dXNlcg==")
Expect(exec.OutputToString()).Should(ContainSubstring(string(username)))

exec = podmanTest.Podman([]string{"exec", "-it", "mypod2-myctr", "cat", "/etc/bar/username"})
exec = podmanTest.Podman([]string{"exec", "mypod2-myctr", "cat", "/etc/bar/username"})
exec.WaitWithDefaultTimeout()
Expect(exec).Should(Exit(0))
username, _ = base64.StdEncoding.DecodeString("Y2RvZXJu")
Expect(exec.OutputToString()).Should(ContainSubstring(string(username)))

exec = podmanTest.Podman([]string{"exec", "-it", "mypod2-myctr", "cat", "/etc/baz/plain_note"})
exec = podmanTest.Podman([]string{"exec", "mypod2-myctr", "cat", "/etc/baz/plain_note"})
exec.WaitWithDefaultTimeout()
Expect(exec).Should(Exit(0))
Expect(exec.OutputToString()).Should(ContainSubstring("This is a test"))
Expand Down Expand Up @@ -4983,7 +4983,7 @@ spec:
playKube.WaitWithDefaultTimeout()
Expect(playKube).Should(Exit(0))

exec := podmanTest.Podman([]string{"exec", "-it", "testpod-testctr", "cat", "/var/123.txt"})
exec := podmanTest.Podman([]string{"exec", "testpod-testctr", "cat", "/var/123.txt"})
exec.WaitWithDefaultTimeout()
Expect(exec).Should(Exit(0))
Expect(exec.OutputToString()).Should(Equal("hi"))
Expand Down Expand Up @@ -5012,7 +5012,7 @@ spec:
playKube := podmanTest.Podman([]string{"play", "kube", kubeYaml})
playKube.WaitWithDefaultTimeout()
Expect(playKube).Should(Exit(0))
exec := podmanTest.Podman([]string{"exec", "-it", "testpod-testctr", "ls", "/var"})
exec := podmanTest.Podman([]string{"exec", "testpod-testctr", "ls", "/var"})
exec.WaitWithDefaultTimeout()
Expect(exec).Should(Exit(0))
Expect(exec.OutputToString()).Should(ContainSubstring("123.txt"))
Expand Down Expand Up @@ -5095,7 +5095,7 @@ spec:
kube.WaitWithDefaultTimeout()
Expect(kube).Should(Exit(0), string(out))

exec := podmanTest.Podman([]string{"exec", "-it", "testpod-testctr", "ls", "/etc/"})
exec := podmanTest.Podman([]string{"exec", "testpod-testctr", "ls", "/etc/"})
exec.WaitWithDefaultTimeout()
Expect(exec).Should(Exit(0))
Expect(exec.OutputToString()).ShouldNot(HaveLen(3))
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/pod_clone_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ var _ = Describe("Podman pod clone", func() {
podClone.WaitWithDefaultTimeout()
Expect(podClone).Should(Exit(0))

run := podmanTest.Podman([]string{"run", "-it", "--pod", podClone.OutputToString(), ALPINE, "mount"})
run := podmanTest.Podman([]string{"run", "--pod", podClone.OutputToString(), ALPINE, "mount"})
run.WaitWithDefaultTimeout()
Expect(run).Should(Exit(0))
t, strings := run.GrepString("shm on /dev/shm type tmpfs")
Expand All @@ -167,7 +167,7 @@ var _ = Describe("Podman pod clone", func() {
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))

session = podmanTest.Podman([]string{"run", "-it", "--pod", session.OutputToString(), ALPINE, "printenv", "HOSTNAME"})
session = podmanTest.Podman([]string{"run", "--pod", session.OutputToString(), ALPINE, "printenv", "HOSTNAME"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session.OutputToString()).To(ContainSubstring(hostname))
Expand Down
Loading

0 comments on commit eeb210b

Please sign in to comment.