diff --git a/e2e/vm/additional_disk_test.go b/e2e/vm/additional_disk_test.go index 7c0dfb3c6..7fd87146f 100644 --- a/e2e/vm/additional_disk_test.go +++ b/e2e/vm/additional_disk_test.go @@ -5,6 +5,7 @@ package vm import ( "fmt" + "time" "github.com/onsi/ginkgo/v2" "github.com/onsi/gomega" @@ -19,23 +20,28 @@ const ( networkName = "test-network" ) -var testAdditionalDisk = func(o *option.Option) { +var testAdditionalDisk = func(o *option.Option, installed bool) { ginkgo.Describe("Additional disk", ginkgo.Serial, func() { ginkgo.It("Retains container user data after the VM is deleted", func() { + resetVM(o, installed) + resetDisks(o, installed) + command.New(o, virtualMachineRootCmd, "init").WithTimeoutInSeconds(600).Run() command.Run(o, "volume", "create", volumeName) ginkgo.DeferCleanup(command.Run, o, "volume", "rm", volumeName) command.Run(o, "network", "create", networkName) ginkgo.DeferCleanup(command.Run, o, "network", "rm", networkName) command.Run(o, "run", "-d", "--name", containerName, "-v", fmt.Sprintf("%s:/tmp", volumeName), - savedImage, "sh", "-c", "sleep infinity") + savedImage, "sleep", "infinity") command.Run(o, "exec", containerName, "sh", "-c", "echo foo > /tmp/test.txt") ginkgo.DeferCleanup(command.Run, o, "rmi", savedImage) ginkgo.DeferCleanup(command.Run, o, "rm", "-f", containerName) - command.Run(o, "kill", containerName) + command.New(o, "stop", containerName).WithTimeoutInSeconds(30).Run() - command.New(o, virtualMachineRootCmd, "stop").WithoutCheckingExitCode().WithTimeoutInSeconds(90).Run() + time.Sleep(20 * time.Second) + + command.New(o, virtualMachineRootCmd, "stop").WithTimeoutInSeconds(90).Run() command.Run(o, virtualMachineRootCmd, "remove") command.New(o, virtualMachineRootCmd, "init").WithTimeoutInSeconds(240).Run() diff --git a/e2e/vm/config_darwin_test.go b/e2e/vm/config_darwin_test.go index a7f416f78..77aea3853 100644 --- a/e2e/vm/config_darwin_test.go +++ b/e2e/vm/config_darwin_test.go @@ -21,6 +21,8 @@ import ( "github.com/runfinch/finch/pkg/config" ) +var finchConfigFilePath string = os.Getenv("HOME") + "/.finch/finch.yaml" + var testConfig = func(o *option.Option, installed bool) { ginkgo.Describe("Config (after init)", ginkgo.Serial, func() { ginkgo.It("updates init-only config values when values are changed after init", func() { diff --git a/e2e/vm/config_test.go b/e2e/vm/config_test.go index c2be5978b..8440a5496 100644 --- a/e2e/vm/config_test.go +++ b/e2e/vm/config_test.go @@ -22,8 +22,6 @@ import ( "github.com/runfinch/finch/e2e" ) -var finchConfigFilePath = os.Getenv("HOME") + "/.finch/finch.yaml" - const defaultLimaConfigFilePath = "../../_output/lima/data/_config/override.yaml" func readFile(filePath string) []byte { diff --git a/e2e/vm/finch_config_file_test.go b/e2e/vm/finch_config_file_test.go index b84508bb4..0137c8b8f 100644 --- a/e2e/vm/finch_config_file_test.go +++ b/e2e/vm/finch_config_file_test.go @@ -50,6 +50,7 @@ var testFinchConfigFile = func(o *option.Option) { for command.StdoutStr(o, "inspect", "-f", "{{.State.Running}}", containerID) != "true" { time.Sleep(1 * time.Second) } + time.Sleep(10 * time.Second) registry := fmt.Sprintf(`localhost:%d`, port) command.Run(o, "login", registry, "-u", "testUser", "-p", "testPassword") diff --git a/e2e/vm/vm_darwin_test.go b/e2e/vm/vm_darwin_test.go index aad547b6d..e4d2eee67 100644 --- a/e2e/vm/vm_darwin_test.go +++ b/e2e/vm/vm_darwin_test.go @@ -44,7 +44,7 @@ func TestVM(t *testing.T) { ginkgo.Describe("", func() { testVMLifecycle(o) - testAdditionalDisk(o) + testAdditionalDisk(o, *e2e.Installed) testConfig(o, *e2e.Installed) testFinchConfigFile(o) testVersion(o) diff --git a/e2e/vm/vm_test.go b/e2e/vm/vm_test.go index c1992d2a0..106a95573 100644 --- a/e2e/vm/vm_test.go +++ b/e2e/vm/vm_test.go @@ -6,6 +6,7 @@ package vm import ( "os/exec" "path/filepath" + "runtime" "github.com/onsi/ginkgo/v2" "github.com/onsi/gomega" @@ -33,14 +34,22 @@ var resetVM = func(o *option.Option, installed bool) string { } origLimaCfg := readFile(limaConfigFilePath) - command.New(o, virtualMachineRootCmd, "stop", "-f").WithoutCheckingExitCode().WithTimeoutInSeconds(90).Run() - command.New(o, virtualMachineRootCmd, "remove", "-f").WithoutCheckingExitCode().WithTimeoutInSeconds(90).Run() + command.New(o, virtualMachineRootCmd, "stop").WithTimeoutInSeconds(120).Run() + command.New(o, virtualMachineRootCmd, "remove").WithTimeoutInSeconds(90).Run() + if runtime.GOOS == "windows" { + // clean up iptables + // https://docs.rancherdesktop.io/troubleshooting-tips/#q-how-do-i-fix-fata0005-subnet-1040024-overlaps-with-other-one-on-this-address-space-when-running-a-container-using-nerdctl-run + gomega.Expect(exec.Command("wsl", "--shutdown").Run()).Should(gomega.BeNil()) + } ginkgo.DeferCleanup(func() { writeFile(finchConfigFilePath, origFinchCfg) writeFile(limaConfigFilePath, origLimaCfg) - command.New(o, virtualMachineRootCmd, "stop", "-f").WithoutCheckingExitCode().WithTimeoutInSeconds(90).Run() - command.New(o, virtualMachineRootCmd, "remove", "-f").WithoutCheckingExitCode().WithTimeoutInSeconds(90).Run() + command.New(o, virtualMachineRootCmd, "stop").WithTimeoutInSeconds(180).Run() + command.New(o, virtualMachineRootCmd, "remove").WithTimeoutInSeconds(180).Run() + if runtime.GOOS == "windows" { + gomega.Expect(exec.Command("wsl", "--shutdown").Run()).Should(gomega.BeNil()) + } command.New(o, virtualMachineRootCmd, "init").WithoutCheckingExitCode().WithTimeoutInSeconds(600).Run() }) diff --git a/e2e/vm/vm_windows_test.go b/e2e/vm/vm_windows_test.go index 4d378f0cb..d180880c3 100644 --- a/e2e/vm/vm_windows_test.go +++ b/e2e/vm/vm_windows_test.go @@ -41,7 +41,7 @@ func TestVM(t *testing.T) { ginkgo.Describe("", func() { testVMLifecycle(o) - testAdditionalDisk(o) + testAdditionalDisk(o, *e2e.Installed) testFinchConfigFile(o) testVersion(o) testSupportBundle(o)