Skip to content

test for the bundled ns template tiers being annotated as such #1154

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
4 changes: 1 addition & 3 deletions test/e2e/parallel/nstemplatetier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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 {
Expand Down
26 changes: 26 additions & 0 deletions test/migration/verify/verify_migration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package verify
import (
"context"
"fmt"
"slices"
"sync"
"testing"
"time"
Expand All @@ -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) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()),
Expand Down
5 changes: 5 additions & 0 deletions testsupport/wait/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading