Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add github action to run test-e2e #6

Merged
merged 2 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/test-suite.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: DBaaS controller tests

on: pull_request

jobs:
test-suite:
runs-on: ubuntu-latest
strategy:
fail-fast: false

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: "0"

- name: Configure kind network
run: |
docker network create kind

- name: Create kind cluster
uses: helm/[email protected]
with:
version: v0.22.0
node_image: kindest/node:v1.28.7@sha256:9bc6c451a289cf96ad0bbaf33d416901de6fd632415b076ab05f5fa7e4f65c58
kubectl_version: v1.28.7
cluster_name: kind
config: kind-config.yaml

- name: Run github/test-e2e
run: make github/test-e2e
25 changes: 21 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ else
GOBIN=$(shell go env GOBIN)
endif

KIND_CLUSTER ?= kind

# CONTAINER_TOOL defines the container tool to be used for building images.
# Be aware that the target commands are only tested with Docker which is
# scaffolded by default. However, you might want to replace it to use other
Expand Down Expand Up @@ -64,10 +66,25 @@ vet: ## Run go vet against code.
test: manifests generate fmt vet envtest ## Run tests.
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test $$(go list ./... | grep -v /e2e) -coverprofile cover.out

.PHONY: create-kind-cluster
create-kind-cluster:
docker network inspect $(KIND_CLUSTER) >/dev/null || docker network create $(KIND_CLUSTER)
kind create cluster --wait=60s --name=$(KIND_CLUSTER) --config=kind-config.yaml

.PHONY: delete-kind-cluster
delete-kind-cluster:
kind delete cluster --name=$(KIND_CLUSTER) && docker network rm $(KIND_CLUSTER)

# Utilize Kind or modify the e2e tests to load the image locally, enabling compatibility with other vendors.
.PHONY: test-e2e # Run the e2e tests against a Kind k8s instance that is spun up.
test-e2e:
kind export kubeconfig --name=kind
.PHONY: github/test-e2e # Run the e2e tests against a Kind k8s instance that is spun up inside github action.
github/test-e2e:
go test ./test/e2e/ -v -ginkgo.v

# Create a kind cluster locally and run the test e2e test suite against it
.PHONY: local-kind/test-e2e # Run the e2e tests against a Kind k8s instance that is spun up locally
local-kind/test-e2e: create-kind-cluster
export KIND_CLUSTER=$(KIND_CLUSTER) && \
kind export kubeconfig --name=$(KIND_CLUSTER) && \
go test ./test/e2e/ -v -ginkgo.v

.PHONY: lint
Expand Down Expand Up @@ -201,4 +218,4 @@ echo "Downloading $${package}" ;\
GOBIN=$(LOCALBIN) go install $${package} ;\
mv "$$(echo "$(1)" | sed "s/-$(3)$$//")" $(1) ;\
}
endef
endef
2 changes: 0 additions & 2 deletions kind-config.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
name: dbaas-controller-cluster
nodes:
- role: control-plane
- role: worker
- role: worker
image: kindest/node:v1.29.2