Skip to content

Commit

Permalink
ci: add virtualization framework (vz) testing (#352)
Browse files Browse the repository at this point in the history
Issue #, if available:
Closes #351 

*Description of changes:*
This change updates the test matrix for e2e to test both Qemu and
Virtualization framework (VZ) virtual machines on macOS.

*Testing done:*
CI is successful

- [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: Austin Vazquez <[email protected]>
  • Loading branch information
austinvazquez authored Jul 1, 2024
1 parent ea05b67 commit 6ad913e
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ jobs:
[self-hosted, macos, arm64, 13, test],
[self-hosted, macos, arm64, 14, test],
]
vm_type: [ "vz", "qemu" ]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
Expand Down Expand Up @@ -95,4 +96,4 @@ jobs:
make install.dependencies
- name: Run e2e tests
shell: zsh {0}
run: make test-e2e
run: FINCH_VM_TYPE=${{ matrix.vm_type }} make test-e2e
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ all: install.dependencies
# Rootfs required for Windows, require full OS for Mac
FINCH_IMAGE_LOCATION ?=
FINCH_IMAGE_DIGEST ?=
FINCH_VM_TYPE ?=
BUILD_OS ?= $(OS)
ifeq ($(BUILD_OS), Windows_NT)
include Makefile.windows
Expand Down Expand Up @@ -60,4 +61,4 @@ clean:

.PHONY: test-e2e
test-e2e: $(LIMA_TEMPLATE_OUTDIR)/fedora.yaml
cd e2e && go test -timeout 30m -v ./... -ginkgo.v
cd e2e && VM_TYPE=$(FINCH_VM_TYPE) go test -timeout 30m -v ./... -ginkgo.v
4 changes: 4 additions & 0 deletions Makefile.darwin
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ endif
FINCH_IMAGE_LOCATION := $(OS_OUTDIR)/$(FINCH_OS_BASENAME)
FINCH_IMAGE_DIGEST := "sha512:$(FINCH_OS_DIGEST)"

# Virtualization framework is the default virtual machine type on Finch on macOS
# This is only used for testing of Finch core bundles.
FINCH_VM_TYPE ?= vz

install.dependencies: install.os install.lima-dependencies install.lima-socket-vmnet

.PHONY: install.os
Expand Down
3 changes: 3 additions & 0 deletions Makefile.windows
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ else
$(error Finch on Windows ARM not supported)
endif

# WSL2 is the only virtual machine type supported for Finch on Windows
FINCH_VM_TYPE := wsl2

WINGIT_TEMP_DIR := $(CURDIR)/wingit-temp
WINGIT_x86_URL := $(or $(WINGIT_x86_URL),https://github.com/git-for-windows/git/releases/download/v2.42.0.windows.2/Git-2.42.0.2-64-bit.tar.bz2)
WINGIT_x86_BASENAME ?= $(notdir $(WINGIT_x86_URL))
Expand Down
22 changes: 16 additions & 6 deletions e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,28 +29,38 @@ func TestE2e(t *testing.T) {
// Put ./../_output/bin first on path to override other installations of lima and qemu
newPath := limaAbsPath + string(os.PathListSeparator) + currentPath
err = os.Setenv("PATH", newPath)

if err != nil {
t.Fatalf("Error setting PATH: %v", err)
}

wd, err := os.Getwd()
if err != nil {
t.Fatalf("failed to get the current working directory: %v", err)
}
subject := "limactl"

vmConfigFile := filepath.Join(wd, "./../_output/lima-template/fedora.yaml")
vmName := "fedora"

subject := "limactl"
limaOpt, err := option.New([]string{subject})
if err != nil {
t.Fatalf("failed to initialize a testing option %v", err)
t.Fatalf("failed to initialize a testing option: %v", err)
}
nerdctlOpt, err := option.New([]string{subject, "shell", "fedora", "sudo", "-E", "nerdctl"})

vmName := "fedora"

nerdctlOpt, err := option.New([]string{subject, "shell", vmName, "sudo", "-E", "nerdctl"})
if err != nil {
t.Fatalf("failed to initialize a testing option: %v", err)
}

vmType := os.Getenv("VM_TYPE")
if vmType == "" {
// Virtualization framework is the default Finch launch type on macOS.
vmType = "vz"
}

ginkgo.SynchronizedBeforeSuite(func() []byte {
command.New(limaOpt, "start", vmConfigFile).WithTimeoutInSeconds(600).Run()
command.New(limaOpt, "start", vmConfigFile, "--name", vmName, "--vm-type", vmType).WithTimeoutInSeconds(600).Run()
tests.SetupLocalRegistry(nerdctlOpt)
return nil
}, func(bytes []byte) {})
Expand Down

0 comments on commit 6ad913e

Please sign in to comment.