summaryrefslogtreecommitdiff
path: root/test/e2e
diff options
context:
space:
mode:
Diffstat (limited to 'test/e2e')
-rw-r--r--test/e2e/image_scp_test.go104
-rw-r--r--test/e2e/pod_stats_test.go22
-rw-r--r--test/e2e/run_cgroup_parent_test.go17
-rw-r--r--test/e2e/stats_test.go44
4 files changed, 169 insertions, 18 deletions
diff --git a/test/e2e/image_scp_test.go b/test/e2e/image_scp_test.go
new file mode 100644
index 000000000..9fd8d7e27
--- /dev/null
+++ b/test/e2e/image_scp_test.go
@@ -0,0 +1,104 @@
+package integration
+
+import (
+ "io/ioutil"
+ "os"
+
+ "github.com/containers/common/pkg/config"
+ . "github.com/containers/podman/v3/test/utils"
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ . "github.com/onsi/gomega/gexec"
+)
+
+var _ = Describe("podman image scp", func() {
+ ConfPath := struct {
+ Value string
+ IsSet bool
+ }{}
+ var (
+ tempdir string
+ podmanTest *PodmanTestIntegration
+ )
+
+ BeforeEach(func() {
+ ConfPath.Value, ConfPath.IsSet = os.LookupEnv("CONTAINERS_CONF")
+ conf, err := ioutil.TempFile("", "containersconf")
+ if err != nil {
+ panic(err)
+ }
+ os.Setenv("CONTAINERS_CONF", conf.Name())
+ tempdir, err = CreateTempDirInTempDir()
+ if err != nil {
+ os.Exit(1)
+ }
+ podmanTest = PodmanTestCreate(tempdir)
+ podmanTest.Setup()
+ })
+
+ AfterEach(func() {
+ podmanTest.Cleanup()
+ os.Remove(os.Getenv("CONTAINERS_CONF"))
+ if ConfPath.IsSet {
+ os.Setenv("CONTAINERS_CONF", ConfPath.Value)
+ } else {
+ os.Unsetenv("CONTAINERS_CONF")
+ }
+ f := CurrentGinkgoTestDescription()
+ processTestResult(f)
+
+ })
+
+ It("podman image scp quiet flag", func() {
+ if IsRemote() {
+ Skip("this test is only for non-remote")
+ }
+ scp := podmanTest.Podman([]string{"image", "scp", "-q", ALPINE})
+ scp.WaitWithDefaultTimeout()
+ Expect(scp).To(Exit(0))
+ })
+
+ It("podman image scp bogus image", func() {
+ if IsRemote() {
+ Skip("this test is only for non-remote")
+ }
+ scp := podmanTest.Podman([]string{"image", "scp", "FOOBAR"})
+ scp.WaitWithDefaultTimeout()
+ Expect(scp).To(ExitWithError())
+ })
+
+ It("podman image scp with proper connection", func() {
+ if IsRemote() {
+ Skip("this test is only for non-remote")
+ }
+ cmd := []string{"system", "connection", "add",
+ "--default",
+ "QA",
+ "ssh://root@server.fubar.com:2222/run/podman/podman.sock",
+ }
+ session := podmanTest.Podman(cmd)
+ session.WaitWithDefaultTimeout()
+ Expect(session).To(Exit(0))
+
+ cfg, err := config.ReadCustomConfig()
+ Expect(err).ShouldNot(HaveOccurred())
+ Expect(cfg.Engine.ActiveService).To(Equal("QA"))
+ Expect(cfg.Engine.ServiceDestinations["QA"]).To(Equal(
+ config.Destination{
+ URI: "ssh://root@server.fubar.com:2222/run/podman/podman.sock",
+ },
+ ))
+
+ scp := podmanTest.Podman([]string{"image", "scp", ALPINE, "QA::"})
+ scp.Wait(45)
+ // exit with error because we cannot make an actual ssh connection
+ // This tests that the input we are given is validated and prepared correctly
+ // Error: failed to connect: dial tcp: address foo: missing port in address
+ Expect(scp).To(ExitWithError())
+ Expect(scp.ErrorToString()).To(ContainSubstring(
+ "Error: failed to connect: dial tcp 66.151.147.142:2222: i/o timeout",
+ ))
+
+ })
+
+})
diff --git a/test/e2e/pod_stats_test.go b/test/e2e/pod_stats_test.go
index 46043b16d..5ec209034 100644
--- a/test/e2e/pod_stats_test.go
+++ b/test/e2e/pod_stats_test.go
@@ -37,19 +37,19 @@ var _ = Describe("Podman pod stats", func() {
processTestResult(f)
})
- It("podman stats should run with no pods", func() {
+ It("podman pod stats should run with no pods", func() {
session := podmanTest.Podman([]string{"pod", "stats", "--no-stream"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
})
- It("podman stats with a bogus pod", func() {
+ It("podman pod stats with a bogus pod", func() {
session := podmanTest.Podman([]string{"pod", "stats", "foobar"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(125))
})
- It("podman stats on a specific running pod", func() {
+ It("podman pod stats on a specific running pod", func() {
_, ec, podid := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0))
@@ -66,7 +66,7 @@ var _ = Describe("Podman pod stats", func() {
Expect(stats).Should(Exit(0))
})
- It("podman stats on a specific running pod with shortID", func() {
+ It("podman pod stats on a specific running pod with shortID", func() {
_, ec, podid := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0))
@@ -83,7 +83,7 @@ var _ = Describe("Podman pod stats", func() {
Expect(stats).Should(Exit(0))
})
- It("podman stats on a specific running pod with name", func() {
+ It("podman pod stats on a specific running pod with name", func() {
_, ec, podid := podmanTest.CreatePod(map[string][]string{"--name": {"test"}})
Expect(ec).To(Equal(0))
@@ -100,7 +100,7 @@ var _ = Describe("Podman pod stats", func() {
Expect(stats).Should(Exit(0))
})
- It("podman stats on running pods", func() {
+ It("podman pod stats on running pods", func() {
_, ec, podid := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0))
@@ -117,7 +117,7 @@ var _ = Describe("Podman pod stats", func() {
Expect(stats).Should(Exit(0))
})
- It("podman stats on all pods", func() {
+ It("podman pod stats on all pods", func() {
_, ec, podid := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0))
@@ -134,7 +134,7 @@ var _ = Describe("Podman pod stats", func() {
Expect(stats).Should(Exit(0))
})
- It("podman stats with json output", func() {
+ It("podman pod stats with json output", func() {
_, ec, podid := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0))
@@ -151,7 +151,7 @@ var _ = Describe("Podman pod stats", func() {
Expect(stats).Should(Exit(0))
Expect(stats.IsJSONOutputValid()).To(BeTrue())
})
- It("podman stats with GO template", func() {
+ It("podman pod stats with GO template", func() {
_, ec, podid := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0))
@@ -163,7 +163,7 @@ var _ = Describe("Podman pod stats", func() {
Expect(stats).To(Exit(0))
})
- It("podman stats with invalid GO template", func() {
+ It("podman pod stats with invalid GO template", func() {
_, ec, podid := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0))
@@ -175,7 +175,7 @@ var _ = Describe("Podman pod stats", func() {
Expect(stats).To(ExitWithError())
})
- It("podman stats on net=host post", func() {
+ It("podman pod stats on net=host post", func() {
SkipIfRootless("--net=host not supported for rootless pods at present")
podName := "testPod"
podCreate := podmanTest.Podman([]string{"pod", "create", "--net=host", "--name", podName})
diff --git a/test/e2e/run_cgroup_parent_test.go b/test/e2e/run_cgroup_parent_test.go
index 300c3a8e0..3e261961b 100644
--- a/test/e2e/run_cgroup_parent_test.go
+++ b/test/e2e/run_cgroup_parent_test.go
@@ -2,6 +2,7 @@ package integration
import (
"fmt"
+ "io/ioutil"
"os"
"path/filepath"
"strings"
@@ -80,7 +81,21 @@ var _ = Describe("Podman run with --cgroup-parent", func() {
exec.WaitWithDefaultTimeout()
Expect(exec).Should(Exit(0))
- cgroup := filepath.Dir(strings.TrimRight(strings.Replace(exec.OutputToString(), "0::", "", -1), "\n"))
+ containerCgroup := strings.TrimRight(strings.Replace(exec.OutputToString(), "0::", "", -1), "\n")
+
+ content, err := ioutil.ReadFile(filepath.Join("/sys/fs/cgroup", containerCgroup, "cgroup.procs"))
+ Expect(err).To(BeNil())
+
+ // Move the container process to a sub cgroup
+ subCgroupPath := filepath.Join(filepath.Join("/sys/fs/cgroup", containerCgroup, "old-container"))
+
+ err = os.MkdirAll(subCgroupPath, 0755)
+ Expect(err).To(BeNil())
+
+ err = ioutil.WriteFile(filepath.Join(subCgroupPath, "cgroup.procs"), content, 0644)
+ Expect(err).To(BeNil())
+
+ cgroup := filepath.Dir(containerCgroup)
run = podmanTest.Podman([]string{"--cgroup-manager=cgroupfs", "run", "-d", fmt.Sprintf("--cgroup-parent=%s", cgroup), fedoraMinimal, "sleep", "100"})
run.WaitWithDefaultTimeout()
diff --git a/test/e2e/stats_test.go b/test/e2e/stats_test.go
index e32d515a0..a0be5d462 100644
--- a/test/e2e/stats_test.go
+++ b/test/e2e/stats_test.go
@@ -1,5 +1,3 @@
-// +build
-
package integration
import (
@@ -84,15 +82,49 @@ var _ = Describe("Podman stats", func() {
Expect(session).Should(Exit(0))
})
- It("podman stats only output CPU data", func() {
+ It("podman stats with GO template", func() {
session := podmanTest.RunTopContainer("")
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
- session = podmanTest.Podman([]string{"stats", "--all", "--no-stream", "--format", "\"{{.ID}} {{.UpTime}} {{.AVGCPU}}\""})
+ stats := podmanTest.Podman([]string{"stats", "-a", "--no-reset", "--no-stream", "--format", "table {{.ID}} {{.AVGCPU}} {{.MemUsage}} {{.CPU}} {{.NetIO}} {{.BlockIO}} {{.PIDS}}"})
+ stats.WaitWithDefaultTimeout()
+ Expect(stats).To(Exit(0))
+ })
+
+ It("podman stats with invalid GO template", func() {
+ session := podmanTest.RunTopContainer("")
session.WaitWithDefaultTimeout()
- Expect(session.LineInOutputContains("UpTime")).To(BeTrue())
- Expect(session.LineInOutputContains("AVGCPU")).To(BeTrue())
Expect(session).Should(Exit(0))
+ stats := podmanTest.Podman([]string{"stats", "-a", "--no-reset", "--no-stream", "--format", "\"table {{.ID}} {{.NoSuchField}} \""})
+ stats.WaitWithDefaultTimeout()
+ Expect(stats).To(ExitWithError())
+ })
+
+ It("podman stats with negative interval", func() {
+ session := podmanTest.RunTopContainer("")
+ session.WaitWithDefaultTimeout()
+ Expect(session).Should(Exit(0))
+ stats := podmanTest.Podman([]string{"stats", "-a", "--no-reset", "--no-stream", "--interval=-1"})
+ stats.WaitWithDefaultTimeout()
+ Expect(stats).To(ExitWithError())
+ })
+
+ It("podman stats with zero interval", func() {
+ session := podmanTest.RunTopContainer("")
+ session.WaitWithDefaultTimeout()
+ Expect(session).Should(Exit(0))
+ stats := podmanTest.Podman([]string{"stats", "-a", "--no-reset", "--no-stream", "--interval=0"})
+ stats.WaitWithDefaultTimeout()
+ Expect(stats).To(ExitWithError())
+ })
+
+ It("podman stats with interval", func() {
+ session := podmanTest.RunTopContainer("")
+ session.WaitWithDefaultTimeout()
+ Expect(session).Should(Exit(0))
+ stats := podmanTest.Podman([]string{"stats", "-a", "--no-reset", "--no-stream", "--interval=5"})
+ stats.WaitWithDefaultTimeout()
+ Expect(stats).Should(Exit(0))
})
It("podman stats with json output", func() {