mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
tests: check Metrics.RowsAddedTotal in unit tests (#6895)
### Describe Your Changes This is a follow-up PR: Unit tests introduced in #6872 can now use RowsAddedTotal counter whose scope was fixed in #6841. ### Checklist The following checks are **mandatory**: - [x] My change adheres [VictoriaMetrics contributing guidelines](https://docs.victoriametrics.com/contributing/). Signed-off-by: Artem Fetishev <wwctrsrx@gmail.com> Co-authored-by: Nikolay <nik@victoriametrics.com>
This commit is contained in:
parent
f586082520
commit
2c856c6951
1 changed files with 15 additions and 0 deletions
|
@ -1733,6 +1733,7 @@ func testStorageVariousDataPatterns(t *testing.T, registerOnly bool, op func(s *
|
|||
sameRowDates: sameRowDates,
|
||||
})
|
||||
strict := concurrency == 1
|
||||
rowsAddedTotal := wantCounts.metrics.RowsAddedTotal
|
||||
|
||||
s := MustOpenStorage(t.Name(), 0, 0, 0)
|
||||
|
||||
|
@ -1745,6 +1746,7 @@ func testStorageVariousDataPatterns(t *testing.T, registerOnly bool, op func(s *
|
|||
s.mustRotateIndexDB(time.Now())
|
||||
testDoConcurrently(s, op, concurrency, splitBatches, batches)
|
||||
s.DebugFlush()
|
||||
wantCounts.metrics.RowsAddedTotal += rowsAddedTotal
|
||||
assertCounts(t, s, wantCounts, strict)
|
||||
|
||||
// Empty the tsidCache to test the case when tsid is retrived from the
|
||||
|
@ -1752,6 +1754,7 @@ func testStorageVariousDataPatterns(t *testing.T, registerOnly bool, op func(s *
|
|||
s.resetAndSaveTSIDCache()
|
||||
testDoConcurrently(s, op, concurrency, splitBatches, batches)
|
||||
s.DebugFlush()
|
||||
wantCounts.metrics.RowsAddedTotal += rowsAddedTotal
|
||||
assertCounts(t, s, wantCounts, strict)
|
||||
|
||||
// Empty the tsidCache and rotate indexDB to test the case when tsid is
|
||||
|
@ -1761,6 +1764,7 @@ func testStorageVariousDataPatterns(t *testing.T, registerOnly bool, op func(s *
|
|||
s.mustRotateIndexDB(time.Now())
|
||||
testDoConcurrently(s, op, concurrency, splitBatches, batches)
|
||||
s.DebugFlush()
|
||||
wantCounts.metrics.RowsAddedTotal += rowsAddedTotal
|
||||
assertCounts(t, s, wantCounts, strict)
|
||||
|
||||
s.MustClose()
|
||||
|
@ -1943,6 +1947,10 @@ func assertCounts(t *testing.T, s *Storage, want *counts, strict bool) {
|
|||
|
||||
var gotMetrics Metrics
|
||||
s.UpdateMetrics(&gotMetrics)
|
||||
if got, want := gotMetrics.RowsAddedTotal, want.metrics.RowsAddedTotal; got != want {
|
||||
t.Errorf("unexpected Metrics.RowsAddedTotal: got %d, want %d", got, want)
|
||||
}
|
||||
|
||||
gotCnt, wantCnt := gotMetrics.NewTimeseriesCreated, want.metrics.NewTimeseriesCreated
|
||||
if strict {
|
||||
if gotCnt != wantCnt {
|
||||
|
@ -2063,8 +2071,15 @@ func testGenerateMetricRowBatches(opts *batchOptions) ([][]MetricRow, *counts) {
|
|||
}
|
||||
|
||||
allTimeseries := len(names)
|
||||
rowsAddedTotal := uint64(opts.numBatches * opts.numRowsPerBatch)
|
||||
// When RegisterMetricNames() is called it only restisters the time series
|
||||
// in IndexDB but no samples is written to the storage.
|
||||
if opts.registerOnly {
|
||||
rowsAddedTotal = 0
|
||||
}
|
||||
want := counts{
|
||||
metrics: &Metrics{
|
||||
RowsAddedTotal: rowsAddedTotal,
|
||||
NewTimeseriesCreated: uint64(allTimeseries),
|
||||
},
|
||||
timeRangeCounts: make(map[TimeRange]int),
|
||||
|
|
Loading…
Reference in a new issue