Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
reconcile_test: Extend DataSource / DataImportCron restore test
Browse files Browse the repository at this point in the history
Extend the test that ensures DataSources are not restored when a
DataImportCron is present into a table with a PVC and a Snapshot
entry.

Signed-off-by: kubevirt-bot <[email protected]>
kubevirt-bot committed Nov 21, 2023

Verified

This commit was signed with the committer’s verified signature.
JMazurkiewicz Jakub Mazurkiewicz
1 parent 2958c67 commit 8714cb2
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions internal/operands/data-sources/reconcile_test.go
Original file line number Diff line number Diff line change
@@ -221,7 +221,7 @@ var _ = Describe("Data-Sources operand", func() {
Expect(ds.Spec).To(Equal(testDataSources[0].Spec))
})

It("should not restore DataSource if DataImportCron prefers snapshots sources", func() {
DescribeTable("should not restore DataSource if DataImportCron is present", func(source cdiv1beta1.DataSourceSource) {
_, err := operand.Reconcile(&request)
Expect(err).ToNot(HaveOccurred())

@@ -232,25 +232,31 @@ var _ = Describe("Data-Sources operand", func() {
// Update DataSource to simulate CDI
ds := &cdiv1beta1.DataSource{}
Expect(request.Client.Get(request.Context, client.ObjectKeyFromObject(&testDataSources[0]), ds)).To(Succeed())
ds.Spec.Source.PVC = nil
ds.Spec.Source.Snapshot = &cdiv1beta1.DataVolumeSourceSnapshot{
Namespace: "test",
Name: "test",
}
ds.Spec.Source = source
Expect(request.Client.Update(request.Context, ds)).To(Succeed())

_, err = operand.Reconcile(&request)
Expect(err).ToNot(HaveOccurred())

// Test that DataSource was not changed
Expect(request.Client.Get(request.Context, client.ObjectKeyFromObject(&testDataSources[0]), ds)).To(Succeed())
Expect(ds.Spec.Source).To(Equal(cdiv1beta1.DataSourceSource{
Expect(ds.Spec.Source).To(Equal(source))
},
Entry("and prefers PVCs", cdiv1beta1.DataSourceSource{
PVC: &cdiv1beta1.DataVolumeSourcePVC{
Namespace: "test",
Name: "test",
},
Snapshot: nil,
}),
Entry("and prefers Snapshots", cdiv1beta1.DataSourceSource{
PVC: nil,
Snapshot: &cdiv1beta1.DataVolumeSourceSnapshot{
Namespace: "test",
Name: "test",
},
}))
})
}),
)
})

Context("with existing PVC", func() {

0 comments on commit 8714cb2

Please sign in to comment.