Skip to content

Commit

Permalink
Fix failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
olim7t committed Aug 28, 2024
1 parent 635f9c0 commit 237da85
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions pkg/reconciliation/reconcile_racks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2473,13 +2473,15 @@ func TestCheckVolumeClaimSizesValidation(t *testing.T) {
require.NoErrorf(err, "error occurred creating statefulset")

res = rc.CheckVolumeClaimSizes(originalStatefulSet, desiredStatefulSet)
require.Equal(result.Error(fmt.Errorf("PVC resize requested, but cassandra.datastax.com/allow-storage-changes annotation is not set to 'true'")), res, "We should have an error, feature flag is not set")
_, err = res.Output()
require.EqualError(err, "PVC resize requested, but cassandra.datastax.com/allow-storage-changes annotation is not set to 'true'", "We should have an error, feature flag is not set")

metav1.SetMetaDataAnnotation(&rc.Datacenter.ObjectMeta, api.AllowStorageChangesAnnotation, "true")
require.NoError(rc.Client.Update(rc.Ctx, rc.Datacenter))

res = rc.CheckVolumeClaimSizes(originalStatefulSet, desiredStatefulSet)
require.Equal(result.Error(fmt.Errorf("PVC resize requested, but StorageClass standard does not support expansion")), res, "We should have an error, StorageClass does not allow expansion")
_, err = res.Output()
require.EqualError(err, "PVC resize requested, but StorageClass standard does not support expansion", "We should have an error, StorageClass does not allow expansion")
cond, found := rc.Datacenter.GetCondition(api.DatacenterValid)
require.True(found)
require.Equal(corev1.ConditionFalse, cond.Status)
Expand All @@ -2495,7 +2497,8 @@ func TestCheckVolumeClaimSizesValidation(t *testing.T) {
desiredStatefulSet, err = newStatefulSetForCassandraDatacenter(nil, "default", rc.Datacenter, 2)
require.NoErrorf(err, "error occurred creating statefulset")
res = rc.CheckVolumeClaimSizes(originalStatefulSet, desiredStatefulSet)
require.Equal(result.Error(fmt.Errorf("shrinking PVC %s is not supported", originalStatefulSet.Spec.VolumeClaimTemplates[0].Name)), res, "We should have an error, shrinking is disabled")
_, err = res.Output()
require.EqualError(err, fmt.Sprintf("shrinking PVC %s is not supported", originalStatefulSet.Spec.VolumeClaimTemplates[0].Name), "We should have an error, shrinking is disabled")
cond, found = rc.Datacenter.GetCondition(api.DatacenterValid)
require.True(found)
require.Equal(corev1.ConditionFalse, cond.Status)
Expand Down Expand Up @@ -2715,7 +2718,8 @@ func TestCheckRackPodTemplateWithVolumeExpansion(t *testing.T) {
rc.Datacenter.Spec.StorageConfig.CassandraDataVolumeClaimSpec.Resources.Requests = map[corev1.ResourceName]resource.Quantity{corev1.ResourceStorage: resource.MustParse("2Gi")}
require.NoError(rc.Client.Update(rc.Ctx, rc.Datacenter))
res = rc.CheckRackPodTemplate()
require.Equal(result.Error(fmt.Errorf("PVC resize requested, but StorageClass standard does not support expansion")), res, "We should have an error, storageClass does not support expansion")
_, err := res.Output()
require.EqualError(err, "PVC resize requested, but StorageClass standard does not support expansion", "We should have an error, storageClass does not support expansion")

// Mark the StorageClass as allowing expansion
storageClass := &storagev1.StorageClass{}
Expand Down

0 comments on commit 237da85

Please sign in to comment.