(t *testing.T, scenario sampleTypeScenario)
| 6775 | } |
| 6776 | |
| 6777 | func testOOOAppendAndQuery(t *testing.T, scenario sampleTypeScenario) { |
| 6778 | opts := DefaultOptions() |
| 6779 | opts.OutOfOrderCapMax = 30 |
| 6780 | opts.OutOfOrderTimeWindow = 4 * time.Hour.Milliseconds() |
| 6781 | |
| 6782 | db := newTestDB(t, withOpts(opts)) |
| 6783 | db.DisableCompactions() |
| 6784 | |
| 6785 | s1 := labels.FromStrings("foo", "bar1") |
| 6786 | s2 := labels.FromStrings("foo", "bar2") |
| 6787 | |
| 6788 | minutes := func(m int64) int64 { return m * time.Minute.Milliseconds() } |
| 6789 | appendedSamples := make(map[string][]chunks.Sample) |
| 6790 | totalSamples := 0 |
| 6791 | addSample := func(lbls labels.Labels, fromMins, toMins int64, faceError bool) { |
| 6792 | app := db.Appender(context.Background()) |
| 6793 | key := lbls.String() |
| 6794 | from, to := minutes(fromMins), minutes(toMins) |
| 6795 | for m := from; m <= to; m += time.Minute.Milliseconds() { |
| 6796 | val := rand.Intn(1000) |
| 6797 | _, s, err := scenario.appendFunc(app, lbls, m, int64(val)) |
| 6798 | if faceError { |
| 6799 | require.Error(t, err) |
| 6800 | } else { |
| 6801 | require.NoError(t, err) |
| 6802 | appendedSamples[key] = append(appendedSamples[key], s) |
| 6803 | totalSamples++ |
| 6804 | } |
| 6805 | } |
| 6806 | if faceError { |
| 6807 | require.NoError(t, app.Rollback()) |
| 6808 | } else { |
| 6809 | require.NoError(t, app.Commit()) |
| 6810 | } |
| 6811 | } |
| 6812 | |
| 6813 | testQuery := func(from, to int64) { |
| 6814 | querier, err := db.Querier(from, to) |
| 6815 | require.NoError(t, err) |
| 6816 | |
| 6817 | seriesSet := query(t, querier, labels.MustNewMatcher(labels.MatchRegexp, "foo", "bar.")) |
| 6818 | |
| 6819 | for k, v := range appendedSamples { |
| 6820 | sort.Slice(v, func(i, j int) bool { |
| 6821 | return v[i].T() < v[j].T() |
| 6822 | }) |
| 6823 | appendedSamples[k] = v |
| 6824 | } |
| 6825 | |
| 6826 | expSamples := make(map[string][]chunks.Sample) |
| 6827 | for k, samples := range appendedSamples { |
| 6828 | for _, s := range samples { |
| 6829 | if s.T() < from { |
| 6830 | continue |
| 6831 | } |
| 6832 | if s.T() > to { |
| 6833 | continue |
| 6834 | } |
no test coverage detected
searching dependent graphs…