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

Function TestIsLagged

modules/livestore/live_store_test.go:1108–1246  ·  modules/livestore/live_store_test.go::TestIsLagged
(t *testing.T)

Source from the content-addressed store, hash-verified

1106}
1107
1108func TestIsLagged(t *testing.T) {
1109 now := time.Now()
1110 testCases := []struct {
1111 name string
1112 failOnHighLag bool
1113 readerLag int64
1114 lastRecordNano int64
1115 end time.Time
1116 expectedLagged bool
1117 expectedError bool
1118 description string
1119 }{
1120 {
1121 name: "config disabled - never lagged",
1122 failOnHighLag: false,
1123 readerLag: 50000000, // high lag
1124 lastRecordNano: now.Add(-100 * time.Hour).UnixNano(), // high lag
1125 end: now.Add(-1 * time.Second),
1126 expectedLagged: true,
1127 expectedError: false,
1128 description: "When FailOnHighLag is disabled, isLagged should returns true, but methods should not return error",
1129 },
1130 {
1131 name: "lag unknown - should be lagged",
1132 failOnHighLag: true,
1133 readerLag: -1, // lag unknown
1134 lastRecordNano: now.Add(-100 * time.Hour).UnixNano(), // high lag
1135 end: now,
1136 expectedLagged: true,
1137 expectedError: true,
1138 description: "When lag is unknown (nil), prefer error over potentially incomplete results",
1139 },
1140 {
1141 name: "no last record - should be lagged",
1142 failOnHighLag: true,
1143 readerLag: 10, // low lag
1144 lastRecordNano: -1, // no last record yet
1145 end: now,
1146 expectedLagged: true,
1147 expectedError: true,
1148 description: "When no last record yet, should not be lagged",
1149 },
1150 {
1151 name: "no lag - recent request - not lagged",
1152 failOnHighLag: true,
1153 readerLag: 100, // low lag
1154 lastRecordNano: now.UnixNano(), // no lag
1155 end: now.Add(-1 * time.Second),
1156 expectedLagged: false,
1157 expectedError: false,
1158 description: "When lag is low (near zero), recent requests should not be lagged",
1159 },
1160 {
1161 name: "high lag - recent request - should be lagged",
1162 failOnHighLag: true,
1163 readerLag: 5000, // high lag
1164 lastRecordNano: now.Add(-10 * time.Second).UnixNano(), // 10 seconds ago
1165 end: now.Add(-5 * time.Second), // 5 seconds ago

Callers

nothing calls this directly

Calls 11

defaultLiveStoreFunction · 0.85
isLaggedMethod · 0.80
NowMethod · 0.65
AddMethod · 0.65
StoreMethod · 0.65
ContextMethod · 0.65
SearchRecentMethod · 0.65
QueryRangeMethod · 0.65
RunMethod · 0.45
getOrCreateInstanceMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected