Skip to content

Commit b5de66a

Browse files
perdasilvaPer Goncalves da Silvacamilamacedo86
authored
🐛 Unblock e2e (operator-framework#1683)
* Remove ginkgo from bingo in favor of go.mod version Signed-off-by: Per Goncalves da Silva <[email protected]> * fix(e2e): wait for leader election TestClusterExtensionAfterOLMUpgrade was failing due to increased leader election timeouts, causing reconciliation checks to run before leadership was acquired. This fix ensures the test explicitly waits for leader election logs (`"successfully acquired lease"`) before verifying reconciliation. * Add leader election wait fit for catalogd upgrade-e2e Signed-off-by: Per Goncalves da Silva <[email protected]> --------- Signed-off-by: Per Goncalves da Silva <[email protected]> Co-authored-by: Per Goncalves da Silva <[email protected]> Co-authored-by: Camila Macedo <[email protected]>
1 parent e77c53c commit b5de66a

File tree

7 files changed

+26
-25
lines changed

7 files changed

+26
-25
lines changed

Diff for: .bingo/Variables.mk

-6
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,6 @@ $(CRD_REF_DOCS): $(BINGO_DIR)/crd-ref-docs.mod
4141
@echo "(re)installing $(GOBIN)/crd-ref-docs-v0.1.0"
4242
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=crd-ref-docs.mod -o=$(GOBIN)/crd-ref-docs-v0.1.0 "github.com/elastic/crd-ref-docs"
4343

44-
GINKGO := $(GOBIN)/ginkgo-v2.22.2
45-
$(GINKGO): $(BINGO_DIR)/ginkgo.mod
46-
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
47-
@echo "(re)installing $(GOBIN)/ginkgo-v2.22.2"
48-
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=ginkgo.mod -o=$(GOBIN)/ginkgo-v2.22.2 "github.com/onsi/ginkgo/v2/ginkgo"
49-
5044
GOLANGCI_LINT := $(GOBIN)/golangci-lint-v1.63.4
5145
$(GOLANGCI_LINT): $(BINGO_DIR)/golangci-lint.mod
5246
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.

Diff for: .bingo/ginkgo.mod

-7
This file was deleted.

Diff for: .bingo/ginkgo.sum

-8
This file was deleted.

Diff for: .bingo/variables.env

-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ CRD_DIFF="${GOBIN}/crd-diff-v0.1.0"
1616

1717
CRD_REF_DOCS="${GOBIN}/crd-ref-docs-v0.1.0"
1818

19-
GINKGO="${GOBIN}/ginkgo-v2.22.2"
20-
2119
GOLANGCI_LINT="${GOBIN}/golangci-lint-v1.63.4"
2220

2321
GORELEASER="${GOBIN}/goreleaser-v1.26.2"

Diff for: catalogd/Makefile

+4-2
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ TESTDATA_DIR := testdata
4444
CATALOGD_NAMESPACE := olmv1-system
4545
KIND_CLUSTER_IMAGE := kindest/node:v1.30.0@sha256:047357ac0cfea04663786a612ba1eaba9702bef25227a794b52890dd8bcd692e
4646

47+
GINKGO := go run github.com/onsi/ginkgo/v2/ginkgo
48+
4749
##@ General
4850

4951
# The help target prints out all targets with their descriptions organized
@@ -76,7 +78,7 @@ FOCUS := $(if $(TEST),-v -focus "$(TEST)")
7678
ifeq ($(origin E2E_FLAGS), undefined)
7779
E2E_FLAGS :=
7880
endif
79-
test-e2e: $(GINKGO) ## Run the e2e tests on existing cluster
81+
test-e2e: ## Run the e2e tests on existing cluster
8082
$(GINKGO) $(E2E_FLAGS) -trace -vv $(FOCUS) test/e2e
8183

8284
e2e: KIND_CLUSTER_NAME := catalogd-e2e
@@ -105,7 +107,7 @@ run-latest-release:
105107
cd ..; curl -L -s https://github.com/operator-framework/operator-controller/releases/latest/download/install.sh | bash -s
106108

107109
.PHONY: post-upgrade-checks
108-
post-upgrade-checks: $(GINKGO)
110+
post-upgrade-checks:
109111
$(GINKGO) $(E2E_FLAGS) -trace -vv $(FOCUS) test/upgrade
110112

111113
##@ Build

Diff for: catalogd/test/upgrade/unpack_test.go

+11
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,17 @@ var _ = Describe("ClusterCatalog Unpacking", func() {
5454
managerPod = managerPods.Items[0]
5555
}).Should(Succeed())
5656

57+
By("Waiting for acquired leader election")
58+
// Average case is under 1 minute but in the worst case: (previous leader crashed)
59+
// we could have LeaseDuration (137s) + RetryPeriod (26s) +/- 163s
60+
leaderCtx, leaderCancel := context.WithTimeout(ctx, 3*time.Minute)
61+
defer leaderCancel()
62+
63+
leaderSubstrings := []string{"successfully acquired lease"}
64+
leaderElected, err := watchPodLogsForSubstring(leaderCtx, &managerPod, "manager", leaderSubstrings...)
65+
Expect(err).To(Succeed())
66+
Expect(leaderElected).To(BeTrue())
67+
5768
By("Reading logs to make sure that ClusterCatalog was reconciled by catalogdv1")
5869
logCtx, cancel := context.WithTimeout(ctx, time.Minute)
5970
defer cancel()

Diff for: test/upgrade-e2e/post_upgrade_test.go

+11
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,17 @@ func TestClusterExtensionAfterOLMUpgrade(t *testing.T) {
4040
t.Log("Wait for operator-controller deployment to be ready")
4141
managerPod := waitForDeployment(t, ctx, "operator-controller-controller-manager")
4242

43+
t.Log("Wait for acquired leader election")
44+
// Average case is under 1 minute but in the worst case: (previous leader crashed)
45+
// we could have LeaseDuration (137s) + RetryPeriod (26s) +/- 163s
46+
leaderCtx, leaderCancel := context.WithTimeout(ctx, 3*time.Minute)
47+
defer leaderCancel()
48+
49+
leaderSubstrings := []string{"successfully acquired lease"}
50+
leaderElected, err := watchPodLogsForSubstring(leaderCtx, managerPod, "manager", leaderSubstrings...)
51+
require.NoError(t, err)
52+
require.True(t, leaderElected)
53+
4354
t.Log("Reading logs to make sure that ClusterExtension was reconciled by operator-controller before we update it")
4455
// Make sure that after we upgrade OLM itself we can still reconcile old objects without any changes
4556
logCtx, cancel := context.WithTimeout(ctx, time.Minute)

0 commit comments

Comments
 (0)