Skip to content

test(e2e): add Helm-chart upgrade scenario#1610

Open
Sanil2108 wants to merge 2 commits intokedacore:mainfrom
Sanil2108:feat/e2e-upgrade-scenario
Open

test(e2e): add Helm-chart upgrade scenario#1610
Sanil2108 wants to merge 2 commits intokedacore:mainfrom
Sanil2108:feat/e2e-upgrade-scenario

Conversation

@Sanil2108
Copy link
Copy Markdown

Summary

Refs #1427. Adds an upgrade scenario to `tests/checks/` that installs a previous release of the `kedacore/http-add-on` Helm chart, verifies a basic HTTPScaledObject scales on load, runs `helm upgrade` to a target version, and then verifies the same HTTPScaledObject still reconciles and scales after the upgrade.

How it runs

The test is skipped unless both env vars are set:

  • `HTTPADDON_UPGRADE_FROM_VERSION` — the Helm chart version to install as baseline (e.g. `0.10.0`).
  • `HTTPADDON_UPGRADE_TO_VERSION` — the Helm chart version to upgrade to (e.g. `0.11.0`).

So the addition is a no-op for the existing e2e suite. Running it requires a dedicated CI job (or a local invocation) that sets both variables before running `go run -tags e2e ./tests/run-all.go` with an `E2E_TEST_REGEX` narrowed to `upgrade`.

Why skip-by-default

The main legacy e2e suite installs the add-on once at the start (`TestDeployKEDAHttpAddOn`) and assumes every check runs against that single, pinned release. The upgrade scenario intentionally swaps the cluster-wide release, so it can't safely share a run with other checks (runner uses `concurrentTests=2`). Guarding on the env vars keeps the existing suite's assumptions intact.

What the test verifies

  1. `helm upgrade --install http-add-on kedacore/http-add-on --version $FROM` succeeds.
  2. A plain deployment + service + HTTPScaledObject in a fresh namespace reconciles, and `curl` traffic through the interceptor scales it from 0 → 1.
  3. `helm upgrade --install http-add-on kedacore/http-add-on --version $TO` succeeds and the operator / interceptor / scaler deployments all come back ready.
  4. The pre-existing HTTPScaledObject is still honored by the upgraded operator — the deployment stays up, load still scales correctly, and scale-in still works.

Notes / open questions for the maintainer

  • This tests chart-released version → chart-released version upgrades. Upgrading to the local dev build needs `make deploy-e2e` + ko + Kind image loading, which felt out of scope for an initial upgrade check. Happy to add that as a follow-up if you want CI to also cover "released → HEAD".
  • Release-branch CI could set the env vars to exercise the last two minor versions, giving us a permanent safety net for upgrade breakage.
  • Deployment names in `waitForAddonReady` (`keda-add-ons-http-operator`, `keda-add-ons-http-interceptor`, `keda-add-ons-http-external-scaler`) match the current chart. If those names change historically, I can switch to label-based readiness.

Refs #1427

Adds a dedicated e2e check that exercises the Helm-chart upgrade path
of the http-add-on:

  1. Install a previous release via `helm upgrade --install
     kedacore/http-add-on --version $HTTPADDON_UPGRADE_FROM_VERSION`.
  2. Create a sample workload + HTTPScaledObject and verify it scales
     from 0 to maxReplicaCount under load.
  3. Upgrade to the target release
     (`$HTTPADDON_UPGRADE_TO_VERSION`).
  4. Verify the pre-existing HTTPScaledObject is still reconciled by
     the upgraded operator and that the deployment continues to scale
     correctly on load.

Skipped by default; only runs when both
HTTPADDON_UPGRADE_FROM_VERSION and HTTPADDON_UPGRADE_TO_VERSION env
vars are set. The intent is a dedicated CI job, since the scenario
swaps the cluster-wide add-on release that the rest of the e2e suite
assumes is pinned.

Refs kedacore#1427

Signed-off-by: Sanil2108 <[email protected]>
Copilot AI review requested due to automatic review settings April 24, 2026 14:08
@Sanil2108 Sanil2108 requested a review from a team as a code owner April 24, 2026 14:08
@snyk-io
Copy link
Copy Markdown

snyk-io Bot commented Apr 24, 2026

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new skip-by-default e2e check that exercises a Helm chart upgrade path for the KEDA HTTP Add-on and validates that an existing HTTPScaledObject continues to reconcile and scale across the upgrade.

Changes:

  • Add upgrade_httpso e2e test that installs an older chart version, validates scale-out, upgrades to a target chart version, and validates scaling behavior post-upgrade.
  • Gate the scenario behind HTTPADDON_UPGRADE_FROM_VERSION / HTTPADDON_UPGRADE_TO_VERSION environment variables.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +192 to +203
func installOrUpgradeAddon(t *testing.T, version string) {
t.Helper()
_, err := ExecuteCommand("helm repo add kedacore https://kedacore.github.io/charts")
require.NoErrorf(t, err, "cannot add kedacore helm repo - %s", err)
_, err = ExecuteCommand("helm repo update kedacore")
require.NoErrorf(t, err, "cannot update kedacore helm repo - %s", err)
_, err = ExecuteCommand(fmt.Sprintf(
"helm upgrade --install %s %s --version %s --namespace %s --wait",
releaseName, chartRef, version, KEDANamespace,
))
require.NoErrorf(t, err, "cannot install/upgrade %s to version %s - %s", releaseName, version, err)
}
Comment on lines +180 to +183
t.Log("--- HTTPScaledObject survives upgrade ---")
// Give the new operator a moment to reconcile pre-existing HTTPScaledObject resources.
assert.True(t, WaitForDeploymentReplicaReadyCount(t, kc, deploymentName, testNamespace, maxReplicaCount, 6, 10),
"expected HTTPScaledObject to still route traffic and keep the deployment at max replicas post-upgrade")
…d after upgrade

Two review concerns from Copilot:

1. Installing the Helm release into the `keda` namespace conflicts with
   the `keda-add-ons-http-*` resources `tests/utils/setup_test.go`
   already created via `make deploy-e2e`. `make undeploy` them before
   the first Helm install so the release can take ownership cleanly.
   Added a matching `helm uninstall` in t.Cleanup so the cluster is
   left without the Helm release at the end (a subsequent
   `make deploy-e2e` can restore the kustomize install).

2. The post-upgrade `WaitForDeploymentReplicaReadyCount(maxReplicaCount)`
   assumed load from the pre-upgrade scale-out was still pending, but
   `scaledownPeriod: 10s` expires before the upgrade completes. Added
   an explicit scale-in between the baseline and upgrade blocks, then
   a fresh scale-out after the upgrade — which is the real assertion
   we want (HTTPScaledObject survives the upgrade and still routes
   traffic under new load).

Refs kedacore#1427

Signed-off-by: Sanil2108 <[email protected]>
@Sanil2108
Copy link
Copy Markdown
Author

Thanks for the review! Addressed both points in the follow-up commit:

  1. Release-ownership conflict (L203): Added a make undeploy call at the start to clear the kustomize/ko install before the first helm upgrade --install, plus a helm uninstall in t.Cleanup so the cluster is left without the Helm release at the end. A follow-up make deploy-e2e can restore the regular kustomize install if the dedicated job is running alongside anything else.

  2. Flaky post-upgrade replica assertion (L183): The previous flow was relying on leftover pending load to keep the deployment at maxReplicaCount across the upgrade, which isn't safe given scaledownPeriod: 10s. Restructured: baseline scale-out → baseline scale-in → upgrade → fresh scale-out → fresh scale-in. The post-upgrade scale-out is now the real "HTTPScaledObject survives the upgrade" assertion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants