summaryrefslogtreecommitdiff
path: root/test/e2e
diff options
context:
space:
mode:
authorJhon Honce <jhonce@redhat.com>2020-07-21 10:36:44 -0700
committerJhon Honce <jhonce@redhat.com>2020-07-22 15:25:44 -0700
commit964d3300c657047bb16c261e3ca5bdf4e0e1c3e5 (patch)
tree7c7e3c1a23ab3c9c5db61f5a45bedd4a300f9723 /test/e2e
parent1aac197f79e91b06ec7e948bd73bb2464e8a508f (diff)
downloadpodman-964d3300c657047bb16c261e3ca5bdf4e0e1c3e5.tar.gz
podman-964d3300c657047bb16c261e3ca5bdf4e0e1c3e5.tar.bz2
podman-964d3300c657047bb16c261e3ca5bdf4e0e1c3e5.zip
[WIP] Refactor podman system connection
* Add support to manage multiple connections * Add connection * Remove connection * Rename connection * Set connection as default * Add markdown/man pages * Fix recursion in hack/xref-helpmsgs-manpages Signed-off-by: Jhon Honce <jhonce@redhat.com>
Diffstat (limited to 'test/e2e')
-rw-r--r--test/e2e/system_connection_test.go176
1 files changed, 176 insertions, 0 deletions
diff --git a/test/e2e/system_connection_test.go b/test/e2e/system_connection_test.go
new file mode 100644
index 000000000..4c750ee7f
--- /dev/null
+++ b/test/e2e/system_connection_test.go
@@ -0,0 +1,176 @@
+package integration
+
+import (
+ "fmt"
+ "io/ioutil"
+ "os"
+
+ "github.com/containers/common/pkg/config"
+ . "github.com/containers/libpod/v2/test/utils"
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ . "github.com/onsi/gomega/gbytes"
+ . "github.com/onsi/gomega/gexec"
+)
+
+var _ = Describe("podman system connection", func() {
+ ConfPath := struct {
+ Value string
+ IsSet bool
+ }{}
+
+ var (
+ 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 {
+ panic(err)
+ }
+ 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()
+ timedResult := fmt.Sprintf("Test: %s completed in %f seconds", f.TestText, f.Duration.Seconds())
+ GinkgoWriter.Write([]byte(timedResult))
+ })
+
+ It("add", func() {
+ cmd := []string{"system", "connection", "add",
+ "--default",
+ "--identity", "~/.ssh/id_rsa",
+ "QA",
+ "ssh://root@server.fubar.com:2222/run/podman/podman.sock",
+ }
+ session := podmanTest.Podman(cmd)
+ session.WaitWithDefaultTimeout()
+ Expect(session).Should(Exit(0))
+ Expect(session.Out).Should(Say(""))
+
+ 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",
+ Identity: "~/.ssh/id_rsa",
+ },
+ ))
+
+ cmd = []string{"system", "connection", "rename",
+ "QA",
+ "QE",
+ }
+ session = podmanTest.Podman(cmd)
+ session.WaitWithDefaultTimeout()
+ Expect(session).Should(Exit(0))
+
+ cfg, err = config.ReadCustomConfig()
+ Expect(err).ShouldNot(HaveOccurred())
+ Expect(cfg.Engine.ActiveService).To(Equal("QE"))
+ Expect(cfg.Engine.ServiceDestinations["QE"]).To(Equal(
+ config.Destination{
+ URI: "ssh://root@server.fubar.com:2222/run/podman/podman.sock",
+ Identity: "~/.ssh/id_rsa",
+ },
+ ))
+ })
+
+ It("remove", func() {
+ cmd := []string{"system", "connection", "add",
+ "--default",
+ "--identity", "~/.ssh/id_rsa",
+ "QA",
+ "ssh://root@server.fubar.com:2222/run/podman/podman.sock",
+ }
+ session := podmanTest.Podman(cmd)
+ session.WaitWithDefaultTimeout()
+ Expect(session).Should(Exit(0))
+
+ for i := 0; i < 2; i++ {
+ cmd = []string{"system", "connection", "remove", "QA"}
+ session = podmanTest.Podman(cmd)
+ session.WaitWithDefaultTimeout()
+ Expect(session).Should(Exit(0))
+ Expect(session.Out).Should(Say(""))
+
+ cfg, err := config.ReadCustomConfig()
+ Expect(err).ShouldNot(HaveOccurred())
+ Expect(cfg.Engine.ActiveService).To(BeEmpty())
+ Expect(cfg.Engine.ServiceDestinations).To(BeEmpty())
+ }
+ })
+
+ It("default", func() {
+ for _, name := range []string{"devl", "qe"} {
+ cmd := []string{"system", "connection", "add",
+ "--default",
+ "--identity", "~/.ssh/id_rsa",
+ name,
+ "ssh://root@server.fubar.com:2222/run/podman/podman.sock",
+ }
+ session := podmanTest.Podman(cmd)
+ session.WaitWithDefaultTimeout()
+ Expect(session).Should(Exit(0))
+ }
+
+ cmd := []string{"system", "connection", "default", "devl"}
+ session := podmanTest.Podman(cmd)
+ session.WaitWithDefaultTimeout()
+ Expect(session).Should(Exit(0))
+ Expect(session.Out).Should(Say(""))
+
+ cfg, err := config.ReadCustomConfig()
+ Expect(err).ShouldNot(HaveOccurred())
+ Expect(cfg.Engine.ActiveService).To(Equal("devl"))
+
+ cmd = []string{"system", "connection", "list"}
+ session = podmanTest.Podman(cmd)
+ session.WaitWithDefaultTimeout()
+ Expect(session).Should(Exit(0))
+ Expect(session.Out).Should(Say("Name *Identity *URI"))
+ })
+
+ It("failed default", func() {
+ cmd := []string{"system", "connection", "default", "devl"}
+ session := podmanTest.Podman(cmd)
+ session.WaitWithDefaultTimeout()
+ Expect(session).ShouldNot(Exit(0))
+ Expect(session.Err).Should(Say("destination is not defined"))
+ })
+
+ It("failed rename", func() {
+ cmd := []string{"system", "connection", "rename", "devl", "QE"}
+ session := podmanTest.Podman(cmd)
+ session.WaitWithDefaultTimeout()
+ Expect(session).ShouldNot(Exit(0))
+ Expect(session.Err).Should(Say("destination is not defined"))
+ })
+
+ It("empty list", func() {
+ cmd := []string{"system", "connection", "list"}
+ session := podmanTest.Podman(cmd)
+ session.WaitWithDefaultTimeout()
+ Expect(session).Should(Exit(0))
+ Expect(session.Out).Should(Say(""))
+ Expect(session.Err).Should(Say(""))
+ })
+})