Skip to content
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

SANDBOX-554 tests for setting ScheduledDeactivationTime on UserSignup #933

Merged
merged 35 commits into from
May 15, 2024

Conversation

sbryzak
Copy link
Contributor

@sbryzak sbryzak commented Mar 25, 2024

@sbryzak
Copy link
Contributor Author

sbryzak commented Mar 26, 2024

/retest

@sbryzak
Copy link
Contributor Author

sbryzak commented Apr 18, 2024

/retest

Copy link
Contributor

@rsoaresd rsoaresd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @sbryzak 👋 Just a minor suggestion:

testsupport/wait/host.go Show resolved Hide resolved
Copy link
Contributor

@alexeykazakov alexeykazakov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Apart from @rsoaresd's suggestion.

@openshift-ci openshift-ci bot removed the approved label May 9, 2024
Copy link
Collaborator

@MatousJobanek MatousJobanek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, but it would be nice to update also the generic assertion function expecting the value to be always set for all provisioned UserSignup CRs.

func VerifyUserRelatedResources(t *testing.T, awaitilities wait.Awaitilities, signup *toolchainv1alpha1.UserSignup, tierName string, userAccountOption UserAccountOption) (*toolchainv1alpha1.UserSignup, *toolchainv1alpha1.MasterUserRecord) {
hostAwait := awaitilities.Host()
// Get the latest signup version, wait for usersignup to have the approved label and wait for the complete status to
// ensure the compliantusername is available
userSignup, err := hostAwait.WaitForUserSignup(t, signup.Name,
wait.UntilUserSignupHasStateLabel(toolchainv1alpha1.UserSignupStateLabelValueApproved),
wait.ContainsCondition(wait.Complete()))
require.NoError(t, err)
userAccountStatusWaitCriterion := wait.UntilMasterUserRecordHasUserAccountStatusesInClusters()
if userAccountOption.expectUserAccount {
userAccountStatusWaitCriterion = wait.UntilMasterUserRecordHasAnyUserAccountStatus()
if userAccountOption.targetCluster != nil {
userAccountStatusWaitCriterion = wait.UntilMasterUserRecordHasUserAccountStatusesInClusters(userAccountOption.targetCluster.ClusterName)
}
}
// First, wait for the MasterUserRecord to exist, no matter what status
mur, err := hostAwait.WaitForMasterUserRecord(t, userSignup.Status.CompliantUsername,
wait.UntilMasterUserRecordHasTierName(tierName),
wait.UntilMasterUserRecordHasConditions(wait.Provisioned(), wait.ProvisionedNotificationCRCreated()),
userAccountStatusWaitCriterion)
require.NoError(t, err)
// Verify last target cluster annotation is set
lastCluster, foundLastCluster := userSignup.Annotations[toolchainv1alpha1.UserSignupLastTargetClusterAnnotationKey]
require.True(t, foundLastCluster)
// todo - change that as soon as we set the last-target-cluster annotation based on the "home" Space location
// todo - and as soon as we drop the embedded UserAccounts from MUR
require.Equal(t, mur.Spec.UserAccounts[0].TargetCluster, lastCluster)
if userAccountOption.expectUserAccount {
verifyUserAccount(t, awaitilities, userSignup, mur, userAccountOption)
} else {
for _, memberAwait := range awaitilities.AllMembers() {
// let's verify that the UserAccounts from all members are gone
err := memberAwait.WaitUntilUserDeleted(t, mur.Name)
require.NoError(t, err)
}
}
return userSignup, mur
}

Comment on lines 259 to 261
bytes, err2 := wait.StringifyObject(userSignupMember1)
require.NoError(t, err2)
t.Logf("### DEBUG usersignup: %s", string(bytes))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

most likely some left-over from troubleshooting?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not quite left over, i'm actively trying to diagnose the cause of the current test failures.

func UntilUserSignupHasScheduledDeactivationTime() UserSignupWaitCriterion {
return UserSignupWaitCriterion{
Match: func(actual *toolchainv1alpha1.UserSignup) bool {
return actual.Status.ScheduledDeactivationTimestamp != nil
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we verify also the content of the timestamp, so we know that it's properly calculated and set?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently I'm only using this function to ensure the state of the UserSignup, i.e. the deactivation controller has run and set a value for the scheduled deactivation time property. In the test where I'm calling it I'm already checking the actual value is as expected.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see that for all cases. Where do you verify the timestamp for this particular case?
https://github.com/sbryzak/toolchain-e2e/blob/1257d0941845405bbe0c584c05184d0795684640/test/e2e/user_management_test.go#L352-L355

Copy link

openshift-ci bot commented May 14, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alexeykazakov, sbryzak

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [alexeykazakov,sbryzak]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sbryzak
Copy link
Contributor Author

sbryzak commented May 14, 2024

@MatousJobanek i think that updating the generic VerifyUserRelatedResources function might be a bad idea, not all usersignups will have the scheduled deactivation time set, e.g. signups that are on an excluded email domain.

Copy link

sonarcloud bot commented May 15, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
8.6% Duplication on New Code

See analysis details on SonarCloud

@sbryzak sbryzak merged commit 2346e49 into codeready-toolchain:master May 15, 2024
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants