2019-05-22 21:16:55 +00:00
|
|
|
package storage
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestTableOpenClose(t *testing.T) {
|
|
|
|
const path = "TestTableOpenClose"
|
2020-10-20 11:29:26 +00:00
|
|
|
const retentionMsecs = 123 * msecsPerMonth
|
2019-05-22 21:16:55 +00:00
|
|
|
|
|
|
|
if err := os.RemoveAll(path); err != nil {
|
|
|
|
t.Fatalf("cannot remove %q: %s", path, err)
|
|
|
|
}
|
|
|
|
defer func() {
|
|
|
|
_ = os.RemoveAll(path)
|
|
|
|
}()
|
|
|
|
|
|
|
|
// Create a new table
|
2022-10-23 13:23:44 +00:00
|
|
|
strg := newTestStorage()
|
2022-10-23 22:30:50 +00:00
|
|
|
strg.retentionMsecs = retentionMsecs
|
2023-04-15 06:01:20 +00:00
|
|
|
tb := mustOpenTable(path, strg)
|
2019-05-22 21:16:55 +00:00
|
|
|
|
|
|
|
// Close it
|
|
|
|
tb.MustClose()
|
|
|
|
|
|
|
|
// Re-open created table multiple times.
|
|
|
|
for i := 0; i < 10; i++ {
|
2023-04-15 06:01:20 +00:00
|
|
|
tb := mustOpenTable(path, strg)
|
2019-05-22 21:16:55 +00:00
|
|
|
tb.MustClose()
|
|
|
|
}
|
2023-07-14 00:13:24 +00:00
|
|
|
|
|
|
|
stopTestStorage(strg)
|
2019-05-22 21:16:55 +00:00
|
|
|
}
|