-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pkg/machine/e2e: fix broken cleanup #23154
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the interest of allowing CI tests to run locally, would it make sense to set this to a tempdir? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that is already a tmpdir, see above. The entire home is overwritten but as windows is using APPDATA it does not help there. Of course I could overwrite APPDATA for windows but this seems simpler and more consistent to me |
||
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": | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a lot of those tests! Would it make sense for those tests to set a
SkipMachineCleanup
orInvalidVM
state flag?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not trusting test writers to remove this flag when it is no longer needed and it doesn't help if a bug causes the machine to be created all of the sudden then we leak machines.
IMO the reasonable fix to to make rm -f not error on non existing machine like our other commands do, i.e.
podman rm -f blah