MCPcopy Index your code
hub / github.com/zalando/postgres-operator / TestPodAnnotationsSync

Function TestPodAnnotationsSync

pkg/cluster/sync_test.go:157–330  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

155}
156
157func TestPodAnnotationsSync(t *testing.T) {
158 clusterName := "acid-test-cluster-2"
159 namespace := "default"
160 podAnnotation := "no-scale-down"
161 podAnnotations := map[string]string{podAnnotation: "true"}
162 customPodAnnotation := "foo"
163 customPodAnnotations := map[string]string{customPodAnnotation: "true"}
164
165 ctrl := gomock.NewController(t)
166 defer ctrl.Finish()
167 mockClient := mocks.NewMockHTTPClient(ctrl)
168 client, _ := newFakeK8sAnnotationsClient()
169
170 pg := acidv1.Postgresql{
171 ObjectMeta: metav1.ObjectMeta{
172 Name: clusterName,
173 Namespace: namespace,
174 },
175 Spec: acidv1.PostgresSpec{
176 Volume: acidv1.Volume{
177 Size: "1Gi",
178 },
179 EnableConnectionPooler: boolToPointer(true),
180 EnableLogicalBackup: true,
181 EnableReplicaConnectionPooler: boolToPointer(true),
182 PodAnnotations: podAnnotations,
183 NumberOfInstances: 2,
184 },
185 }
186
187 var cluster = New(
188 Config{
189 OpConfig: config.Config{
190 PatroniAPICheckInterval: time.Duration(1),
191 PatroniAPICheckTimeout: time.Duration(5),
192 PodManagementPolicy: "ordered_ready",
193 CustomPodAnnotations: customPodAnnotations,
194 ConnectionPooler: config.ConnectionPooler{
195 ConnectionPoolerDefaultCPURequest: "100m",
196 ConnectionPoolerDefaultCPULimit: "100m",
197 ConnectionPoolerDefaultMemoryRequest: "100Mi",
198 ConnectionPoolerDefaultMemoryLimit: "100Mi",
199 NumberOfInstances: k8sutil.Int32ToPointer(1),
200 },
201 Resources: config.Resources{
202 ClusterLabels: map[string]string{"application": "spilo"},
203 ClusterNameLabel: "cluster-name",
204 DefaultCPURequest: "300m",
205 DefaultCPULimit: "300m",
206 DefaultMemoryRequest: "300Mi",
207 DefaultMemoryLimit: "300Mi",
208 MaxInstances: -1,
209 PodRoleLabel: "spilo-role",
210 ResourceCheckInterval: time.Duration(3),
211 ResourceCheckTimeout: time.Duration(10),
212 },
213 },
214 }, client, pg, logger, eventRecorder)

Callers

nothing calls this directly

Calls 15

Int32ToPointerFunction · 0.92
NewFunction · 0.92
boolToPointerFunction · 0.85
clusterLabelsOptionsFunction · 0.85
createPodsFunction · 0.85
annotateResourcesFunction · 0.85
createStatefulSetMethod · 0.80
SyncMethod · 0.80
connectionPoolerNameMethod · 0.80

Tested by

no test coverage detected