-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
61fe287
commit 2c73554
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
core/src/test/scala/filodb.core/memstore/ratelimit/RocksDbCardinalityStoreSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package filodb.core.memstore.ratelimit | ||
|
||
import org.scalatest.funspec.AnyFunSpec | ||
import org.scalatest.matchers.should.Matchers | ||
|
||
import filodb.core.memstore.ratelimit.CardinalityStore._ | ||
import filodb.core.MetricsTestData | ||
|
||
class RocksDbCardinalityStoreSpec extends AnyFunSpec with Matchers { | ||
it ("should correctly return overflow record") { | ||
val dset = MetricsTestData.timeseriesDatasetMultipleShardKeys | ||
val shard = 0 | ||
val numOverflow = 123 | ||
|
||
val db = new RocksDbCardinalityStore(dset.ref, shard) | ||
|
||
(0 until MAX_RESULT_SIZE + numOverflow).foreach{ i => | ||
val prefix = Seq("ws", "ns", s"metric-$i") | ||
db.store(CardinalityRecord(shard, prefix, 1, 1, 1, 1)) | ||
} | ||
|
||
Seq(Nil, Seq("ws"), Seq("ws", "ns")).foreach{ prefix => | ||
val res = db.scanChildren(prefix, 3) | ||
res.size shouldEqual MAX_RESULT_SIZE + 1 // one extra for the overflow CardinalityRecord | ||
res.contains(CardinalityRecord(shard, OVERFLOW_PREFIX, | ||
numOverflow, numOverflow, numOverflow, numOverflow)) shouldEqual true | ||
} | ||
} | ||
} |