Skip to content

Commit daef6ed

Browse files
authored
verify that SSA apply is used for deploying the registration service (codeready-toolchain#1145)
1 parent 802e16b commit daef6ed

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

test/migration/verify/verify_migration_test.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@ import (
1616
"github.com/codeready-toolchain/toolchain-e2e/testsupport/cleanup"
1717
. "github.com/codeready-toolchain/toolchain-e2e/testsupport/space"
1818
"github.com/codeready-toolchain/toolchain-e2e/testsupport/wait"
19+
appsv1 "k8s.io/api/apps/v1"
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1921
"k8s.io/apimachinery/pkg/types"
2022

23+
"github.com/stretchr/testify/assert"
2124
"github.com/stretchr/testify/require"
2225
"sigs.k8s.io/controller-runtime/pkg/client"
2326
)
@@ -92,6 +95,7 @@ func runVerifyFunctions(t *testing.T, awaitilities wait.Awaitilities) {
9295
func() { verifyAppStudioProvisionedSignup(t, awaitilities, appstudioProvisionedSignup) },
9396
func() { verifyDeactivatedSignup(t, awaitilities, deactivatedSignup) },
9497
func() { verifyBannedSignup(t, awaitilities, bannedSignup) },
98+
func() { verifyAdditionalDeploymentsCreatedUsingSSA(t, &awaitilities) },
9599
}
96100

97101
// when & then - run all functions in parallel
@@ -231,6 +235,34 @@ func verifyBannedSignup(t *testing.T, awaitilities wait.Awaitilities, signup *to
231235
VerifyResourcesProvisionedForSignup(t, awaitilities, signup)
232236
}
233237

238+
func verifyAdditionalDeploymentsCreatedUsingSSA(t *testing.T, awaitilities *wait.Awaitilities) {
239+
testDeployment := func(t *testing.T, deploymentName, ns, originalFieldManager, expectedFieldManager string) {
240+
// when
241+
deployment := &appsv1.Deployment{}
242+
require.NoError(t, awaitilities.Host().Client.Get(context.TODO(), client.ObjectKey{Name: deploymentName, Namespace: ns}, deployment))
243+
244+
var applyEntry *metav1.ManagedFieldsEntry
245+
var updateEntry *metav1.ManagedFieldsEntry
246+
for _, mf := range deployment.ManagedFields {
247+
if mf.Manager == expectedFieldManager {
248+
applyEntry = &mf
249+
}
250+
if mf.Manager == originalFieldManager {
251+
updateEntry = &mf
252+
}
253+
}
254+
255+
// then
256+
assert.NotNil(t, applyEntry)
257+
assert.Equal(t, metav1.ManagedFieldsOperationApply, applyEntry.Operation)
258+
assert.Nil(t, updateEntry)
259+
}
260+
261+
t.Run("verify registration service deployed using SSA in host", func(t *testing.T) {
262+
testDeployment(t, "registration-service", awaitilities.Host().RegistrationServiceNs, "host-operator", "kubesaw-host-operator")
263+
})
264+
}
265+
234266
func checkMURMigratedAndGetSignup(t *testing.T, hostAwait *wait.HostAwaitility, murName string) *toolchainv1alpha1.UserSignup {
235267
provisionedMur, err := hostAwait.WithRetryOptions(wait.TimeoutOption(time.Second*120)).WaitForMasterUserRecord(t, murName,
236268
wait.UntilMasterUserRecordHasCondition(wait.Provisioned()),

0 commit comments

Comments
 (0)