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

Function TestDB

tempodb/tempodb_test.go:77–126  ·  tempodb/tempodb_test.go::TestDB
(t *testing.T)

Source from the content-addressed store, hash-verified

75}
76
77func TestDB(t *testing.T) {
78 r, w, c, _ := testConfig(t, 0)
79
80 ctx, cancel := context.WithCancel(context.Background())
81 defer cancel()
82
83 err := c.EnableCompaction(ctx, &CompactorConfig{
84 MaxCompactionRange: time.Hour,
85 BlockRetention: 0,
86 CompactedBlockRetention: 0,
87 }, &mockSharder{}, &mockOverrides{})
88 require.NoError(t, err)
89
90 r.EnablePolling(ctx, &mockJobSharder{}, false)
91
92 blockID := backend.NewUUID()
93
94 wal := w.WAL()
95
96 meta := &backend.BlockMeta{BlockID: blockID, TenantID: testTenantID}
97 head, err := wal.NewBlock(meta, model.CurrentEncoding)
98 assert.NoError(t, err)
99
100 dec := model.MustNewSegmentDecoder(model.CurrentEncoding)
101
102 // write
103 numMsgs := 10
104 reqs := make([]*tempopb.Trace, numMsgs)
105 ids := make([]common.ID, numMsgs)
106 for i := 0; i < numMsgs; i++ {
107 ids[i] = test.ValidTraceID(nil)
108 reqs[i] = test.MakeTrace(10, ids[i])
109 writeTraceToWal(t, head, dec, ids[i], reqs[i], 0, 0)
110 }
111
112 _, err = w.CompleteBlock(ctx, head)
113 assert.NoError(t, err)
114
115 // poll
116 r.(*readerWriter).pollBlocklist(ctx)
117
118 // read
119 for i, id := range ids {
120 bFound, failedBlocks, err := r.Find(ctx, testTenantID, id, BlockIDMin, BlockIDMax, 0, 0, common.DefaultSearchOptions())
121 assert.NoError(t, err)
122 assert.Nil(t, failedBlocks)
123 assert.True(t, proto.Equal(bFound[0].Trace, reqs[i]))
124 require.Greater(t, bFound[0].Metrics.InspectedBytes, uint64(100000))
125 }
126}
127
128func TestNoCompactionWhenCompactionRange0(t *testing.T) {
129 _, _, c, _ := testConfig(t, 0)

Callers

nothing calls this directly

Calls 15

NewUUIDFunction · 0.92
MustNewSegmentDecoderFunction · 0.92
ValidTraceIDFunction · 0.92
MakeTraceFunction · 0.92
DefaultSearchOptionsFunction · 0.92
NewBlockMethod · 0.80
pollBlocklistMethod · 0.80
testConfigFunction · 0.70
writeTraceToWalFunction · 0.70
EnableCompactionMethod · 0.65
EnablePollingMethod · 0.65
WALMethod · 0.65

Tested by

no test coverage detected