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

enhance tests (part 1) #81

Merged
merged 11 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions internal/controller/mantlebackup_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ const (
annotRetainIfExpired = "mantle.cybozu.io/retain-if-expired"
annotSyncMode = "mantle.cybozu.io/sync-mode"

MantleExportJobPrefix = "mantle-export-"
MantleUploadJobPrefix = "mantle-upload-"
MantleExportDataPVCPrefix = "mantle-export-"
MantleImportJobPrefix = "mantle-import-"
MantleDiscardJobPrefix = "mantle-discard-"
MantleDiscardPVCPrefix = "mantle-discard-"
MantleDiscardPVPrefix = "mantle-discard-"

syncModeFull = "full"
syncModeIncremental = "incremental"
)
Expand Down Expand Up @@ -1060,35 +1068,35 @@ func (r *MantleBackupReconciler) createOrUpdateExportDataPVC(ctx context.Context
}

func makeExportJobName(target *mantlev1.MantleBackup) string {
return fmt.Sprintf("mantle-export-%s", target.GetUID())
return MantleExportJobPrefix + string(target.GetUID())
}

func makeUploadJobName(target *mantlev1.MantleBackup) string {
return fmt.Sprintf("mantle-upload-%s", target.GetUID())
return MantleUploadJobPrefix + string(target.GetUID())
}

func makeExportDataPVCName(target *mantlev1.MantleBackup) string {
return fmt.Sprintf("mantle-export-%s", target.GetUID())
return MantleExportDataPVCPrefix + string(target.GetUID())
}

func makeObjectNameOfExportedData(name, uid string) string {
return fmt.Sprintf("%s-%s.bin", name, uid)
}

func makeImportJobName(target *mantlev1.MantleBackup) string {
return fmt.Sprintf("mantle-import-%s", target.GetUID())
return MantleImportJobPrefix + string(target.GetUID())
}

func makeDiscardJobName(target *mantlev1.MantleBackup) string {
return fmt.Sprintf("mantle-discard-%s", target.GetUID())
return MantleDiscardJobPrefix + string(target.GetUID())
}

func makeDiscardPVCName(target *mantlev1.MantleBackup) string {
return fmt.Sprintf("mantle-discard-%s", target.GetUID())
return MantleDiscardPVCPrefix + string(target.GetUID())
}

func makeDiscardPVName(target *mantlev1.MantleBackup) string {
return fmt.Sprintf("mantle-discard-%s", target.GetUID())
return MantleDiscardPVPrefix + string(target.GetUID())
}

func (r *MantleBackupReconciler) createOrUpdateExportJob(ctx context.Context, target *mantlev1.MantleBackup, sourceBackupNamePtr *string) error {
Expand Down
6 changes: 3 additions & 3 deletions internal/controller/mantlebackup_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ var _ = Describe("MantleBackup controller", func() {
err = k8sClient.Get(
ctx,
types.NamespacedName{
Name: fmt.Sprintf("mantle-upload-%s", backup.GetUID()),
Name: makeUploadJobName(backup),
Namespace: resMgr.ClusterID,
},
&jobUpload,
Expand All @@ -551,7 +551,7 @@ var _ = Describe("MantleBackup controller", func() {
err = k8sClient.Get(
ctx,
types.NamespacedName{
Name: fmt.Sprintf("mantle-upload-%s", backup.GetUID()),
Name: makeUploadJobName(backup),
Namespace: resMgr.ClusterID,
},
&jobUpload,
Expand Down Expand Up @@ -622,7 +622,7 @@ var _ = Describe("MantleBackup controller", func() {
err = k8sClient.Get(
ctx,
types.NamespacedName{
Name: fmt.Sprintf("mantle-export-%s", backup2.GetUID()),
Name: makeExportJobName(backup2),
Namespace: resMgr.ClusterID,
},
&jobExport2,
Expand Down
Loading