Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: Malay Kumar Parida <[email protected]>
  • Loading branch information
malayparida2000 authored and openshift-cherrypick-robot committed Jan 29, 2025
1 parent a448739 commit 7bbd468
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 19 deletions.
12 changes: 1 addition & 11 deletions controllers/storagecluster/cephcluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -542,31 +542,26 @@ func TestStorageClassDeviceSetCreation(t *testing.T) {
label string
sc *ocsv1.StorageCluster
topologyKey string
lenOfMatchExpression int
}{
{
label: "case 1",
sc: sc1,
topologyKey: "zone",
lenOfMatchExpression: 1,
},
{
label: "case 2",
sc: sc2,
topologyKey: "zone",
lenOfMatchExpression: 1,
},
{
label: "case 3",
sc: sc3,
topologyKey: "zone",
lenOfMatchExpression: 0,
},
{
label: "case 4",
sc: sc4,
topologyKey: "rack",
lenOfMatchExpression: 1,
},
}

Expand Down Expand Up @@ -597,12 +592,7 @@ func TestStorageClassDeviceSetCreation(t *testing.T) {
} else {
assert.DeepEqual(t, getPlacement(c.sc, "osd"), scds.Placement)
}
if c.lenOfMatchExpression == 0 {
assert.Assert(t, is.Nil(scds.Placement.NodeAffinity))
} else {
matchExpressions := scds.Placement.NodeAffinity.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms[0].MatchExpressions
assert.Equal(t, c.lenOfMatchExpression, len(matchExpressions))
}

topologyKey := scds.PreparePlacement.TopologySpreadConstraints[0].TopologyKey

if c.topologyKey == "rack" {
Expand Down
9 changes: 1 addition & 8 deletions controllers/storagecluster/placement_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ func TestGetPlacement(t *testing.T) {
Tolerations: defaults.DaemonPlacements["all"].Tolerations,
},
"mon": {
NodeAffinity: defaults.DefaultNodeAffinity,
PodAntiAffinity: defaults.DaemonPlacements["mon"].PodAntiAffinity,
},
"mds": {
Expand All @@ -196,9 +195,7 @@ func TestGetPlacement(t *testing.T) {
"all": {
NodeAffinity: defaults.DefaultNodeAffinity,
},
"mon": {
NodeAffinity: defaults.DefaultNodeAffinity,
},
"mon": {},
"mds": {
NodeAffinity: defaults.DefaultNodeAffinity,
},
Expand Down Expand Up @@ -323,7 +320,6 @@ func TestGetPlacement(t *testing.T) {
Tolerations: defaults.DaemonPlacements["all"].Tolerations,
},
"mon": {
NodeAffinity: defaults.DefaultNodeAffinity,
PodAntiAffinity: customMONPlacement.PodAntiAffinity,
},
"mds": {
Expand Down Expand Up @@ -389,7 +385,6 @@ func TestGetPlacement(t *testing.T) {
},

"mon": {
NodeAffinity: defaults.DefaultNodeAffinity,
PodAntiAffinity: &corev1.PodAntiAffinity{
RequiredDuringSchedulingIgnoredDuringExecution: []corev1.PodAffinityTerm{
{
Expand Down Expand Up @@ -429,7 +424,6 @@ func TestGetPlacement(t *testing.T) {
Tolerations: defaults.DaemonPlacements["all"].Tolerations,
},
"mon": {
NodeAffinity: defaults.DefaultNodeAffinity,
PodAntiAffinity: &corev1.PodAntiAffinity{},
},
"mds": {
Expand Down Expand Up @@ -475,7 +469,6 @@ func TestGetPlacement(t *testing.T) {
Tolerations: defaults.DaemonPlacements["all"].Tolerations,
},
"mon": {
NodeAffinity: defaults.DefaultNodeAffinity,
Tolerations: []corev1.Toleration{
getOcsToleration(),
},
Expand Down

0 comments on commit 7bbd468

Please sign in to comment.