Skip to content

Commit

Permalink
chore: more deflake (#629)
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Vishwas Siravara <[email protected]>
Co-authored-by: Vishwas Siravara <[email protected]>
  • Loading branch information
vsiravar and Vishwas Siravara committed Oct 17, 2023
1 parent ead3f8d commit d686562
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 16 deletions.
21 changes: 12 additions & 9 deletions e2e/vm/config_windows_test.go
Original file line number Diff line number Diff line change
@@ -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")
20 changes: 16 additions & 4 deletions e2e/vm/cred_helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
package vm

import (
"fmt"
"runtime"

"github.com/onsi/ginkgo/v2"
"github.com/onsi/gomega"
"github.com/onsi/gomega/gexec"
Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion e2e/vm/lifecycle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
Expand Down
1 change: 1 addition & 0 deletions e2e/vm/vm_darwin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {})
Expand Down
4 changes: 2 additions & 2 deletions e2e/vm/vm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
Expand Down
1 change: 1 addition & 0 deletions e2e/vm/vm_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {})
Expand Down

0 comments on commit d686562

Please sign in to comment.