-
Notifications
You must be signed in to change notification settings - Fork 55
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
PB-7821: Automate the few cluster share testcases #2734
base: master
Are you sure you want to change the base?
Conversation
#2729 is doing exactly same. Is this PR needed ? |
// This testcase verifies whether the restores created/owned by the user were deleted during the cluster un-share. | ||
It("VerifyRestoreObjectsAreDeletedCreatedByNonSuperAdmin", func() { | ||
//TODO: Need to update the testrail ID | ||
StartPxBackupTorpedoTest("VerifyRestoreObjectsAreDeletedCreatedByNonSuperAdmin", "VerifyRestoreObjectsAreDeletedCreatedByNonSuperAdmin during the cluster unshare", nil, 0, Sgajawada, Q2FY25) |
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.
Please make and entry of your name in https://github.com/portworx/torpedo/blob/master/tests/backup_helper.go#L80
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.
Also, please do not add any automation test without importing it into testrail. Testrail ID is mandatory
|
||
}) | ||
// This testcase verifies whether the restores created/owned by the user with super-admin role were not deleted during the cluster un-share. | ||
It("VerifyRestoreObjectsAreNotDeletedCreatedBySuperAdmin", func() { |
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.
@mkoppal-px can we go ahead with multiple it's or should we break down the code where we can have one it per describe?
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.
As long as the aetos dashboard shows the correct data, we are good.
_, err = Inst().Backup.InspectRestore(ctx, restoreInspectRequest) | ||
log.FailOnError(err, "inspect restore %s", restoreName) | ||
}) | ||
|
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.
Ideally you would want to move cleanup in JustAfterEach
tests/backup_helper.go
Outdated
return err | ||
} | ||
|
||
// ShareCluster provides access to the mentioned groups or/add users |
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.
comment should be updated according to unshare functionality
}) | ||
|
||
}) | ||
// This testcase verifies whether the restores created/owned by the user with super-admin role were not deleted during the cluster un-share. |
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.
Can we combine the above test case and this one, both looks similar apart from in the above test case we want to verify restores are deleted in case of normal user and in this we want to verify restores are not deleted in case of super admin. We can have these as two separate steps.
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.
As discussed with @vsundarraj-px he mentioned it is better to maintain the isolation.
restoreUID string | ||
) | ||
|
||
Step("Get login context for the test users", func() { |
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.
Can we move this to beforeEach as I see we are repeating it.
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.
Yes the Step is same but here we were fetching the context after adding the role.
Example:
VerifyRestoreObjectsAreDeletedCreatedByNonSuperAdmin - Uses infra admin role
VerifyRestoreObjectsAreNotDeletedCreatedBySuperAdmin - Uses the super admin role
Fetching the context should be after assigning the user role. So it cant be part of JustBeforeEach
} | ||
}) | ||
|
||
Step("Create a cluster object with User1 and Share with User2", func() { |
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.
Same here, we are repeating it.
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.
It can't be part of JustBeforeEach because
VerifyRestoreCreateBySharedClusterUser is sharing a destination cluster and all the testcases were sharing the source cluster
dash.VerifyFatal(err, nil, fmt.Sprintf("Verifying share of source [%s] cluster with %s user using %s ctx", SourceClusterName, testUsers[2].name, testUsers[1].name)) | ||
}) | ||
|
||
Step("Create backup location and cloud setting with User2", func() { |
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.
This one too we are repeating same lines of code
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.
done
|
||
}) | ||
// This testcase verifies the restore creation on the shared cluster by the shared user. | ||
It("VerifyRestoreCreateBySharedClusterUser", func() { |
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.
Can we verify this case also as part of the first testcase you have written? Looks like it is just verifying restore creation which is part of first testcase
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.
As discussed with @vsundarraj-px he mentioned it is better to maintain the isolation.
tests/backup_helper.go
Outdated
backupDriver := Inst().Backup | ||
userIDs := make([]string, 0) | ||
|
||
clusterUid, err := backupDriver.GetClusterUID(ctx, BackupOrgID, clusterName) |
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.
@sgajawada-px I'm passing clusterUid as an input parameter for both methods in my PR. Fetching clusterUid may cause issues if the context is admin and the admin has multiple clusters from users with the same name. If you are planning to rebase with my branch, it's better to pass clusterUid at the test case level.
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.
Few things to note here:
- Please submit one test case per PR. It alway better to have multiple small PRs rather than a one big PR. Easier to review and maintain.
- Create sub directory under
tests/backup
calledbackup-functional
and move the_test.go
files there
@mkoppal-px Not sure we can combine one Test case with one PR. We have created FC tasks based on object operation. For instance restore related test cases will be combined with 1 task. |
We usually create one task per test case. It is easier to track and review. |
- Verify Cluster Unshare deletes Restore Objects from user. - Verify Cluster unshare when BackupSchedules are deleted. - Verify RestoreObjects are not deleted when unshare from Super Admin is executed. - Shared user can restore to shared cluster from backup created on owned cluster.
1d07304
to
598fa2b
Compare
Testcases
sheet: https://docs.google.com/spreadsheets/d/1YmxvyOkwUaEKdJiInNZ4C0diXEvhsfhD6n0brYlm5lI/edit?gid=1744627660#gid=1744627660
What this PR does / why we need it:
To automate the PX-backup cluster share FC testcases
Which issue(s) this PR fixes (optional)
Closes #PB-7821
Special notes for your reviewer:
https://jenkins.pwx.dev.purestorage.com/job/portworx-backup/job/system-tests/job/byoc/job/px-backup-on-demand-system-test-byoc/6321/
https://jenkins.pwx.dev.purestorage.com/job/portworx-backup/job/system-tests/job/byoc/job/px-backup-on-demand-system-test-byoc/6324/
TestCase: Verify RestoreObjects are not deleted when unshare from Super Admin is executed
Is failed as we have not done the implementation at px-backup
[2024-08-13T18:37:15.371Z] Summarizing 1 Failure:
[2024-08-13T18:37:15.372Z] [FAIL] {ClusterShare} [It] VerifyRestoreObjectsAreNotDeletedCreatedBySuperAdmin [ClusterUnShare]
[2024-08-13T18:37:15.372Z] /go/src/github.com/portworx/torpedo/pkg/log/log.go:333
[2024-08-13T18:37:15.372Z] Ran 4 of 135 Specs in 1698.978 seconds
[2024-08-13T18:37:15.372Z] FAIL! -- 3 Passed | 1 Failed | 0 Pending | 131 Skipped
[2024-08-13T18:37:15.372Z] --- FAIL: TestBasic (1700.14s)
[2024-08-13T18:37:15.372Z] FAIL