From d6865621d6969002f1f9d7052cc7bedaff9ce82b Mon Sep 17 00:00:00 2001 From: Vishwas Siravara Date: Thu, 12 Oct 2023 23:46:42 +0000 Subject: [PATCH] chore: more deflake (#629) Issue #, if available: *Description of changes:* - change `vm stop` -> `vm stop -f` and `vm remove` -> `vm remove -f` *Testing done:* Yes on macOS - [X] I've reviewed the guidance in CONTRIBUTING.md #### License Acceptance By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. --------- Signed-off-by: Vishwas Siravara Signed-off-by: Vishwas Siravara Co-authored-by: Vishwas Siravara --- e2e/vm/config_windows_test.go | 21 ++++++++++++--------- e2e/vm/cred_helper_test.go | 20 ++++++++++++++++---- e2e/vm/lifecycle_test.go | 2 +- e2e/vm/vm_darwin_test.go | 1 + e2e/vm/vm_test.go | 4 ++-- e2e/vm/vm_windows_test.go | 1 + 6 files changed, 33 insertions(+), 16 deletions(-) diff --git a/e2e/vm/config_windows_test.go b/e2e/vm/config_windows_test.go index 57f19f4d5..53f368b7f 100644 --- a/e2e/vm/config_windows_test.go +++ b/e2e/vm/config_windows_test.go @@ -1,9 +1,12 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -//go:build windows - -package vm - -import "os" - -var finchConfigFilePath = os.Getenv("LOCALAPPDATA") + "/.finch/finch.yaml" +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 +//go:build windows + +package vm + +import ( + "os" + "path/filepath" +) + +var finchConfigFilePath = filepath.Join(os.Getenv("LOCALAPPDATA"), ".finch", "finch.yaml") diff --git a/e2e/vm/cred_helper_test.go b/e2e/vm/cred_helper_test.go index cf22330e5..ff41105c5 100644 --- a/e2e/vm/cred_helper_test.go +++ b/e2e/vm/cred_helper_test.go @@ -4,6 +4,9 @@ package vm import ( + "fmt" + "runtime" + "github.com/onsi/ginkgo/v2" "github.com/onsi/gomega" "github.com/onsi/gomega/gexec" @@ -13,14 +16,23 @@ import ( var testCredHelper = func(o *option.Option, installed bool, registry string) { ginkgo.Describe("Credential Helper", func() { + var vmType string + + ginkgo.BeforeEach(func() { + if runtime.GOOS == "windows" { + vmType = "wsl2" + } else { + vmType = "vz" + } + }) ginkgo.It("should pull from container registry", func() { - resetVM(o, installed) - resetDisks(o, installed) if registry == "" { ginkgo.Skip("No Provided Container Registry Url") } - writeFile(finchConfigFilePath, []byte("cpus: 6\nmemory: 4GiB\ncreds_helpers:\n "+ - "- ecr-login\nvmType: vz\nrosetta: true")) + resetVM(o, installed) + resetDisks(o, installed) + writeFile(finchConfigFilePath, []byte(fmt.Sprintf("cpus: 6\nmemory: 4GiB\ncreds_helpers:\n "+ + "- ecr-login\nvmType: %s\nrosetta: true", vmType))) initCmdSession := command.New(o, virtualMachineRootCmd, "init").WithTimeoutInSeconds(600).Run() gomega.Expect(initCmdSession).Should(gexec.Exit(0)) command.New(o, "pull", registry).WithTimeoutInSeconds(600).Run() diff --git a/e2e/vm/lifecycle_test.go b/e2e/vm/lifecycle_test.go index e5c99c9f6..587f45a3d 100644 --- a/e2e/vm/lifecycle_test.go +++ b/e2e/vm/lifecycle_test.go @@ -25,7 +25,7 @@ var testVMLifecycle = func(o *option.Option) { ginkgo.It("should be able to force stop the virtual machine", func() { command.Run(o, "images") - command.New(o, virtualMachineRootCmd, "stop", "--force").WithTimeoutInSeconds(90).Run() + command.New(o, virtualMachineRootCmd, "stop", "--force").WithTimeoutInSeconds(180).Run() command.RunWithoutSuccessfulExit(o, "images") command.New(o, virtualMachineRootCmd, "start").WithTimeoutInSeconds(240).Run() }) diff --git a/e2e/vm/vm_darwin_test.go b/e2e/vm/vm_darwin_test.go index e4d2eee67..ebba93b2e 100644 --- a/e2e/vm/vm_darwin_test.go +++ b/e2e/vm/vm_darwin_test.go @@ -33,6 +33,7 @@ func TestVM(t *testing.T) { } ginkgo.SynchronizedBeforeSuite(func() []byte { + resetDisks(o, *e2e.Installed) command.New(o, "vm", "init").WithTimeoutInSeconds(600).Run() return nil }, func(bytes []byte) {}) diff --git a/e2e/vm/vm_test.go b/e2e/vm/vm_test.go index 8e8eca47b..bc1ddf504 100644 --- a/e2e/vm/vm_test.go +++ b/e2e/vm/vm_test.go @@ -46,8 +46,8 @@ var resetVM = func(o *option.Option, installed bool) string { ginkgo.DeferCleanup(func() { writeFile(finchConfigFilePath, origFinchCfg) writeFile(limaConfigFilePath, origLimaCfg) - command.New(o, virtualMachineRootCmd, "stop").WithTimeoutInSeconds(180).Run() - command.New(o, virtualMachineRootCmd, "remove").WithTimeoutInSeconds(180).Run() + command.New(o, virtualMachineRootCmd, "stop", "-f").WithTimeoutInSeconds(180).Run() + command.New(o, virtualMachineRootCmd, "remove", "-f").WithTimeoutInSeconds(180).Run() if runtime.GOOS == "windows" { gomega.Expect(exec.Command("wsl", "--shutdown").Run()).Should(gomega.BeNil()) } diff --git a/e2e/vm/vm_windows_test.go b/e2e/vm/vm_windows_test.go index d180880c3..bde28bd07 100644 --- a/e2e/vm/vm_windows_test.go +++ b/e2e/vm/vm_windows_test.go @@ -30,6 +30,7 @@ func TestVM(t *testing.T) { } ginkgo.SynchronizedBeforeSuite(func() []byte { + resetDisks(o, *e2e.Installed) command.New(o, "vm", "init").WithTimeoutInSeconds(600).Run() return nil }, func(bytes []byte) {})