Skip to content

Commit

Permalink
Clean up and make cluster Make targets consistent. (#359)
Browse files Browse the repository at this point in the history
Change Makefile targets for running the Yunikorn services to make
testing a separate UHS instance a bit easier. Developers can now use
`make create-cluster` and `make delete-cluster`, to be consistent with
Kind's `create-cluster` and `delete-cluster` commands.

Fixes #356
  • Loading branch information
richscott authored Dec 2, 2024
1 parent a944ebf commit 05e6982
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -208,23 +208,20 @@ go-lint-fix: golangci-lint ## lint Golang code using golangci-lint.

##@ Test

define start-cluster
.PHONY: create-cluster
create-cluster:
@echo "**********************************"
@echo "Creating cluster"
@echo "**********************************"
@CLUSTER_NAME=uhs-test $(MAKE) create-cluster
@CLUSTER_NAME=uhs-test $(MAKE) start-cluster

@echo "**********************************"
@echo "Install and configure dependencies"
@echo "**********************************"
$(MAKE) install-dependencies migrate-up
endef

define cleanup-cluster
cleanup() {
echo "**********************************"
echo "Deleting cluster"
echo "**********************************"
CLUSTER_NAME=uhs-test $(MAKE) delete-cluster
}
endef
Expand All @@ -236,14 +233,14 @@ test: test-go-unit integration-tests ## run all tests.
.ONESHELL:
integration-tests: ## start dependencies and run integration tests.
@$(cleanup-cluster); trap cleanup EXIT
@$(start-cluster)
$(MAKE) create-cluster
UHS_SERVER=${UHS_SERVER:-http://localhost:8989} $(MAKE) test-go-integration

.PHONY: e2e-tests
.ONESHELL:
e2e-tests: ## start dependencies and run e2e tests.
@$(cleanup-cluster); trap cleanup EXIT
@$(start-cluster)
$(MAKE) create-cluster
CLUSTER_NAME=uhs-test UHS_SERVER=${UHS_SERVER:-http://localhost:8989} $(MAKE) test-go-e2e

.PHONY: performance-tests
Expand All @@ -260,7 +257,7 @@ performance-tests: k6 ## start dependencies and run performance tests.
fi
cleanup
}; trap stop_perf_cluster EXIT
@$(start-cluster)
$(MAKE) create-cluster
@echo "**********************************"
@echo "Run unicorn history server"
@mkdir -p test-reports/performance
Expand Down Expand Up @@ -396,22 +393,29 @@ kind-all-local: kind-all helm-install-uhs-local ## create kind cluster, install
.PHONY: kind-all
kind-all minikube-all: create-cluster install-dependencies migrate-up ## create cluster and install dependencies.

.PHONY: create-cluster
create-cluster: $(KIND) $(MINIKUBE) ## create a cluster.
.PHONY: start-cluster
start-cluster: $(KIND) $(MINIKUBE) ## start a cluster.
ifeq ($(strip $(CLUSTER_MGR)),kind)
$(KIND) create cluster --name $(CLUSTER_NAME) --config hack/kind-config.yml
else
$(MINIKUBE) start --ports=30000:30000 --ports=30001:30001 --ports=30002:30002 --ports=30003:30003
endif

.PHONY: delete-cluster
delete-cluster: $(KIND) $(MINIKUBE) ## delete the cluster.
.PHONY: stop-cluster
stop-cluster: $(KIND) $(MINIKUBE) ## stop a cluster.
ifeq ($(strip $(CLUSTER_MGR)),kind)
$(KIND) delete cluster --name $(CLUSTER_NAME)
else
$(MINIKUBE) delete
endif

.PHONY: delete-cluster
delete-cluster: $(KIND) $(MINIKUBE) ## delete the cluster.
@echo "**********************************"
@echo "Deleting cluster"
@echo "**********************************"
@CLUSTER_NAME=uhs-test $(MAKE) stop-cluster

.PHONY: kind-load-image
kind-load-image: docker-build-amd64 ## inject the local docker image into the kind cluster.
kind load docker-image $(IMAGE_TAG) --name $(CLUSTER_NAME)
Expand Down

0 comments on commit 05e6982

Please sign in to comment.