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

backup:add unit test for backup controller #406

Merged
merged 1 commit into from
Oct 20, 2023

Conversation

Xieql
Copy link
Contributor

@Xieql Xieql commented Oct 20, 2023

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

backup:add unit test for backup controller

part of #404

kurator.dev/kurator/pkg/fleet-manager/backup_controller.go:42: SetupWithManager 0.0%
kurator.dev/kurator/pkg/fleet-manager/backup_controller.go:49: Reconcile 83.3%
kurator.dev/kurator/pkg/fleet-manager/backup_controller.go:91: reconcileBackup 66.7%
kurator.dev/kurator/pkg/fleet-manager/backup_controller.go:110: reconcileBackupResources 50.0%
kurator.dev/kurator/pkg/fleet-manager/backup_controller.go:151: reconcileBackupStatus 57.1%
kurator.dev/kurator/pkg/fleet-manager/backup_controller.go:167: reconcileOneTimeBackupStatus 25.0%
kurator.dev/kurator/pkg/fleet-manager/backup_controller.go:210: reconcileScheduleBackupStatus 0.0%
kurator.dev/kurator/pkg/fleet-manager/backup_controller.go:273: reconcileDeleteBackup 82.4%

kurator.dev/kurator/pkg/fleet-manager/backup_restore_migrate_shared.go:62: fetchDestinationClusters 38.1%
kurator.dev/kurator/pkg/fleet-manager/backup_restore_migrate_shared.go:103: buildVeleroBackupInstance 100.0%
kurator.dev/kurator/pkg/fleet-manager/backup_restore_migrate_shared.go:112: buildVeleroScheduleInstance 100.0%
kurator.dev/kurator/pkg/fleet-manager/backup_restore_migrate_shared.go:123: buildVeleroBackupSpec 66.7%
kurator.dev/kurator/pkg/fleet-manager/backup_restore_migrate_shared.go:144: newSyncVeleroTaskFunc 0.0%
kurator.dev/kurator/pkg/fleet-manager/backup_restore_migrate_shared.go:150: syncVeleroObj 0.0%
kurator.dev/kurator/pkg/fleet-manager/backup_restore_migrate_shared.go:165: allBackupsCompleted 100.0%
kurator.dev/kurator/pkg/fleet-manager/backup_restore_migrate_shared.go:185: deleteResourcesInClusters 17.6%
kurator.dev/kurator/pkg/fleet-manager/backup_restore_migrate_shared.go:220: isScheduleBackup 100.0%
kurator.dev/kurator/pkg/fleet-manager/backup_restore_migrate_shared.go:224: generateVeleroInstanceLabel 100.0%
kurator.dev/kurator/pkg/fleet-manager/backup_restore_migrate_shared.go:232: generateVeleroResourceObjectMeta 100.0%
kurator.dev/kurator/pkg/fleet-manager/backup_restore_migrate_shared.go:241: generateVeleroResourceName 100.0%
kurator.dev/kurator/pkg/fleet-manager/backup_restore_migrate_shared.go:247: MostRecentCompletedBackup 100.0%
kurator.dev/kurator/pkg/fleet-manager/backup_restore_migrate_shared.go:269: GetCronInterval 100.0%
kurator.dev/kurator/pkg/fleet-manager/backup_restore_migrate_shared.go:290: getResourceFromClusterClient 0.0%
kurator.dev/kurator/pkg/fleet-manager/backup_restore_migrate_shared.go:301: listResourcesFromClusterClient 0.0%

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:


@netlify
Copy link

netlify bot commented Oct 20, 2023

Deploy Preview for kurator-dev canceled.

Name Link
🔨 Latest commit abb4d9f
🔍 Latest deploy log https://app.netlify.com/sites/kurator-dev/deploys/65321c5959b570000847084f

@Xieql Xieql force-pushed the test-backup branch 4 times, most recently from 94e0e86 to 822bb94 Compare October 20, 2023 06:10
@Xieql
Copy link
Contributor Author

Xieql commented Oct 20, 2023

@hzxuzhonghu

backupapi "kurator.dev/kurator/pkg/apis/backups/v1alpha1"
)

const backupTestDataPath = "backup-testdata/backup/"
Copy link
Member

Choose a reason for hiding this comment

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

nit: ./testdata/backup/

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. actually, the path may changes when we add a backup dir and put all related file in it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix in #407

const backupTestDataPath = "backup-testdata/backup/"

// buildVeleroBackupInstanceForTest is a helper function for testing for buildVeleroBackupInstance, which constructs a Velero Backup instance with a specified TypeMeta.
func buildVeleroBackupInstanceForTest(backupSpec *backupapi.BackupSpec, labels map[string]string, veleroBackupName string, typeMeta *metav1.TypeMeta) *velerov1.Backup {
Copy link
Member

Choose a reason for hiding this comment

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

change typeMeta to value type

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,fix in #407

if tt.wantFinalizer {
assert.Contains(t, tt.backup.Finalizers, BackupFinalizer)
} else {
assert.NotContains(t, tt.backup.Finalizers, BackupFinalizer)
Copy link
Member

Choose a reason for hiding this comment

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

do you have any case for this

Copy link
Member

@hzxuzhonghu hzxuzhonghu left a comment

Choose a reason for hiding this comment

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

/lgtm

@kurator-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hzxuzhonghu

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kurator-bot kurator-bot merged commit 9524091 into kurator-dev:main Oct 20, 2023
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.

3 participants