MCPcopy Create free account
hub / github.com/cortexproject/cortex / TestIngester_Push

Function TestIngester_Push

pkg/ingester/ingester_test.go:1109–2128  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1107}
1108
1109func TestIngester_Push(t *testing.T) {
1110 metricLabelAdapters := []cortexpb.LabelAdapter{{Name: labels.MetricName, Value: "test"}}
1111 metricLabels := cortexpb.FromLabelAdaptersToLabels(metricLabelAdapters)
1112 metricNames := []string{
1113 "cortex_ingester_ingested_samples_total",
1114 "cortex_ingester_ingested_samples_failures_total",
1115 "cortex_ingester_memory_series",
1116 "cortex_ingester_memory_users",
1117 "cortex_ingester_memory_series_created_total",
1118 "cortex_ingester_memory_series_removed_total",
1119 }
1120 userID := "test"
1121
1122 testHistogram := cortexpb.WrapHistogram(cortexpb.HistogramToHistogramProto(10, tsdbutil.GenerateTestHistogram(1)))
1123 testFloatHistogram := cortexpb.WrapHistogram(cortexpb.FloatHistogramToHistogramProto(11, tsdbutil.GenerateTestFloatHistogram(1)))
1124 tests := map[string]struct {
1125 reqs []*cortexpb.WriteRequest
1126 expectedErr error
1127 expectedIngested []cortexpb.TimeSeries
1128 expectedMetadataIngested []*cortexpb.MetricMetadata
1129 expectedExemplarsIngested []cortexpb.TimeSeries
1130 expectedMetrics string
1131 additionalMetrics []string
1132 disableActiveSeries bool
1133 maxExemplars int
1134 oooTimeWindow time.Duration
1135 disableNativeHistogram bool
1136 }{
1137 "should record native histogram discarded": {
1138 reqs: []*cortexpb.WriteRequest{
1139 cortexpb.ToWriteRequest(
1140 []labels.Labels{metricLabels},
1141 []cortexpb.Sample{{Value: 2, TimestampMs: 10}},
1142 []*cortexpb.MetricMetadata{
1143 {MetricFamilyName: "metric_name_2", Help: "a help for metric_name_2", Unit: "", Type: cortexpb.GAUGE},
1144 },
1145 []cortexpb.WrappedHistogram{
1146 {Histogram: cortexpb.Histogram{
1147 TimestampMs: 10,
1148 }},
1149 },
1150 cortexpb.API),
1151 },
1152 expectedErr: nil,
1153 expectedIngested: []cortexpb.TimeSeries{
1154 {Labels: metricLabelAdapters, Samples: []cortexpb.Sample{{Value: 2, TimestampMs: 10}}},
1155 },
1156 expectedMetadataIngested: []*cortexpb.MetricMetadata{
1157 {MetricFamilyName: "metric_name_2", Help: "a help for metric_name_2", Unit: "", Type: cortexpb.GAUGE},
1158 },
1159 additionalMetrics: []string{"cortex_discarded_samples_total", "cortex_ingester_active_series", "cortex_ingester_active_native_histogram_series"},
1160 disableNativeHistogram: true,
1161 expectedMetrics: `
1162 # HELP cortex_ingester_ingested_samples_total The total number of samples ingested.
1163 # TYPE cortex_ingester_ingested_samples_total counter
1164 cortex_ingester_ingested_samples_total 1
1165 # HELP cortex_ingester_ingested_samples_failures_total The total number of samples that errored on ingestion.
1166 # TYPE cortex_ingester_ingested_samples_failures_total counter

Callers

nothing calls this directly

Calls 15

WrapHistogramFunction · 0.92
ToWriteRequestFunction · 0.92
StartAndAwaitRunningFunction · 0.92
StopAndAwaitTerminatedFunction · 0.92
PollFunction · 0.92
SeriesSetToQueryResponseFunction · 0.92
wrapWithUserFunction · 0.85
wrappedTSDBIngestErrFunction · 0.85

Tested by

no test coverage detected