(t *testing.T)
| 171 | } |
| 172 | |
| 173 | func TestWriteV2RequestFixture(t *testing.T) { |
| 174 | // Generate dynamically writeV2RequestFixture, reusing v1 fixture elements. |
| 175 | st := writev2.NewSymbolTable() |
| 176 | b := labels.NewScratchBuilder(0) |
| 177 | labelRefs := st.SymbolizeLabels(writeRequestFixture.Timeseries[0].ToLabels(&b, nil), nil) |
| 178 | exemplar1LabelRefs := st.SymbolizeLabels(writeRequestFixture.Timeseries[0].Exemplars[0].ToExemplar(&b, nil).Labels, nil) |
| 179 | exemplar2LabelRefs := st.SymbolizeLabels(writeRequestFixture.Timeseries[1].Exemplars[0].ToExemplar(&b, nil).Labels, nil) |
| 180 | expected := &writev2.Request{ |
| 181 | Timeseries: []writev2.TimeSeries{ |
| 182 | { |
| 183 | LabelsRefs: labelRefs, |
| 184 | Metadata: writev2.Metadata{ |
| 185 | Type: writev2.Metadata_METRIC_TYPE_GAUGE, |
| 186 | HelpRef: st.Symbolize(writeV2RequestSeries1Metadata.Help), |
| 187 | UnitRef: st.Symbolize(writeV2RequestSeries1Metadata.Unit), |
| 188 | }, |
| 189 | Samples: []writev2.Sample{{Value: 1, Timestamp: 10, StartTimestamp: 1}}, |
| 190 | Exemplars: []writev2.Exemplar{{LabelsRefs: exemplar1LabelRefs, Value: 1, Timestamp: 10}}, |
| 191 | Histograms: []writev2.Histogram{ |
| 192 | writev2.FromIntHistogram(10, &testHistogram), |
| 193 | writev2.FromFloatHistogram(20, testHistogram.ToFloat(nil)), |
| 194 | writev2.FromIntHistogram(30, &testHistogramCustomBuckets), |
| 195 | writev2.FromFloatHistogram(40, testHistogramCustomBuckets.ToFloat(nil)), |
| 196 | }, |
| 197 | }, |
| 198 | { |
| 199 | LabelsRefs: labelRefs, |
| 200 | Metadata: writev2.Metadata{ |
| 201 | Type: writev2.Metadata_METRIC_TYPE_COUNTER, |
| 202 | HelpRef: st.Symbolize(writeV2RequestSeries2Metadata.Help), |
| 203 | // No unit. |
| 204 | }, |
| 205 | Samples: []writev2.Sample{{Value: 2, Timestamp: 20}}, |
| 206 | Exemplars: []writev2.Exemplar{{LabelsRefs: exemplar2LabelRefs, Value: 2, Timestamp: 20}}, |
| 207 | Histograms: []writev2.Histogram{ |
| 208 | writev2.FromIntHistogram(50, &testHistogram), |
| 209 | writev2.FromFloatHistogram(60, testHistogram.ToFloat(nil)), |
| 210 | writev2.FromIntHistogram(70, &testHistogramCustomBuckets), |
| 211 | writev2.FromFloatHistogram(80, testHistogramCustomBuckets.ToFloat(nil)), |
| 212 | }, |
| 213 | }, |
| 214 | }, |
| 215 | Symbols: st.Symbols(), |
| 216 | } |
| 217 | // Check if it matches static writeV2RequestFixture. |
| 218 | require.Equal(t, expected, writeV2RequestFixture) |
| 219 | } |
| 220 | |
| 221 | func TestValidateLabelsAndMetricName(t *testing.T) { |
| 222 | tests := []struct { |
nothing calls this directly
no test coverage detected
searching dependent graphs…