-
Notifications
You must be signed in to change notification settings - Fork 72
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
Conversation
/retest |
…into SANDBOX-554
/retest |
There was a problem hiding this 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:
There was a problem hiding this 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.
Co-authored-by: Rafaela Soares <119665479+rsoaresd@users.noreply.github.com>
There was a problem hiding this 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.
toolchain-e2e/testsupport/user_assertions.go
Lines 64 to 106 in 4485a0f
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 | |
} |
test/e2e/user_management_test.go
Outdated
bytes, err2 := wait.StringifyObject(userSignupMember1) | ||
require.NoError(t, err2) | ||
t.Logf("### DEBUG usersignup: %s", string(bytes)) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
…e set.. modify the wait conditions so that we wait for the state to be set to deactivating
[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:
Approvers can indicate their approval by writing |
@MatousJobanek i think that updating the generic |
Quality Gate passedIssues Measures |
Tests for codeready-toolchain/host-operator#988