forked from hashicorp/vault
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add InitialMmapSize to bolt options (hashicorp#13178)
- Loading branch information
1 parent
21a590a
commit db0464f
Showing
7 changed files
with
133 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:improvement | ||
raft: set InitialMmapSize to 100GB on 64bit architectures | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// +build 386 arm | ||
|
||
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) | ||
} | ||
|
||
o, err := boltOptions() | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
|
||
if o.InitialMmapSize != tc.expectedSize { | ||
t.Errorf("expected InitialMmapSize to be %d but it was %d", tc.expectedSize, o.InitialMmapSize) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// +build !386,!arm | ||
|
||
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", "", 100 * 1024 * 1024 * 1024}, | ||
{"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) | ||
} | ||
|
||
o := boltOptions() | ||
|
||
if o.InitialMmapSize != tc.expectedSize { | ||
t.Errorf("expected InitialMmapSize to be %d but it was %d", tc.expectedSize, o.InitialMmapSize) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// +build 386 arm | ||
|
||
package raft | ||
|
||
const initialMmapSize = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// +build !386,!arm | ||
|
||
package raft | ||
|
||
const initialMmapSize = 100 * 1024 * 1024 * 1024 // 100GB |