From 27f69f5a397e55dafa4d54d79edddcc574b5936d Mon Sep 17 00:00:00 2001 From: Trung Minh Lai Date: Mon, 18 Nov 2024 15:24:49 +0700 Subject: [PATCH] Fix UT --- pkg/cluster/k8sres_test.go | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/pkg/cluster/k8sres_test.go b/pkg/cluster/k8sres_test.go index a50e1420d..010f856a4 100644 --- a/pkg/cluster/k8sres_test.go +++ b/pkg/cluster/k8sres_test.go @@ -3890,6 +3890,9 @@ func TestGenerateCapabilities(t *testing.T) { func TestTopologySpreadConstraints(t *testing.T) { clusterName := "acid-test-cluster" namespace := "default" + labelSelector := &metav1.LabelSelector{ + MatchLabels: cluster.labelsSet(true), + } pg := acidv1.Postgresql{ ObjectMeta: metav1.ObjectMeta{ @@ -3910,9 +3913,7 @@ func TestTopologySpreadConstraints(t *testing.T) { MaxSkew: 1, TopologyKey: "topology.kubernetes.io/zone", WhenUnsatisfiable: v1.DoNotSchedule, - LabelSelector: &metav1.LabelSelector{ - MatchLabels: cluster.labelsSet(true), - }, + LabelSelector: labelSelector, }, }, }, @@ -3930,14 +3931,11 @@ func TestTopologySpreadConstraints(t *testing.T) { s, err := cluster.generateStatefulSet(&pg.Spec) assert.NoError(t, err) - assert.Contains(t, s.Spec.Template.Spec.TopologySpreadConstraints, []v1.TopologySpreadConstraint{ - { - MaxSkew: int32(1), - TopologyKey: "topology.kubernetes.io/zone", - WhenUnsatisfiable: v1.DoNotSchedule, - LabelSelector: &metav1.LabelSelector{ - MatchLabels: cluster.labelsSet(true), - }, - }, - }) + assert.Contains(t, s.Spec.Template.Spec.TopologySpreadConstraints, v1.TopologySpreadConstraint{ + MaxSkew: int32(1), + TopologyKey: "topology.kubernetes.io/zone", + WhenUnsatisfiable: v1.DoNotSchedule, + LabelSelector: labelSelector, + }, + ) }