Skip to content
Open
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
60 changes: 31 additions & 29 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,17 @@ verify-crd-compatibility: $(CRD_DIFF) manifests

#SECTION Test

define install-sh
.PHONY: $(1)/install.sh
$(1)/install.sh: manifests
@echo -e "\n\U1F4D8 Using $(1).yaml as source manifest\n"
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This recipe uses echo -e with \U... escapes. echo -e and Unicode escape handling vary across /bin/sh implementations, so this can break in some environments. Prefer printf for portable escape/newline handling.

Suggested change
@echo -e "\n\U1F4D8 Using $(1).yaml as source manifest\n"
@printf '\n\U1F4D8 Using %s.yaml as source manifest\n\n' "$(1)"

Copilot uses AI. Check for mistakes.
sed "s/cert-git-version/cert-$$(VERSION)/g" manifests/$(1).yaml > $(2)
MANIFEST=$(2) INSTALL_DEFAULT_CATALOGS=false DEFAULT_CATALOG=$$(RELEASE_CATALOGS) envsubst '$$$$DEFAULT_CATALOG,$$$$CERT_MGR_VERSION,$$$$INSTALL_DEFAULT_CATALOGS,$$$$MANIFEST' < scripts/install.tpl.sh > $(1)-install.sh
Comment on lines +242 to +246
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

install-sh defines a phony target named $(1)/install.sh, but the recipe actually writes $(1)-install.sh (and also writes the manifest to $(2) in the repo root). This mismatch makes the target name misleading and can leave generated artifacts around unintentionally. Consider aligning target/output names (or making the generated files the actual targets) and placing generated artifacts under a dedicated build/output dir or ensuring they’re cleaned up.

Suggested change
.PHONY: $(1)/install.sh
$(1)/install.sh: manifests
@echo -e "\n\U1F4D8 Using $(1).yaml as source manifest\n"
sed "s/cert-git-version/cert-$$(VERSION)/g" manifests/$(1).yaml > $(2)
MANIFEST=$(2) INSTALL_DEFAULT_CATALOGS=false DEFAULT_CATALOG=$$(RELEASE_CATALOGS) envsubst '$$$$DEFAULT_CATALOG,$$$$CERT_MGR_VERSION,$$$$INSTALL_DEFAULT_CATALOGS,$$$$MANIFEST' < scripts/install.tpl.sh > $(1)-install.sh
.PHONY: $(1)-install.sh
$(1)-install.sh: manifests
@echo -e "\n\U1F4D8 Using $(1).yaml as source manifest\n"
sed "s/cert-git-version/cert-$$(VERSION)/g" manifests/$(1).yaml > $(2)
MANIFEST=$(2) INSTALL_DEFAULT_CATALOGS=false DEFAULT_CATALOG=$$(RELEASE_CATALOGS) envsubst '$$$$DEFAULT_CATALOG,$$$$CERT_MGR_VERSION,$$$$INSTALL_DEFAULT_CATALOGS,$$$$MANIFEST' < scripts/install.tpl.sh > $@

Copilot uses AI. Check for mistakes.
endef

$(eval $(call install-sh,experimental,operator-controller-experimental.yaml))
$(eval $(call install-sh,standard,operator-controller-standard.yaml))

.PHONY: test
test: manifests generate fmt lint test-unit test-e2e test-regression #HELP Run all tests.

Expand Down Expand Up @@ -335,52 +346,43 @@ run-latest-release:
@echo -e "\n\U23EC Using $(RELEASE_INSTALL) as release installer\n"
curl -L -s https://github.com/operator-framework/operator-controller/releases/latest/download/$(notdir $(RELEASE_INSTALL)) | bash -s

.PHONY: pre-upgrade-setup
pre-upgrade-setup:
./hack/test/pre-upgrade-setup.sh $(CATALOG_IMG) $(TEST_CLUSTER_CATALOG_NAME) $(TEST_CLUSTER_EXTENSION_NAME)

.PHONY: post-upgrade-checks
post-upgrade-checks:
go test -count=1 -v ./test/upgrade-e2e/...
.PHONY: test-upgrade-e2e
test-upgrade-e2e:
RELEASE_INSTALL=$(RELEASE_INSTALL) \
RELEASE_UPGRADE=$(RELEASE_UPGRADE) \
KIND_CLUSTER_NAME=$(KIND_CLUSTER_NAME) \
ROOT_DIR=$(ROOT_DIR) \
go test -count=1 -v ./test/upgrade-e2e/upgrade_test.go


TEST_UPGRADE_E2E_TASKS := kind-cluster run-latest-release image-registry pre-upgrade-setup docker-build kind-load kind-deploy post-upgrade-checks kind-clean
TEST_UPGRADE_E2E_TASKS := kind-cluster docker-build kind-load test-upgrade-e2e kind-clean

.PHONY: test-upgrade-st2st-e2e
test-upgrade-st2st-e2e: SOURCE_MANIFEST := $(STANDARD_MANIFEST)
test-upgrade-st2st-e2e: RELEASE_INSTALL := $(STANDARD_RELEASE_INSTALL)
test-upgrade-st2st-e2e: RELEASE_INSTALL := https://github.com/operator-framework/operator-controller/releases/latest/download/install.sh
test-upgrade-st2st-e2e: RELEASE_UPGRADE := $(ROOT_DIR)/standard-install.sh
test-upgrade-st2st-e2e: KIND_CLUSTER_NAME := operator-controller-upgrade-st2st-e2e
test-upgrade-st2st-e2e: export MANIFEST := $(STANDARD_RELEASE_MANIFEST)
test-upgrade-st2st-e2e: export TEST_CLUSTER_CATALOG_NAME := test-catalog
test-upgrade-st2st-e2e: export TEST_CLUSTER_EXTENSION_NAME := test-package
test-upgrade-st2st-e2e: $(TEST_UPGRADE_E2E_TASKS) #HELP Run upgrade (standard -> standard) e2e tests on a local kind cluster
test-upgrade-st2st-e2e: standard/install.sh $(TEST_UPGRADE_E2E_TASKS) #HELP Run upgrade (standard -> standard) e2e tests on a local kind cluster

.PHONY: test-upgrade-ex2ex-e2e
test-upgrade-ex2ex-e2e: SOURCE_MANIFEST := $(EXPERIMENTAL_MANIFEST)
test-upgrade-ex2ex-e2e: RELEASE_INSTALL := $(EXPERIMENTAL_RELEASE_INSTALL)
test-upgrade-ex2ex-e2e: RELEASE_INSTALL := https://github.com/operator-framework/operator-controller/releases/latest/download/install-experimental.sh
test-upgrade-ex2ex-e2e: KIND_CLUSTER_NAME := operator-controller-upgrade-ex2ex-e2e
test-upgrade-ex2ex-e2e: export MANIFEST := $(EXPERIMENTAL_RELEASE_MANIFEST)
test-upgrade-ex2ex-e2e: export TEST_CLUSTER_CATALOG_NAME := test-catalog
test-upgrade-ex2ex-e2e: export TEST_CLUSTER_EXTENSION_NAME := test-package
test-upgrade-ex2ex-e2e: $(TEST_UPGRADE_E2E_TASKS) #HELP Run upgrade (experimental -> experimental) e2e tests on a local kind cluster
test-upgrade-ex2ex-e2e: RELEASE_UPGRADE := $(ROOT_DIR)/experimental-install.sh
test-upgrade-ex2ex-e2e: experimental/install.sh $(TEST_UPGRADE_E2E_TASKS) #HELP Run upgrade (experimental -> experimental) e2e tests on a local kind cluster

.PHONY: test-upgrade-st2ex-e2e
test-upgrade-st2ex-e2e: SOURCE_MANIFEST := $(EXPERIMENTAL_MANIFEST)
test-upgrade-st2ex-e2e: RELEASE_INSTALL := $(STANDARD_RELEASE_INSTALL)
test-upgrade-st2ex-e2e: RELEASE_INSTALL := https://github.com/operator-framework/operator-controller/releases/latest/download/install.sh
test-upgrade-st2ex-e2e: RELEASE_UPGRADE := $(ROOT_DIR)/experimental-install.sh
test-upgrade-st2ex-e2e: KIND_CLUSTER_NAME := operator-controller-upgrade-st2ex-e2e
test-upgrade-st2ex-e2e: export MANIFEST := $(EXPERIMENTAL_RELEASE_MANIFEST)
test-upgrade-st2ex-e2e: export TEST_CLUSTER_CATALOG_NAME := test-catalog
test-upgrade-st2ex-e2e: export TEST_CLUSTER_EXTENSION_NAME := test-package
test-upgrade-st2ex-e2e: $(TEST_UPGRADE_E2E_TASKS) #HELP Run upgrade (standard -> experimental) e2e tests on a local kind cluster
test-upgrade-st2ex-e2e: experimental/install.sh $(TEST_UPGRADE_E2E_TASKS) #HELP Run upgrade (standard -> experimental) e2e tests on a local kind cluster

.PHONY: test-st2ex-e2e
test-st2ex-e2e: SOURCE_MANIFEST := $(STANDARD_MANIFEST)
test-st2ex-e2e: RELEASE_INSTALL := $(STANDARD_RELEASE_INSTALL)
test-st2ex-e2e: RELEASE_INSTALL := $(ROOT_DIR)/standard-install.sh
test-st2ex-e2e: RELEASE_UPGRADE := $(ROOT_DIR)/experimental-install.sh
test-st2ex-e2e: KIND_CLUSTER_NAME := operator-controller-st2ex-e2e
test-st2ex-e2e: export MANIFEST := $(STANDARD_RELEASE_MANIFEST)
test-st2ex-e2e: export TEST_CLUSTER_CATALOG_NAME := test-catalog
test-st2ex-e2e: export TEST_CLUSTER_EXTENSION_NAME := test-package
test-st2ex-e2e: run-internal image-registry pre-upgrade-setup kind-deploy-experimental post-upgrade-checks kind-clean #HELP Run swichover (standard -> experimental) e2e tests on a local kind cluster
test-st2ex-e2e: experimental/install.sh standard/install.sh $(TEST_UPGRADE_E2E_TASKS) #HELP Run swichover (standard -> experimental) e2e tests on a local kind cluster

.PHONY: e2e-coverage
e2e-coverage:
Expand Down
172 changes: 0 additions & 172 deletions hack/test/pre-upgrade-setup.sh

This file was deleted.

36 changes: 23 additions & 13 deletions test/e2e/steps/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ type scenarioContext struct {
id string
namespace string
clusterExtensionName string
clusterCatalogName string
removedResources []unstructured.Unstructured
backGroundCmds []*exec.Cmd
metricsResponse map[string]string
leaderPods map[string]string // component name -> leader pod name

extensionObjects []client.Object
}
Expand Down Expand Up @@ -87,30 +89,37 @@ func RegisterHooks(sc *godog.ScenarioContext) {
sc.After(ScenarioCleanup)
}

func BeforeSuite() {
if devMode {
logger = textlogger.NewLogger(textlogger.NewConfig(textlogger.Verbosity(1)))
} else {
logger = textlogger.NewLogger(textlogger.NewConfig())
}

func detectOLMDeployment() (*appsv1.Deployment, error) {
raw, err := k8sClient("get", "deployments", "-A", "-l", "app.kubernetes.io/part-of=olm", "-o", "jsonpath={.items}")
if err != nil {
panic(fmt.Errorf("failed to get OLM deployments: %v", err))
return nil, err
}
dl := []appsv1.Deployment{}
if err := json.Unmarshal([]byte(raw), &dl); err != nil {
panic(fmt.Errorf("failed to unmarshal OLM deployments: %v", err))
return nil, fmt.Errorf("failed to unmarshal OLM deployments: %v", err)
}
var olm *appsv1.Deployment

for _, d := range dl {
if d.Name == olmDeploymentName {
olm = &d
olmNamespace = d.Namespace
break
return &d, nil
}
Comment on lines 102 to 105
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returning &d here takes the address of the range loop variable. It’s safe today because you return immediately, but it’s a common footgun and easy to break if the code is refactored (e.g., storing pointers). Prefer iterating by index and returning &dl[i].

Copilot uses AI. Check for mistakes.
}
return nil, fmt.Errorf("failed to detect OLM Deployment")
}

func BeforeSuite() {
if devMode {
logger = textlogger.NewLogger(textlogger.NewConfig(textlogger.Verbosity(1)))
} else {
logger = textlogger.NewLogger(textlogger.NewConfig())
}

olm, err := detectOLMDeployment()
if err != nil {
logger.Info("OLM deployments not found; skipping feature gate detection (upgrade scenarios will install OLM in Background)")
return
}
olmNamespace = olm.Namespace

featureGatePattern := regexp.MustCompile(`--feature-gates=([[:alnum:]]+)=(true|false)`)
for _, c := range olm.Spec.Template.Spec.Containers {
Expand Down Expand Up @@ -144,6 +153,7 @@ func CreateScenarioContext(ctx context.Context, sc *godog.Scenario) (context.Con
id: sc.Id,
namespace: fmt.Sprintf("ns-%s", sc.Id),
clusterExtensionName: fmt.Sprintf("ce-%s", sc.Id),
leaderPods: make(map[string]string),
}
return context.WithValue(ctx, scenarioContextKey, scCtx), nil
}
Expand Down
Loading