mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-23 12:31:07 +01:00
lib/mergeset: add a test for too long item passed to Table.AddItems()
This commit is contained in:
parent
5817e4c0c1
commit
0f5176380b
@ -244,6 +244,7 @@ func (ris *rawItemsShard) addItems(tb *Table, items [][]byte) [][]byte {
|
||||
ibs = append(ibs, ib)
|
||||
continue
|
||||
}
|
||||
ris.mu.Unlock()
|
||||
logger.Panicf("BUG: cannot insert too big item into an empty inmemoryBlock; len(item)=%d; the caller should be responsible for avoiding too big items", len(item))
|
||||
}
|
||||
ris.ibs = ibs
|
||||
|
@ -33,6 +33,27 @@ func TestTableOpenClose(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestTableAddItemsTooLongItem(t *testing.T) {
|
||||
const path = "TestTableAddItemsTooLongItem"
|
||||
if err := os.RemoveAll(path); err != nil {
|
||||
t.Fatalf("cannot remove %q: %s", path, err)
|
||||
}
|
||||
|
||||
var isReadOnly uint32
|
||||
tb := MustOpenTable(path, nil, nil, &isReadOnly)
|
||||
func() {
|
||||
defer func() {
|
||||
if r := recover(); r == nil {
|
||||
t.Fatalf("expecting panic")
|
||||
}
|
||||
}()
|
||||
tb.AddItems([][]byte{make([]byte, maxInmemoryBlockSize+1)})
|
||||
}()
|
||||
t.Logf("foobar")
|
||||
tb.MustClose()
|
||||
_ = os.RemoveAll(path)
|
||||
}
|
||||
|
||||
func TestTableAddItemsSerial(t *testing.T) {
|
||||
r := rand.New(rand.NewSource(1))
|
||||
const path = "TestTableAddItemsSerial"
|
||||
|
Loading…
Reference in New Issue
Block a user