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

Function Benchmark_Ingester_PushOnError

pkg/ingester/ingester_test.go:2747–3037  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

2745}
2746
2747func Benchmark_Ingester_PushOnError(b *testing.B) {
2748 var (
2749 ctx = user.InjectOrgID(context.Background(), userID)
2750 sampleTimestamp = int64(100)
2751 metricName = "test"
2752 )
2753
2754 scenarios := map[string]struct {
2755 numSeriesPerRequest int
2756 numConcurrentClients int
2757 }{
2758 "no concurrency": {
2759 numSeriesPerRequest: 1000,
2760 numConcurrentClients: 1,
2761 },
2762 "low concurrency": {
2763 numSeriesPerRequest: 1000,
2764 numConcurrentClients: 100,
2765 },
2766 "high concurrency": {
2767 numSeriesPerRequest: 1000,
2768 numConcurrentClients: 1000,
2769 },
2770 }
2771
2772 instanceLimits := map[string]*InstanceLimits{
2773 "no limits": nil,
2774 "limits set": {MaxIngestionRate: 1000, MaxInMemoryTenants: 1, MaxInMemorySeries: 1000, MaxInflightPushRequests: 1000}, // these match max values from scenarios
2775 }
2776
2777 tests := map[string]struct {
2778 // If this returns false, test is skipped.
2779 prepareConfig func(limits *validation.Limits, instanceLimits *InstanceLimits) bool
2780 beforeBenchmark func(b *testing.B, ingester *Ingester, numSeriesPerRequest int)
2781 runBenchmark func(b *testing.B, ingester *Ingester, metrics []labels.Labels, samples []cortexpb.Sample)
2782 }{
2783 "out of bound samples": {
2784 prepareConfig: func(limits *validation.Limits, instanceLimits *InstanceLimits) bool { return true },
2785 beforeBenchmark: func(b *testing.B, ingester *Ingester, numSeriesPerRequest int) {
2786 // Push a single time series to set the TSDB min time.
2787 currTimeReq := cortexpb.ToWriteRequest(
2788 []labels.Labels{labels.FromStrings(labels.MetricName, metricName)},
2789 []cortexpb.Sample{{Value: 1, TimestampMs: util.TimeToMillis(time.Now())}},
2790 nil,
2791 nil,
2792 cortexpb.API)
2793 _, err := ingester.Push(ctx, currTimeReq)
2794 require.NoError(b, err)
2795 },
2796 runBenchmark: func(b *testing.B, ingester *Ingester, metrics []labels.Labels, samples []cortexpb.Sample) {
2797 expectedErr := storage.ErrOutOfBounds.Error()
2798
2799 // Push out of bound samples.
2800 for b.Loop() {
2801 _, err := ingester.Push(ctx, cortexpb.ToWriteRequest(metrics, samples, nil, nil, cortexpb.API)) // nolint:errcheck
2802
2803 verifyErrorString(b, err, expectedErr)
2804 }

Callers

nothing calls this directly

Calls 15

ToWriteRequestFunction · 0.92
TimeToMillisFunction · 0.92
StartAndAwaitRunningFunction · 0.92
StopAndAwaitTerminatedFunction · 0.92
PollFunction · 0.92
verifyErrorStringFunction · 0.85
generateSamplesForLabelFunction · 0.85
defaultLimitsTestConfigFunction · 0.85
LoopMethod · 0.80
DoneMethod · 0.80

Tested by

no test coverage detected