MCPcopy
hub / github.com/grafana/tempo / TestArtificialLatency

Function TestArtificialLatency

modules/distributor/distributor_test.go:1707–1736  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1705}
1706
1707func TestArtificialLatency(t *testing.T) {
1708 // prepare test data
1709 overridesConfig := overrides.Config{}
1710 overridesConfig.RegisterFlagsAndApplyDefaults(&flag.FlagSet{})
1711
1712 latency := 50 * time.Millisecond
1713 buf := &bytes.Buffer{}
1714 logger := kitlog.NewJSONLogger(kitlog.NewSyncWriter(buf))
1715 d := prepare(t, overridesConfig, logger)
1716 d.cfg.ArtificialDelay = latency
1717
1718 batches := []*v1.ResourceSpans{
1719 makeResourceSpans("test-service", []*v1.ScopeSpans{
1720 makeScope(
1721 makeSpan("0a0102030405060708090a0b0c0d0e0f", "dad44adc9a83b370", "Test Span1", nil)),
1722 makeScope(
1723 makeSpan("bb42ec04df789ff04b10ea5274491685", "1b3a296034f4031e", "Test Span3", nil)),
1724 }),
1725 }
1726
1727 traces := batchesToTraces(t, batches)
1728 reqStart := time.Now()
1729 _, err := d.PushTraces(ctx, traces)
1730 if err != nil {
1731 t.Fatal(err)
1732 }
1733
1734 const tolerance = 10 * time.Millisecond
1735 assert.GreaterOrEqual(t, time.Since(reqStart)+tolerance, latency, "Expected artificial latency not respected")
1736}
1737
1738func TestArtificialLatencyIsAppliedOnError(t *testing.T) {
1739 // prepare test data

Callers

nothing calls this directly

Calls 8

prepareFunction · 0.85
makeResourceSpansFunction · 0.85
makeScopeFunction · 0.85
makeSpanFunction · 0.85
batchesToTracesFunction · 0.85
NowMethod · 0.65
PushTracesMethod · 0.65

Tested by

no test coverage detected