Skip to content

Commit 4252e6d

Browse files
committed
Update Ginkgo to V2
Two significant changes affected our code base: 1. The table DSL i.e. `DescribeTable` and `Entry` have been moved to top-level. It was not required to import `extensions/table` anymore 1. Changes to CLI flag arguments to randomise all specs There was a function name conflict because our code base and Ginkgo define the function `Label()`. Due to the dot-import, it caused a name conflict. This was resolved by aliasing our module. Disabled metrics in integration tests to avoid MacOS firewall popup everytime we run integration tests. We do not observe or scrape metrics in the integration tests at the moment. In the future, we could bind to localhost if needed. Small refactor on getting the configuration to use a library function, instead of a home-made one. Signed-off-by: Aitor Perez Cedres <acedres@vmware.com>
1 parent de7d30f commit 4252e6d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+74
-101
lines changed

Makefile

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ help:
99
ENVTEST_K8S_VERSION = 1.20.2
1010
ARCHITECTURE = amd64
1111
LOCAL_TESTBIN = $(CURDIR)/testbin
12+
13+
K8S_OPERATOR_NAMESPACE ?= rabbitmq-system
14+
1215
# "Control plane binaries (etcd and kube-apiserver) are loaded by default from /usr/local/kubebuilder/bin.
1316
# This can be overridden by setting the KUBEBUILDER_ASSETS environment variable"
1417
# https://pkg.go.dev/sigs.k8s.io/controller-runtime/pkg/envtest
@@ -19,7 +22,7 @@ $(KUBEBUILDER_ASSETS):
1922

2023
.PHONY: unit-tests
2124
unit-tests: install-tools $(KUBEBUILDER_ASSETS) generate fmt vet manifests ## Run unit tests
22-
ginkgo -r --randomizeAllSpecs api/ internal/
25+
ginkgo -r --randomize-all api/ internal/
2326

2427
.PHONY: integration-tests
2528
integration-tests: install-tools $(KUBEBUILDER_ASSETS) generate fmt vet manifests ## Run integration tests
@@ -54,7 +57,7 @@ generate: install-tools api-reference
5457

5558
# Build manager binary
5659
manager: generate fmt vet
57-
go mod tidy
60+
go mod download
5861
go build -o bin/manager main.go
5962

6063
deploy-manager: ## Deploy manager
@@ -77,15 +80,14 @@ destroy: ## Cleanup all controller artefacts
7780
run: generate manifests fmt vet install deploy-namespace-rbac just-run ## Run operator binary locally against the configured Kubernetes cluster in ~/.kube/config
7881

7982
just-run: ## Just runs 'go run main.go' without regenerating any manifests or deploying RBACs
80-
KUBECONFIG=${HOME}/.kube/config OPERATOR_NAMESPACE=rabbitmq-system go run ./main.go -metrics-bind-address 127.0.0.1:9782 --zap-devel $(OPERATOR_ARGS)
83+
KUBECONFIG=${HOME}/.kube/config OPERATOR_NAMESPACE=$(K8S_OPERATOR_NAMESPACE) go run ./main.go -metrics-bind-address 127.0.0.1:9782 --zap-devel $(OPERATOR_ARGS)
8184

8285
delve: generate install deploy-namespace-rbac just-delve ## Deploys CRD, Namespace, RBACs and starts Delve debugger
8386

8487
just-delve: install-tools ## Just starts Delve debugger
85-
KUBECONFIG=${HOME}/.kube/config OPERATOR_NAMESPACE=rabbitmq-system dlv debug
88+
KUBECONFIG=${HOME}/.kube/config OPERATOR_NAMESPACE=$(K8S_OPERATOR_NAMESPACE) dlv debug
8689

87-
# Install CRDs into a cluster
88-
install: manifests
90+
install: manifests ## Install CRDs into a cluster
8991
kubectl apply -f config/crd/bases
9092

9193
deploy-namespace-rbac:
@@ -161,15 +163,15 @@ kind-unprepare: ## Remove KIND support for LoadBalancer services
161163
@kubectl delete -f https://raw.githubusercontent.com/metallb/metallb/v0.9.3/manifests/namespace.yaml
162164

163165
system-tests: install-tools ## Run end-to-end tests against Kubernetes cluster defined in ~/.kube/config
164-
NAMESPACE="rabbitmq-system" ginkgo -nodes=3 -randomizeAllSpecs -r system_tests/
166+
NAMESPACE="$(K8S_OPERATOR_NAMESPACE)" ginkgo -nodes=3 --randomize-all -r system_tests/
165167

166168
kubectl-plugin-tests: ## Run kubectl-rabbitmq tests
167169
echo "running kubectl plugin tests"
168170
PATH=$(PWD)/bin:$$PATH ./bin/kubectl-rabbitmq.bats
169171

170172
tests: unit-tests integration-tests system-tests kubectl-plugin-tests
171173

172-
docker-registry-secret: check-env-docker-credentials operator-namespace
174+
docker-registry-secret: check-env-docker-credentials
173175
echo "creating registry secret and patching default service account"
174176
@kubectl -n $(K8S_OPERATOR_NAMESPACE) create secret docker-registry $(DOCKER_REGISTRY_SECRET) --docker-server='$(DOCKER_REGISTRY_SERVER)' --docker-username="$$DOCKER_REGISTRY_USERNAME" --docker-password="$$DOCKER_REGISTRY_PASSWORD" || true
175177
@kubectl -n $(K8S_OPERATOR_NAMESPACE) patch serviceaccount rabbitmq-cluster-operator -p '{"imagePullSecrets": [{"name": "$(DOCKER_REGISTRY_SECRET)"}]}'
@@ -178,11 +180,6 @@ install-tools:
178180
go mod download
179181
grep _ tools/tools.go | awk -F '"' '{print $$2}' | xargs -t go install
180182

181-
operator-namespace:
182-
ifeq (, $(K8S_OPERATOR_NAMESPACE))
183-
K8S_OPERATOR_NAMESPACE=rabbitmq-system
184-
endif
185-
186183
check-env-docker-repo: check-env-registry-server
187184
ifndef OPERATOR_IMAGE
188185
$(error OPERATOR_IMAGE is undefined: path to the Operator image within the registry specified in DOCKER_REGISTRY_SERVER (e.g. rabbitmq/cluster-operator - without leading slash))

api/v1beta1/rabbitmqcluster_status_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package v1beta1
22

33
import (
4-
. "github.com/onsi/ginkgo"
4+
. "github.com/onsi/ginkgo/v2"
55
. "github.com/onsi/gomega"
66
"github.com/rabbitmq/cluster-operator/internal/status"
77
appsv1 "k8s.io/api/apps/v1"

api/v1beta1/rabbitmqcluster_types_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
package v1beta1
1010

1111
import (
12-
. "github.com/onsi/ginkgo"
12+
. "github.com/onsi/ginkgo/v2"
1313
. "github.com/onsi/gomega"
1414
"github.com/rabbitmq/cluster-operator/internal/status"
1515
appsv1 "k8s.io/api/apps/v1"

api/v1beta1/suite_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"path/filepath"
1313
"testing"
1414

15-
. "github.com/onsi/ginkgo"
15+
. "github.com/onsi/ginkgo/v2"
1616
. "github.com/onsi/gomega"
1717

1818
"k8s.io/client-go/kubernetes/scheme"

controllers/rabbitmqcluster_controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919

2020
"k8s.io/apimachinery/pkg/util/intstr"
2121

22-
. "github.com/onsi/ginkgo"
22+
. "github.com/onsi/ginkgo/v2"
2323

2424
. "github.com/onsi/gomega"
2525
. "github.com/onsi/gomega/gstruct"

controllers/reconcile_cli_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
appsv1 "k8s.io/api/apps/v1"
1010
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1111

12-
. "github.com/onsi/ginkgo"
12+
. "github.com/onsi/ginkgo/v2"
1313
. "github.com/onsi/gomega"
1414
rabbitmqv1beta1 "github.com/rabbitmq/cluster-operator/api/v1beta1"
1515
)

controllers/reconcile_finalizer_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package controllers_test
33
import (
44
rabbitmqv1beta1 "github.com/rabbitmq/cluster-operator/api/v1beta1"
55

6-
. "github.com/onsi/ginkgo"
6+
. "github.com/onsi/ginkgo/v2"
77
. "github.com/onsi/gomega"
88

99
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

controllers/reconcile_no_persistence_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"context"
55
"fmt"
66

7-
. "github.com/onsi/ginkgo"
7+
. "github.com/onsi/ginkgo/v2"
88
. "github.com/onsi/gomega"
99
rabbitmqv1beta1 "github.com/rabbitmq/cluster-operator/api/v1beta1"
1010
"github.com/rabbitmq/cluster-operator/internal/status"

controllers/reconcile_persistence_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"context"
55
"fmt"
66

7-
. "github.com/onsi/ginkgo"
7+
. "github.com/onsi/ginkgo/v2"
88
. "github.com/onsi/gomega"
99
rabbitmqv1beta1 "github.com/rabbitmq/cluster-operator/api/v1beta1"
1010
"github.com/rabbitmq/cluster-operator/internal/status"

controllers/reconcile_rabbitmq_configurations_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ import (
44
rabbitmqv1beta1 "github.com/rabbitmq/cluster-operator/api/v1beta1"
55
"time"
66

7-
. "github.com/onsi/ginkgo"
8-
. "github.com/onsi/ginkgo/extensions/table"
7+
. "github.com/onsi/ginkgo/v2"
98
. "github.com/onsi/gomega"
109

1110
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

0 commit comments

Comments
 (0)