This reverts commit 60d8bff89c490c5489c97b98b168de9a50239815.
This commit is contained in:
parent
918d1001e0
commit
976ab9c87f
|
@ -795,6 +795,8 @@ type TestCluster struct {
|
||||||
|
|
||||||
cleanupFuncs []func()
|
cleanupFuncs []func()
|
||||||
base *CoreConfig
|
base *CoreConfig
|
||||||
|
LicensePublicKey ed25519.PublicKey
|
||||||
|
LicensePrivateKey ed25519.PrivateKey
|
||||||
opts *TestClusterOptions
|
opts *TestClusterOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1620,6 +1622,15 @@ func NewTestCluster(t testing.T, base *CoreConfig, opts *TestClusterOptions) *Te
|
||||||
coreConfig.HAPhysical = haPhys.(physical.HABackend)
|
coreConfig.HAPhysical = haPhys.(physical.HABackend)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if testCluster.LicensePublicKey == nil {
|
||||||
|
pubKey, priKey, err := GenerateTestLicenseKeys()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("err: %v", err)
|
||||||
|
}
|
||||||
|
testCluster.LicensePublicKey = pubKey
|
||||||
|
testCluster.LicensePrivateKey = priKey
|
||||||
|
}
|
||||||
|
|
||||||
if opts != nil && opts.InmemClusterLayers {
|
if opts != nil && opts.InmemClusterLayers {
|
||||||
if opts.ClusterLayers != nil {
|
if opts.ClusterLayers != nil {
|
||||||
t.Fatalf("cannot specify ClusterLayers when InmemClusterLayers is true")
|
t.Fatalf("cannot specify ClusterLayers when InmemClusterLayers is true")
|
||||||
|
@ -1654,7 +1665,7 @@ func NewTestCluster(t testing.T, base *CoreConfig, opts *TestClusterOptions) *Te
|
||||||
coreConfigs := []*CoreConfig{}
|
coreConfigs := []*CoreConfig{}
|
||||||
|
|
||||||
for i := 0; i < numCores; i++ {
|
for i := 0; i < numCores; i++ {
|
||||||
cleanup, c, localConfig, handler := testCluster.newCore(t, i, coreConfig, opts, listeners[i])
|
cleanup, c, localConfig, handler := testCluster.newCore(t, i, coreConfig, opts, listeners[i], testCluster.LicensePublicKey)
|
||||||
|
|
||||||
testCluster.cleanupFuncs = append(testCluster.cleanupFuncs, cleanup)
|
testCluster.cleanupFuncs = append(testCluster.cleanupFuncs, cleanup)
|
||||||
cores = append(cores, c)
|
cores = append(cores, c)
|
||||||
|
@ -1714,6 +1725,11 @@ func NewTestCluster(t testing.T, base *CoreConfig, opts *TestClusterOptions) *Te
|
||||||
testCluster.Cores[i].Client = testCluster.getAPIClient(t, opts, listeners[i][0].Address.Port, tlsConfigs[i])
|
testCluster.Cores[i].Client = testCluster.getAPIClient(t, opts, listeners[i][0].Address.Port, tlsConfigs[i])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Extra Setup
|
||||||
|
for _, tcc := range testCluster.Cores {
|
||||||
|
testExtraTestCoreSetup(t, testCluster.LicensePrivateKey, tcc)
|
||||||
|
}
|
||||||
|
|
||||||
// Cleanup
|
// Cleanup
|
||||||
testCluster.CleanupFunc = func() {
|
testCluster.CleanupFunc = func() {
|
||||||
for _, c := range testCluster.cleanupFuncs {
|
for _, c := range testCluster.cleanupFuncs {
|
||||||
|
@ -1791,7 +1807,7 @@ func (cluster *TestCluster) StartCore(t testing.T, idx int, opts *TestClusterOpt
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a new Core
|
// Create a new Core
|
||||||
cleanup, newCore, localConfig, coreHandler := cluster.newCore(t, idx, tcc.CoreConfig, opts, tcc.Listeners)
|
cleanup, newCore, localConfig, coreHandler := cluster.newCore(t, idx, tcc.CoreConfig, opts, tcc.Listeners, cluster.LicensePublicKey)
|
||||||
if coreHandler != nil {
|
if coreHandler != nil {
|
||||||
tcc.Handler = coreHandler
|
tcc.Handler = coreHandler
|
||||||
tcc.Server.Handler = coreHandler
|
tcc.Server.Handler = coreHandler
|
||||||
|
@ -1809,6 +1825,7 @@ func (cluster *TestCluster) StartCore(t testing.T, idx int, opts *TestClusterOpt
|
||||||
tcc.Client = cluster.getAPIClient(t, opts, tcc.Listeners[0].Address.Port, tcc.tlsConfig)
|
tcc.Client = cluster.getAPIClient(t, opts, tcc.Listeners[0].Address.Port, tcc.tlsConfig)
|
||||||
|
|
||||||
testAdjustUnderlyingStorage(tcc)
|
testAdjustUnderlyingStorage(tcc)
|
||||||
|
testExtraTestCoreSetup(t, cluster.LicensePrivateKey, tcc)
|
||||||
|
|
||||||
// Start listeners
|
// Start listeners
|
||||||
for _, ln := range tcc.Listeners {
|
for _, ln := range tcc.Listeners {
|
||||||
|
@ -1819,7 +1836,7 @@ func (cluster *TestCluster) StartCore(t testing.T, idx int, opts *TestClusterOpt
|
||||||
tcc.Logger().Info("restarted test core", "core", idx)
|
tcc.Logger().Info("restarted test core", "core", idx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (testCluster *TestCluster) newCore(t testing.T, idx int, coreConfig *CoreConfig, opts *TestClusterOptions, listeners []*TestListener) (func(), *Core, CoreConfig, http.Handler) {
|
func (testCluster *TestCluster) newCore(t testing.T, idx int, coreConfig *CoreConfig, opts *TestClusterOptions, listeners []*TestListener, pubKey ed25519.PublicKey) (func(), *Core, CoreConfig, http.Handler) {
|
||||||
localConfig := *coreConfig
|
localConfig := *coreConfig
|
||||||
cleanupFunc := func() {}
|
cleanupFunc := func() {}
|
||||||
var handler http.Handler
|
var handler http.Handler
|
||||||
|
@ -1898,7 +1915,14 @@ func (testCluster *TestCluster) newCore(t testing.T, idx int, coreConfig *CoreCo
|
||||||
localConfig.ClusterAddr = "https://" + localConfig.ClusterNetworkLayer.Listeners()[0].Addr().String()
|
localConfig.ClusterAddr = "https://" + localConfig.ClusterNetworkLayer.Listeners()[0].Addr().String()
|
||||||
}
|
}
|
||||||
|
|
||||||
localConfig.LicensingConfig = testGetLicensingConfig(nil)
|
switch {
|
||||||
|
case localConfig.LicensingConfig != nil:
|
||||||
|
if pubKey != nil {
|
||||||
|
localConfig.LicensingConfig.AdditionalPublicKeys = append(localConfig.LicensingConfig.AdditionalPublicKeys, pubKey)
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
localConfig.LicensingConfig = testGetLicensingConfig(pubKey)
|
||||||
|
}
|
||||||
|
|
||||||
if localConfig.MetricsHelper == nil {
|
if localConfig.MetricsHelper == nil {
|
||||||
inm := metrics.NewInmemSink(10*time.Second, time.Minute)
|
inm := metrics.NewInmemSink(10*time.Second, time.Minute)
|
||||||
|
|
|
@ -7,10 +7,13 @@ package vault
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/ed25519"
|
"crypto/ed25519"
|
||||||
|
|
||||||
|
testing "github.com/mitchellh/go-testing-interface"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GenerateTestLicenseKeys() (ed25519.PublicKey, ed25519.PrivateKey, error) { return nil, nil, nil }
|
func GenerateTestLicenseKeys() (ed25519.PublicKey, ed25519.PrivateKey, error) { return nil, nil, nil }
|
||||||
func testGetLicensingConfig(key ed25519.PublicKey) *LicensingConfig { return &LicensingConfig{} }
|
func testGetLicensingConfig(key ed25519.PublicKey) *LicensingConfig { return &LicensingConfig{} }
|
||||||
|
func testExtraTestCoreSetup(testing.T, ed25519.PrivateKey, *TestClusterCore) {}
|
||||||
func testAdjustUnderlyingStorage(tcc *TestClusterCore) {
|
func testAdjustUnderlyingStorage(tcc *TestClusterCore) {
|
||||||
tcc.UnderlyingStorage = tcc.physical
|
tcc.UnderlyingStorage = tcc.physical
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue