Skip to content
6 changes: 5 additions & 1 deletion make/clean.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ clean-users:
$(Q)-oc delete spaces --all --all-namespaces
$(Q)-oc wait --for=delete namespaces -l toolchain.dev.openshift.com/type

clean-nstemplatetiers:
$(Q)-oc delete nstemplatetier --all --all-namespaces
$(Q)-oc wait --for=delete nstemplatetier --all --all-namespaces

.PHONY: clean-cluster-wide-config
## Delete all cluster-wide configuration resources like PriorityClass, MutatingWebhookConfiguration, and ClusterRoleBinding for e2e SA
clean-cluster-wide-config:
Expand Down Expand Up @@ -43,7 +47,7 @@ clean-toolchain-dev-sso-resources:
## * all user-related resources
## * operator namespaces created during both the dev and e2e test setup (for both operators host and member)
## * cluster-wide config
clean-e2e-resources: clean-users clean-toolchain-namespaces-in-e2e clean-cluster-wide-config
clean-e2e-resources: clean-users clean-nstemplatetiers clean-toolchain-namespaces-in-e2e clean-cluster-wide-config

.PHONY: clean-toolchain-namespaces-in-dev
## Delete dev namespaces
Expand Down
42 changes: 42 additions & 0 deletions test/migration/verify/verify_migration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ import (
"github.com/codeready-toolchain/toolchain-e2e/testsupport/wait"
appsv1 "k8s.io/api/apps/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/types"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"sigs.k8s.io/controller-runtime/pkg/client"
)
Expand Down Expand Up @@ -95,6 +97,7 @@ func runVerifyFunctions(t *testing.T, awaitilities wait.Awaitilities) {
func() { verifyDeactivatedSignup(t, awaitilities, deactivatedSignup) },
func() { verifyBannedSignup(t, awaitilities, bannedSignup) },
func() { verifyAdditionalDeploymentsCreatedUsingSSA(t, &awaitilities) },
func() { verifyResourcesDeployedUsingSSA(t, &awaitilities) },
}

// when & then - run all functions in parallel
Expand Down Expand Up @@ -270,6 +273,45 @@ func verifyAdditionalDeploymentsCreatedUsingSSA(t *testing.T, awaitilities *wait
})
}

func verifyResourcesDeployedUsingSSA(t *testing.T, awaitilities *wait.Awaitilities) {
testList := func(t *testing.T, obj client.Object) {
assert.EventuallyWithT(t, func(t *assert.CollectT) {
a := awaitilities.Host().Awaitility
list := &unstructured.UnstructuredList{}
gvks, _, err := a.Client.Scheme().ObjectKinds(obj)
require.NoError(t, err)
require.Len(t, gvks, 1)
list.SetGroupVersionKind(gvks[0])
assert.NoError(t, a.Client.List(context.TODO(), list, client.InNamespace(a.Namespace)))

for _, o := range list.Items {
var applyEntry *metav1.ManagedFieldsEntry
var updateEntry *metav1.ManagedFieldsEntry
for _, mf := range o.GetManagedFields() {
if mf.Manager == "kubesaw-host-operator" {
applyEntry = &mf
}
if mf.Manager == "host-operator" {
updateEntry = &mf
}
}

require.NotNil(t, applyEntry)
assert.Equal(t, metav1.ManagedFieldsOperationApply, applyEntry.Operation)
assert.Nil(t, updateEntry)
}
}, 1*time.Minute, 1*time.Second)
}

t.Run("verify bundled UserTiers deployed using SSA", func(t *testing.T) {
testList(t, &toolchainv1alpha1.UserTier{})
})

t.Run("verify bundled NSTemplateTiers deployed using SSA", func(t *testing.T) {
testList(t, &toolchainv1alpha1.NSTemplateTier{})
})
}

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
Loading