mirror of
https://github.com/containers/podman.git
synced 2025-06-30 15:49:03 +08:00
ExitWithError() - s files
Followup to #22270: wherever possible/practical, extend command error checks to include explicit exit status codes and error strings. This commit handles test/e2e/s*_test.go Signed-off-by: Ed Santiago <santiago@redhat.com>
This commit is contained in:
@ -62,7 +62,7 @@ var _ = Describe("Podman save", func() {
|
|||||||
|
|
||||||
save := podmanTest.Podman([]string{"save", "-q", "-o", outfile, "FOOBAR"})
|
save := podmanTest.Podman([]string{"save", "-q", "-o", outfile, "FOOBAR"})
|
||||||
save.WaitWithDefaultTimeout()
|
save.WaitWithDefaultTimeout()
|
||||||
Expect(save).To(ExitWithError())
|
Expect(save).To(ExitWithError(125, "repository name must be lowercase"))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman save to directory with oci format", func() {
|
It("podman save to directory with oci format", func() {
|
||||||
@ -102,13 +102,11 @@ var _ = Describe("Podman save", func() {
|
|||||||
|
|
||||||
save := podmanTest.Podman([]string{"save", "-q", "--compress", "--format", "docker-archive", "-o", outdir, ALPINE})
|
save := podmanTest.Podman([]string{"save", "-q", "--compress", "--format", "docker-archive", "-o", outdir, ALPINE})
|
||||||
save.WaitWithDefaultTimeout()
|
save.WaitWithDefaultTimeout()
|
||||||
// should not be 0
|
Expect(save).To(ExitWithError(125, "--compress can only be set when --format is 'docker-dir'"))
|
||||||
Expect(save).To(ExitWithError())
|
|
||||||
|
|
||||||
save = podmanTest.Podman([]string{"save", "-q", "--compress", "--format", "oci-archive", "-o", outdir, ALPINE})
|
save = podmanTest.Podman([]string{"save", "-q", "--compress", "--format", "oci-archive", "-o", outdir, ALPINE})
|
||||||
save.WaitWithDefaultTimeout()
|
save.WaitWithDefaultTimeout()
|
||||||
// should not be 0
|
Expect(save).To(ExitWithError(125, "--compress can only be set when --format is 'docker-dir'"))
|
||||||
Expect(save).To(ExitWithError())
|
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -117,7 +115,7 @@ var _ = Describe("Podman save", func() {
|
|||||||
|
|
||||||
save := podmanTest.Podman([]string{"save", "-q", "--compress", "--format", "docker-dir", "-o", outdir, ALPINE})
|
save := podmanTest.Podman([]string{"save", "-q", "--compress", "--format", "docker-dir", "-o", outdir, ALPINE})
|
||||||
save.WaitWithDefaultTimeout()
|
save.WaitWithDefaultTimeout()
|
||||||
Expect(save).To(ExitWithError())
|
Expect(save).To(ExitWithError(125, fmt.Sprintf(`invalid filename (should not contain ':') "%s"`, outdir)))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman save remove signature", func() {
|
It("podman save remove signature", func() {
|
||||||
@ -199,7 +197,7 @@ default-docker:
|
|||||||
outfile := filepath.Join(podmanTest.TempDir, "temp.tar")
|
outfile := filepath.Join(podmanTest.TempDir, "temp.tar")
|
||||||
save := podmanTest.Podman([]string{"save", "-q", "remove-signatures=true", "-o", outfile, pushedImage})
|
save := podmanTest.Podman([]string{"save", "-q", "remove-signatures=true", "-o", outfile, pushedImage})
|
||||||
save.WaitWithDefaultTimeout()
|
save.WaitWithDefaultTimeout()
|
||||||
Expect(save).To(ExitWithError())
|
Expect(save).To(ExitWithError(125, "invalid reference format"))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -12,7 +12,6 @@ import (
|
|||||||
. "github.com/containers/podman/v5/test/utils"
|
. "github.com/containers/podman/v5/test/utils"
|
||||||
. "github.com/onsi/ginkgo/v2"
|
. "github.com/onsi/ginkgo/v2"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
. "github.com/onsi/gomega/gexec"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type endpoint struct {
|
type endpoint struct {
|
||||||
@ -314,9 +313,8 @@ registries = []`
|
|||||||
search := podmanTest.Podman([]string{"search", image, "--tls-verify=true"})
|
search := podmanTest.Podman([]string{"search", image, "--tls-verify=true"})
|
||||||
search.WaitWithDefaultTimeout()
|
search.WaitWithDefaultTimeout()
|
||||||
|
|
||||||
Expect(search).Should(Exit(125))
|
Expect(search).Should(ExitWithError(125, fmt.Sprintf(`couldn't search registry "localhost:%d": pinging container registry localhost:%d: Get "https://localhost:%d/v2/": http: server gave HTTP response to HTTPS client`, port, port, port)))
|
||||||
Expect(search.OutputToString()).Should(BeEmpty())
|
Expect(search.OutputToString()).Should(BeEmpty())
|
||||||
Expect(search.ErrorToString()).To(ContainSubstring("http: server gave HTTP response to HTTPS client"))
|
|
||||||
|
|
||||||
// cleanup
|
// cleanup
|
||||||
resetRegistriesConfigEnv()
|
resetRegistriesConfigEnv()
|
||||||
@ -359,9 +357,8 @@ registries = []`
|
|||||||
search := podmanTest.Podman([]string{"search", image})
|
search := podmanTest.Podman([]string{"search", image})
|
||||||
search.WaitWithDefaultTimeout()
|
search.WaitWithDefaultTimeout()
|
||||||
|
|
||||||
Expect(search).Should(Exit(125))
|
Expect(search).Should(ExitWithError(125, fmt.Sprintf(`couldn't search registry "localhost:%d": pinging container registry localhost:%d: Get "https://localhost:%d/v2/": http: server gave HTTP response to HTTPS client`, port, port, port)))
|
||||||
Expect(search.OutputToString()).Should(BeEmpty())
|
Expect(search.OutputToString()).Should(BeEmpty())
|
||||||
Expect(search.ErrorToString()).To(ContainSubstring("http: server gave HTTP response to HTTPS client"))
|
|
||||||
|
|
||||||
// cleanup
|
// cleanup
|
||||||
resetRegistriesConfigEnv()
|
resetRegistriesConfigEnv()
|
||||||
@ -371,7 +368,7 @@ registries = []`
|
|||||||
It("podman search fail with nonexistent --authfile", func() {
|
It("podman search fail with nonexistent --authfile", func() {
|
||||||
search := podmanTest.Podman([]string{"search", "--authfile", "/tmp/nonexistent", ALPINE})
|
search := podmanTest.Podman([]string{"search", "--authfile", "/tmp/nonexistent", ALPINE})
|
||||||
search.WaitWithDefaultTimeout()
|
search.WaitWithDefaultTimeout()
|
||||||
Expect(search).To(ExitWithError())
|
Expect(search).To(ExitWithError(125, "credential file is not accessible: faccessat /tmp/nonexistent: no such file or directory"))
|
||||||
})
|
})
|
||||||
|
|
||||||
// Registry is unreliable (#18484), this is another super-common flake
|
// Registry is unreliable (#18484), this is another super-common flake
|
||||||
@ -395,22 +392,19 @@ registries = []`
|
|||||||
|
|
||||||
search = podmanTest.Podman([]string{"search", "--filter=is-official", "--list-tags", "quay.io/podman/stable"})
|
search = podmanTest.Podman([]string{"search", "--filter=is-official", "--list-tags", "quay.io/podman/stable"})
|
||||||
search.WaitWithDefaultTimeout()
|
search.WaitWithDefaultTimeout()
|
||||||
Expect(search).To(Exit(125))
|
Expect(search).To(ExitWithError(125, "filters are not applicable to list tags result"))
|
||||||
Expect(search.ErrorToString()).To(ContainSubstring("filters are not applicable to list tags result"))
|
|
||||||
|
|
||||||
// With trailing slash
|
// With trailing slash
|
||||||
search = podmanTest.Podman([]string{"search", "--list-tags", "quay.io/podman/"})
|
search = podmanTest.Podman([]string{"search", "--list-tags", "quay.io/podman/"})
|
||||||
search.WaitWithDefaultTimeout()
|
search.WaitWithDefaultTimeout()
|
||||||
Expect(search).To(Exit(125))
|
Expect(search).To(ExitWithError(125, `reference "podman/" must be a docker reference`))
|
||||||
Expect(search.OutputToStringArray()).To(BeEmpty())
|
Expect(search.OutputToStringArray()).To(BeEmpty())
|
||||||
Expect(search.ErrorToString()).To(ContainSubstring("must be a docker reference"))
|
|
||||||
|
|
||||||
// No trailing slash
|
// No trailing slash
|
||||||
search = podmanTest.Podman([]string{"search", "--list-tags", "quay.io/podman"})
|
search = podmanTest.Podman([]string{"search", "--list-tags", "quay.io/podman"})
|
||||||
search.WaitWithDefaultTimeout()
|
search.WaitWithDefaultTimeout()
|
||||||
Expect(search).To(Exit(125))
|
Expect(search).To(ExitWithError(125, "getting repository tags: fetching tags list: StatusCode: 404"))
|
||||||
Expect(search.OutputToStringArray()).To(BeEmpty())
|
Expect(search.OutputToStringArray()).To(BeEmpty())
|
||||||
Expect(search.ErrorToString()).To(ContainSubstring("fetching tags list: StatusCode: 404"))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman search with limit over 100", func() {
|
It("podman search with limit over 100", func() {
|
||||||
|
@ -39,8 +39,7 @@ var _ = Describe("Podman secret", func() {
|
|||||||
|
|
||||||
session = podmanTest.Podman([]string{"secret", "create", "-d", "file", "--driver-opts", "opt1=val1", "a", secretFilePath})
|
session = podmanTest.Podman([]string{"secret", "create", "-d", "file", "--driver-opts", "opt1=val1", "a", secretFilePath})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(125))
|
Expect(session).Should(ExitWithError(125, "Error: a: secret name in use"))
|
||||||
Expect(session.ErrorToString()).To(Equal("Error: a: secret name in use"))
|
|
||||||
|
|
||||||
session = podmanTest.Podman([]string{"secret", "create", "-d", "file", "--driver-opts", "opt1=val1", "--replace", "a", secretFilePath})
|
session = podmanTest.Podman([]string{"secret", "create", "-d", "file", "--driver-opts", "opt1=val1", "--replace", "a", secretFilePath})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
@ -49,8 +48,7 @@ var _ = Describe("Podman secret", func() {
|
|||||||
|
|
||||||
inspect = podmanTest.Podman([]string{"secret", "inspect", "-f", "{{.Spec.Driver.Options}}", secrID})
|
inspect = podmanTest.Podman([]string{"secret", "inspect", "-f", "{{.Spec.Driver.Options}}", secrID})
|
||||||
inspect.WaitWithDefaultTimeout()
|
inspect.WaitWithDefaultTimeout()
|
||||||
Expect(inspect).To(ExitWithError())
|
Expect(inspect).To(ExitWithError(125, fmt.Sprintf("Error: inspecting secret: no secret with name or id %q: no such secret", secrID)))
|
||||||
Expect(inspect.ErrorToString()).To(ContainSubstring(fmt.Sprintf("Error: inspecting secret: no secret with name or id %q: no such secret", secrID)))
|
|
||||||
|
|
||||||
inspect = podmanTest.Podman([]string{"secret", "inspect", "-f", "{{.Spec.Driver.Options}}", "a"})
|
inspect = podmanTest.Podman([]string{"secret", "inspect", "-f", "{{.Spec.Driver.Options}}", "a"})
|
||||||
inspect.WaitWithDefaultTimeout()
|
inspect.WaitWithDefaultTimeout()
|
||||||
@ -66,14 +64,12 @@ var _ = Describe("Podman secret", func() {
|
|||||||
badName := "foo/bar"
|
badName := "foo/bar"
|
||||||
session := podmanTest.Podman([]string{"secret", "create", badName, secretFilePath})
|
session := podmanTest.Podman([]string{"secret", "create", badName, secretFilePath})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).To(ExitWithError())
|
Expect(session).To(ExitWithError(125, fmt.Sprintf("Error: secret name %q can not include '=', '/', ',', or the '\\0' (NULL) and be between 1 and 253 characters: invalid secret name", badName)))
|
||||||
Expect(session.ErrorToString()).To(Equal(fmt.Sprintf("Error: secret name %q can not include '=', '/', ',', or the '\\0' (NULL) and be between 1 and 253 characters: invalid secret name", badName)))
|
|
||||||
|
|
||||||
badName = "foo=bar"
|
badName = "foo=bar"
|
||||||
session = podmanTest.Podman([]string{"secret", "create", badName, secretFilePath})
|
session = podmanTest.Podman([]string{"secret", "create", badName, secretFilePath})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).To(ExitWithError())
|
Expect(session).To(ExitWithError(125, fmt.Sprintf("Error: secret name %q can not include '=', '/', ',', or the '\\0' (NULL) and be between 1 and 253 characters: invalid secret name", badName)))
|
||||||
Expect(session.ErrorToString()).To(Equal(fmt.Sprintf("Error: secret name %q can not include '=', '/', ',', or the '\\0' (NULL) and be between 1 and 253 characters: invalid secret name", badName)))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman secret inspect", func() {
|
It("podman secret inspect", func() {
|
||||||
@ -164,7 +160,7 @@ var _ = Describe("Podman secret", func() {
|
|||||||
|
|
||||||
inspect := podmanTest.Podman([]string{"secret", "inspect", "bogus"})
|
inspect := podmanTest.Podman([]string{"secret", "inspect", "bogus"})
|
||||||
inspect.WaitWithDefaultTimeout()
|
inspect.WaitWithDefaultTimeout()
|
||||||
Expect(inspect).To(ExitWithError())
|
Expect(inspect).To(ExitWithError(125, `inspecting secret: no secret with name or id "bogus": no such secret`))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman secret ls", func() {
|
It("podman secret ls", func() {
|
||||||
@ -352,7 +348,7 @@ var _ = Describe("Podman secret", func() {
|
|||||||
// no env variable set, should fail
|
// no env variable set, should fail
|
||||||
session := podmanTest.Podman([]string{"secret", "create", "--env", "a", "MYENVVAR"})
|
session := podmanTest.Podman([]string{"secret", "create", "--env", "a", "MYENVVAR"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).To(ExitWithError())
|
Expect(session).To(ExitWithError(125, "cannot create store secret data: environment variable MYENVVAR is not set"))
|
||||||
|
|
||||||
os.Setenv("MYENVVAR", "somedata")
|
os.Setenv("MYENVVAR", "somedata")
|
||||||
if IsRemote() {
|
if IsRemote() {
|
||||||
|
@ -10,7 +10,6 @@ import (
|
|||||||
. "github.com/containers/podman/v5/test/utils"
|
. "github.com/containers/podman/v5/test/utils"
|
||||||
. "github.com/onsi/ginkgo/v2"
|
. "github.com/onsi/ginkgo/v2"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
. "github.com/onsi/gomega/gexec"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("Podman start", func() {
|
var _ = Describe("Podman start", func() {
|
||||||
@ -18,7 +17,7 @@ var _ = Describe("Podman start", func() {
|
|||||||
It("podman start bogus container", func() {
|
It("podman start bogus container", func() {
|
||||||
session := podmanTest.Podman([]string{"start", "123"})
|
session := podmanTest.Podman([]string{"start", "123"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(125))
|
Expect(session).Should(ExitWithError(125, `no container with name or ID "123" found: no such container`))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman start single container by id", func() {
|
It("podman start single container by id", func() {
|
||||||
@ -37,10 +36,10 @@ var _ = Describe("Podman start", func() {
|
|||||||
Expect(session).Should(ExitCleanly())
|
Expect(session).Should(ExitCleanly())
|
||||||
session = podmanTest.Podman([]string{"start", "test"})
|
session = podmanTest.Podman([]string{"start", "test"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(125))
|
Expect(session).Should(ExitWithError(125, "not found in $PATH"))
|
||||||
session = podmanTest.Podman([]string{"container", "exists", "test"})
|
session = podmanTest.Podman([]string{"container", "exists", "test"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).To(ExitWithError())
|
Expect(session).To(ExitWithError(1))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman start --rm --attach removed on failure", func() {
|
It("podman start --rm --attach removed on failure", func() {
|
||||||
@ -50,10 +49,10 @@ var _ = Describe("Podman start", func() {
|
|||||||
cid := session.OutputToString()
|
cid := session.OutputToString()
|
||||||
session = podmanTest.Podman([]string{"start", "--attach", cid})
|
session = podmanTest.Podman([]string{"start", "--attach", cid})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(125))
|
Expect(session).Should(ExitWithError(125, "not found in $PATH"))
|
||||||
session = podmanTest.Podman([]string{"container", "exists", cid})
|
session = podmanTest.Podman([]string{"container", "exists", cid})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).To(ExitWithError())
|
Expect(session).To(ExitWithError(1))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman container start single container by id", func() {
|
It("podman container start single container by id", func() {
|
||||||
@ -98,7 +97,7 @@ var _ = Describe("Podman start", func() {
|
|||||||
session = podmanTest.Podman([]string{"start", "--attach", cid})
|
session = podmanTest.Podman([]string{"start", "--attach", cid})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
// It should forward the signal
|
// It should forward the signal
|
||||||
Expect(session).Should(Exit(1))
|
Expect(session).Should(ExitWithError(1))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman start multiple containers", func() {
|
It("podman start multiple containers", func() {
|
||||||
@ -119,7 +118,7 @@ var _ = Describe("Podman start", func() {
|
|||||||
cid1 := session.OutputToString()
|
cid1 := session.OutputToString()
|
||||||
session = podmanTest.Podman([]string{"start", cid1, "doesnotexist"})
|
session = podmanTest.Podman([]string{"start", cid1, "doesnotexist"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(125))
|
Expect(session).Should(ExitWithError(125, `no container with name or ID "doesnotexist" found: no such container`))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman multiple containers -- attach should fail", func() {
|
It("podman multiple containers -- attach should fail", func() {
|
||||||
@ -131,7 +130,7 @@ var _ = Describe("Podman start", func() {
|
|||||||
Expect(session).Should(ExitCleanly())
|
Expect(session).Should(ExitCleanly())
|
||||||
session = podmanTest.Podman([]string{"start", "-a", "foobar1", "foobar2"})
|
session = podmanTest.Podman([]string{"start", "-a", "foobar1", "foobar2"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(125))
|
Expect(session).Should(ExitWithError(125, "you cannot start and attach multiple containers at once"))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman failed to start with --rm should delete the container", func() {
|
It("podman failed to start with --rm should delete the container", func() {
|
||||||
@ -144,7 +143,7 @@ var _ = Describe("Podman start", func() {
|
|||||||
|
|
||||||
wait := podmanTest.Podman([]string{"wait", "test1"})
|
wait := podmanTest.Podman([]string{"wait", "test1"})
|
||||||
wait.WaitWithDefaultTimeout()
|
wait.WaitWithDefaultTimeout()
|
||||||
Expect(wait).To(ExitWithError())
|
Expect(wait).To(ExitWithError(125, `no container with name or ID "test1" found: no such container`))
|
||||||
|
|
||||||
Eventually(podmanTest.NumberOfContainers, defaultWaitTimeout, 3.0).Should(BeZero())
|
Eventually(podmanTest.NumberOfContainers, defaultWaitTimeout, 3.0).Should(BeZero())
|
||||||
})
|
})
|
||||||
@ -156,19 +155,19 @@ var _ = Describe("Podman start", func() {
|
|||||||
|
|
||||||
start := podmanTest.Podman([]string{"start", session.OutputToString()})
|
start := podmanTest.Podman([]string{"start", session.OutputToString()})
|
||||||
start.WaitWithDefaultTimeout()
|
start.WaitWithDefaultTimeout()
|
||||||
Expect(start).To(ExitWithError())
|
Expect(start).To(ExitWithError(125, "not found in $PATH"))
|
||||||
|
|
||||||
Eventually(podmanTest.NumberOfContainers, defaultWaitTimeout, 3.0).Should(Equal(1))
|
Eventually(podmanTest.NumberOfContainers, defaultWaitTimeout, 3.0).Should(Equal(1))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman start --sig-proxy should not work without --attach", func() {
|
It("podman start --sig-proxy should not work without --attach", func() {
|
||||||
session := podmanTest.Podman([]string{"create", ALPINE, "ls"})
|
session := podmanTest.Podman([]string{"create", "--name", "sigproxyneedsattach", ALPINE, "ls"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(ExitCleanly())
|
Expect(session).Should(ExitCleanly())
|
||||||
|
|
||||||
session = podmanTest.Podman([]string{"start", "-l", "--sig-proxy"})
|
session = podmanTest.Podman([]string{"start", "--sig-proxy", "sigproxyneedsattach"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(125))
|
Expect(session).Should(ExitWithError(125, "you cannot use sig-proxy without --attach: invalid argument"))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman start container with special pidfile", func() {
|
It("podman start container with special pidfile", func() {
|
||||||
|
@ -8,7 +8,6 @@ import (
|
|||||||
. "github.com/containers/podman/v5/test/utils"
|
. "github.com/containers/podman/v5/test/utils"
|
||||||
. "github.com/onsi/ginkgo/v2"
|
. "github.com/onsi/ginkgo/v2"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
. "github.com/onsi/gomega/gexec"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: we need to check the output. Currently, we only check the exit codes
|
// TODO: we need to check the output. Currently, we only check the exit codes
|
||||||
@ -25,7 +24,12 @@ var _ = Describe("Podman stats", func() {
|
|||||||
It("podman stats with bogus container", func() {
|
It("podman stats with bogus container", func() {
|
||||||
session := podmanTest.Podman([]string{"stats", "--no-stream", "123"})
|
session := podmanTest.Podman([]string{"stats", "--no-stream", "123"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(125))
|
expect := `unable to get list of containers: unable to look up container 123: no container with name or ID "123" found: no such container`
|
||||||
|
// FIXME: #22612
|
||||||
|
if IsRemote() {
|
||||||
|
expect = "types.ContainerStatsReport.Error: decode non empty interface: can not unmarshal into nil, error found in #9 byte"
|
||||||
|
}
|
||||||
|
Expect(session).Should(ExitWithError(125, expect))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman stats on a running container", func() {
|
It("podman stats on a running container", func() {
|
||||||
@ -81,7 +85,7 @@ var _ = Describe("Podman stats", func() {
|
|||||||
Expect(session).Should(ExitCleanly())
|
Expect(session).Should(ExitCleanly())
|
||||||
stats := podmanTest.Podman([]string{"stats", "-a", "--no-reset", "--no-stream", "--format", "\"table {{.ID}} {{.NoSuchField}} \""})
|
stats := podmanTest.Podman([]string{"stats", "-a", "--no-reset", "--no-stream", "--format", "\"table {{.ID}} {{.NoSuchField}} \""})
|
||||||
stats.WaitWithDefaultTimeout()
|
stats.WaitWithDefaultTimeout()
|
||||||
Expect(stats).To(ExitWithError())
|
Expect(stats).To(ExitWithError(125, `template: stats:1:28: executing "stats" at <.NoSuchField>: can't evaluate field NoSuchField in type containers.containerStats`))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman stats with negative interval", func() {
|
It("podman stats with negative interval", func() {
|
||||||
@ -90,7 +94,7 @@ var _ = Describe("Podman stats", func() {
|
|||||||
Expect(session).Should(ExitCleanly())
|
Expect(session).Should(ExitCleanly())
|
||||||
stats := podmanTest.Podman([]string{"stats", "-a", "--no-reset", "--no-stream", "--interval=-1"})
|
stats := podmanTest.Podman([]string{"stats", "-a", "--no-reset", "--no-stream", "--interval=-1"})
|
||||||
stats.WaitWithDefaultTimeout()
|
stats.WaitWithDefaultTimeout()
|
||||||
Expect(stats).To(ExitWithError())
|
Expect(stats).To(ExitWithError(125, "invalid interval, must be a positive number greater zero"))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman stats with zero interval", func() {
|
It("podman stats with zero interval", func() {
|
||||||
@ -99,7 +103,7 @@ var _ = Describe("Podman stats", func() {
|
|||||||
Expect(session).Should(ExitCleanly())
|
Expect(session).Should(ExitCleanly())
|
||||||
stats := podmanTest.Podman([]string{"stats", "-a", "--no-reset", "--no-stream", "--interval=0"})
|
stats := podmanTest.Podman([]string{"stats", "-a", "--no-reset", "--no-stream", "--interval=0"})
|
||||||
stats.WaitWithDefaultTimeout()
|
stats.WaitWithDefaultTimeout()
|
||||||
Expect(stats).To(ExitWithError())
|
Expect(stats).To(ExitWithError(125, "invalid interval, must be a positive number greater zero"))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman stats with interval", func() {
|
It("podman stats with interval", func() {
|
||||||
|
@ -95,8 +95,7 @@ var _ = Describe("podman system df", func() {
|
|||||||
It("podman system df --format with --verbose", func() {
|
It("podman system df --format with --verbose", func() {
|
||||||
session := podmanTest.Podman([]string{"system", "df", "--format", "json", "--verbose"})
|
session := podmanTest.Podman([]string{"system", "df", "--format", "json", "--verbose"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).To(ExitWithError())
|
Expect(session).To(ExitWithError(125, "Error: cannot combine --format and --verbose flags"))
|
||||||
Expect(session.ErrorToString()).To(Equal("Error: cannot combine --format and --verbose flags"))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman system df --format json", func() {
|
It("podman system df --format json", func() {
|
||||||
|
Reference in New Issue
Block a user