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

Function TestLiveStoreLookback

integration/operations/livestore_test.go:165–246  ·  integration/operations/livestore_test.go::TestLiveStoreLookback
(t *testing.T)

Source from the content-addressed store, hash-verified

163}
164
165func TestLiveStoreLookback(t *testing.T) {
166 for _, testCase := range []struct {
167 name string
168 configOverlay string
169 startNewLiveStore bool
170 expectedTraces float64
171 }{
172 {
173 name: "restart_2s",
174 configOverlay: "config-livestore-short-timeout.yaml", // lookback period twice greater
175 startNewLiveStore: false,
176 expectedTraces: 2, // fresh and after start
177 },
178 {
179 name: "restart_default",
180 configOverlay: "", // default is 1h
181 startNewLiveStore: false,
182 expectedTraces: 3, // old, fresh and after start, but not already committed
183 },
184 {
185 name: "start_2s",
186 configOverlay: "config-livestore-short-timeout.yaml", // lookback period twice greater
187 startNewLiveStore: true,
188 expectedTraces: 2, // fresh and after start
189 },
190 {
191 name: "start_default",
192 configOverlay: "", // default is 1h
193 startNewLiveStore: true,
194 expectedTraces: 4, // all traces
195 },
196 } {
197 t.Run(testCase.name, func(t *testing.T) {
198 util.RunIntegrationTests(t, util.TestHarnessConfig{
199 ConfigOverlay: testCase.configOverlay,
200 }, func(h *util.TempoHarness) {
201 // Start initial live store
202 liveStoreB := h.Services[util.ServiceLiveStoreZoneB]
203 require.NoError(t, liveStoreB.Stop())
204
205 h.WaitTracesWritable(t)
206
207 // Write first trace - will be committed by the first live store before shutdown
208 info := tempoUtil.NewTraceInfo(time.Now(), "")
209 require.NoError(t, h.WriteTraceInfo(info, ""))
210
211 // wait queryable
212 liveStoreA := h.Services[util.ServiceLiveStoreZoneA]
213 require.NoError(t, liveStoreA.WaitSumMetricsWithOptions(e2e.GreaterOrEqual(float64(1)), []string{"tempo_live_store_traces_created_total"}, e2e.WaitMissingMetrics))
214
215 // Stop the live store
216 require.NoError(t, liveStoreA.Stop())
217
218 // Write old trace (during downtime)
219 require.NoError(t, h.WriteTraceInfo(tempoUtil.NewTraceInfo(time.Now(), ""), ""))
220 time.Sleep(3 * time.Second)
221
222 // Write fresh trace (during downtime)

Callers

nothing calls this directly

Calls 7

WaitTracesWritableMethod · 0.80
WriteTraceInfoMethod · 0.80
StopMethod · 0.65
NowMethod · 0.65
SleepMethod · 0.65
StartMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected