(t *testing.T)
| 1027 | } |
| 1028 | |
| 1029 | func TestPostgresParameters(t *testing.T) { |
| 1030 | t.Run("NoInstrumentation", func(t *testing.T) { |
| 1031 | cluster := new(v1beta1.PostgresCluster) |
| 1032 | cluster.Spec.PostgresVersion = 99 |
| 1033 | |
| 1034 | before := postgres.NewParameters() |
| 1035 | params := postgres.NewParameters() |
| 1036 | PostgreSQLParameters(t.Context(), cluster, ¶ms) |
| 1037 | |
| 1038 | assert.DeepEqual(t, before, params) |
| 1039 | }) |
| 1040 | |
| 1041 | t.Run("Specified", func(t *testing.T) { |
| 1042 | cluster := new(v1beta1.PostgresCluster) |
| 1043 | cluster.Spec.PostgresVersion = 99 |
| 1044 | require.UnmarshalInto(t, &cluster.Spec.Instrumentation, `{}`) |
| 1045 | |
| 1046 | // Feature disabled |
| 1047 | { |
| 1048 | before := postgres.NewParameters() |
| 1049 | params := postgres.NewParameters() |
| 1050 | PostgreSQLParameters(t.Context(), cluster, ¶ms) |
| 1051 | |
| 1052 | assert.DeepEqual(t, before, params) |
| 1053 | } |
| 1054 | |
| 1055 | // Feature enabled |
| 1056 | gate := feature.NewGate() |
| 1057 | assert.NilError(t, gate.SetFromMap(map[string]bool{ |
| 1058 | feature.OpenTelemetryLogs: true, |
| 1059 | })) |
| 1060 | ctx := feature.NewContext(t.Context(), gate) |
| 1061 | |
| 1062 | params := postgres.NewParameters() |
| 1063 | PostgreSQLParameters(ctx, cluster, ¶ms) |
| 1064 | |
| 1065 | assert.Equal(t, params.Mandatory.Value("log_destination"), "jsonlog") |
| 1066 | assert.Assert(t, params.Mandatory.Value("log_filename") != "") |
| 1067 | assert.Assert(t, params.Mandatory.Value("log_rotation_age") != "") |
| 1068 | assert.Assert(t, params.Mandatory.Value("log_rotation_size") != "") |
| 1069 | assert.Equal(t, params.Mandatory.Value("log_timezone"), "UTC") |
| 1070 | assert.Equal(t, params.Mandatory.Value("log_truncate_on_rotation"), "on") |
| 1071 | assert.Equal(t, params.Mandatory.Value("logging_collector"), "on") |
| 1072 | }) |
| 1073 | |
| 1074 | t.Run("OldPostgres", func(t *testing.T) { |
| 1075 | cluster := new(v1beta1.PostgresCluster) |
| 1076 | cluster.Spec.PostgresVersion = 10 |
| 1077 | require.UnmarshalInto(t, &cluster.Spec.Instrumentation, `{}`) |
| 1078 | |
| 1079 | // Feature enabled |
| 1080 | gate := feature.NewGate() |
| 1081 | assert.NilError(t, gate.SetFromMap(map[string]bool{ |
| 1082 | feature.OpenTelemetryLogs: true, |
| 1083 | })) |
| 1084 | ctx := feature.NewContext(t.Context(), gate) |
| 1085 | |
| 1086 | params := postgres.NewParameters() |
nothing calls this directly
no test coverage detected