fix system connection and scp testing

podman image scp and podman system connection tests were querying an existing website during testing.
Change to a URL that will never exist given an improper domain extension

also just generally clean up a few things in both scp and connection testing

resolves #14699

Signed-off-by: Charlie Doern <cdoern@redhat.com>
This commit is contained in:
Charlie Doern
2022-06-22 14:14:33 -04:00
parent 8e88abda85
commit ad78d239dd
2 changed files with 21 additions and 24 deletions

View File

@ -22,12 +22,10 @@ var _ = Describe("podman image scp", func() {
) )
BeforeEach(func() { BeforeEach(func() {
ConfPath.Value, ConfPath.IsSet = os.LookupEnv("CONTAINERS_CONF") ConfPath.Value, ConfPath.IsSet = os.LookupEnv("CONTAINERS_CONF")
conf, err := ioutil.TempFile("", "containersconf") conf, err := ioutil.TempFile("", "containersconf")
if err != nil { Expect(err).ToNot(HaveOccurred())
panic(err)
}
os.Setenv("CONTAINERS_CONF", conf.Name()) os.Setenv("CONTAINERS_CONF", conf.Name())
tempdir, err = CreateTempDirInTempDir() tempdir, err = CreateTempDirInTempDir()
if err != nil { if err != nil {
@ -57,7 +55,7 @@ var _ = Describe("podman image scp", func() {
} }
scp := podmanTest.Podman([]string{"image", "scp", "FOOBAR"}) scp := podmanTest.Podman([]string{"image", "scp", "FOOBAR"})
scp.WaitWithDefaultTimeout() scp.WaitWithDefaultTimeout()
Expect(scp).To(ExitWithError()) Expect(scp).Should(ExitWithError())
}) })
It("podman image scp with proper connection", func() { It("podman image scp with proper connection", func() {
@ -67,27 +65,28 @@ var _ = Describe("podman image scp", func() {
cmd := []string{"system", "connection", "add", cmd := []string{"system", "connection", "add",
"--default", "--default",
"QA", "QA",
"ssh://root@server.fubar.com:2222/run/podman/podman.sock", "ssh://root@podman.test:2222/run/podman/podman.sock",
} }
session := podmanTest.Podman(cmd) session := podmanTest.Podman(cmd)
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).To(Exit(0)) Expect(session).Should(Exit(0))
cfg, err := config.ReadCustomConfig() cfg, err := config.ReadCustomConfig()
Expect(err).ShouldNot(HaveOccurred()) Expect(err).ShouldNot(HaveOccurred())
Expect(cfg.Engine).To(HaveField("ActiveService", "QA")) Expect(cfg.Engine).Should(HaveField("ActiveService", "QA"))
Expect(cfg.Engine.ServiceDestinations).To(HaveKeyWithValue("QA", Expect(cfg.Engine.ServiceDestinations).To(HaveKeyWithValue("QA",
config.Destination{ config.Destination{
URI: "ssh://root@server.fubar.com:2222/run/podman/podman.sock", URI: "ssh://root@podman.test:2222/run/podman/podman.sock",
}, },
)) ))
scp := podmanTest.Podman([]string{"image", "scp", ALPINE, "QA::"}) scp := podmanTest.Podman([]string{"image", "scp", ALPINE, "QA::"})
scp.Wait(45) scp.WaitWithDefaultTimeout()
// exit with error because we cannot make an actual ssh connection // exit with error because we cannot make an actual ssh connection
// This tests that the input we are given is validated and prepared correctly // This tests that the input we are given is validated and prepared correctly
// The error given should either be a missing image (due to testing suite complications) or a i/o timeout on ssh // The error given should either be a missing image (due to testing suite complications) or a no such host timeout on ssh
Expect(scp).To(ExitWithError()) Expect(scp).Should(ExitWithError())
Expect(scp.ErrorToString()).Should(ContainSubstring("no such host"))
}) })

View File

@ -47,9 +47,7 @@ var _ = Describe("podman system connection", func() {
} }
f := CurrentGinkgoTestDescription() f := CurrentGinkgoTestDescription()
_, _ = GinkgoWriter.Write( processTestResult(f)
[]byte(
fmt.Sprintf("Test: %s completed in %f seconds", f.TestText, f.Duration.Seconds())))
}) })
Context("without running API service", func() { Context("without running API service", func() {
@ -58,7 +56,7 @@ var _ = Describe("podman system connection", func() {
"--default", "--default",
"--identity", "~/.ssh/id_rsa", "--identity", "~/.ssh/id_rsa",
"QA", "QA",
"ssh://root@server.fubar.com:2222/run/podman/podman.sock", "ssh://root@podman.test:2222/run/podman/podman.sock",
} }
session := podmanTest.Podman(cmd) session := podmanTest.Podman(cmd)
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
@ -67,10 +65,10 @@ var _ = Describe("podman system connection", func() {
cfg, err := config.ReadCustomConfig() cfg, err := config.ReadCustomConfig()
Expect(err).ShouldNot(HaveOccurred()) Expect(err).ShouldNot(HaveOccurred())
Expect(cfg).To(HaveActiveService("QA")) Expect(cfg).Should(HaveActiveService("QA"))
Expect(cfg).Should(VerifyService( Expect(cfg).Should(VerifyService(
"QA", "QA",
"ssh://root@server.fubar.com:2222/run/podman/podman.sock", "ssh://root@podman.test:2222/run/podman/podman.sock",
"~/.ssh/id_rsa", "~/.ssh/id_rsa",
)) ))
@ -82,7 +80,7 @@ var _ = Describe("podman system connection", func() {
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
Expect(config.ReadCustomConfig()).To(HaveActiveService("QE")) Expect(config.ReadCustomConfig()).Should(HaveActiveService("QE"))
}) })
It("add UDS", func() { It("add UDS", func() {
@ -141,7 +139,7 @@ var _ = Describe("podman system connection", func() {
"--default", "--default",
"--identity", "~/.ssh/id_rsa", "--identity", "~/.ssh/id_rsa",
"QA", "QA",
"ssh://root@server.fubar.com:2222/run/podman/podman.sock", "ssh://root@podman.test:2222/run/podman/podman.sock",
}) })
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
@ -155,8 +153,8 @@ var _ = Describe("podman system connection", func() {
cfg, err := config.ReadCustomConfig() cfg, err := config.ReadCustomConfig()
Expect(err).ShouldNot(HaveOccurred()) Expect(err).ShouldNot(HaveOccurred())
Expect(cfg.Engine.ActiveService).To(BeEmpty()) Expect(cfg.Engine.ActiveService).Should(BeEmpty())
Expect(cfg.Engine.ServiceDestinations).To(BeEmpty()) Expect(cfg.Engine.ServiceDestinations).Should(BeEmpty())
} }
}) })
@ -165,7 +163,7 @@ var _ = Describe("podman system connection", func() {
"--default", "--default",
"--identity", "~/.ssh/id_rsa", "--identity", "~/.ssh/id_rsa",
"QA", "QA",
"ssh://root@server.fubar.com:2222/run/podman/podman.sock", "ssh://root@podman.test:2222/run/podman/podman.sock",
}) })
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
@ -187,7 +185,7 @@ var _ = Describe("podman system connection", func() {
"--default", "--default",
"--identity", "~/.ssh/id_rsa", "--identity", "~/.ssh/id_rsa",
name, name,
"ssh://root@server.fubar.com:2222/run/podman/podman.sock", "ssh://root@podman.test:2222/run/podman/podman.sock",
} }
session := podmanTest.Podman(cmd) session := podmanTest.Podman(cmd)
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()