Files
12c257987e 🌱 add v1beta1 e2e tests for addon API - preserve v1alpha1 tests (#1553)
* test: add v1beta1 e2e tests for addon lifecycle and install strategy

Add v1beta1 e2e test coverage following the alpha/beta split pattern from
integration tests. Rename framework helper functions to use explicit
V1Alpha1/V1Beta1 suffixes for consistency.

Framework changes (test/framework/managedclusteraddon.go):
- Rename CreateManagedClusterAddOn to CreateManagedClusterAddOnV1Alpha1
- Rename CheckManagedClusterAddOnStatus to CheckManagedClusterAddOnStatusV1Alpha1
- Add CheckManagedClusterAddOnStatusV1Beta1 helper
- Organize functions with Alpha version followed by Beta counterpart

E2E test changes:
- Rename addon_test.go to addon_alpha_test.go (v1alpha1 API)
- Create new addon_test.go with v1beta1 API using V1Beta1 helpers
- Rename addon_install_test.go to addon_install_alpha_test.go (v1alpha1 API)
- Create new addon_install_test.go with v1beta1 API
- Update addon_lease_test.go, addon_token_auth_test.go, addonmanagement_test.go
  to use V1Alpha1 helpers

Test coverage (both alpha and v1beta1):
- addon_test.go: Basic ManagedClusterAddOn lifecycle and availability
- addon_install_test.go: ClusterManagementAddOn with placement-based install
  strategy, addon annotation syncing

Naming pattern matches integration tests: *_alpha_test.go for v1alpha1,
*_test.go (no suffix) for v1beta1.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Tesshu Flower <tflower@redhat.com>

* test: add v1beta1 e2e tests for addon lease health check

Add v1beta1 e2e test coverage for addon lease-based health checking
following the alpha/beta split pattern.

Changes:
- Rename addon_lease_test.go to addon_lease_alpha_test.go (v1alpha1 API)
- Create new addon_lease_test.go with v1beta1 API using V1Beta1 helpers
- Update all AddonClient.AddonV1alpha1() calls to AddonV1beta1() in beta test

Both alpha and v1beta1 tests cover:
- Addon status remains available while lease is updated
- Addon status changes to unavailable when lease stops updating
- Addon status changes to unknown when no lease exists
- Addon status changes to unknown when managed cluster lease stops updating

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Tesshu Flower <tflower@redhat.com>

* test: migrate addon_token_auth test to alpha/beta versions

- Rename addon_token_auth_test.go to addon_token_auth_alpha_test.go
- Update alpha Describe to include (v1alpha1)
- Create new addon_token_auth_test.go for v1beta1
- Update imports and client calls to use v1beta1 API

Signed-off-by: Tesshu Flower <tflower@redhat.com>

---------

Signed-off-by: Tesshu Flower <tflower@redhat.com>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-06-04 02:06:45 +00:00

54 lines
2.0 KiB
Go

package e2e
import (
"context"
"fmt"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/rand"
)
var _ = Describe("Manage the managed cluster addons (v1alpha1)", Label("addon"), func() {
var addOnName string
BeforeEach(func() {
addOnName = fmt.Sprintf("e2e-addon-%s", rand.String(6))
})
AfterEach(func() {
err := hub.AddonClient.AddonV1alpha1().ManagedClusterAddOns(universalClusterName).Delete(context.TODO(), addOnName, metav1.DeleteOptions{})
Expect(err).ToNot(HaveOccurred())
})
It("Create one managed cluster addon and make sure it is available", func() {
By(fmt.Sprintf("create the addon %v on the managed cluster namespace %v", addOnName, universalClusterName))
err := hub.CreateManagedClusterAddOnV1Alpha1(universalClusterName, addOnName, addOnName)
Expect(err).ToNot(HaveOccurred())
By(fmt.Sprintf("create the addon lease %v on addon install namespace %v", addOnName, addOnName))
err = hub.CreateManagedClusterAddOnLease(addOnName, addOnName)
Expect(err).ToNot(HaveOccurred())
By(fmt.Sprintf("wait the addon %v available condition to be true", addOnName))
Eventually(func() error {
return hub.CheckManagedClusterAddOnStatusV1Alpha1(universalClusterName, addOnName)
}).Should(Succeed())
})
It("Create one managed cluster addon and make sure it is available in Hosted mode", func() {
By(fmt.Sprintf("create the addon %v on the managed cluster namespace %v", addOnName, universalClusterName))
err := hub.CreateManagedClusterAddOnV1Alpha1(universalClusterName, addOnName, addOnName)
Expect(err).ToNot(HaveOccurred())
By(fmt.Sprintf("create the addon lease %v on addon install namespace %v", addOnName, addOnName))
err = hub.CreateManagedClusterAddOnLease(addOnName, addOnName)
Expect(err).ToNot(HaveOccurred())
By(fmt.Sprintf("wait the addon %v available condition to be true", addOnName))
Eventually(func() error {
return hub.CheckManagedClusterAddOnStatusV1Alpha1(universalClusterName, addOnName)
}).Should(Succeed())
})
})