Skip to content
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
60 changes: 31 additions & 29 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,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 +244 to +248
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 @@ -343,52 +354,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
Comment on lines 390 to 392
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

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

test-st2ex-e2e still exports MANIFEST, TEST_CLUSTER_CATALOG_NAME, and TEST_CLUSTER_EXTENSION_NAME, but the upgrade test flow no longer consumes these variables (the old pre/post upgrade scripts were removed and the new Godog feature hard-codes the resource names). These exports are now dead configuration and can be removed to avoid confusion about what the upgrade tests actually use.

Suggested change
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

Copilot uses AI. Check for mistakes.
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
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

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

Typo in help text: swichover should be switchover.

Suggested change
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
test-st2ex-e2e: experimental/install.sh standard/install.sh $(TEST_UPGRADE_E2E_TASKS) #HELP Run switchover (standard -> experimental) e2e tests on a local kind cluster

Copilot uses AI. Check for mistakes.

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

This file was deleted.

8 changes: 5 additions & 3 deletions test/e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ test/e2e/
├── steps.go # Step definition implementations
├── hooks.go # Test hooks and scenario context
└── testdata/ # Test data (RBAC templates, catalogs)
├── rbac-template.yaml
├── serviceaccount-template.yaml
├── olm-sa-helm-rbac-template.yaml
├── olm-sa-boxcutter-rbac-template.yaml
├── pvc-probe-sa-boxcutter-rbac-template.yaml
├── cluster-admin-rbac-template.yaml
├── metrics-reader-rbac-template.yaml
├── test-catalog-template.yaml
├── extra-catalog-template.yaml
└── ...
└── extra-catalog-template.yaml
```

## Architecture
Expand Down
39 changes: 25 additions & 14 deletions test/e2e/steps/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,12 @@ type scenarioContext struct {
namespace string
clusterExtensionName string
clusterExtensionRevisionName string
clusterCatalogName string
addedResources []resource
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 @@ -89,30 +92,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 105 to 108
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 @@ -147,6 +157,7 @@ func CreateScenarioContext(ctx context.Context, sc *godog.Scenario) (context.Con
namespace: fmt.Sprintf("ns-%s", sc.Id),
clusterExtensionName: fmt.Sprintf("ce-%s", sc.Id),
clusterExtensionRevisionName: fmt.Sprintf("cer-%s", sc.Id),
leaderPods: make(map[string]string),
}
return context.WithValue(ctx, scenarioContextKey, scCtx), nil
}
Expand Down Expand Up @@ -174,7 +185,7 @@ func ScenarioCleanup(ctx context.Context, _ *godog.Scenario, err error) (context
return ctx, err
}

forDeletion := []resource{}
forDeletion := sc.addedResources
if sc.clusterExtensionName != "" {
forDeletion = append(forDeletion, resource{name: sc.clusterExtensionName, kind: "clusterextension"})
}
Expand Down
Loading
Loading