forked from grafana/tempo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlimits_test.go
60 lines (49 loc) · 1.8 KB
/
limits_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package e2e
import (
"context"
"testing"
"github.com/prometheus/prometheus/model/labels"
"github.com/stretchr/testify/require"
"github.com/grafana/e2e"
util "github.com/grafana/tempo/integration"
)
const (
configLimits = "config-limits.yaml"
)
func TestLimits(t *testing.T) {
s, err := e2e.NewScenario("tempo_e2e")
require.NoError(t, err)
defer s.Close()
require.NoError(t, util.CopyFileToSharedDir(s, configLimits, "config.yaml"))
tempo := util.NewTempoAllInOne()
require.NoError(t, s.StartAndWaitReady(tempo))
// Get port for the otlp receiver endpoint
c, err := util.NewJaegerGRPCClient(tempo.Endpoint(14250))
require.NoError(t, err)
require.NotNil(t, c)
// should fail b/c the trace is too large. each batch should be ~70 bytes
batch := makeThriftBatchWithSpanCount(2)
require.Error(t, c.EmitBatch(context.Background(), batch))
// should fail b/c this will be too many traces
batch = makeThriftBatch()
require.Error(t, c.EmitBatch(context.Background(), batch))
// should fail b/c due to ingestion rate limit
batch = makeThriftBatchWithSpanCount(10)
require.Error(t, c.EmitBatch(context.Background(), batch))
// test limit metrics
err = tempo.WaitSumMetricsWithOptions(e2e.Equals(2),
[]string{"tempo_discarded_spans_total"},
e2e.WithLabelMatchers(labels.MustNewMatcher(labels.MatchEqual, "reason", "trace_too_large")),
)
require.NoError(t, err)
err = tempo.WaitSumMetricsWithOptions(e2e.Equals(1),
[]string{"tempo_discarded_spans_total"},
e2e.WithLabelMatchers(labels.MustNewMatcher(labels.MatchEqual, "reason", "live_traces_exceeded")),
)
require.NoError(t, err)
err = tempo.WaitSumMetricsWithOptions(e2e.Equals(10),
[]string{"tempo_discarded_spans_total"},
e2e.WithLabelMatchers(labels.MustNewMatcher(labels.MatchEqual, "reason", "rate_limited")),
)
require.NoError(t, err)
}