Skip to content

Commit

Permalink
Fix sp consts names + more
Browse files Browse the repository at this point in the history
Signed-off-by: raaizik <[email protected]>
  • Loading branch information
raaizik committed Jan 25, 2024
1 parent 3af0070 commit a48b66e
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ import (
)

const (
pgAutoscaleMode = "pg_autoscale_mode"
pgNum = "pg_num"
pgpNum = "pgp_num"
namespaceName = "test-ns"
deviceClass = "ssd"
kind = "StorageProfile"
pgAutoscaleMode = "pg_autoscale_mode"
pgNum = "pg_num"
pgpNum = "pgp_num"
namespaceName = "test-ns"
deviceClass = "ssd"
storageProfileKind = "StorageProfile"
)

var fakeStorageProfile = &v1.StorageProfile{
TypeMeta: metav1.TypeMeta{Kind: kind},
TypeMeta: metav1.TypeMeta{Kind: storageProfileKind},
ObjectMeta: metav1.ObjectMeta{
Name: "medium",
Namespace: namespaceName,
Expand All @@ -54,7 +54,7 @@ var fakeStorageProfile = &v1.StorageProfile{
}

var validStorageProfile = &v1.StorageProfile{
TypeMeta: metav1.TypeMeta{Kind: kind},
TypeMeta: metav1.TypeMeta{Kind: storageProfileKind},
ObjectMeta: metav1.ObjectMeta{
Name: "valid",
Namespace: namespaceName,
Expand All @@ -72,8 +72,10 @@ var validStorageProfile = &v1.StorageProfile{
Status: v1.StorageProfileStatus{Phase: ""},
}

// A rejected StorageProfile is one that is invalid due to having a blank device class field and is set to
// Rejected in its phase.
var rejectedStorageProfile = &v1.StorageProfile{
TypeMeta: metav1.TypeMeta{Kind: kind},
TypeMeta: metav1.TypeMeta{Kind: storageProfileKind},
ObjectMeta: metav1.ObjectMeta{
Name: "rejected",
Namespace: namespaceName,
Expand Down Expand Up @@ -336,9 +338,7 @@ func TestStorageProfileCephBlockPool(t *testing.T) {
fmt.Println(caseLabel)

r := createFakeReconciler(t)
if strings.Contains(c.label, "rejected") {
r.storageCluster.Spec.DefaultStorageProfile = rejectedStorageProfile.Name
}
r.storageCluster.Spec.DefaultStorageProfile = c.storageProfile.Name
r.StorageClassRequest.Spec.Type = "blockpool"

r.StorageClassRequest.Spec.StorageProfile = c.storageProfile.Name
Expand All @@ -362,9 +362,10 @@ func TestStorageProfileCephBlockPool(t *testing.T) {
expectedStorageProfileParameters := validStorageProfile.Spec.BlockPoolConfiguration.Parameters
actualBlockPoolParameters := r.cephBlockPool.Spec.Parameters
assert.Equal(t, expectedStorageProfileParameters, actualBlockPoolParameters, caseLabel)
assert.NotEqual(t, v1.StorageProfilePhaseRejected, c.storageProfile.Status.Phase)
} else {
actualBlockPoolParameters := r.cephBlockPool.Spec.Parameters
assert.Equal(t, v1.StorageProfilePhaseRejected, rejectedStorageProfile.Status.Phase)
assert.Equal(t, v1.StorageProfilePhaseRejected, c.storageProfile.Status.Phase)
assert.Nil(t, actualBlockPoolParameters, caseLabel)
}
}
Expand Down
3 changes: 2 additions & 1 deletion controllers/storagecluster/cephblockpools_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ func getInitData(customSpec *api.StorageClusterSpec) *api.StorageCluster {
}

func createReconcilerFromCustomResources(t *testing.T, platform *Platform, cr *api.StorageCluster) StorageClusterReconciler {
reconciler := createFakeInitializationStorageClusterReconcilerWithPlatform(t, platform, &nbv1.NooBaa{})
reconciler := createFakeInitializationStorageClusterReconcilerWithPlatform(
t, platform, &nbv1.NooBaa{})

secret := corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Expand Down
30 changes: 16 additions & 14 deletions controllers/storagecluster/storagecluster_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,20 +193,22 @@ var mockDeviceSets = []api.StorageDeviceSet{
}

func getMockStorageProfiles() *api.StorageProfileList {
const pgAutoscaleMode = "pg_autoscale_mode"
const pgNum = "pg_num"
const pgpNum = "pgp_num"
const namespace = ""
const kind = "StorageProfile"
const apiVersion = "ocs.openshift.io/v1"
const (
pgAutoscaleMode = "pg_autoscale_mode"
pgNum = "pg_num"
pgpNum = "pgp_num"
storageProfileNamespace = ""
storageProfileKind = "StorageProfile"
apiVersion = "ocs.openshift.io/v1"
)
spfast := &api.StorageProfile{
TypeMeta: metav1.TypeMeta{
Kind: kind,
Kind: storageProfileKind,
APIVersion: apiVersion,
},
ObjectMeta: metav1.ObjectMeta{
Name: "fast-performance",
Namespace: namespace,
Namespace: storageProfileNamespace,
},
Spec: api.StorageProfileSpec{
DeviceClass: "fast",
Expand All @@ -228,12 +230,12 @@ func getMockStorageProfiles() *api.StorageProfileList {
}
spmed := &api.StorageProfile{
TypeMeta: metav1.TypeMeta{
Kind: kind,
Kind: storageProfileKind,
APIVersion: apiVersion,
},
ObjectMeta: metav1.ObjectMeta{
Name: "med-performance",
Namespace: namespace,
Namespace: storageProfileNamespace,
},
Spec: api.StorageProfileSpec{
DeviceClass: "med",
Expand All @@ -255,12 +257,12 @@ func getMockStorageProfiles() *api.StorageProfileList {
}
spslow := &api.StorageProfile{
TypeMeta: metav1.TypeMeta{
Kind: kind,
Kind: storageProfileKind,
APIVersion: apiVersion,
},
ObjectMeta: metav1.ObjectMeta{
Name: "slow-performance",
Namespace: namespace,
Namespace: storageProfileNamespace,
},
Spec: api.StorageProfileSpec{
DeviceClass: "slow",
Expand All @@ -282,12 +284,12 @@ func getMockStorageProfiles() *api.StorageProfileList {
}
spblankdeviceclass := &api.StorageProfile{
TypeMeta: metav1.TypeMeta{
Kind: kind,
Kind: storageProfileKind,
APIVersion: apiVersion,
},
ObjectMeta: metav1.ObjectMeta{
Name: "blank-performance",
Namespace: namespace,
Namespace: storageProfileNamespace,
},
Spec: api.StorageProfileSpec{
DeviceClass: "",
Expand Down

0 comments on commit a48b66e

Please sign in to comment.