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