summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd/podman/login.go3
-rw-r--r--cmd/podman/spec.go2
-rw-r--r--cmd/podman/spec_test.go6
-rw-r--r--test/e2e/kill_test.go95
-rw-r--r--test/e2e/libpod_suite_test.go21
-rw-r--r--test/e2e/ps_test.go68
-rw-r--r--test/e2e/rm_test.go6
-rw-r--r--test/podman_kill.bats71
8 files changed, 150 insertions, 122 deletions
diff --git a/cmd/podman/login.go b/cmd/podman/login.go
index 325bf8621..f57f34532 100644
--- a/cmd/podman/login.go
+++ b/cmd/podman/login.go
@@ -5,7 +5,6 @@ import (
"context"
"fmt"
"os"
- "path/filepath"
"strings"
"github.com/containers/image/docker"
@@ -75,7 +74,7 @@ func loginCmd(c *cli.Context) error {
}
sc.DockerInsecureSkipTLSVerify = !c.BoolT("tls-verify")
if c.String("cert-dir") != "" {
- sc.DockerCertPath = filepath.Join(c.String("cert-dir"), server)
+ sc.DockerCertPath = c.String("cert-dir")
}
if err = docker.CheckAuth(context.TODO(), sc, username, password, server); err == nil {
diff --git a/cmd/podman/spec.go b/cmd/podman/spec.go
index 0b5a3c3e3..a14bd7dfb 100644
--- a/cmd/podman/spec.go
+++ b/cmd/podman/spec.go
@@ -439,7 +439,7 @@ func getDefaultAnnotations() map[string]string {
annotations[ann.Annotations] = ""
annotations[ann.ContainerID] = ""
annotations[ann.ContainerName] = ""
- annotations[ann.ContainerType] = ""
+ annotations[ann.ContainerType] = "sandbox"
annotations[ann.Created] = ""
annotations[ann.HostName] = ""
annotations[ann.IP] = ""
diff --git a/cmd/podman/spec_test.go b/cmd/podman/spec_test.go
index 586c09656..768b079aa 100644
--- a/cmd/podman/spec_test.go
+++ b/cmd/podman/spec_test.go
@@ -23,6 +23,12 @@ func TestCreateConfig_GetVolumeMounts(t *testing.T) {
assert.True(t, reflect.DeepEqual(data, specMount[0]))
}
+func TestCreateConfig_GetAnnotations(t *testing.T) {
+ config := createConfig{}
+ annotations := config.GetAnnotations()
+ assert.True(t, reflect.DeepEqual("sandbox", annotations["io.kubernetes.cri-o.ContainerType"]))
+}
+
func TestCreateConfig_GetTmpfsMounts(t *testing.T) {
data := spec.Mount{
Destination: "/homer",
diff --git a/test/e2e/kill_test.go b/test/e2e/kill_test.go
new file mode 100644
index 000000000..c0ee3dab9
--- /dev/null
+++ b/test/e2e/kill_test.go
@@ -0,0 +1,95 @@
+package integration
+
+import (
+ "os"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+)
+
+var _ = Describe("Podman kill", func() {
+ var (
+ tempdir string
+ err error
+ podmanTest PodmanTest
+ )
+
+ BeforeEach(func() {
+ tempdir, err = CreateTempDirInTempDir()
+ if err != nil {
+ os.Exit(1)
+ }
+ podmanTest = PodmanCreate(tempdir)
+ podmanTest.RestoreAllArtifacts()
+ })
+
+ AfterEach(func() {
+ podmanTest.Cleanup()
+
+ })
+
+ It("podman kill bogus container", func() {
+ session := podmanTest.Podman([]string{"kill", "foobar"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Not(Equal(0)))
+ })
+
+ It("podman kill a running container by id", func() {
+ session := podmanTest.RunSleepContainer("")
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ cid := session.OutputToString()
+
+ result := podmanTest.Podman([]string{"kill", cid})
+ result.WaitWithDefaultTimeout()
+
+ Expect(result.ExitCode()).To(Equal(0))
+ Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0))
+ })
+
+ It("podman kill a running container by id with TERM", func() {
+ session := podmanTest.RunSleepContainer("")
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ cid := session.OutputToString()
+
+ result := podmanTest.Podman([]string{"kill", "-s", "9", cid})
+ result.WaitWithDefaultTimeout()
+ Expect(result.ExitCode()).To(Equal(0))
+ Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0))
+ })
+
+ It("podman kill a running container by name", func() {
+ session := podmanTest.RunSleepContainer("test1")
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ result := podmanTest.Podman([]string{"kill", "-s", "9", "test1"})
+ result.WaitWithDefaultTimeout()
+ Expect(result.ExitCode()).To(Equal(0))
+ Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0))
+ })
+
+ It("podman kill a running container by id with a bogus signal", func() {
+ session := podmanTest.RunSleepContainer("")
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ cid := session.OutputToString()
+
+ result := podmanTest.Podman([]string{"kill", "-s", "foobar", cid})
+ result.WaitWithDefaultTimeout()
+ Expect(result.ExitCode()).To(Equal(125))
+ Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1))
+ })
+
+ It("podman kill latest container", func() {
+ session := podmanTest.RunSleepContainer("")
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ result := podmanTest.Podman([]string{"kill", "-l"})
+ result.WaitWithDefaultTimeout()
+ Expect(result.ExitCode()).To(Equal(0))
+ Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0))
+ })
+})
diff --git a/test/e2e/libpod_suite_test.go b/test/e2e/libpod_suite_test.go
index aaad97447..be9be93d8 100644
--- a/test/e2e/libpod_suite_test.go
+++ b/test/e2e/libpod_suite_test.go
@@ -345,11 +345,28 @@ func (p *PodmanTest) RunSleepContainer(name string) *PodmanSession {
//RunLsContainer runs a simple container in the background that
// simply runs ls. If the name passed != "", it will have a name
-func (p *PodmanTest) RunLsContainer(name string) *PodmanSession {
+func (p *PodmanTest) RunLsContainer(name string) (*PodmanSession, int, string) {
var podmanArgs = []string{"run"}
if name != "" {
podmanArgs = append(podmanArgs, "--name", name)
}
podmanArgs = append(podmanArgs, "-d", ALPINE, "ls")
- return p.Podman(podmanArgs)
+ session := p.Podman(podmanArgs)
+ session.WaitWithDefaultTimeout()
+ return session, session.ExitCode(), session.OutputToString()
+}
+
+//NumberOfContainersRunning returns an int of how many
+// containers are currently running.
+func (p *PodmanTest) NumberOfContainersRunning() int {
+ var containers []string
+ ps := p.Podman([]string{"ps", "-q"})
+ ps.WaitWithDefaultTimeout()
+ Expect(ps.ExitCode()).To(Equal(0))
+ for _, i := range ps.OutputToStringArray() {
+ if i != "" {
+ containers = append(containers, i)
+ }
+ }
+ return len(containers)
}
diff --git a/test/e2e/ps_test.go b/test/e2e/ps_test.go
index 690015552..d0aa0bd7c 100644
--- a/test/e2e/ps_test.go
+++ b/test/e2e/ps_test.go
@@ -47,9 +47,8 @@ var _ = Describe("Podman ps", func() {
})
It("podman ps all", func() {
- session := podmanTest.RunLsContainer("")
- session.WaitWithDefaultTimeout()
- Expect(session.ExitCode()).To(Equal(0))
+ _, ec, _ := podmanTest.RunLsContainer("")
+ Expect(ec).To(Equal(0))
result := podmanTest.Podman([]string{"ps", "-a"})
result.WaitWithDefaultTimeout()
@@ -58,9 +57,8 @@ var _ = Describe("Podman ps", func() {
})
It("podman ps size flag", func() {
- session := podmanTest.RunLsContainer("")
- session.WaitWithDefaultTimeout()
- Expect(session.ExitCode()).To(Equal(0))
+ _, ec, _ := podmanTest.RunLsContainer("")
+ Expect(ec).To(Equal(0))
result := podmanTest.Podman([]string{"ps", "-a", "--size"})
result.WaitWithDefaultTimeout()
@@ -69,10 +67,8 @@ var _ = Describe("Podman ps", func() {
})
It("podman ps quiet flag", func() {
- session := podmanTest.RunLsContainer("")
- session.WaitWithDefaultTimeout()
- Expect(session.ExitCode()).To(Equal(0))
- fullCid := session.OutputToString()
+ _, ec, fullCid := podmanTest.RunLsContainer("")
+ Expect(ec).To(Equal(0))
result := podmanTest.Podman([]string{"ps", "-a", "-q"})
result.WaitWithDefaultTimeout()
@@ -82,9 +78,8 @@ var _ = Describe("Podman ps", func() {
})
It("podman ps latest flag", func() {
- session := podmanTest.RunLsContainer("")
- session.WaitWithDefaultTimeout()
- Expect(session.ExitCode()).To(Equal(0))
+ _, ec, _ := podmanTest.RunLsContainer("")
+ Expect(ec).To(Equal(0))
result := podmanTest.Podman([]string{"ps", "--latest"})
result.WaitWithDefaultTimeout()
@@ -93,18 +88,15 @@ var _ = Describe("Podman ps", func() {
})
It("podman ps last flag", func() {
- session := podmanTest.RunLsContainer("test1")
- session.WaitWithDefaultTimeout()
- Expect(session.ExitCode()).To(Equal(0))
+ _, ec, _ := podmanTest.RunLsContainer("test1")
+ Expect(ec).To(Equal(0))
- session = podmanTest.RunLsContainer("test2")
- session.WaitWithDefaultTimeout()
- Expect(session.ExitCode()).To(Equal(0))
+ _, ec, _ = podmanTest.RunLsContainer("test2")
+ Expect(ec).To(Equal(0))
- session = podmanTest.RunLsContainer("test3")
- session.WaitWithDefaultTimeout()
+ _, ec, _ = podmanTest.RunLsContainer("test3")
+ Expect(ec).To(Equal(0))
- Expect(session.ExitCode()).To(Equal(0))
result := podmanTest.Podman([]string{"ps", "--last", "2"})
result.WaitWithDefaultTimeout()
Expect(result.ExitCode()).To(Equal(0))
@@ -112,10 +104,8 @@ var _ = Describe("Podman ps", func() {
})
It("podman ps no-trunc", func() {
- session := podmanTest.RunLsContainer("test1")
- session.WaitWithDefaultTimeout()
- Expect(session.ExitCode()).To(Equal(0))
- fullCid := session.OutputToString()
+ _, ec, fullCid := podmanTest.RunLsContainer("")
+ Expect(ec).To(Equal(0))
result := podmanTest.Podman([]string{"ps", "-aq", "--no-trunc"})
result.WaitWithDefaultTimeout()
@@ -125,9 +115,8 @@ var _ = Describe("Podman ps", func() {
})
It("podman ps namespace flag", func() {
- session := podmanTest.RunLsContainer("test1")
- session.WaitWithDefaultTimeout()
- Expect(session.ExitCode()).To(Equal(0))
+ _, ec, _ := podmanTest.RunLsContainer("")
+ Expect(ec).To(Equal(0))
result := podmanTest.Podman([]string{"ps", "-a", "--namespace"})
result.WaitWithDefaultTimeout()
@@ -136,9 +125,8 @@ var _ = Describe("Podman ps", func() {
})
It("podman ps namespace flag with json format", func() {
- session := podmanTest.RunLsContainer("test1")
- session.WaitWithDefaultTimeout()
- Expect(session.ExitCode()).To(Equal(0))
+ _, ec, _ := podmanTest.RunLsContainer("test1")
+ Expect(ec).To(Equal(0))
result := podmanTest.Podman([]string{"ps", "-a", "--ns", "--format", "json"})
result.WaitWithDefaultTimeout()
@@ -147,9 +135,8 @@ var _ = Describe("Podman ps", func() {
})
It("podman ps namespace flag with go template format", func() {
- session := podmanTest.RunLsContainer("test1")
- session.WaitWithDefaultTimeout()
- Expect(session.ExitCode()).To(Equal(0))
+ _, ec, _ := podmanTest.RunLsContainer("test1")
+ Expect(ec).To(Equal(0))
result := podmanTest.Podman([]string{"ps", "-a", "--format", "\"table {{.ID}} {{.Image}} {{.Labels}}\""})
result.WaitWithDefaultTimeout()
@@ -158,9 +145,8 @@ var _ = Describe("Podman ps", func() {
})
It("podman ps ancestor filter flag", func() {
- session := podmanTest.RunLsContainer("test1")
- session.WaitWithDefaultTimeout()
- Expect(session.ExitCode()).To(Equal(0))
+ _, ec, _ := podmanTest.RunLsContainer("test1")
+ Expect(ec).To(Equal(0))
result := podmanTest.Podman([]string{"ps", "-a", "--filter", "ancestor=docker.io/library/alpine:latest"})
result.WaitWithDefaultTimeout()
@@ -168,10 +154,8 @@ var _ = Describe("Podman ps", func() {
})
It("podman ps id filter flag", func() {
- session := podmanTest.RunLsContainer("test1")
- session.WaitWithDefaultTimeout()
- Expect(session.ExitCode()).To(Equal(0))
- fullCid := session.OutputToString()
+ _, ec, fullCid := podmanTest.RunLsContainer("")
+ Expect(ec).To(Equal(0))
result := podmanTest.Podman([]string{"ps", "-a", "--filter", fmt.Sprintf("id=%s", fullCid)})
result.WaitWithDefaultTimeout()
diff --git a/test/e2e/rm_test.go b/test/e2e/rm_test.go
index 1ef8ee5e6..a59b2ee01 100644
--- a/test/e2e/rm_test.go
+++ b/test/e2e/rm_test.go
@@ -29,10 +29,8 @@ var _ = Describe("Podman rm", func() {
})
It("podman rm stopped container", func() {
- session := podmanTest.RunLsContainer("")
- session.WaitWithDefaultTimeout()
- Expect(session.ExitCode()).To(Equal(0))
- cid := session.OutputToString()
+ _, ec, cid := podmanTest.RunLsContainer("")
+ Expect(ec).To(Equal(0))
result := podmanTest.Podman([]string{"rm", cid})
result.WaitWithDefaultTimeout()
diff --git a/test/podman_kill.bats b/test/podman_kill.bats
deleted file mode 100644
index f24bd0971..000000000
--- a/test/podman_kill.bats
+++ /dev/null
@@ -1,71 +0,0 @@
-#!/usr/bin/env bats
-
-load helpers
-
-function teardown() {
- cleanup_test
-}
-
-function setup() {
- copy_images
-}
-
-@test "kill a bogus container" {
- run ${PODMAN_BINARY} ${PODMAN_OPTIONS} kill foobar
- echo "$output"
- [ "$status" -ne 0 ]
-}
-
-@test "kill a running container by id" {
- run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run -d ${ALPINE} sleep 9999
- [ "$status" -eq 0 ]
- ctr_id="$output"
- run ${PODMAN_BINARY} ${PODMAN_OPTIONS} ps
- [ "$status" -eq 0 ]
- run ${PODMAN_BINARY} ${PODMAN_OPTIONS} kill $ctr_id
- [ "$status" -eq 0 ]
- run ${PODMAN_BINARY} ${PODMAN_OPTIONS} ps
- [ "$status" -eq 0 ]
-}
-
-@test "kill a running container by id with TERM" {
- run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run -d ${ALPINE} sleep 9999
- [ "$status" -eq 0 ]
- ctr_id="$output"
- run ${PODMAN_BINARY} ${PODMAN_OPTIONS} ps
- [ "$status" -eq 0 ]
- run ${PODMAN_BINARY} ${PODMAN_OPTIONS} kill -s TERM $ctr_id
- [ "$status" -eq 0 ]
- run ${PODMAN_BINARY} ${PODMAN_OPTIONS} ps --no-trunc
- [ "$status" -eq 0 ]
-}
-
-@test "kill a running container by name" {
- run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run --name test1 -d ${ALPINE} sleep 9999
- [ "$status" -eq 0 ]
- run ${PODMAN_BINARY} ${PODMAN_OPTIONS} ps
- [ "$status" -eq 0 ]
- run ${PODMAN_BINARY} ${PODMAN_OPTIONS} kill -s TERM test1
- [ "$status" -eq 0 ]
- run ${PODMAN_BINARY} ${PODMAN_OPTIONS} ps --no-trunc
- [ "$status" -eq 0 ]
-}
-
-@test "kill a running container by id with a bogus signal" {
- run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run -d ${ALPINE} sleep 9999
- [ "$status" -eq 0 ]
- ctr_id="$output"
- run ${PODMAN_BINARY} ${PODMAN_OPTIONS} ps
- [ "$status" -eq 0 ]
- run ${PODMAN_BINARY} ${PODMAN_OPTIONS} kill -s foobar $ctr_id
- [ "$status" -eq 125 ]
- run ${PODMAN_BINARY} ${PODMAN_OPTIONS} ps --no-trunc
- [ "$status" -eq 0 ]
-}
-
-@test "kill the latest container run" {
- ${PODMAN_BINARY} ${PODMAN_OPTIONS} run -d ${ALPINE} sleep 9999
- run ${PODMAN_BINARY} ${PODMAN_OPTIONS} kill -l
- echo "$output"
- [ "$status" -eq 0 ]
-}