-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add resource filtering test cases #4404
Conversation
b5e2a94
to
ad05846
Compare
f42dce1
to
a87618b
Compare
test/e2e/e2e_suite_test.go
Outdated
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) |
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.
Typo: ResourceFiltering
. "github.com/vmware-tanzu/velero/test/e2e/util/k8s" | ||
) | ||
|
||
type VeleroTest interface { |
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.
Will this interface cover all test cases?
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.
yeah, I want to use one interface to cover basic test flow
test/e2e/test/test.go
Outdated
type VeleroTest interface { | ||
Init(client TestClient, isTestBackup bool) VeleroTest | ||
CreateResources() error | ||
CheckResources() error |
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 CreateResources
and CreateResources
be merged? Why do we need to check the resources again if they are already created successfully in CreateResources
?
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.
ok, I'll remove it
test/e2e/test/test.go
Outdated
) | ||
|
||
type VeleroTest interface { | ||
Init(client TestClient, isTestBackup bool) VeleroTest |
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.
What is isTestBackup
used for?
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.
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.
test/e2e/test/test.go
Outdated
Clean() error | ||
GetText() string | ||
GetDesc() string | ||
GetFalidMsg() string |
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.
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?
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.
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 |
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.
Is it possible to use the standard error definitions to check the not found error?
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.
ok
velero.io/exclude-from-backup=true | ||
*/ | ||
|
||
func ResourceFilering(test VeleroTest, isTestBackup bool) 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.
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
c3f5f36
to
0bac1b2
Compare
Signed-off-by: Ming <mqiu@vmware.com>
0bac1b2
to
0c8063c
Compare
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.
LGTM
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:
/kind changelog-not-required
.site/content/docs/main
.