2019-05-22 23:16:55 +02:00
|
|
|
package storage
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestTableOpenClose(t *testing.T) {
|
|
|
|
const path = "TestTableOpenClose"
|
2020-10-20 13:29:26 +02:00
|
|
|
const retentionMsecs = 123 * msecsPerMonth
|
2019-05-22 23:16:55 +02: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 15:23:44 +02:00
|
|
|
strg := newTestStorage()
|
2022-10-24 00:30:50 +02:00
|
|
|
strg.retentionMsecs = retentionMsecs
|
2023-04-15 08:01:20 +02:00
|
|
|
tb := mustOpenTable(path, strg)
|
2019-05-22 23:16:55 +02:00
|
|
|
|
|
|
|
// Close it
|
|
|
|
tb.MustClose()
|
|
|
|
|
|
|
|
// Re-open created table multiple times.
|
|
|
|
for i := 0; i < 10; i++ {
|
2023-04-15 08:01:20 +02:00
|
|
|
tb := mustOpenTable(path, strg)
|
2019-05-22 23:16:55 +02:00
|
|
|
tb.MustClose()
|
|
|
|
}
|
2023-07-14 02:13:24 +02:00
|
|
|
|
|
|
|
stopTestStorage(strg)
|
2019-05-22 23:16:55 +02:00
|
|
|
}
|