2019-05-22 21:16:55 +00:00
|
|
|
package storage
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestTableOpenClose(t *testing.T) {
|
|
|
|
const path = "TestTableOpenClose"
|
2023-09-03 08:33:37 +00:00
|
|
|
const retention = 123 * retention31Days
|
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()
|
2023-09-01 07:27:51 +00:00
|
|
|
strg.retentionMsecs = retention.Milliseconds()
|
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
|
|
|
}
|