VictoriaMetrics/lib/storage/table_test.go
Aliaksandr Valialkin d739511f5b
lib/storage: replace OpenStorage() with MustOpenStorage()
Callers of OpenStorage() log the returned error and exit.
The error logging and exit can be performed inside MustOpenStorage()
alongside with printing the stack trace for better debuggability.
This simplifies the code at caller side.
2023-04-14 23:04:42 -07:00

33 lines
582 B
Go

package storage
import (
"os"
"testing"
)
func TestTableOpenClose(t *testing.T) {
const path = "TestTableOpenClose"
const retentionMsecs = 123 * msecsPerMonth
if err := os.RemoveAll(path); err != nil {
t.Fatalf("cannot remove %q: %s", path, err)
}
defer func() {
_ = os.RemoveAll(path)
}()
// Create a new table
strg := newTestStorage()
strg.retentionMsecs = retentionMsecs
tb := mustOpenTable(path, strg)
// Close it
tb.MustClose()
// Re-open created table multiple times.
for i := 0; i < 10; i++ {
tb := mustOpenTable(path, strg)
tb.MustClose()
}
}