mirror of
https://github.com/containers/podman.git
synced 2025-06-06 15:00:40 +08:00
fix ps --last=N
Fix `ps --last=N` to also include non-running containers. Also add an e2e test to prevent us from regressing in the future. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
This commit is contained in:
@ -23,7 +23,7 @@ func GetContainerLists(runtime *libpod.Runtime, options entities.ContainerListOp
|
|||||||
filterFuncs []libpod.ContainerFilter
|
filterFuncs []libpod.ContainerFilter
|
||||||
pss []entities.ListContainer
|
pss []entities.ListContainer
|
||||||
)
|
)
|
||||||
all := options.All
|
all := options.All || options.Last > 0
|
||||||
if len(options.Filters) > 0 {
|
if len(options.Filters) > 0 {
|
||||||
for k, v := range options.Filters {
|
for k, v := range options.Filters {
|
||||||
for _, val := range v {
|
for _, val := range v {
|
||||||
|
@ -114,6 +114,17 @@ var _ = Describe("Podman ps", func() {
|
|||||||
It("podman ps last flag", func() {
|
It("podman ps last flag", func() {
|
||||||
Skip("--last flag nonfunctional and disabled")
|
Skip("--last flag nonfunctional and disabled")
|
||||||
|
|
||||||
|
// Make sure that non-running containers are being counted as
|
||||||
|
// well.
|
||||||
|
session := podmanTest.Podman([]string{"create", "alpine", "top"})
|
||||||
|
session.WaitWithDefaultTimeout()
|
||||||
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
|
|
||||||
|
result := podmanTest.Podman([]string{"ps", "--last", "2"})
|
||||||
|
result.WaitWithDefaultTimeout()
|
||||||
|
Expect(result.ExitCode()).To(Equal(0))
|
||||||
|
Expect(len(result.OutputToStringArray())).Should(Equal(2)) // 1 container
|
||||||
|
|
||||||
_, ec, _ := podmanTest.RunLsContainer("test1")
|
_, ec, _ := podmanTest.RunLsContainer("test1")
|
||||||
Expect(ec).To(Equal(0))
|
Expect(ec).To(Equal(0))
|
||||||
|
|
||||||
@ -123,10 +134,20 @@ var _ = Describe("Podman ps", func() {
|
|||||||
_, ec, _ = podmanTest.RunLsContainer("test3")
|
_, ec, _ = podmanTest.RunLsContainer("test3")
|
||||||
Expect(ec).To(Equal(0))
|
Expect(ec).To(Equal(0))
|
||||||
|
|
||||||
result := podmanTest.Podman([]string{"ps", "--last", "2"})
|
result = podmanTest.Podman([]string{"ps", "--last", "2"})
|
||||||
result.WaitWithDefaultTimeout()
|
result.WaitWithDefaultTimeout()
|
||||||
Expect(result.ExitCode()).To(Equal(0))
|
Expect(result.ExitCode()).To(Equal(0))
|
||||||
Expect(len(result.OutputToStringArray())).Should(Equal(3))
|
Expect(len(result.OutputToStringArray())).Should(Equal(3)) // 2 containers
|
||||||
|
|
||||||
|
result = podmanTest.Podman([]string{"ps", "--last", "3"})
|
||||||
|
result.WaitWithDefaultTimeout()
|
||||||
|
Expect(result.ExitCode()).To(Equal(0))
|
||||||
|
Expect(len(result.OutputToStringArray())).Should(Equal(4)) // 3 containers
|
||||||
|
|
||||||
|
result = podmanTest.Podman([]string{"ps", "--last", "100"})
|
||||||
|
result.WaitWithDefaultTimeout()
|
||||||
|
Expect(result.ExitCode()).To(Equal(0))
|
||||||
|
Expect(len(result.OutputToStringArray())).Should(Equal(5)) // 4 containers (3 running + 1 created)
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman ps no-trunc", func() {
|
It("podman ps no-trunc", func() {
|
||||||
|
Reference in New Issue
Block a user