diff --git a/go.mod b/go.mod index eea481642..5c1a4e2ba 100644 --- a/go.mod +++ b/go.mod @@ -1,7 +1,7 @@ module github.com/codeready-toolchain/toolchain-e2e require ( - github.com/codeready-toolchain/api v0.0.0-20250506092100-39b4862e1271 + github.com/codeready-toolchain/api v0.0.0-20250605152105-383ffe6cac27 github.com/codeready-toolchain/toolchain-common v0.0.0-20250506093954-2b65ad3a2e12 github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc github.com/fatih/color v1.18.0 diff --git a/go.sum b/go.sum index 1e33e988d..7603f4c89 100644 --- a/go.sum +++ b/go.sum @@ -30,8 +30,8 @@ github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDk github.com/cloudflare/circl v1.1.0/go.mod h1:prBCrKB9DV4poKZY1l9zBXg2QJY7mvgRvtMxxK7fi4I= github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU= github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA= -github.com/codeready-toolchain/api v0.0.0-20250506092100-39b4862e1271 h1:AHrFr/aPuJ4+0zHw4sFXcfMA92kChy12JAPS5bLODlw= -github.com/codeready-toolchain/api v0.0.0-20250506092100-39b4862e1271/go.mod h1:20258od6i5+jP406Z76YaI2ow/vc7URwsDU2bokpkRE= +github.com/codeready-toolchain/api v0.0.0-20250605152105-383ffe6cac27 h1:g1ivSPPHTC96RHp8S/gRmqODWgoHyivq+/d5kSI0pEs= +github.com/codeready-toolchain/api v0.0.0-20250605152105-383ffe6cac27/go.mod h1:20258od6i5+jP406Z76YaI2ow/vc7URwsDU2bokpkRE= github.com/codeready-toolchain/toolchain-common v0.0.0-20250506093954-2b65ad3a2e12 h1:w54sojJJ8PsHZzK1mC+/EUBrQ9F2sC/k7JUVc8LSqK4= github.com/codeready-toolchain/toolchain-common v0.0.0-20250506093954-2b65ad3a2e12/go.mod h1:TrMvD0sP69wI6Rouzfs7OsOUSj4CGn/ZiIdiDBAFQjk= github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= diff --git a/test/e2e/parallel/nstemplatetier_test.go b/test/e2e/parallel/nstemplatetier_test.go index bcb912e16..f950cde2e 100644 --- a/test/e2e/parallel/nstemplatetier_test.go +++ b/test/e2e/parallel/nstemplatetier_test.go @@ -50,7 +50,7 @@ func TestNSTemplateTiers(t *testing.T) { space := user.Space // all tiers to check - keep the base as the last one, it will verify downgrade back to the default tier at the end of the test - tiersToCheck := []string{"advanced", "baseextendedidling", "baselarge", "test", "appstudio", "appstudiolarge", "appstudio-env", "base1ns", "base1nsnoidling", "base1ns6didler", "intelmedium", "intellarge", "intelxlarge", "base"} + tiersToCheck := wait.E2eNSTemplateTiers // when the tiers are created during the startup then we can verify them allTiers := &toolchainv1alpha1.NSTemplateTierList{} @@ -479,7 +479,6 @@ func TestTierTemplateRevision(t *testing.T) { Value: "100", }) }) - }) t.Run("when updating one tiertemplate the revisions field should be cleaned up from old entries", func(t *testing.T) { @@ -517,7 +516,6 @@ func TestTierTemplateRevision(t *testing.T) { // revisions values should be different compared to the previous ones assert.NotEqual(t, revisionsBeforeUpdate, updatedTier.Status.Revisions) }) - } func getTestCRQ(podsCount string) unstructured.Unstructured { diff --git a/test/migration/verify/verify_migration_test.go b/test/migration/verify/verify_migration_test.go index 49bdc93e8..2b23d7106 100644 --- a/test/migration/verify/verify_migration_test.go +++ b/test/migration/verify/verify_migration_test.go @@ -3,6 +3,7 @@ package verify import ( "context" "fmt" + "slices" "sync" "testing" "time" @@ -20,8 +21,10 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" ) func TestAfterMigration(t *testing.T) { @@ -95,6 +98,7 @@ func runVerifyFunctions(t *testing.T, awaitilities wait.Awaitilities) { func() { verifyDeactivatedSignup(t, awaitilities, deactivatedSignup) }, func() { verifyBannedSignup(t, awaitilities, bannedSignup) }, func() { verifyAdditionalDeploymentsCreatedUsingSSA(t, &awaitilities) }, + func() { verifyBundledNSTemplateTiersHaveFinalizer(t, &awaitilities) }, } // when & then - run all functions in parallel @@ -270,6 +274,28 @@ func verifyAdditionalDeploymentsCreatedUsingSSA(t *testing.T, awaitilities *wait }) } +func verifyBundledNSTemplateTiersHaveFinalizer(t *testing.T, awaitilities *wait.Awaitilities) { + list := &toolchainv1alpha1.NSTemplateTierList{} + require.NoError(t, awaitilities.Host().Client.List(context.TODO(), list, client.InNamespace(awaitilities.Host().Namespace))) + + // e2e tests have custom appstudio tiers + assert.GreaterOrEqual(t, len(list.Items), len(wait.BundledNSTemplateTiers)) + + unmatchedBundledTiers := make([]string, len(wait.BundledNSTemplateTiers)) + copy(unmatchedBundledTiers, wait.BundledNSTemplateTiers) + + finalizerName := toolchainv1alpha1.LabelKeyPrefix + "bundled-tier" + for _, tier := range list.Items { + if controllerutil.ContainsFinalizer(&tier, finalizerName) { + if i := slices.Index(unmatchedBundledTiers, tier.Name); i >= 0 { + unmatchedBundledTiers = slices.Delete(unmatchedBundledTiers, i, i+1) + } + } + } + + assert.Empty(t, unmatchedBundledTiers) +} + func checkMURMigratedAndGetSignup(t *testing.T, hostAwait *wait.HostAwaitility, murName string) *toolchainv1alpha1.UserSignup { provisionedMur, err := hostAwait.WithRetryOptions(wait.TimeoutOption(time.Second*120)).WaitForMasterUserRecord(t, murName, wait.UntilMasterUserRecordHasCondition(wait.Provisioned()), diff --git a/testsupport/wait/host.go b/testsupport/wait/host.go index 104b03815..5e843ad9c 100644 --- a/testsupport/wait/host.go +++ b/testsupport/wait/host.go @@ -49,6 +49,11 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" ) +var ( + BundledNSTemplateTiers []string = []string{"advanced", "baseextendedidling", "baselarge", "test", "base1ns", "base1nsnoidling", "base1ns6didler", "intelmedium", "intellarge", "intelxlarge", "base"} + E2eNSTemplateTiers []string = append(BundledNSTemplateTiers, "appstudio", "appstudiolarge", "appstudio-env") +) + // HostAwaitility the Awaitility for the Host cluster type HostAwaitility struct { *Awaitility