From 00e0760608c4c1f2f617bbbe7d61ed9ac2607dd3 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Mon, 10 Jun 2019 12:36:42 +0300 Subject: [PATCH] lib/storage: test GetSeriesCount --- lib/storage/index_db_test.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/storage/index_db_test.go b/lib/storage/index_db_test.go index acdbd67e48..f571ab72dc 100644 --- a/lib/storage/index_db_test.go +++ b/lib/storage/index_db_test.go @@ -405,6 +405,21 @@ func testIndexDBCheckTSIDByName(db *indexDB, mns []MetricName, tsids []TSID, isC } } + // Check timerseriesCounters only for serial test. + // Concurrent test may create duplicate timeseries, so GetSeriesCount + // would return more timeseries than needed. + if !isConcurrent { + for k, tc := range timeseriesCounters { + n, err := db.GetSeriesCount(k.AccountID, k.ProjectID) + if err != nil { + return fmt.Errorf("unexpected error in GetSeriesCount(%v): %s", k, err) + } + if n != uint64(len(tc)) { + return fmt.Errorf("unexpected GetSeriesCount(%v); got %d; want %d", k, n, uint64(len(tc))) + } + } + } + // Try tag filters. for i := range mns { mn := &mns[i]