test: fix concurrent map access when setting up test vault

This commit is contained in:
R.B. Boyer 2019-03-01 12:24:32 -06:00 committed by R.B. Boyer
parent 6955186239
commit 409c901f8e
1 changed files with 6 additions and 0 deletions

View File

@ -4,6 +4,7 @@ import (
"fmt"
"io/ioutil"
"net"
"sync"
"testing"
"time"
@ -16,11 +17,16 @@ import (
"github.com/stretchr/testify/require"
)
var vaultLock sync.Mutex
func testVaultCluster(t *testing.T) (*VaultProvider, *vault.Core, net.Listener) {
return testVaultClusterWithConfig(t, true, nil)
}
func testVaultClusterWithConfig(t *testing.T, isRoot bool, rawConf map[string]interface{}) (*VaultProvider, *vault.Core, net.Listener) {
vaultLock.Lock()
defer vaultLock.Unlock()
if err := vault.AddTestLogicalBackend("pki", pki.Factory); err != nil {
t.Fatal(err)
}