Skip to content

Commit

Permalink
Run e2e-test on Kind in CI
Browse files Browse the repository at this point in the history
Signed-off-by: Jacob Salway <jacob.salway@gmail.com>
  • Loading branch information
jacobsalway committed Aug 30, 2024
1 parent 9cc1c02 commit 439db1d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 55 deletions.
33 changes: 11 additions & 22 deletions .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ jobs:
done
build-helm-chart:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- name: Determine branch name
id: get_branch
Expand Down Expand Up @@ -163,37 +163,26 @@ jobs:
minikube image load docker.io/kubeflow/spark-operator:local
ct install
integration-test:
runs-on: ubuntu-22.04
e2e-test:
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v4
with:
fetch-depth: "0"
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
go-version-file: go.mod

- name: setup minikube
uses: manusa/actions-setup-minikube@v2.11.0
with:
minikube version: v1.33.0
kubernetes version: v1.30.0
start args: --memory 6g --cpus=2 --addons ingress
github token: ${{ inputs.github-token }}
- name: Create a Kind cluster
uses: helm/kind-action@v1

- name: Build local spark-operator docker image for minikube testing
- name: Build and load image to Kind cluster
run: |
docker build -t docker.io/kubeflow/spark-operator:local .
minikube image load docker.io/kubeflow/spark-operator:local
# The integration tests are currently broken see: https://github.com/kubeflow/spark-operator/issues/1416
# - name: Run chart-testing (integration test)
# run: make integration-test
kind load docker-image docker.io/kubeflow/spark-operator:local
- name: Setup tmate session
if: failure()
uses: mxschmitt/action-tmate@v3
timeout-minutes: 15
- name: Run e2e tests
run: make e2e-test IMAGE_TAG=local
33 changes: 1 addition & 32 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,12 @@ IMAGE_REPOSITORY ?= kubeflow/spark-operator
IMAGE_TAG ?= $(VERSION)
IMAGE ?= $(IMAGE_REGISTRY)/$(IMAGE_REPOSITORY):$(IMAGE_TAG)

# Kind cluster
KIND_CLUSTER_NAME ?= spark-operator
KIND_CONFIG_FILE ?= charts/spark-operator-chart/ci/kind-config.yaml
KIND_KUBE_CONFIG ?= $(HOME)/.kube/config

## Location to install binaries
LOCALBIN ?= $(shell pwd)/bin

## Versions
KUSTOMIZE_VERSION ?= v5.4.1
CONTROLLER_TOOLS_VERSION ?= v0.15.0
KIND_VERSION ?= v0.23.0
ENVTEST_VERSION ?= release-0.18
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION ?= 1.29.3
Expand All @@ -67,7 +61,6 @@ SPARKCTL ?= $(LOCALBIN)/sparkctl
KUBECTL ?= kubectl
KUSTOMIZE ?= $(LOCALBIN)/kustomize-$(KUSTOMIZE_VERSION)
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen-$(CONTROLLER_TOOLS_VERSION)
KIND ?= $(LOCALBIN)/kind-$(KIND_VERSION)
ENVTEST ?= $(LOCALBIN)/setup-envtest-$(ENVTEST_VERSION)
GOLANGCI_LINT ?= $(LOCALBIN)/golangci-lint-$(GOLANGCI_LINT_VERSION)
GEN_CRD_API_REFERENCE_DOCS ?= $(LOCALBIN)/gen-crd-api-reference-docs-$(GEN_CRD_API_REFERENCE_DOCS_VERSION)
Expand Down Expand Up @@ -153,7 +146,7 @@ unit-test: envtest ## Run unit tests.
go test $(shell go list ./... | grep -v /e2e) -coverprofile cover.out

.PHONY: e2e-test
e2e-test: envtest ## Run the e2e tests against a Kind k8s instance that is spun up.
e2e-test: envtest ## Run the e2e tests. This uses the current kubectl context.
@echo "Running e2e tests..."
go test ./test/e2e/ -v -ginkgo.v -timeout 30m

Expand Down Expand Up @@ -239,25 +232,6 @@ helm-docs: helm-docs-plugin ## Generates markdown documentation for helm charts

##@ Deployment

ifndef ignore-not-found
ignore-not-found = false
endif

.PHONY: kind-create-cluster
kind-create-cluster: kind ## Create a kind cluster for integration tests.
if ! $(KIND) get clusters 2>/dev/null | grep -q "^$(KIND_CLUSTER_NAME)$$"; then \
kind create cluster --name $(KIND_CLUSTER_NAME) --config $(KIND_CONFIG_FILE) --kubeconfig $(KIND_KUBE_CONFIG); \
fi

.PHONY: kind-load-image
kind-load-image: kind-create-cluster docker-build ## Load the image into the kind cluster.
$(KIND) load docker-image --name $(KIND_CLUSTER_NAME) $(IMAGE)

.PHONY: kind-delete-custer
kind-delete-custer: kind ## Delete the created kind cluster.
$(KIND) delete cluster --name $(KIND_CLUSTER_NAME) && \
rm -f $(KIND_KUBE_CONFIG)

.PHONY: install
install-crd: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/crd | $(KUBECTL) apply -f -
Expand Down Expand Up @@ -290,11 +264,6 @@ controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessar
$(CONTROLLER_GEN): $(LOCALBIN)
$(call go-install-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen,$(CONTROLLER_TOOLS_VERSION))

.PHONY: kind
kind: $(KIND) ## Download kind locally if necessary.
$(KIND): $(LOCALBIN)
$(call go-install-tool,$(KIND),sigs.k8s.io/kind,$(KIND_VERSION))

.PHONY: envtest
envtest: $(ENVTEST) ## Download setup-envtest locally if necessary.
$(ENVTEST): $(LOCALBIN)
Expand Down
7 changes: 6 additions & 1 deletion test/e2e/suit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,12 @@ var _ = BeforeSuite(func() {
chart, err := loader.Load(chartPath)
Expect(err).NotTo(HaveOccurred())
Expect(chart).NotTo(BeNil())
release, err := installAction.Run(chart, nil)

values := make(map[string]interface{})
if imageTag := os.Getenv("IMAGE_TAG"); imageTag != "" {
values["image.tag"] = imageTag
}
release, err := installAction.Run(chart, values)
Expect(err).NotTo(HaveOccurred())
Expect(release).NotTo(BeNil())
})
Expand Down

0 comments on commit 439db1d

Please sign in to comment.