-
Notifications
You must be signed in to change notification settings - Fork 61
/
Copy pathtopology_test.go
51 lines (45 loc) · 1.15 KB
/
topology_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Copyright 2021 - 2024 Crunchy Data Solutions, Inc.
//
// SPDX-License-Identifier: Apache-2.0
package postgrescluster
import (
"testing"
"gotest.tools/v3/assert"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/percona/percona-postgresql-operator/internal/testing/cmp"
)
func TestDefaultTopologySpreadConstraints(t *testing.T) {
constraints := defaultTopologySpreadConstraints(metav1.LabelSelector{
MatchLabels: map[string]string{"basic": "stuff"},
MatchExpressions: []metav1.LabelSelectorRequirement{
{Key: "k1", Operator: "op", Values: []string{"v1", "v2"}},
},
})
// Entire selector, hostname, zone, and ScheduleAnyway.
assert.Assert(t, cmp.MarshalMatches(constraints, `
- labelSelector:
matchExpressions:
- key: k1
operator: op
values:
- v1
- v2
matchLabels:
basic: stuff
maxSkew: 1
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: ScheduleAnyway
- labelSelector:
matchExpressions:
- key: k1
operator: op
values:
- v1
- v2
matchLabels:
basic: stuff
maxSkew: 1
topologyKey: topology.kubernetes.io/zone
whenUnsatisfiable: ScheduleAnyway
`))
}