Skip to content

Commit

Permalink
Create BSL in NAB Reconcile tests
Browse files Browse the repository at this point in the history
Signed-off-by: Tiger Kaovilai <[email protected]>
  • Loading branch information
kaovilai committed Feb 7, 2025
1 parent 82e0592 commit 3da9110
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions internal/controller/nonadminbackup_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,24 @@ var _ = ginkgo.Describe("Test single reconciles of NonAdminBackup Reconcile func
}))
})

func testStorageLocation(name, namespace, provider, bucket, prefix string) velerov1.BackupStorageLocation {
return velerov1.BackupStorageLocation{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: namespace,
},
Spec: velerov1.BackupStorageLocationSpec{
Provider: provider,
StorageType: velerov1.StorageType{
ObjectStorage: &velerov1.ObjectStorageLocation{
Bucket: bucket,
Prefix: prefix,
},
},
},
}
}

var _ = ginkgo.Describe("Test full reconcile loop of NonAdminBackup Controller", func() {
var (
ctx context.Context
Expand Down Expand Up @@ -840,6 +858,11 @@ var _ = ginkgo.Describe("Test full reconcile loop of NonAdminBackup Controller",

gomega.Expect(createTestNamespaces(ctx, nonAdminObjectNamespace, oadpNamespace)).To(gomega.Succeed())

// Create test BSL
testBSL := testStorageLocation("test-create-event", oadpNamespace, "aws", "creative-bucket", "unique-prefix")
err := k8sClient.Create(context.Background(), &testBSL)
gomega.Expect(err).ToNot(gomega.HaveOccurred())

k8sManager, err := ctrl.NewManager(cfg, ctrl.Options{
Scheme: k8sClient.Scheme(),
})
Expand Down Expand Up @@ -882,6 +905,13 @@ var _ = ginkgo.Describe("Test full reconcile loop of NonAdminBackup Controller",

ginkgo.By("Waiting Reconcile of create event")
nonAdminBackup := buildTestNonAdminBackup(nonAdminObjectNamespace, nonAdminObjectName, scenario.spec)
// insert bsl name into nab spec
// TODO: NaBSL test
nonAdminBackup.Spec.BackupSpec.StorageLocation = testBSL.Name
if scenario.enforcedBackupSpec != nil {
scenario.enforcedBackupSpec.StorageLocation = testBSL.Name
}

gomega.Expect(k8sClient.Create(ctxTimeout, nonAdminBackup)).To(gomega.Succeed())
// wait NAB reconcile
time.Sleep(2 * time.Second)
Expand Down

0 comments on commit 3da9110

Please sign in to comment.