MCPcopy Create free account
hub / github.com/CrunchyData/postgres-operator / TestExporterEnabled

Function TestExporterEnabled

internal/pgmonitor/util_test.go:18–46  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

16)
17
18func TestExporterEnabled(t *testing.T) {
19 cluster := &v1beta1.PostgresCluster{}
20 ctx := context.Background()
21 assert.Assert(t, !ExporterEnabled(ctx, cluster))
22
23 cluster.Spec.Monitoring = &v1beta1.MonitoringSpec{}
24 assert.Assert(t, !ExporterEnabled(ctx, cluster))
25
26 cluster.Spec.Monitoring.PGMonitor = &v1beta1.PGMonitorSpec{}
27 assert.Assert(t, !ExporterEnabled(ctx, cluster))
28
29 cluster.Spec.Monitoring.PGMonitor.Exporter = &v1beta1.ExporterSpec{}
30 assert.Assert(t, ExporterEnabled(ctx, cluster))
31
32 // Enabling the OpenTelemetryMetrics is not sufficient to disable the exporter
33 gate := feature.NewGate()
34 assert.NilError(t, gate.SetFromMap(map[string]bool{
35 feature.OpenTelemetryMetrics: true,
36 }))
37 ctx = feature.NewContext(ctx, gate)
38 assert.Assert(t, ExporterEnabled(ctx, cluster))
39
40 require.UnmarshalInto(t, &cluster.Spec, `{
41 instrumentation: {
42 logs: { retentionPeriod: 5h },
43 },
44 }`)
45 assert.Assert(t, !ExporterEnabled(ctx, cluster))
46}

Callers

nothing calls this directly

Calls 5

NewGateFunction · 0.92
NewContextFunction · 0.92
UnmarshalIntoFunction · 0.92
ExporterEnabledFunction · 0.85
SetFromMapMethod · 0.80

Tested by

no test coverage detected