summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/compose/slirp4netns_opts/tests.sh9
-rw-r--r--test/e2e/attach_test.go8
-rw-r--r--test/e2e/checkpoint_test.go8
-rw-r--r--test/e2e/commit_test.go7
-rw-r--r--test/e2e/common_test.go3
-rw-r--r--test/e2e/create_test.go7
-rw-r--r--test/e2e/healthcheck_run_test.go10
-rw-r--r--test/e2e/inspect_test.go8
-rw-r--r--test/e2e/system_df_test.go17
-rw-r--r--test/system/010-images.bats9
-rw-r--r--test/system/200-pod.bats9
-rw-r--r--test/utils/common_function_test.go11
-rw-r--r--test/utils/matchers.go8
-rw-r--r--test/utils/utils.go5
14 files changed, 77 insertions, 42 deletions
diff --git a/test/compose/slirp4netns_opts/tests.sh b/test/compose/slirp4netns_opts/tests.sh
index cfa84e1e4..2d41311ad 100644
--- a/test/compose/slirp4netns_opts/tests.sh
+++ b/test/compose/slirp4netns_opts/tests.sh
@@ -1,20 +1,19 @@
# -*- bash -*-
-output="$(cat $OUTFILE)"
expected="teststring"
# Reading from the nc socket is flaky because docker-compose only starts
# the containers. We cannot know at this point if the container did already
# send the message. Give the container 5 seconds time to send the message
# to prevent flakes.
-local _timeout=5
-while [ $_timeout -gt 0 ]; do
+container_timeout=5
+while [ $container_timeout -gt 0 ]; do
+ output="$(< $OUTFILE)"
if [ -n "$output" ]; then
break
fi
sleep 1
- _timeout=$(($_timeout - 1))
- output="$(cat $OUTFILE)"
+ container_timeout=$(($container_timeout - 1))
done
is "$output" "$expected" "$testname : nc received teststring"
diff --git a/test/e2e/attach_test.go b/test/e2e/attach_test.go
index a7af76529..74e3a619a 100644
--- a/test/e2e/attach_test.go
+++ b/test/e2e/attach_test.go
@@ -1,7 +1,6 @@
package integration
import (
- "os"
"syscall"
"time"
@@ -20,12 +19,11 @@ var _ = Describe("Podman attach", func() {
BeforeEach(func() {
tempdir, err = CreateTempDirInTempDir()
- if err != nil {
- os.Exit(1)
- }
+ Expect(err).To(BeNil())
podmanTest = PodmanTestCreate(tempdir)
podmanTest.Setup()
- podmanTest.SeedImages()
+ err = podmanTest.SeedImages()
+ Expect(err).To(BeNil())
})
AfterEach(func() {
diff --git a/test/e2e/checkpoint_test.go b/test/e2e/checkpoint_test.go
index 5abc672e9..7b2dd89c9 100644
--- a/test/e2e/checkpoint_test.go
+++ b/test/e2e/checkpoint_test.go
@@ -37,12 +37,12 @@ var _ = Describe("Podman checkpoint", func() {
BeforeEach(func() {
SkipIfRootless("checkpoint not supported in rootless mode")
tempdir, err = CreateTempDirInTempDir()
- if err != nil {
- os.Exit(1)
- }
+ Expect(err).To(BeNil())
+
podmanTest = PodmanTestCreate(tempdir)
podmanTest.Setup()
- podmanTest.SeedImages()
+ err = podmanTest.SeedImages()
+ Expect(err).To(BeNil())
// Check if the runtime implements checkpointing. Currently only
// runc's checkpoint/restore implementation is supported.
cmd := exec.Command(podmanTest.OCIRuntime, "checkpoint", "--help")
diff --git a/test/e2e/commit_test.go b/test/e2e/commit_test.go
index 6bcf17bfe..78b607f1e 100644
--- a/test/e2e/commit_test.go
+++ b/test/e2e/commit_test.go
@@ -21,12 +21,11 @@ var _ = Describe("Podman commit", func() {
BeforeEach(func() {
tempdir, err = CreateTempDirInTempDir()
- if err != nil {
- os.Exit(1)
- }
+ Expect(err).To(BeNil())
podmanTest = PodmanTestCreate(tempdir)
podmanTest.Setup()
- podmanTest.SeedImages()
+ err = podmanTest.SeedImages()
+ Expect(err).To(BeNil())
})
AfterEach(func() {
diff --git a/test/e2e/common_test.go b/test/e2e/common_test.go
index bc6d89fad..cb6574f23 100644
--- a/test/e2e/common_test.go
+++ b/test/e2e/common_test.go
@@ -809,7 +809,8 @@ func (p *PodmanTestIntegration) RestoreArtifactToCache(image string) error {
func populateCache(podman *PodmanTestIntegration) {
for _, image := range CACHE_IMAGES {
- podman.RestoreArtifactToCache(image)
+ err := podman.RestoreArtifactToCache(image)
+ Expect(err).To(BeNil())
}
// logformatter uses this to recognize the first test
fmt.Printf("-----------------------------\n")
diff --git a/test/e2e/create_test.go b/test/e2e/create_test.go
index 339fa66d8..4c3b5604a 100644
--- a/test/e2e/create_test.go
+++ b/test/e2e/create_test.go
@@ -24,12 +24,11 @@ var _ = Describe("Podman create", func() {
BeforeEach(func() {
tempdir, err = CreateTempDirInTempDir()
- if err != nil {
- os.Exit(1)
- }
+ Expect(err).To(BeNil())
podmanTest = PodmanTestCreate(tempdir)
podmanTest.Setup()
- podmanTest.SeedImages()
+ err = podmanTest.SeedImages()
+ Expect(err).To(BeNil())
})
AfterEach(func() {
diff --git a/test/e2e/healthcheck_run_test.go b/test/e2e/healthcheck_run_test.go
index 866edbf0e..757eaed20 100644
--- a/test/e2e/healthcheck_run_test.go
+++ b/test/e2e/healthcheck_run_test.go
@@ -54,6 +54,16 @@ var _ = Describe("Podman healthcheck run", func() {
Expect(hc).Should(Exit(125))
})
+ It("podman disable healthcheck with --no-healthcheck must not show starting on status", func() {
+ session := podmanTest.Podman([]string{"run", "-dt", "--no-healthcheck", "--name", "hc", healthcheck})
+ session.WaitWithDefaultTimeout()
+ Expect(session).Should(Exit(0))
+ hc := podmanTest.Podman([]string{"container", "inspect", "--format", "{{.State.Health.Status}}", "hc"})
+ hc.WaitWithDefaultTimeout()
+ Expect(hc).Should(Exit(0))
+ Expect(hc.OutputToString()).To(Not(ContainSubstring("starting")))
+ })
+
It("podman run healthcheck and logs should contain healthcheck output", func() {
session := podmanTest.Podman([]string{"run", "--name", "test-logs", "-dt", "--health-interval", "1s", "--health-cmd", "echo working", "busybox", "sleep", "3600"})
session.WaitWithDefaultTimeout()
diff --git a/test/e2e/inspect_test.go b/test/e2e/inspect_test.go
index 3943a5e87..bb5a3a6ad 100644
--- a/test/e2e/inspect_test.go
+++ b/test/e2e/inspect_test.go
@@ -86,6 +86,7 @@ var _ = Describe("Podman inspect", func() {
It("podman inspect container with GO format for ConmonPidFile", func() {
session, ec, _ := podmanTest.RunLsContainer("test1")
+ session.WaitWithDefaultTimeout()
Expect(ec).To(Equal(0))
session = podmanTest.Podman([]string{"inspect", "--format", "{{.ConmonPidFile}}", "test1"})
@@ -94,7 +95,8 @@ var _ = Describe("Podman inspect", func() {
})
It("podman inspect container with size", func() {
- _, ec, _ := podmanTest.RunLsContainer("sizetest")
+ session, ec, _ := podmanTest.RunLsContainer("sizetest")
+ session.WaitWithDefaultTimeout()
Expect(ec).To(Equal(0))
result := podmanTest.Podman([]string{"inspect", "--size", "sizetest"})
@@ -107,6 +109,7 @@ var _ = Describe("Podman inspect", func() {
It("podman inspect container and image", func() {
ls, ec, _ := podmanTest.RunLsContainer("")
+ ls.WaitWithDefaultTimeout()
Expect(ec).To(Equal(0))
cid := ls.OutputToString()
@@ -118,6 +121,7 @@ var _ = Describe("Podman inspect", func() {
It("podman inspect container and filter for Image{ID}", func() {
ls, ec, _ := podmanTest.RunLsContainer("")
+ ls.WaitWithDefaultTimeout()
Expect(ec).To(Equal(0))
cid := ls.OutputToString()
@@ -134,6 +138,7 @@ var _ = Describe("Podman inspect", func() {
It("podman inspect container and filter for CreateCommand", func() {
ls, ec, _ := podmanTest.RunLsContainer("")
+ ls.WaitWithDefaultTimeout()
Expect(ec).To(Equal(0))
cid := ls.OutputToString()
@@ -529,6 +534,7 @@ var _ = Describe("Podman inspect", func() {
It("podman inspect container with GO format for PidFile", func() {
SkipIfRemote("pidfile not handled by remote")
session, ec, _ := podmanTest.RunLsContainer("test1")
+ session.WaitWithDefaultTimeout()
Expect(ec).To(Equal(0))
session = podmanTest.Podman([]string{"inspect", "--format", "{{.PidFile}}", "test1"})
diff --git a/test/e2e/system_df_test.go b/test/e2e/system_df_test.go
index 2d75316ad..a9fa5f4ac 100644
--- a/test/e2e/system_df_test.go
+++ b/test/e2e/system_df_test.go
@@ -41,11 +41,17 @@ var _ = Describe("podman system df", func() {
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
- session = podmanTest.Podman([]string{"volume", "create", "data"})
+ // run two containers with volumes to create something in the volume
+ session = podmanTest.Podman([]string{"run", "-v", "data1:/data", "--name", "container1", BB, "sh", "-c", "echo test > /data/1"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
- session = podmanTest.Podman([]string{"create", "-v", "data:/data", "--name", "container1", BB})
+ session = podmanTest.Podman([]string{"run", "-v", "data2:/data", "--name", "container2", BB, "sh", "-c", "echo test > /data/1"})
+ session.WaitWithDefaultTimeout()
+ Expect(session).Should(Exit(0))
+
+ // remove one container, we keep the volume
+ session = podmanTest.Podman([]string{"rm", "container2"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
@@ -61,9 +67,10 @@ var _ = Describe("podman system df", func() {
images := strings.Fields(session.OutputToStringArray()[1])
containers := strings.Fields(session.OutputToStringArray()[2])
volumes := strings.Fields(session.OutputToStringArray()[3])
- Expect(images[1]).To(Equal(string(totImages)))
- Expect(containers[1]).To(Equal("2"))
- Expect(volumes[2]).To(Equal("1"))
+ Expect(images[1]).To(Equal(string(totImages)), "total images expected")
+ Expect(containers[1]).To(Equal("2"), "total containers expected")
+ Expect(volumes[2]).To(Equal("2"), "total volumes expected")
+ Expect(volumes[6]).To(Equal("(50%)"), "percentage usage expected")
})
It("podman system df image with no tag", func() {
diff --git a/test/system/010-images.bats b/test/system/010-images.bats
index dbf4b2828..257508418 100644
--- a/test/system/010-images.bats
+++ b/test/system/010-images.bats
@@ -303,4 +303,13 @@ Deleted: $pauseID"
run_podman image exists $IMAGE
}
+@test "podman rmi --ignore" {
+ random_image_name=$(random_string)
+ random_image_name=${random_image_name,,} # name must be lowercase
+ run_podman 1 rmi $random_image_name
+ is "$output" "Error: $random_image_name: image not known.*"
+ run_podman rmi --ignore $random_image_name
+ is "$output" ""
+}
+
# vim: filetype=sh
diff --git a/test/system/200-pod.bats b/test/system/200-pod.bats
index ca931e244..f5fe41924 100644
--- a/test/system/200-pod.bats
+++ b/test/system/200-pod.bats
@@ -6,7 +6,7 @@ load helpers
function teardown() {
run_podman pod rm -f -t 0 -a
run_podman rm -f -t 0 -a
- run_podman ? rmi $(pause_image)
+ run_podman rmi --ignore $(pause_image)
basic_teardown
}
@@ -317,16 +317,17 @@ EOF
@test "podman pod create should fail when infra-name is already in use" {
local infra_name="infra_container_$(random_string 10 | tr A-Z a-z)"
+ local infra_image="k8s.gcr.io/pause:3.5"
local pod_name="$(random_string 10 | tr A-Z a-z)"
- run_podman --noout pod create --name $pod_name --infra-name "$infra_name" --infra-image "k8s.gcr.io/pause:3.5"
- is "$output" "" "output should be empty"
+ run_podman --noout pod create --name $pod_name --infra-name "$infra_name" --infra-image "$infra_image"
+ is "$output" "" "output from pod create should be empty"
run_podman '?' pod create --infra-name "$infra_name"
if [ $status -eq 0 ]; then
die "Podman should fail when user try to create two pods with the same infra-name value"
fi
run_podman pod rm -f $pod_name
- run_podman images -a
+ run_podman rmi $infra_image
}
@test "podman pod create --share" {
diff --git a/test/utils/common_function_test.go b/test/utils/common_function_test.go
index 810d9f2a5..6323b44eb 100644
--- a/test/utils/common_function_test.go
+++ b/test/utils/common_function_test.go
@@ -51,7 +51,8 @@ var _ = Describe("Common functions test", func() {
txt := fmt.Sprintf("ID=%s\nVERSION_ID=%s", id, ver)
if !empty {
f, _ := os.Create(path)
- f.WriteString(txt)
+ _, err := f.WriteString(txt)
+ Expect(err).To(BeNil(), "Failed to write data.")
f.Close()
}
@@ -102,9 +103,10 @@ var _ = Describe("Common functions test", func() {
Item2: []string{"test"},
}
- testByte, _ := json.Marshal(testData)
- err := WriteJSONFile(testByte, "/tmp/testJSON")
+ testByte, err := json.Marshal(testData)
+ Expect(err).To(BeNil(), "Failed to marshal data.")
+ err = WriteJSONFile(testByte, "/tmp/testJSON")
Expect(err).To(BeNil(), "Failed to write JSON to file.")
read, err := os.Open("/tmp/testJSON")
@@ -135,7 +137,8 @@ var _ = Describe("Common functions test", func() {
}
if createFile {
f, _ := os.Create(path)
- f.WriteString(txt)
+ _, err := f.WriteString(txt)
+ Expect(err).To(BeNil(), "Failed to write data.")
f.Close()
}
ProcessOneCgroupPath = path
diff --git a/test/utils/matchers.go b/test/utils/matchers.go
index 288779b63..0c0948e4b 100644
--- a/test/utils/matchers.go
+++ b/test/utils/matchers.go
@@ -13,7 +13,7 @@ import (
"github.com/onsi/gomega/types"
)
-// HaveActiveService verifies the given service is the active service
+// HaveActiveService verifies the given service is the active service.
func HaveActiveService(name interface{}) OmegaMatcher {
return WithTransform(
func(cfg *config.Config) string {
@@ -86,7 +86,7 @@ type URLMatcher struct {
matchers.EqualMatcher
}
-// VerifyURL matches when actual is a valid URL and matches expected
+// VerifyURL matches when actual is a valid URL and matches expected.
func VerifyURL(uri interface{}) OmegaMatcher {
return &URLMatcher{matchers.EqualMatcher{Expected: uri}}
}
@@ -129,7 +129,7 @@ func ExitWithError(optionalExitCode ...int) *ExitMatcher {
return &ExitMatcher{Expected: exitCode}
}
-// Match follows gexec.Matcher interface
+// Match follows gexec.Matcher interface.
func (matcher *ExitMatcher) Match(actual interface{}) (success bool, err error) {
exiter, ok := actual.(gexec.Exiter)
if !ok {
@@ -184,7 +184,7 @@ func (matcher *ValidJSONMatcher) Match(actual interface{}) (success bool, err er
var i interface{}
if err := json.Unmarshal([]byte(s), &i); err != nil {
- return false, nil
+ return false, err
}
return true, nil
}
diff --git a/test/utils/utils.go b/test/utils/utils.go
index 8fe45dca0..a6295cd19 100644
--- a/test/utils/utils.go
+++ b/test/utils/utils.go
@@ -479,7 +479,10 @@ func IsCommandAvailable(command string) bool {
func WriteJSONFile(data []byte, filePath string) error {
var jsonData map[string]interface{}
json.Unmarshal(data, &jsonData)
- formatJSON, _ := json.MarshalIndent(jsonData, "", " ")
+ formatJSON, err := json.MarshalIndent(jsonData, "", " ")
+ if err != nil {
+ return err
+ }
return ioutil.WriteFile(filePath, formatJSON, 0644)
}