mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-16 00:41:24 +01:00
39 lines
723 B
Go
39 lines
723 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, err := openTable(path, strg)
|
|
if err != nil {
|
|
t.Fatalf("cannot create new table: %s", err)
|
|
}
|
|
|
|
// Close it
|
|
tb.MustClose()
|
|
|
|
// Re-open created table multiple times.
|
|
for i := 0; i < 10; i++ {
|
|
tb, err := openTable(path, strg)
|
|
if err != nil {
|
|
t.Fatalf("cannot open created table: %s", err)
|
|
}
|
|
tb.MustClose()
|
|
}
|
|
}
|