(t *testing.T)
| 4136 | } |
| 4137 | |
| 4138 | func TestOOOWALWrite(t *testing.T) { |
| 4139 | minutes := func(m int64) int64 { return m * time.Minute.Milliseconds() } |
| 4140 | |
| 4141 | s := labels.NewSymbolTable() |
| 4142 | scratchBuilder1 := labels.NewScratchBuilderWithSymbolTable(s, 1) |
| 4143 | scratchBuilder1.Add("l", "v1") |
| 4144 | s1 := scratchBuilder1.Labels() |
| 4145 | scratchBuilder2 := labels.NewScratchBuilderWithSymbolTable(s, 1) |
| 4146 | scratchBuilder2.Add("l", "v2") |
| 4147 | s2 := scratchBuilder2.Labels() |
| 4148 | |
| 4149 | scenarios := map[string]struct { |
| 4150 | appendSample func(app storage.Appender, l labels.Labels, mins int64) (storage.SeriesRef, error) |
| 4151 | expectedOOORecords []any |
| 4152 | expectedInORecords []any |
| 4153 | }{ |
| 4154 | "float": { |
| 4155 | appendSample: func(app storage.Appender, l labels.Labels, mins int64) (storage.SeriesRef, error) { |
| 4156 | seriesRef, err := app.Append(0, l, minutes(mins), float64(mins)) |
| 4157 | require.NoError(t, err) |
| 4158 | return seriesRef, nil |
| 4159 | }, |
| 4160 | expectedOOORecords: []any{ |
| 4161 | // The MmapRef in this are not hand calculated, and instead taken from the test run. |
| 4162 | // What is important here is the order of records, and that MmapRef increases for each record. |
| 4163 | []record.RefMmapMarker{ |
| 4164 | {Ref: 1}, |
| 4165 | }, |
| 4166 | []record.RefSample{ |
| 4167 | {Ref: 1, T: minutes(40), V: 40}, |
| 4168 | }, |
| 4169 | |
| 4170 | []record.RefMmapMarker{ |
| 4171 | {Ref: 2}, |
| 4172 | }, |
| 4173 | []record.RefSample{ |
| 4174 | {Ref: 2, T: minutes(42), V: 42}, |
| 4175 | }, |
| 4176 | |
| 4177 | []record.RefSample{ |
| 4178 | {Ref: 2, T: minutes(45), V: 45}, |
| 4179 | {Ref: 1, T: minutes(35), V: 35}, |
| 4180 | }, |
| 4181 | []record.RefMmapMarker{ // 3rd sample, hence m-mapped. |
| 4182 | {Ref: 1, MmapRef: 0x100000000 + 8}, |
| 4183 | }, |
| 4184 | []record.RefSample{ |
| 4185 | {Ref: 1, T: minutes(36), V: 36}, |
| 4186 | {Ref: 1, T: minutes(37), V: 37}, |
| 4187 | }, |
| 4188 | |
| 4189 | []record.RefMmapMarker{ // 3rd sample, hence m-mapped. |
| 4190 | {Ref: 1, MmapRef: 0x100000000 + 58}, |
| 4191 | }, |
| 4192 | []record.RefSample{ // Does not contain the in-order sample here. |
| 4193 | {Ref: 1, T: minutes(50), V: 50}, |
| 4194 | }, |
| 4195 |
nothing calls this directly
no test coverage detected
searching dependent graphs…