Skip to content

Commit

Permalink
ci: add e2e test job
Browse files Browse the repository at this point in the history
Signed-off-by: Zespre Schmidt <[email protected]>
  • Loading branch information
starbops committed Nov 18, 2024
1 parent 9769fca commit 66171b9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 23 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.22'
go-version: '1.23'
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
Expand Down Expand Up @@ -61,3 +61,6 @@ jobs:
push: false
tags: ${{ env.REPO }}/${{ env.AGENT }}:${{ env.VERSION }}
labels: ${{ steps.meta.outputs.labels }}
- name: Run end-to-end testing
run: make local-e2e-test

20 changes: 10 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,19 @@
VERSION ?= $(shell git describe --tags --exact-match 2>/dev/null || echo "$(shell git rev-parse --abbrev-ref HEAD)-head")
COMMIT ?= $(shell git rev-parse HEAD)

DIRTY :=
ifneq ($(shell git status --porcelain --untracked-files=no),)
DIRTY := -dirty
endif
VERSION := $(VERSION)$(DIRTY)
# Export the tag to be used in the e2e tests
export TAG = $(VERSION)

REPO ?= starbops

# Image URL to use all building/pushing image targets
MGR_IMG ?= $(REPO)/virtbmc-controller:$(VERSION)
AGT_IMG ?= $(REPO)/virtbmc:$(VERSION)
MGR_IMG ?= $(REPO)/virtbmc-controller:$(TAG)
AGT_IMG ?= $(REPO)/virtbmc:$(TAG)

K8S_VERSION = 1.28.13
KIND_K8S_VERSION = v$(shell echo $(K8S_VERSION))
Expand Down Expand Up @@ -95,14 +103,6 @@ golangci-lint:
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell dirname $(GOLANGCI_LINT)) $(GOLANGCI_LINT_VERSION) ;\
}

## Decide the image tag based on git state for e2e tests usage
VERSION = $(shell git rev-parse --short HEAD)
DIRTY :=
ifneq ($(shell git status --porcelain --untracked-files=no),)
DIRTY := -dirty
endif
export TAG = $(VERSION)$(DIRTY)

.PHONY: e2e-setup
e2e-setup: kind ## Setup end-to-end test environment.
$(KIND) create cluster --name kvbmc-e2e --config test/e2e/kind-config.yaml --image=kindest/node:$(KIND_K8S_VERSION)
Expand Down
14 changes: 2 additions & 12 deletions test/e2e/e2e_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,8 @@ func TestE2E(t *testing.T) {
var _ = BeforeSuite(func() {
logf.SetLogger(zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true)))

By("building the controller-manager image")
cmd := exec.Command("make", "docker-build", fmt.Sprintf("IMG=%s", controllerManagerImage))
_, err := util.Run(cmd)
Expect(err).ToNot(HaveOccurred())

By("building the agent image")
cmd = exec.Command("make", "docker-build-virtbmc", fmt.Sprintf("IMG=%s", agentImage))
_, err = util.Run(cmd)
Expect(err).ToNot(HaveOccurred())

By("loading the built images to the Kind cluster")
err = util.LoadImageToKindClusterWithName(controllerManagerImage)
err := util.LoadImageToKindClusterWithName(controllerManagerImage)
Expect(err).ToNot(HaveOccurred())
err = util.LoadImageToKindClusterWithName(agentImage)
Expect(err).ToNot(HaveOccurred())
Expand Down Expand Up @@ -125,7 +115,7 @@ var _ = BeforeSuite(func() {
}

By("deploying the controller-manager")
cmd = exec.Command("make", "deploy", fmt.Sprintf("IMG=%s", controllerManagerImage))
cmd := exec.Command("make", "deploy", fmt.Sprintf("IMG=%s", controllerManagerImage))
_, err = util.Run(cmd)
Expect(err).ToNot(HaveOccurred())
})
Expand Down

0 comments on commit 66171b9

Please sign in to comment.