From 7bbd4689c2e019329d470d70db74bb251d82c07c Mon Sep 17 00:00:00 2001 From: Malay Kumar Parida Date: Thu, 23 Jan 2025 14:15:44 +0530 Subject: [PATCH] Fix unit tests Signed-off-by: Malay Kumar Parida --- controllers/storagecluster/cephcluster_test.go | 12 +----------- controllers/storagecluster/placement_test.go | 9 +-------- 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/controllers/storagecluster/cephcluster_test.go b/controllers/storagecluster/cephcluster_test.go index 3833cb9913..6e8098ec4e 100644 --- a/controllers/storagecluster/cephcluster_test.go +++ b/controllers/storagecluster/cephcluster_test.go @@ -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, }, } @@ -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" { diff --git a/controllers/storagecluster/placement_test.go b/controllers/storagecluster/placement_test.go index d5737c6f71..ba071b208f 100644 --- a/controllers/storagecluster/placement_test.go +++ b/controllers/storagecluster/placement_test.go @@ -177,7 +177,6 @@ func TestGetPlacement(t *testing.T) { Tolerations: defaults.DaemonPlacements["all"].Tolerations, }, "mon": { - NodeAffinity: defaults.DefaultNodeAffinity, PodAntiAffinity: defaults.DaemonPlacements["mon"].PodAntiAffinity, }, "mds": { @@ -196,9 +195,7 @@ func TestGetPlacement(t *testing.T) { "all": { NodeAffinity: defaults.DefaultNodeAffinity, }, - "mon": { - NodeAffinity: defaults.DefaultNodeAffinity, - }, + "mon": {}, "mds": { NodeAffinity: defaults.DefaultNodeAffinity, }, @@ -323,7 +320,6 @@ func TestGetPlacement(t *testing.T) { Tolerations: defaults.DaemonPlacements["all"].Tolerations, }, "mon": { - NodeAffinity: defaults.DefaultNodeAffinity, PodAntiAffinity: customMONPlacement.PodAntiAffinity, }, "mds": { @@ -389,7 +385,6 @@ func TestGetPlacement(t *testing.T) { }, "mon": { - NodeAffinity: defaults.DefaultNodeAffinity, PodAntiAffinity: &corev1.PodAntiAffinity{ RequiredDuringSchedulingIgnoredDuringExecution: []corev1.PodAffinityTerm{ { @@ -429,7 +424,6 @@ func TestGetPlacement(t *testing.T) { Tolerations: defaults.DaemonPlacements["all"].Tolerations, }, "mon": { - NodeAffinity: defaults.DefaultNodeAffinity, PodAntiAffinity: &corev1.PodAntiAffinity{}, }, "mds": { @@ -475,7 +469,6 @@ func TestGetPlacement(t *testing.T) { Tolerations: defaults.DaemonPlacements["all"].Tolerations, }, "mon": { - NodeAffinity: defaults.DefaultNodeAffinity, Tolerations: []corev1.Toleration{ getOcsToleration(), },