mirror of https://github.com/containers/podman.git
Merge pull request #23154 from Luap99/machine-test-connection
pkg/machine/e2e: fix broken cleanup
This commit is contained in:
commit
f5d50a68bc
|
@ -18,17 +18,6 @@ import (
|
|||
)
|
||||
|
||||
var _ = Describe("run basic podman commands", func() {
|
||||
var (
|
||||
mb *machineTestBuilder
|
||||
testDir string
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
testDir, mb = setup()
|
||||
})
|
||||
AfterEach(func() {
|
||||
teardown(originalHomeDir, testDir, mb)
|
||||
})
|
||||
|
||||
It("Basic ops", func() {
|
||||
// golangci-lint has trouble with actually skipping tests marked Skip
|
||||
|
|
|
@ -2,6 +2,11 @@ package e2e_test
|
|||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
. "github.com/onsi/gomega/gexec"
|
||||
)
|
||||
|
||||
type initMachine struct {
|
||||
|
@ -71,7 +76,24 @@ func (i *initMachine) buildCmd(m *machineTestBuilder) []string {
|
|||
if i.userModeNetworking {
|
||||
cmd = append(cmd, "--user-mode-networking")
|
||||
}
|
||||
cmd = append(cmd, m.name)
|
||||
name := m.name
|
||||
cmd = append(cmd, name)
|
||||
|
||||
// when we create a new VM remove it again as cleanup
|
||||
DeferCleanup(func() {
|
||||
r := new(rmMachine)
|
||||
session, err := m.setName(name).setCmd(r.withForce()).run()
|
||||
Expect(err).ToNot(HaveOccurred(), "error occurred rm'ing machine")
|
||||
// Some test create a invalid VM so the VM does not exists in this case we have to ignore the error.
|
||||
// It would be much better if rm -f would behave like other commands and ignore not exists errors.
|
||||
if session.ExitCode() == 125 {
|
||||
if strings.Contains(session.errorToString(), "VM does not exist") {
|
||||
return
|
||||
}
|
||||
}
|
||||
Expect(session).To(Exit(0))
|
||||
})
|
||||
|
||||
i.cmd = cmd
|
||||
return cmd
|
||||
}
|
||||
|
|
|
@ -11,17 +11,6 @@ import (
|
|||
)
|
||||
|
||||
var _ = Describe("podman machine info", func() {
|
||||
var (
|
||||
mb *machineTestBuilder
|
||||
testDir string
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
testDir, mb = setup()
|
||||
})
|
||||
AfterEach(func() {
|
||||
teardown(originalHomeDir, testDir, mb)
|
||||
})
|
||||
|
||||
It("machine info", func() {
|
||||
info := new(infoMachine)
|
||||
|
|
|
@ -20,18 +20,6 @@ import (
|
|||
)
|
||||
|
||||
var _ = Describe("podman machine init", func() {
|
||||
var (
|
||||
mb *machineTestBuilder
|
||||
testDir string
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
testDir, mb = setup()
|
||||
})
|
||||
AfterEach(func() {
|
||||
teardown(originalHomeDir, testDir, mb)
|
||||
})
|
||||
|
||||
cpus := runtime.NumCPU() / 2
|
||||
if cpus == 0 {
|
||||
cpus = 1
|
||||
|
|
|
@ -15,17 +15,6 @@ import (
|
|||
)
|
||||
|
||||
var _ = Describe("podman machine init - windows only", func() {
|
||||
var (
|
||||
mb *machineTestBuilder
|
||||
testDir string
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
testDir, mb = setup()
|
||||
})
|
||||
AfterEach(func() {
|
||||
teardown(originalHomeDir, testDir, mb)
|
||||
})
|
||||
|
||||
It("init with user mode networking", func() {
|
||||
if testProvider.VMType() != define.WSLVirt {
|
||||
|
|
|
@ -11,17 +11,6 @@ import (
|
|||
)
|
||||
|
||||
var _ = Describe("podman inspect stop", func() {
|
||||
var (
|
||||
mb *machineTestBuilder
|
||||
testDir string
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
testDir, mb = setup()
|
||||
})
|
||||
AfterEach(func() {
|
||||
teardown(originalHomeDir, testDir, mb)
|
||||
})
|
||||
|
||||
It("inspect bad name", func() {
|
||||
i := inspectMachine{}
|
||||
|
|
|
@ -14,17 +14,6 @@ import (
|
|||
)
|
||||
|
||||
var _ = Describe("podman machine list", func() {
|
||||
var (
|
||||
mb *machineTestBuilder
|
||||
testDir string
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
testDir, mb = setup()
|
||||
})
|
||||
AfterEach(func() {
|
||||
teardown(originalHomeDir, testDir, mb)
|
||||
})
|
||||
|
||||
It("list machine", func() {
|
||||
list := new(listMachine)
|
||||
|
|
|
@ -111,6 +111,9 @@ func setup() (string, *machineTestBuilder) {
|
|||
if err := os.Unsetenv("SSH_AUTH_SOCK"); err != nil {
|
||||
Fail("unable to unset SSH_AUTH_SOCK")
|
||||
}
|
||||
if err := os.Setenv("PODMAN_CONNECTIONS_CONF", filepath.Join(homeDir, "connections.json")); err != nil {
|
||||
Fail("failed to set PODMAN_CONNECTIONS_CONF")
|
||||
}
|
||||
mb, err := newMB()
|
||||
if err != nil {
|
||||
Fail(fmt.Sprintf("failed to create machine test: %q", err))
|
||||
|
@ -128,14 +131,7 @@ func setup() (string, *machineTestBuilder) {
|
|||
return homeDir, mb
|
||||
}
|
||||
|
||||
func teardown(origHomeDir string, testDir string, mb *machineTestBuilder) {
|
||||
r := new(rmMachine)
|
||||
for _, name := range mb.names {
|
||||
if _, err := mb.setName(name).setCmd(r.withForce()).run(); err != nil {
|
||||
GinkgoWriter.Printf("error occurred rm'ing machine: %q\n", err)
|
||||
}
|
||||
}
|
||||
|
||||
func teardown(origHomeDir string, testDir string) {
|
||||
if err := utils.GuardedRemoveAll(testDir); err != nil {
|
||||
Fail(fmt.Sprintf("failed to remove test dir: %q", err))
|
||||
}
|
||||
|
@ -150,6 +146,18 @@ func teardown(origHomeDir string, testDir string, mb *machineTestBuilder) {
|
|||
}
|
||||
}
|
||||
|
||||
var (
|
||||
mb *machineTestBuilder
|
||||
testDir string
|
||||
)
|
||||
|
||||
var _ = BeforeEach(func() {
|
||||
testDir, mb = setup()
|
||||
DeferCleanup(func() {
|
||||
teardown(originalHomeDir, testDir)
|
||||
})
|
||||
})
|
||||
|
||||
func setTmpDir(value string) (string, error) {
|
||||
switch {
|
||||
case runtime.GOOS != "darwin":
|
||||
|
|
|
@ -7,17 +7,6 @@ package e2e_test
|
|||
// )
|
||||
|
||||
// var _ = Describe("podman machine os apply", func() {
|
||||
// var (
|
||||
// mb *machineTestBuilder
|
||||
// testDir string
|
||||
// )
|
||||
|
||||
// BeforeEach(func() {
|
||||
// testDir, mb = setup()
|
||||
// })
|
||||
// AfterEach(func() {
|
||||
// teardown(originalHomeDir, testDir, mb)
|
||||
// })
|
||||
|
||||
// It("apply machine", func() {
|
||||
// i := new(initMachine)
|
||||
|
|
|
@ -11,17 +11,6 @@ import (
|
|||
)
|
||||
|
||||
var _ = Describe("podman machine proxy settings propagation", func() {
|
||||
var (
|
||||
mb *machineTestBuilder
|
||||
testDir string
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
testDir, mb = setup()
|
||||
})
|
||||
AfterEach(func() {
|
||||
teardown(originalHomeDir, testDir, mb)
|
||||
})
|
||||
|
||||
It("ssh to running machine and check proxy settings", func() {
|
||||
defer func() {
|
||||
|
|
|
@ -7,17 +7,6 @@ import (
|
|||
)
|
||||
|
||||
var _ = Describe("podman machine reset", func() {
|
||||
var (
|
||||
mb *machineTestBuilder
|
||||
testDir string
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
testDir, mb = setup()
|
||||
})
|
||||
AfterEach(func() {
|
||||
teardown(originalHomeDir, testDir, mb)
|
||||
})
|
||||
|
||||
It("starting from scratch should not error", func() {
|
||||
i := resetMachine{}
|
||||
|
|
|
@ -12,17 +12,6 @@ import (
|
|||
)
|
||||
|
||||
var _ = Describe("podman machine rm", func() {
|
||||
var (
|
||||
mb *machineTestBuilder
|
||||
testDir string
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
testDir, mb = setup()
|
||||
})
|
||||
AfterEach(func() {
|
||||
teardown(originalHomeDir, testDir, mb)
|
||||
})
|
||||
|
||||
It("bad init name", func() {
|
||||
i := rmMachine{}
|
||||
|
|
|
@ -13,17 +13,6 @@ import (
|
|||
)
|
||||
|
||||
var _ = Describe("podman machine set", func() {
|
||||
var (
|
||||
mb *machineTestBuilder
|
||||
testDir string
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
testDir, mb = setup()
|
||||
})
|
||||
AfterEach(func() {
|
||||
teardown(originalHomeDir, testDir, mb)
|
||||
})
|
||||
|
||||
It("set machine cpus, disk, memory", func() {
|
||||
skipIfWSL("WSL cannot change set properties of disk, processor, or memory")
|
||||
|
|
|
@ -8,17 +8,6 @@ import (
|
|||
)
|
||||
|
||||
var _ = Describe("podman machine ssh", func() {
|
||||
var (
|
||||
mb *machineTestBuilder
|
||||
testDir string
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
testDir, mb = setup()
|
||||
})
|
||||
AfterEach(func() {
|
||||
teardown(originalHomeDir, testDir, mb)
|
||||
})
|
||||
|
||||
It("bad machine name", func() {
|
||||
name := randomString()
|
||||
|
|
|
@ -14,16 +14,6 @@ import (
|
|||
)
|
||||
|
||||
var _ = Describe("podman machine start", func() {
|
||||
var (
|
||||
mb *machineTestBuilder
|
||||
testDir string
|
||||
)
|
||||
BeforeEach(func() {
|
||||
testDir, mb = setup()
|
||||
})
|
||||
AfterEach(func() {
|
||||
teardown(originalHomeDir, testDir, mb)
|
||||
})
|
||||
|
||||
It("start simple machine", func() {
|
||||
i := new(initMachine)
|
||||
|
|
|
@ -10,17 +10,6 @@ import (
|
|||
)
|
||||
|
||||
var _ = Describe("podman machine stop", func() {
|
||||
var (
|
||||
mb *machineTestBuilder
|
||||
testDir string
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
testDir, mb = setup()
|
||||
})
|
||||
AfterEach(func() {
|
||||
teardown(originalHomeDir, testDir, mb)
|
||||
})
|
||||
|
||||
It("stop bad name", func() {
|
||||
i := stopMachine{}
|
||||
|
|
Loading…
Reference in New Issue