Skip to content

Commit

Permalink
ci(bug-fix): use local registry for VZ/Rosetta tests (#327)
Browse files Browse the repository at this point in the history
Issue #, if available: fixes #322

*Description of changes:*
- Uses the local registry to run Virtualization framework and Rosetta
suites

*Testing done:*
  - Local testing


- [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: Justin Alvarez <alvajus@amazon.com>
  • Loading branch information
pendo324 authored Apr 7, 2023
1 parent 6cfbb9f commit be81af2
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 5 deletions.
14 changes: 12 additions & 2 deletions e2e/vm/virtualization_framework_rosetta_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,14 @@ var testVirtualizationFrameworkAndRosetta = func(o *option.Option, installed boo
}

resetVM(o, installed)
resetDisks(o, installed)
writeFile(finchConfigFilePath, []byte("memory: 4GiB\ncpus: 6\nvmType: vz\nrosetta: false"))
initCmdSession := command.New(o, virtualMachineRootCmd, "init").WithTimeoutInSeconds(180).Run()
initCmdSession := command.New(o, virtualMachineRootCmd, "init").WithTimeoutInSeconds(600).Run()
gomega.Expect(initCmdSession).Should(gexec.Exit(0))
tests.SetupLocalRegistry(o)
ginkgo.DeferCleanup(func() {
tests.CleanupLocalRegistry(o)
})
})

// Run sanity check tests
Expand All @@ -47,9 +52,14 @@ var testVirtualizationFrameworkAndRosetta = func(o *option.Option, installed boo
}

resetVM(o, installed)
resetDisks(o, installed)
writeFile(finchConfigFilePath, []byte("memory: 4GiB\ncpus: 6\nvmType: vz\nrosetta: true"))
initCmdSession := command.New(o, virtualMachineRootCmd, "init").WithTimeoutInSeconds(180).Run()
initCmdSession := command.New(o, virtualMachineRootCmd, "init").WithTimeoutInSeconds(600).Run()
gomega.Expect(initCmdSession).Should(gexec.Exit(0))
tests.SetupLocalRegistry(o)
ginkgo.DeferCleanup(func() {
tests.CleanupLocalRegistry(o)
})
})

// Run sanity check tests
Expand Down
24 changes: 24 additions & 0 deletions e2e/vm/vm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
package vm

import (
"errors"
"io/fs"
"os"
"os/exec"
"path/filepath"
"testing"
Expand Down Expand Up @@ -82,3 +85,24 @@ var resetVM = func(o *option.Option, installed bool) string {

return limaConfigFilePath
}

var resetDisks = func(o *option.Option, installed bool) {
var dataDiskDir string
limaDisksPath := "lima/data/_disks/"
if installed {
path, err := exec.LookPath(e2e.InstalledTestSubject)
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
realFinchPath, err := filepath.EvalSymlinks(path)
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
dataDiskDir = filepath.Join(realFinchPath, "../../", limaDisksPath)
} else {
dataDiskDir = filepath.Join("../../_output/", limaDisksPath)
}
realDiskPath, err := os.Readlink(filepath.Join(dataDiskDir, "finch/datadisk"))
if err == nil {
gomega.Expect(os.Remove(realDiskPath)).ShouldNot(gomega.HaveOccurred())
} else if !errors.Is(err, fs.ErrNotExist) {
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
}
gomega.Expect(os.RemoveAll(dataDiskDir)).ShouldNot(gomega.HaveOccurred())
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/onsi/gomega v1.27.5
github.com/pelletier/go-toml v1.9.5
github.com/pkg/sftp v1.13.5
github.com/runfinch/common-tests v0.6.3
github.com/runfinch/common-tests v0.6.4
github.com/sirupsen/logrus v1.9.0
github.com/spf13/afero v1.9.5
github.com/spf13/cobra v1.6.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,8 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/runfinch/common-tests v0.6.3 h1:Xbk2rzk3Un93wacbB3ACuRk4ujke6pqNyiCcIXhwk5U=
github.com/runfinch/common-tests v0.6.3/go.mod h1:/lEtd8e5vQuK1NjVCeCPl09T/XVF7owDeQCAiOP6rtw=
github.com/runfinch/common-tests v0.6.4 h1:pcBQBUmjS09L25S4e5tUzJvRg3OinCmn3f1t++tQcng=
github.com/runfinch/common-tests v0.6.4/go.mod h1:/lEtd8e5vQuK1NjVCeCPl09T/XVF7owDeQCAiOP6rtw=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=
Expand Down

0 comments on commit be81af2

Please sign in to comment.