MCPcopy Create free account
hub / github.com/cloudnative-pg/cloudnative-pg / generateFakeClusterPods

Function generateFakeClusterPods

internal/controller/suite_test.go:324–355  ·  view source on GitHub ↗
(
	c client.Client,
	cluster *apiv1.Cluster,
	markAsReady bool,
)

Source from the content-addressed store, hash-verified

322}
323
324func generateFakeClusterPods(
325 c client.Client,
326 cluster *apiv1.Cluster,
327 markAsReady bool,
328) []corev1.Pod {
329 var idx int
330 var pods []corev1.Pod
331 for idx < cluster.Spec.Instances {
332 idx++
333 pod, _ := specs.NewInstance(context.TODO(), *cluster, idx, true)
334 cluster.SetInheritedDataAndOwnership(&pod.ObjectMeta)
335
336 err := c.Create(context.Background(), pod)
337 Expect(err).ToNot(HaveOccurred())
338
339 // we overwrite local status, needed for certain tests. The status returned from fake api server will be always
340 // 'Pending'
341 if markAsReady {
342 pod.Status = corev1.PodStatus{
343 Phase: corev1.PodRunning,
344 Conditions: []corev1.PodCondition{
345 {
346 Type: corev1.PodReady,
347 Status: corev1.ConditionTrue,
348 },
349 },
350 }
351 }
352 pods = append(pods, *pod)
353 }
354 return pods
355}
356
357func generateFakeClusterPodsWithDefaultClient(
358 k8sClient client.Client,

Calls 3

NewInstanceFunction · 0.92
CreateMethod · 0.65

Tested by

no test coverage detected