(t *testing.T, appTest *Appendable, a storage.AppendableV2)
| 82 | } |
| 83 | |
| 84 | func testAppendableV2(t *testing.T, appTest *Appendable, a storage.AppendableV2) { |
| 85 | for _, commit := range []bool{true, false} { |
| 86 | appTest.ResultReset() |
| 87 | |
| 88 | app := a.AppenderV2(t.Context()) |
| 89 | |
| 90 | m1 := metadata.Metadata{Type: "gauge", Unit: "", Help: "other help text"} |
| 91 | e1 := exemplar.Exemplar{Labels: labels.FromStrings(model.MetricNameLabel, "yolo"), HasTs: true, Ts: 1} |
| 92 | _, err := app.Append(0, labels.FromStrings(model.MetricNameLabel, "test_metric1", "app", "v2"), -1, 1, 2, nil, nil, storage.AOptions{ |
| 93 | MetricFamilyName: "test_metric1", |
| 94 | Metadata: m1, |
| 95 | Exemplars: []exemplar.Exemplar{e1}, |
| 96 | }) |
| 97 | require.NoError(t, err) |
| 98 | |
| 99 | h := tsdbutil.GenerateTestHistogram(0) |
| 100 | _, err = app.Append(0, labels.FromStrings(model.MetricNameLabel, "test_metric2", "app", "v2"), -2, 2, 0, h, nil, storage.AOptions{}) |
| 101 | require.NoError(t, err) |
| 102 | |
| 103 | fh := tsdbutil.GenerateTestFloatHistogram(0) |
| 104 | _, err = app.Append(0, labels.FromStrings(model.MetricNameLabel, "test_metric3", "app", "v2"), -3, 3, 0, nil, fh, storage.AOptions{}) |
| 105 | require.NoError(t, err) |
| 106 | |
| 107 | exp := []Sample{ |
| 108 | {L: labels.FromStrings(model.MetricNameLabel, "test_metric1", "app", "v2"), MF: "test_metric1", M: m1, ST: -1, T: 1, V: 2, ES: []exemplar.Exemplar{e1}}, |
| 109 | {L: labels.FromStrings(model.MetricNameLabel, "test_metric2", "app", "v2"), ST: -2, T: 2, H: h}, |
| 110 | {L: labels.FromStrings(model.MetricNameLabel, "test_metric3", "app", "v2"), ST: -3, T: 3, FH: fh}, |
| 111 | } |
| 112 | testutil.RequireEqual(t, exp, appTest.PendingSamples()) |
| 113 | require.Nil(t, appTest.ResultSamples()) |
| 114 | require.Nil(t, appTest.RolledbackSamples()) |
| 115 | |
| 116 | if commit { |
| 117 | require.NoError(t, app.Commit()) |
| 118 | require.Nil(t, appTest.PendingSamples()) |
| 119 | testutil.RequireEqual(t, exp, appTest.ResultSamples()) |
| 120 | require.Nil(t, appTest.RolledbackSamples()) |
| 121 | break |
| 122 | } |
| 123 | |
| 124 | require.NoError(t, app.Rollback()) |
| 125 | require.Nil(t, appTest.PendingSamples()) |
| 126 | require.Nil(t, appTest.ResultSamples()) |
| 127 | testutil.RequireEqual(t, exp, appTest.RolledbackSamples()) |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | func TestAppendable(t *testing.T) { |
| 132 | appTest := NewAppendable() |
no test coverage detected
searching dependent graphs…