summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/e2e/checkpoint_test.go32
-rw-r--r--test/e2e/common_test.go33
-rw-r--r--test/e2e/create_staticip_test.go10
-rw-r--r--test/e2e/events_test.go22
-rw-r--r--test/e2e/libpod_suite_remoteclient_test.go15
-rw-r--r--test/e2e/libpod_suite_test.go28
-rw-r--r--test/e2e/pause_test.go4
-rw-r--r--test/e2e/play_kube_test.go75
-rw-r--r--test/e2e/rm_test.go2
-rw-r--r--test/e2e/rmi_test.go2
-rw-r--r--test/e2e/run_staticip_test.go10
-rw-r--r--test/e2e/run_test.go8
-rw-r--r--test/e2e/search_test.go12
-rw-r--r--test/e2e/version_test.go21
-rw-r--r--test/system/005-info.bats2
-rw-r--r--test/system/helpers.bash4
-rw-r--r--test/utils/podmantest_test.go2
-rw-r--r--test/utils/utils.go28
-rw-r--r--test/utils/utils_suite_test.go2
19 files changed, 230 insertions, 82 deletions
diff --git a/test/e2e/checkpoint_test.go b/test/e2e/checkpoint_test.go
index b77c48c8e..d37d7c7cc 100644
--- a/test/e2e/checkpoint_test.go
+++ b/test/e2e/checkpoint_test.go
@@ -3,12 +3,9 @@
package integration
import (
- "math/rand"
"net"
"os"
"os/exec"
- "strconv"
- "time"
"github.com/containers/libpod/pkg/criu"
. "github.com/containers/libpod/test/utils"
@@ -17,12 +14,8 @@ import (
)
func getRunString(input []string) []string {
- // To avoid IP collisions of initialize random seed for random IP addresses
- rand.Seed(time.Now().UnixNano())
- ip3 := strconv.Itoa(rand.Intn(230) + GinkgoParallelNode())
- ip4 := strconv.Itoa(rand.Intn(230) + GinkgoParallelNode())
// CRIU does not work with seccomp correctly on RHEL7 : seccomp=unconfined
- runString := []string{"run", "-it", "--security-opt", "seccomp=unconfined", "-d", "--ip", "10.88." + ip3 + "." + ip4}
+ runString := []string{"run", "-it", "--security-opt", "seccomp=unconfined", "-d", "--ip", GetRandomIPAddress()}
return append(runString, input...)
}
@@ -154,7 +147,7 @@ var _ = Describe("Podman checkpoint", func() {
result = podmanTest.Podman([]string{"rm", cid})
result.WaitWithDefaultTimeout()
- Expect(result.ExitCode()).To(Equal(125))
+ Expect(result.ExitCode()).To(Equal(2))
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1))
result = podmanTest.Podman([]string{"rm", "-f", cid})
@@ -371,8 +364,8 @@ var _ = Describe("Podman checkpoint", func() {
// This test does the same steps which are necessary for migrating
// a container from one host to another
It("podman checkpoint container with export (migration)", func() {
- // CRIU does not work with seccomp correctly on RHEL7
- session := podmanTest.Podman([]string{"run", "-it", "--security-opt", "seccomp=unconfined", "-d", ALPINE, "top"})
+ localRunString := getRunString([]string{"--rm", ALPINE, "top"})
+ session := podmanTest.Podman(localRunString)
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1))
@@ -384,13 +377,7 @@ var _ = Describe("Podman checkpoint", func() {
Expect(result.ExitCode()).To(Equal(0))
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0))
- Expect(podmanTest.GetContainerStatus()).To(ContainSubstring("Exited"))
-
- // Remove all containers to simulate migration
- result = podmanTest.Podman([]string{"rm", "-fa"})
- result.WaitWithDefaultTimeout()
- Expect(result.ExitCode()).To(Equal(0))
- Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0))
+ Expect(podmanTest.NumberOfContainers()).To(Equal(0))
result = podmanTest.Podman([]string{"container", "restore", "-i", fileName})
result.WaitWithDefaultTimeout()
@@ -399,8 +386,12 @@ var _ = Describe("Podman checkpoint", func() {
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1))
Expect(podmanTest.GetContainerStatus()).To(ContainSubstring("Up"))
- // Restore container a second time with different name
- result = podmanTest.Podman([]string{"container", "restore", "-i", fileName, "-n", "restore_again"})
+ // Restore container a second time with different name.
+ // Using '--ignore-static-ip' as for parallel test runs
+ // each containers gets a random IP address via '--ip'.
+ // '--ignore-static-ip' tells the restore to use the next
+ // available IP address.
+ result = podmanTest.Podman([]string{"container", "restore", "-i", fileName, "-n", "restore_again", "--ignore-static-ip"})
result.WaitWithDefaultTimeout()
Expect(result.ExitCode()).To(Equal(0))
@@ -411,6 +402,7 @@ var _ = Describe("Podman checkpoint", func() {
result.WaitWithDefaultTimeout()
Expect(result.ExitCode()).To(Equal(0))
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0))
+ Expect(podmanTest.NumberOfContainers()).To(Equal(0))
// Remove exported checkpoint
os.Remove(fileName)
diff --git a/test/e2e/common_test.go b/test/e2e/common_test.go
index 7e14f9e06..b6dd1ecd1 100644
--- a/test/e2e/common_test.go
+++ b/test/e2e/common_test.go
@@ -4,10 +4,12 @@ import (
"encoding/json"
"fmt"
"io/ioutil"
+ "math/rand"
"os"
"os/exec"
"path/filepath"
"sort"
+ "strconv"
"strings"
"testing"
"time"
@@ -109,10 +111,7 @@ var _ = SynchronizedBeforeSuite(func() []byte {
}
for _, image := range CACHE_IMAGES {
- if err := podman.CreateArtifact(image); err != nil {
- fmt.Printf("%q\n", err)
- os.Exit(1)
- }
+ podman.createArtifact(image)
}
// If running localized tests, the cache dir is created and populated. if the
@@ -285,25 +284,26 @@ func (p *PodmanTestIntegration) RestoreAllArtifacts() error {
return nil
}
-// CreateArtifact creates a cached image in the artifact dir
-func (p *PodmanTestIntegration) CreateArtifact(image string) error {
+// createArtifact creates a cached image in the artifact dir
+func (p *PodmanTestIntegration) createArtifact(image string) {
if os.Getenv("NO_TEST_CACHE") != "" {
- return nil
+ return
}
- fmt.Printf("Caching %s...", image)
dest := strings.Split(image, "/")
destName := fmt.Sprintf("/tmp/%s.tar", strings.Replace(strings.Join(strings.Split(dest[len(dest)-1], "/"), ""), ":", "-", -1))
+ fmt.Printf("Caching %s at %s...", image, destName)
if _, err := os.Stat(destName); os.IsNotExist(err) {
pull := p.PodmanNoCache([]string{"pull", image})
pull.Wait(90)
+ Expect(pull.ExitCode()).To(Equal(0))
save := p.PodmanNoCache([]string{"save", "-o", destName, image})
save.Wait(90)
+ Expect(save.ExitCode()).To(Equal(0))
fmt.Printf("\n")
} else {
fmt.Printf(" already exists.\n")
}
- return nil
}
// InspectImageJSON takes the session output of an inspect
@@ -320,6 +320,7 @@ func (p *PodmanTestIntegration) InspectContainer(name string) []libpod.InspectCo
cmd := []string{"inspect", name}
session := p.Podman(cmd)
session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
return session.InspectContainerToJSON()
}
@@ -339,6 +340,18 @@ func GetPortLock(port string) storage.Locker {
return lock
}
+// GetRandomIPAddress returns a random IP address to avoid IP
+// collisions during parallel tests
+func GetRandomIPAddress() string {
+ // To avoid IP collisions of initialize random seed for random IP addresses
+ rand.Seed(time.Now().UnixNano())
+ // Add GinkgoParallelNode() on top of the IP address
+ // in case of the same random seed
+ ip3 := strconv.Itoa(rand.Intn(230) + GinkgoParallelNode())
+ ip4 := strconv.Itoa(rand.Intn(230) + GinkgoParallelNode())
+ return "10.88." + ip3 + "." + ip4
+}
+
// RunTopContainer runs a simple container in the background that
// runs top. If the name passed != "", it will have a name
func (p *PodmanTestIntegration) RunTopContainer(name string) *PodmanSessionIntegration {
@@ -399,7 +412,7 @@ func (p *PodmanTestIntegration) BuildImage(dockerfile, imageName string, layers
// PodmanPID execs podman and returns its PID
func (p *PodmanTestIntegration) PodmanPID(args []string) (*PodmanSessionIntegration, int) {
- podmanOptions := p.MakeOptions(args)
+ podmanOptions := p.MakeOptions(args, false)
fmt.Printf("Running: %s %s\n", p.PodmanBinary, strings.Join(podmanOptions, " "))
command := exec.Command(p.PodmanBinary, podmanOptions...)
session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter)
diff --git a/test/e2e/create_staticip_test.go b/test/e2e/create_staticip_test.go
index 11301856b..709e56665 100644
--- a/test/e2e/create_staticip_test.go
+++ b/test/e2e/create_staticip_test.go
@@ -60,7 +60,8 @@ var _ = Describe("Podman create with --ip flag", func() {
})
It("Podman create with specified static IP has correct IP", func() {
- result := podmanTest.Podman([]string{"create", "--name", "test", "--ip", "10.88.64.128", ALPINE, "ip", "addr"})
+ ip := GetRandomIPAddress()
+ result := podmanTest.Podman([]string{"create", "--name", "test", "--ip", ip, ALPINE, "ip", "addr"})
result.WaitWithDefaultTimeout()
Expect(result.ExitCode()).To(Equal(0))
@@ -71,14 +72,15 @@ var _ = Describe("Podman create with --ip flag", func() {
result = podmanTest.Podman([]string{"logs", "test"})
result.WaitWithDefaultTimeout()
Expect(result.ExitCode()).To(Equal(0))
- Expect(result.OutputToString()).To(ContainSubstring("10.88.64.128/16"))
+ Expect(result.OutputToString()).To(ContainSubstring(ip + "/16"))
})
It("Podman create two containers with the same IP", func() {
- result := podmanTest.Podman([]string{"create", "--name", "test1", "--ip", "10.88.64.128", ALPINE, "sleep", "999"})
+ ip := GetRandomIPAddress()
+ result := podmanTest.Podman([]string{"create", "--name", "test1", "--ip", ip, ALPINE, "sleep", "999"})
result.WaitWithDefaultTimeout()
Expect(result.ExitCode()).To(Equal(0))
- result = podmanTest.Podman([]string{"create", "--name", "test2", "--ip", "10.88.64.128", ALPINE, "ip", "addr"})
+ result = podmanTest.Podman([]string{"create", "--name", "test2", "--ip", ip, ALPINE, "ip", "addr"})
result.WaitWithDefaultTimeout()
Expect(result.ExitCode()).To(Equal(0))
result = podmanTest.Podman([]string{"start", "test1"})
diff --git a/test/e2e/events_test.go b/test/e2e/events_test.go
index c5eedda3c..0636af74c 100644
--- a/test/e2e/events_test.go
+++ b/test/e2e/events_test.go
@@ -1,6 +1,7 @@
package integration
import (
+ "encoding/json"
"fmt"
"os"
"strings"
@@ -116,4 +117,25 @@ var _ = Describe("Podman events", func() {
Expect(result.ExitCode()).To(BeZero())
})
+ It("podman events format", func() {
+ info := GetHostDistributionInfo()
+ if info.Distribution != "fedora" {
+ Skip("need to verify images have correct packages for journald")
+ }
+ _, ec, _ := podmanTest.RunLsContainer("")
+ Expect(ec).To(Equal(0))
+ test := podmanTest.Podman([]string{"events", "--stream=false", "--format", "json"})
+ test.WaitWithDefaultTimeout()
+ fmt.Println(test.OutputToStringArray())
+ jsonArr := test.OutputToStringArray()
+ Expect(len(jsonArr)).To(Not(BeZero()))
+ eventsMap := make(map[string]string)
+ err := json.Unmarshal([]byte(jsonArr[0]), &eventsMap)
+ if err != nil {
+ os.Exit(1)
+ }
+ _, exist := eventsMap["Status"]
+ Expect(exist).To(BeTrue())
+ Expect(test.ExitCode()).To(BeZero())
+ })
})
diff --git a/test/e2e/libpod_suite_remoteclient_test.go b/test/e2e/libpod_suite_remoteclient_test.go
index c8210f7d1..7f33fec87 100644
--- a/test/e2e/libpod_suite_remoteclient_test.go
+++ b/test/e2e/libpod_suite_remoteclient_test.go
@@ -30,13 +30,20 @@ func SkipIfRootless() {
// Podman is the exec call to podman on the filesystem
func (p *PodmanTestIntegration) Podman(args []string) *PodmanSessionIntegration {
- podmanSession := p.PodmanBase(args, false)
+ podmanSession := p.PodmanBase(args, false, false)
return &PodmanSessionIntegration{podmanSession}
}
// PodmanNoCache calls podman with out adding the imagecache
func (p *PodmanTestIntegration) PodmanNoCache(args []string) *PodmanSessionIntegration {
- podmanSession := p.PodmanBase(args, true)
+ podmanSession := p.PodmanBase(args, true, false)
+ return &PodmanSessionIntegration{podmanSession}
+}
+
+// PodmanNoEvents calls the Podman command without an imagecache and without an
+// events backend. It is used mostly for caching and uncaching images.
+func (p *PodmanTestIntegration) PodmanNoEvents(args []string) *PodmanSessionIntegration {
+ podmanSession := p.PodmanBase(args, true, true)
return &PodmanSessionIntegration{podmanSession}
}
@@ -135,7 +142,7 @@ func (p *PodmanTestIntegration) StopVarlink() {
}
//MakeOptions assembles all the podman main options
-func (p *PodmanTestIntegration) makeOptions(args []string) []string {
+func (p *PodmanTestIntegration) makeOptions(args []string, noEvents bool) []string {
return args
}
@@ -156,7 +163,7 @@ func (p *PodmanTestIntegration) RestoreArtifactToCache(image string) error {
dest := strings.Split(image, "/")
destName := fmt.Sprintf("/tmp/%s.tar", strings.Replace(strings.Join(strings.Split(dest[len(dest)-1], "/"), ""), ":", "-", -1))
p.CrioRoot = p.ImageCacheDir
- restore := p.PodmanNoCache([]string{"load", "-q", "-i", destName})
+ restore := p.PodmanNoEvents([]string{"load", "-q", "-i", destName})
restore.WaitWithDefaultTimeout()
return nil
}
diff --git a/test/e2e/libpod_suite_test.go b/test/e2e/libpod_suite_test.go
index 8d993ee72..1df59dbe3 100644
--- a/test/e2e/libpod_suite_test.go
+++ b/test/e2e/libpod_suite_test.go
@@ -23,19 +23,26 @@ func SkipIfRootless() {
// Podman is the exec call to podman on the filesystem
func (p *PodmanTestIntegration) Podman(args []string) *PodmanSessionIntegration {
- podmanSession := p.PodmanBase(args, false)
+ podmanSession := p.PodmanBase(args, false, false)
return &PodmanSessionIntegration{podmanSession}
}
// PodmanNoCache calls the podman command with no configured imagecache
func (p *PodmanTestIntegration) PodmanNoCache(args []string) *PodmanSessionIntegration {
- podmanSession := p.PodmanBase(args, true)
+ podmanSession := p.PodmanBase(args, true, false)
+ return &PodmanSessionIntegration{podmanSession}
+}
+
+// PodmanNoEvents calls the Podman command without an imagecache and without an
+// events backend. It is used mostly for caching and uncaching images.
+func (p *PodmanTestIntegration) PodmanNoEvents(args []string) *PodmanSessionIntegration {
+ podmanSession := p.PodmanBase(args, true, true)
return &PodmanSessionIntegration{podmanSession}
}
// PodmanAsUser is the exec call to podman on the filesystem with the specified uid/gid and environment
func (p *PodmanTestIntegration) PodmanAsUser(args []string, uid, gid uint32, cwd string, env []string) *PodmanSessionIntegration {
- podmanSession := p.PodmanAsUserBase(args, uid, gid, cwd, env, false)
+ podmanSession := p.PodmanAsUserBase(args, uid, gid, cwd, env, false, false)
return &PodmanSessionIntegration{podmanSession}
}
@@ -59,14 +66,19 @@ func PodmanTestCreate(tempDir string) *PodmanTestIntegration {
}
// MakeOptions assembles all the podman main options
-func (p *PodmanTestIntegration) makeOptions(args []string) []string {
+func (p *PodmanTestIntegration) makeOptions(args []string, noEvents bool) []string {
var debug string
if _, ok := os.LookupEnv("DEBUG"); ok {
debug = "--log-level=debug --syslog=true "
}
- podmanOptions := strings.Split(fmt.Sprintf("%s--root %s --runroot %s --runtime %s --conmon %s --cni-config-dir %s --cgroup-manager %s --tmpdir %s",
- debug, p.CrioRoot, p.RunRoot, p.OCIRuntime, p.ConmonBinary, p.CNIConfigDir, p.CgroupManager, p.TmpDir), " ")
+ eventsType := "file"
+ if noEvents {
+ eventsType = "none"
+ }
+
+ podmanOptions := strings.Split(fmt.Sprintf("%s--root %s --runroot %s --runtime %s --conmon %s --cni-config-dir %s --cgroup-manager %s --tmpdir %s --events-backend %s",
+ debug, p.CrioRoot, p.RunRoot, p.OCIRuntime, p.ConmonBinary, p.CNIConfigDir, p.CgroupManager, p.TmpDir, eventsType), " ")
if os.Getenv("HOOK_OPTION") != "" {
podmanOptions = append(podmanOptions, os.Getenv("HOOK_OPTION"))
}
@@ -81,7 +93,7 @@ func (p *PodmanTestIntegration) RestoreArtifact(image string) error {
fmt.Printf("Restoring %s...\n", image)
dest := strings.Split(image, "/")
destName := fmt.Sprintf("/tmp/%s.tar", strings.Replace(strings.Join(strings.Split(dest[len(dest)-1], "/"), ""), ":", "-", -1))
- restore := p.PodmanNoCache([]string{"load", "-q", "-i", destName})
+ restore := p.PodmanNoEvents([]string{"load", "-q", "-i", destName})
restore.Wait(90)
return nil
}
@@ -93,7 +105,7 @@ func (p *PodmanTestIntegration) RestoreArtifactToCache(image string) error {
destName := fmt.Sprintf("/tmp/%s.tar", strings.Replace(strings.Join(strings.Split(dest[len(dest)-1], "/"), ""), ":", "-", -1))
p.CrioRoot = p.ImageCacheDir
- restore := p.PodmanNoCache([]string{"load", "-q", "-i", destName})
+ restore := p.PodmanNoEvents([]string{"load", "-q", "-i", destName})
restore.WaitWithDefaultTimeout()
return nil
}
diff --git a/test/e2e/pause_test.go b/test/e2e/pause_test.go
index 01fb6d91b..455f60937 100644
--- a/test/e2e/pause_test.go
+++ b/test/e2e/pause_test.go
@@ -126,7 +126,7 @@ var _ = Describe("Podman pause", func() {
result = podmanTest.Podman([]string{"rm", cid})
result.WaitWithDefaultTimeout()
- Expect(result.ExitCode()).To(Equal(125))
+ Expect(result.ExitCode()).To(Equal(2))
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0))
Expect(podmanTest.GetContainerStatus()).To(ContainSubstring(pausedState))
@@ -179,7 +179,7 @@ var _ = Describe("Podman pause", func() {
result = podmanTest.Podman([]string{"rm", cid})
result.WaitWithDefaultTimeout()
- Expect(result.ExitCode()).To(Equal(125))
+ Expect(result.ExitCode()).To(Equal(2))
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1))
result = podmanTest.Podman([]string{"rm", "-f", cid})
diff --git a/test/e2e/play_kube_test.go b/test/e2e/play_kube_test.go
index a6f59a3da..331412a39 100644
--- a/test/e2e/play_kube_test.go
+++ b/test/e2e/play_kube_test.go
@@ -25,7 +25,9 @@ spec:
{{ with .Containers }}
{{ range . }}
- command:
- - {{ .Cmd }}
+ {{ range .Cmd }}
+ - {{.}}
+ {{ end }}
env:
- name: PATH
value: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
@@ -39,7 +41,21 @@ spec:
resources: {}
securityContext:
allowPrivilegeEscalation: true
- capabilities: {}
+ {{ if .Caps }}
+ capabilities:
+ {{ with .CapAdd }}
+ add:
+ {{ range . }}
+ - {{.}}
+ {{ end }}
+ {{ end }}
+ {{ with .CapDrop }}
+ drop:
+ {{ range . }}
+ - {{.}}
+ {{ end }}
+ {{ end }}
+ {{ end }}
privileged: false
readOnlyRootFilesystem: false
workingDir: /
@@ -54,9 +70,12 @@ type Pod struct {
}
type Container struct {
- Cmd string
- Image string
- Name string
+ Cmd []string
+ Image string
+ Name string
+ Caps bool
+ CapAdd []string
+ CapDrop []string
}
func generateKubeYaml(ctrs []Container, fileName string) error {
@@ -104,8 +123,8 @@ var _ = Describe("Podman generate kube", func() {
It("podman play kube test correct command", func() {
ctrName := "testCtr"
- ctrCmd := "top"
- testContainer := Container{ctrCmd, ALPINE, ctrName}
+ ctrCmd := []string{"top"}
+ testContainer := Container{ctrCmd, ALPINE, ctrName, false, nil, nil}
tempFile := filepath.Join(podmanTest.TempDir, "kube.yaml")
err := generateKubeYaml([]Container{testContainer}, tempFile)
@@ -118,6 +137,46 @@ var _ = Describe("Podman generate kube", func() {
inspect := podmanTest.Podman([]string{"inspect", ctrName})
inspect.WaitWithDefaultTimeout()
Expect(inspect.ExitCode()).To(Equal(0))
- Expect(inspect.OutputToString()).To(ContainSubstring(ctrCmd))
+ Expect(inspect.OutputToString()).To(ContainSubstring(ctrCmd[0]))
+ })
+
+ It("podman play kube cap add", func() {
+ ctrName := "testCtr"
+ ctrCmd := []string{"cat", "/proc/self/status"}
+ capAdd := "CAP_SYS_ADMIN"
+ testContainer := Container{ctrCmd, ALPINE, ctrName, true, []string{capAdd}, nil}
+ tempFile := filepath.Join(podmanTest.TempDir, "kube.yaml")
+
+ err := generateKubeYaml([]Container{testContainer}, tempFile)
+ Expect(err).To(BeNil())
+
+ kube := podmanTest.Podman([]string{"play", "kube", tempFile})
+ kube.WaitWithDefaultTimeout()
+ Expect(kube.ExitCode()).To(Equal(0))
+
+ inspect := podmanTest.Podman([]string{"inspect", ctrName})
+ inspect.WaitWithDefaultTimeout()
+ Expect(inspect.ExitCode()).To(Equal(0))
+ Expect(inspect.OutputToString()).To(ContainSubstring(capAdd))
+ })
+
+ It("podman play kube cap add", func() {
+ ctrName := "testCtr"
+ ctrCmd := []string{"cat", "/proc/self/status"}
+ capDrop := "CAP_SYS_ADMIN"
+ testContainer := Container{ctrCmd, ALPINE, ctrName, true, []string{capDrop}, nil}
+ tempFile := filepath.Join(podmanTest.TempDir, "kube.yaml")
+
+ err := generateKubeYaml([]Container{testContainer}, tempFile)
+ Expect(err).To(BeNil())
+
+ kube := podmanTest.Podman([]string{"play", "kube", tempFile})
+ kube.WaitWithDefaultTimeout()
+ Expect(kube.ExitCode()).To(Equal(0))
+
+ inspect := podmanTest.Podman([]string{"inspect", ctrName})
+ inspect.WaitWithDefaultTimeout()
+ Expect(inspect.ExitCode()).To(Equal(0))
+ Expect(inspect.OutputToString()).To(ContainSubstring(capDrop))
})
})
diff --git a/test/e2e/rm_test.go b/test/e2e/rm_test.go
index 2dbabbf6a..8ee7dc750 100644
--- a/test/e2e/rm_test.go
+++ b/test/e2e/rm_test.go
@@ -49,7 +49,7 @@ var _ = Describe("Podman rm", func() {
result := podmanTest.Podman([]string{"rm", cid})
result.WaitWithDefaultTimeout()
- Expect(result.ExitCode()).To(Equal(125))
+ Expect(result.ExitCode()).To(Equal(2))
})
It("podman rm created container", func() {
diff --git a/test/e2e/rmi_test.go b/test/e2e/rmi_test.go
index 1b0329a83..d4e2407ec 100644
--- a/test/e2e/rmi_test.go
+++ b/test/e2e/rmi_test.go
@@ -145,7 +145,7 @@ var _ = Describe("Podman rmi", func() {
session = podmanTest.PodmanNoCache([]string{"rmi", "-f", untaggedImg})
session.WaitWithDefaultTimeout()
- Expect(session.ExitCode()).To(Not(Equal(0)))
+ Expect(session.ExitCode()).To(Equal(2))
})
It("podman rmi image that is created from another named imaged", func() {
diff --git a/test/e2e/run_staticip_test.go b/test/e2e/run_staticip_test.go
index b9698cdd9..7a877ebdc 100644
--- a/test/e2e/run_staticip_test.go
+++ b/test/e2e/run_staticip_test.go
@@ -56,17 +56,19 @@ var _ = Describe("Podman run with --ip flag", func() {
})
It("Podman run with specified static IP has correct IP", func() {
- result := podmanTest.Podman([]string{"run", "-ti", "--ip", "10.88.63.2", ALPINE, "ip", "addr"})
+ ip := GetRandomIPAddress()
+ result := podmanTest.Podman([]string{"run", "-ti", "--ip", ip, ALPINE, "ip", "addr"})
result.WaitWithDefaultTimeout()
Expect(result.ExitCode()).To(Equal(0))
- Expect(result.OutputToString()).To(ContainSubstring("10.88.63.2/16"))
+ Expect(result.OutputToString()).To(ContainSubstring(ip + "/16"))
})
It("Podman run two containers with the same IP", func() {
- result := podmanTest.Podman([]string{"run", "-d", "--ip", "10.88.64.128", ALPINE, "sleep", "999"})
+ ip := GetRandomIPAddress()
+ result := podmanTest.Podman([]string{"run", "-d", "--ip", ip, ALPINE, "sleep", "999"})
result.WaitWithDefaultTimeout()
Expect(result.ExitCode()).To(Equal(0))
- result = podmanTest.Podman([]string{"run", "-ti", "--ip", "10.88.64.128", ALPINE, "ip", "addr"})
+ result = podmanTest.Podman([]string{"run", "-ti", "--ip", ip, ALPINE, "ip", "addr"})
result.WaitWithDefaultTimeout()
Expect(result.ExitCode()).ToNot(Equal(0))
})
diff --git a/test/e2e/run_test.go b/test/e2e/run_test.go
index e35c84f5b..f66d1d2fa 100644
--- a/test/e2e/run_test.go
+++ b/test/e2e/run_test.go
@@ -213,6 +213,11 @@ var _ = Describe("Podman run", func() {
Expect(match).Should(BeTrue())
os.Unsetenv("FOO")
+ session = podmanTest.Podman([]string{"run", "--rm", "--env", "FOO", ALPINE, "printenv", "FOO"})
+ session.WaitWithDefaultTimeout()
+ Expect(len(session.OutputToString())).To(Equal(0))
+ Expect(session.ExitCode()).To(Equal(1))
+
session = podmanTest.Podman([]string{"run", "--rm", ALPINE, "printenv"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
@@ -784,9 +789,10 @@ USER mail`
match, _ := session.GrepString("1.2.3.4")
Expect(match).Should(BeTrue())
- session = podmanTest.Podman([]string{"run", "--rm", "--http-proxy=false", ALPINE, "printenv", "http_proxy"})
+ session = podmanTest.Podman([]string{"run", "--http-proxy=false", ALPINE, "printenv", "http_proxy"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(1))
+ Expect(session.OutputToString()).To(Equal(""))
os.Unsetenv("http_proxy")
})
diff --git a/test/e2e/search_test.go b/test/e2e/search_test.go
index 3b1da859c..9c28849f0 100644
--- a/test/e2e/search_test.go
+++ b/test/e2e/search_test.go
@@ -118,10 +118,20 @@ registries = ['{{.Host}}:{{.Port}}']`
})
It("podman search limit flag", func() {
- search := podmanTest.Podman([]string{"search", "--limit", "3", "docker.io/alpine"})
+ search := podmanTest.Podman([]string{"search", "docker.io/alpine"})
+ search.WaitWithDefaultTimeout()
+ Expect(search.ExitCode()).To(Equal(0))
+ Expect(len(search.OutputToStringArray())).To(Equal(26))
+
+ search = podmanTest.Podman([]string{"search", "--limit", "3", "docker.io/alpine"})
search.WaitWithDefaultTimeout()
Expect(search.ExitCode()).To(Equal(0))
Expect(len(search.OutputToStringArray())).To(Equal(4))
+
+ search = podmanTest.Podman([]string{"search", "--limit", "30", "docker.io/alpine"})
+ search.WaitWithDefaultTimeout()
+ Expect(search.ExitCode()).To(Equal(0))
+ Expect(len(search.OutputToStringArray())).To(Equal(31))
})
It("podman search with filter stars", func() {
diff --git a/test/e2e/version_test.go b/test/e2e/version_test.go
index 2c8b3068c..0db2e2cf2 100644
--- a/test/e2e/version_test.go
+++ b/test/e2e/version_test.go
@@ -4,6 +4,7 @@ import (
"os"
. "github.com/containers/libpod/test/utils"
+ "github.com/containers/libpod/version"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -37,6 +38,26 @@ var _ = Describe("Podman version", func() {
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
Expect(len(session.OutputToStringArray())).To(BeNumerically(">", 2))
+ ok, _ := session.GrepString(version.Version)
+ Expect(ok).To(BeTrue())
+ })
+
+ It("podman -v", func() {
+ SkipIfRemote()
+ session := podmanTest.Podman([]string{"-v"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ ok, _ := session.GrepString(version.Version)
+ Expect(ok).To(BeTrue())
+ })
+
+ It("podman --version", func() {
+ SkipIfRemote()
+ session := podmanTest.Podman([]string{"--version"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ ok, _ := session.GrepString(version.Version)
+ Expect(ok).To(BeTrue())
})
It("podman version --format json", func() {
diff --git a/test/system/005-info.bats b/test/system/005-info.bats
index 0068e35a9..7fccc75af 100644
--- a/test/system/005-info.bats
+++ b/test/system/005-info.bats
@@ -33,7 +33,7 @@ RunRoot:
run_podman info --format=json
expr_nvr="[a-z0-9-]\\\+-[a-z0-9.]\\\+-[a-z0-9]\\\+\."
- expr_path="/[a-z0-9\\\/.]\\\+\\\$"
+ expr_path="/[a-z0-9\\\-\\\/.]\\\+\\\$"
tests="
host.BuildahVersion | [0-9.]
diff --git a/test/system/helpers.bash b/test/system/helpers.bash
index 1db80f111..fe0a25b37 100644
--- a/test/system/helpers.bash
+++ b/test/system/helpers.bash
@@ -133,7 +133,9 @@ function run_podman() {
# stdout is only emitted upon error; this echo is to help a debugger
echo "\$ $PODMAN $*"
- run timeout --foreground -v --kill=10 $PODMAN_TIMEOUT $PODMAN "$@"
+ # BATS hangs if a subprocess remains and keeps FD 3 open; this happens
+ # if podman crashes unexpectedly without cleaning up subprocesses.
+ run timeout --foreground -v --kill=10 $PODMAN_TIMEOUT $PODMAN "$@" 3>/dev/null
# without "quotes", multiple lines are glommed together into one
if [ -n "$output" ]; then
echo "$output"
diff --git a/test/utils/podmantest_test.go b/test/utils/podmantest_test.go
index cb31d5548..9620898af 100644
--- a/test/utils/podmantest_test.go
+++ b/test/utils/podmantest_test.go
@@ -23,7 +23,7 @@ var _ = Describe("PodmanTest test", func() {
FakeOutputs["check"] = []string{"check"}
os.Setenv("HOOK_OPTION", "hook_option")
env := os.Environ()
- session := podmanTest.PodmanAsUserBase([]string{"check"}, 1000, 1000, "", env, true)
+ session := podmanTest.PodmanAsUserBase([]string{"check"}, 1000, 1000, "", env, true, false)
os.Unsetenv("HOOK_OPTION")
session.WaitWithDefaultTimeout()
Expect(session.Command.Process).ShouldNot(BeNil())
diff --git a/test/utils/utils.go b/test/utils/utils.go
index 43819350c..028107d46 100644
--- a/test/utils/utils.go
+++ b/test/utils/utils.go
@@ -26,14 +26,14 @@ var (
// PodmanTestCommon contains common functions will be updated later in
// the inheritance structs
type PodmanTestCommon interface {
- MakeOptions(args []string) []string
+ MakeOptions(args []string, noEvents bool) []string
WaitForContainer() bool
WaitContainerReady(id string, expStr string, timeout int, step int) bool
}
// PodmanTest struct for command line options
type PodmanTest struct {
- PodmanMakeOptions func(args []string) []string
+ PodmanMakeOptions func(args []string, noEvents bool) []string
PodmanBinary string
ArtifactPath string
TempDir string
@@ -59,15 +59,15 @@ type HostOS struct {
}
// MakeOptions assembles all podman options
-func (p *PodmanTest) MakeOptions(args []string) []string {
- return p.PodmanMakeOptions(args)
+func (p *PodmanTest) MakeOptions(args []string, noEvents bool) []string {
+ return p.PodmanMakeOptions(args, noEvents)
}
// PodmanAsUserBase exec podman as user. uid and gid is set for credentials usage. env is used
// to record the env for debugging
-func (p *PodmanTest) PodmanAsUserBase(args []string, uid, gid uint32, cwd string, env []string, nocache bool) *PodmanSession {
+func (p *PodmanTest) PodmanAsUserBase(args []string, uid, gid uint32, cwd string, env []string, nocache, noEvents bool) *PodmanSession {
var command *exec.Cmd
- podmanOptions := p.MakeOptions(args)
+ podmanOptions := p.MakeOptions(args, noEvents)
podmanBinary := p.PodmanBinary
if p.RemoteTest {
podmanBinary = p.RemotePodmanBinary
@@ -105,8 +105,8 @@ func (p *PodmanTest) PodmanAsUserBase(args []string, uid, gid uint32, cwd string
}
// PodmanBase exec podman with default env.
-func (p *PodmanTest) PodmanBase(args []string, nocache bool) *PodmanSession {
- return p.PodmanAsUserBase(args, 0, 0, "", nil, nocache)
+func (p *PodmanTest) PodmanBase(args []string, nocache, noEvents bool) *PodmanSession {
+ return p.PodmanAsUserBase(args, 0, 0, "", nil, nocache, noEvents)
}
// WaitForContainer waits on a started container
@@ -124,7 +124,7 @@ func (p *PodmanTest) WaitForContainer() bool {
// containers are currently running.
func (p *PodmanTest) NumberOfContainersRunning() int {
var containers []string
- ps := p.PodmanBase([]string{"ps", "-q"}, true)
+ ps := p.PodmanBase([]string{"ps", "-q"}, true, false)
ps.WaitWithDefaultTimeout()
Expect(ps.ExitCode()).To(Equal(0))
for _, i := range ps.OutputToStringArray() {
@@ -139,7 +139,7 @@ func (p *PodmanTest) NumberOfContainersRunning() int {
// containers are currently defined.
func (p *PodmanTest) NumberOfContainers() int {
var containers []string
- ps := p.PodmanBase([]string{"ps", "-aq"}, true)
+ ps := p.PodmanBase([]string{"ps", "-aq"}, true, false)
ps.WaitWithDefaultTimeout()
Expect(ps.ExitCode()).To(Equal(0))
for _, i := range ps.OutputToStringArray() {
@@ -154,7 +154,7 @@ func (p *PodmanTest) NumberOfContainers() int {
// pods are currently defined.
func (p *PodmanTest) NumberOfPods() int {
var pods []string
- ps := p.PodmanBase([]string{"pod", "ps", "-q"}, true)
+ ps := p.PodmanBase([]string{"pod", "ps", "-q"}, true, false)
ps.WaitWithDefaultTimeout()
Expect(ps.ExitCode()).To(Equal(0))
for _, i := range ps.OutputToStringArray() {
@@ -170,7 +170,7 @@ func (p *PodmanTest) NumberOfPods() int {
func (p *PodmanTest) GetContainerStatus() string {
var podmanArgs = []string{"ps"}
podmanArgs = append(podmanArgs, "--all", "--format={{.Status}}")
- session := p.PodmanBase(podmanArgs, true)
+ session := p.PodmanBase(podmanArgs, true, false)
session.WaitWithDefaultTimeout()
return session.OutputToString()
}
@@ -178,7 +178,7 @@ func (p *PodmanTest) GetContainerStatus() string {
// WaitContainerReady waits process or service inside container start, and ready to be used.
func (p *PodmanTest) WaitContainerReady(id string, expStr string, timeout int, step int) bool {
startTime := time.Now()
- s := p.PodmanBase([]string{"logs", id}, true)
+ s := p.PodmanBase([]string{"logs", id}, true, false)
s.WaitWithDefaultTimeout()
for {
@@ -191,7 +191,7 @@ func (p *PodmanTest) WaitContainerReady(id string, expStr string, timeout int, s
return true
}
time.Sleep(time.Duration(step) * time.Second)
- s = p.PodmanBase([]string{"logs", id}, true)
+ s = p.PodmanBase([]string{"logs", id}, true, false)
s.WaitWithDefaultTimeout()
}
}
diff --git a/test/utils/utils_suite_test.go b/test/utils/utils_suite_test.go
index b1100892b..5904d37dc 100644
--- a/test/utils/utils_suite_test.go
+++ b/test/utils/utils_suite_test.go
@@ -32,7 +32,7 @@ func FakePodmanTestCreate() *FakePodmanTest {
return p
}
-func (p *FakePodmanTest) makeOptions(args []string) []string {
+func (p *FakePodmanTest) makeOptions(args []string, noEvents bool) []string {
return FakeOutputs[strings.Join(args, " ")]
}