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

Add resource filtering test cases #4404

Merged
merged 1 commit into from
Dec 6, 2021

Conversation

qiuming-best
Copy link
Contributor

Signed-off-by: Ming mqiu@vmware.com

Thank you for contributing to Velero!

Please add a summary of your change

It's a reference to #4349 , Adding test cases on resource filtering

Does your change fix a particular issue?

Fixes #(issue)

Please indicate you've done the following:

@qiuming-best qiuming-best requested review from danfengliu and ywk253100 and removed request for reasonerjt and zubron November 28, 2021 06:52
@qiuming-best qiuming-best changed the title Add resoure filtering test cases Add resource filtering test cases Nov 28, 2021
@qiuming-best qiuming-best force-pushed the resource-filtering branch 2 times, most recently from f42dce1 to a87618b Compare December 2, 2021 07:06
var _ = Describe("[Upgrade][Snapshot] Velero upgrade tests on cluster using the plugin provider for object storage and snapshots for volume backups", BackupUpgradeRestoreWithSnapshots)

// test filter objects by namespace, type, or labels when backup or restore.
var _ = Describe("[ResourceFilering][ExcludeFromBackup] Resources with the label velero.io/exclude-from-backup=true are not included in backup", ExcludeFromBackupTest)
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo: ResourceFiltering

. "github.com/vmware-tanzu/velero/test/e2e/util/k8s"
)

type VeleroTest interface {
Copy link
Contributor

Choose a reason for hiding this comment

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

Will this interface cover all test cases?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, I want to use one interface to cover basic test flow

type VeleroTest interface {
Init(client TestClient, isTestBackup bool) VeleroTest
CreateResources() error
CheckResources() error
Copy link
Contributor

Choose a reason for hiding this comment

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

Can CreateResources and CreateResources be merged? Why do we need to check the resources again if they are already created successfully in CreateResources?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, I'll remove it

)

type VeleroTest interface {
Init(client TestClient, isTestBackup bool) VeleroTest
Copy link
Contributor

Choose a reason for hiding this comment

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

What is isTestBackup used for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe I should name the variable as isTestInBackup. It's some cases that could use the same data or functions. The only difference is test in the backup or test in the restore. I want to re-use the data and functions.
For example: include-namespace is tested in the backup or tested in the restore.

Clean() error
GetText() string
GetDesc() string
GetFalidMsg() string
Copy link
Contributor

Choose a reason for hiding this comment

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

The following four items are almost the same:
Describe: var _ = Describe("[ResourceFilering][ExcludeFromBackup] Resources with the label velero.io/exclude-from-backup=true are not included in backup", ExcludeFromBackupTest)
Text: Should not backup resources with the label velero.io/exclude-from-backup=true
Desc: Backup with the label velero.io/exclude-from-backup=true are not included test
FailedMsg: Failed to backup resources with the label velero.io/exclude-from-backup=true

How about just keeping one of them?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, I'll adjust it.

if err == nil {
return fmt.Errorf("failed to exclude deployment in namespaces %q", namespace)
} else {
if strings.Contains(err.Error(), "not found") { //resource should be excluded
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to use the standard error definitions to check the not found error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

velero.io/exclude-from-backup=true
*/

func ResourceFilering(test VeleroTest, isTestBackup bool) func() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo: ResourceFilering -> ResourceFiltering

Move the function ResourceFiltering into package e2e/test and rename it because it is a general function used not only for resource filtering test cases. Correct me if I'm wrong

@qiuming-best qiuming-best force-pushed the resource-filtering branch 2 times, most recently from c3f5f36 to 0bac1b2 Compare December 3, 2021 12:13
Signed-off-by: Ming <mqiu@vmware.com>
Copy link
Contributor

@danfengliu danfengliu left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants