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 d3be5c1d3a
commit 23f824fb60

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)
}