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

Function verifyOTLPWriteRequestHandler

pkg/util/push/otlp_test.go:1317–1331  ·  view source on GitHub ↗
(t *testing.T, expectSource cortexpb.SourceEnum)

Source from the content-addressed store, hash-verified

1315}
1316
1317func verifyOTLPWriteRequestHandler(t *testing.T, expectSource cortexpb.SourceEnum) func(ctx context.Context, request *cortexpb.WriteRequest) (response *cortexpb.WriteResponse, err error) {
1318 t.Helper()
1319 return func(ctx context.Context, request *cortexpb.WriteRequest) (response *cortexpb.WriteResponse, err error) {
1320 assert.Len(t, request.Timeseries, 13) // 1 (target_info) + 1 (counter) + 1 (gauge) + 7 (hist_bucket) + 2 (hist_sum, hist_count) + 1 (exponential histogram)
1321 // TODO: test more things
1322 assert.Equal(t, expectSource, request.Source)
1323 assert.False(t, request.SkipLabelNameValidation)
1324 for _, ts := range request.Timeseries {
1325 assert.NotEmpty(t, ts.Labels)
1326 // Make sure at least one of sample, exemplar or histogram is set.
1327 assert.True(t, len(ts.Samples) > 0 || len(ts.Exemplars) > 0 || len(ts.Histograms) > 0)
1328 }
1329 return &cortexpb.WriteResponse{}, nil
1330 }
1331}

Callers 2

TestOTLPWriteHandlerFunction · 0.85

Calls 2

EqualMethod · 0.65
LenMethod · 0.45

Tested by

no test coverage detected