@@ -38,10 +38,12 @@ func TestReconcileVolumeSnapshots(t *testing.T) {
3838 discoveryClient , err := discovery .NewDiscoveryClientForConfig (cfg )
3939 assert .NilError (t , err )
4040
41+ recorder := record .NewFakeRecorder (100 )
4142 r := & Reconciler {
4243 Client : cc ,
4344 Owner : client .FieldOwner (t .Name ()),
4445 DiscoveryClient : discoveryClient ,
46+ Recorder : recorder ,
4547 }
4648 ns := setupNamespace (t , cc )
4749
@@ -93,6 +95,43 @@ func TestReconcileVolumeSnapshots(t *testing.T) {
9395 assert .Equal (t , len (snapshots .Items ), 0 )
9496 })
9597
98+ t .Run ("SnapshotsEnabledTablespacesEnabled" , func (t * testing.T ) {
99+ // Enable snapshots feature gate
100+ gate := feature .NewGate ()
101+ assert .NilError (t , gate .SetFromMap (map [string ]bool {
102+ feature .VolumeSnapshots : true ,
103+ feature .TablespaceVolumes : true ,
104+ }))
105+ ctx := feature .NewContext (ctx , gate )
106+
107+ // Create a cluster with snapshots and tablespaces enabled
108+ volumeSnapshotClassName := "my-snapshotclass"
109+ cluster := testCluster ()
110+ cluster .Namespace = ns .Name
111+ cluster .Spec .Backups .Snapshots = & v1beta1.VolumeSnapshots {
112+ VolumeSnapshotClassName : volumeSnapshotClassName ,
113+ }
114+ cluster .Spec .InstanceSets [0 ].TablespaceVolumes = []v1beta1.TablespaceVolume {{
115+ Name : "volume-1" ,
116+ }}
117+
118+ // Create pvc for reconcile
119+ pvc := & corev1.PersistentVolumeClaim {
120+ ObjectMeta : metav1.ObjectMeta {
121+ Name : "dedicated-snapshot-volume" ,
122+ },
123+ }
124+
125+ // Reconcile
126+ err = r .reconcileVolumeSnapshots (ctx , cluster , pvc )
127+ assert .NilError (t , err )
128+
129+ // Assert warning event was created
130+ event , ok := <- recorder .Events
131+ assert .Equal (t , ok , true )
132+ assert .Assert (t , cmp .Contains (event , "IncompatibleFeatures" ))
133+ })
134+
96135 t .Run ("SnapshotsEnabledNoPvcAnnotation" , func (t * testing.T ) {
97136 // Enable snapshots feature gate
98137 gate := feature .NewGate ()
0 commit comments