2023-03-15 16:00:52 +00:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
2022-01-05 18:02:03 +00:00
|
|
|
//go:build 386 || arm
|
2021-11-23 04:16:57 +00:00
|
|
|
|
|
|
|
package raft
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"strconv"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func Test_BoltOptions(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
key := "VAULT_RAFT_INITIAL_MMAP_SIZE"
|
|
|
|
|
|
|
|
testCases := []struct {
|
|
|
|
name string
|
|
|
|
env string
|
|
|
|
expectedSize int
|
|
|
|
}{
|
|
|
|
{"none", "", 0},
|
|
|
|
{"5MB", strconv.Itoa(5 * 1024 * 1024), 5 * 1024 * 1024},
|
|
|
|
{"negative", "-1", 0},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, tc := range testCases {
|
|
|
|
tc := tc
|
|
|
|
|
|
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
|
|
if tc.env != "" {
|
|
|
|
current := os.Getenv(key)
|
|
|
|
defer os.Setenv(key, current)
|
|
|
|
os.Setenv(key, tc.env)
|
|
|
|
}
|
|
|
|
|
2022-01-11 13:16:53 +00:00
|
|
|
o := boltOptions("")
|
2021-11-23 04:16:57 +00:00
|
|
|
|
|
|
|
if o.InitialMmapSize != tc.expectedSize {
|
|
|
|
t.Errorf("expected InitialMmapSize to be %d but it was %d", tc.expectedSize, o.InitialMmapSize)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|