Backport Delete cluster.Start for NewTestCluster clusters, and deprecate and clean up cluster.Cleanup for NewTestCluster clusters into ce/main (#14105)

* Delete cluster.Start for NewTestCluster clusters, and deprecate and clean up cluster.Cleanup for NewTestCluster clusters (#14014)

* progress

* more progress

* missed cleanup

* fix mistakes

* cleanup

* fix docker cleanup

* various fixes

* further fixes

* further cleanup

* the cleanup will continue until morale improves

* two morE

* more fixes

* how did I miss that

* new test cleanup

* update

* cleanup, attempt small de-flake

* fix and extra cleanup

* some docker cleanup

* newlines

* some testwaitactives

* CE changes

---------

Co-authored-by: Violet Hynes <violet.hynes@hashicorp.com>
This commit is contained in:
Vault Automation 2026-04-21 09:33:14 -04:00 committed by GitHub
parent 8ba69fccb1
commit 8b448ab7af
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
109 changed files with 77 additions and 758 deletions

View File

@ -201,7 +201,6 @@ func Test_Something_With_Docker(t *testing.T) {
ImageTag: "latest",
}
cluster := docker.NewTestDockerCluster(t, opts)
defer cluster.Cleanup()
client := cluster.Nodes()[0].APIClient()
_, err := client.Logical().Read("sys/storage/raft/configuration")
@ -226,7 +225,6 @@ func Test_Something_With_Docker(t *testing.T) {
VaultLicense: licenseString, // not a path, the actual license bytes
}
cluster := docker.NewTestDockerCluster(t, opts)
defer cluster.Cleanup()
}
```
@ -245,7 +243,6 @@ build as a debugging convenience.
func Test_Custom_Build_With_Docker(t *testing.T) {
opts := docker.DefaultOptions(t)
cluster := docker.NewTestDockerCluster(t, opts)
defer cluster.Cleanup()
}
```

View File

@ -20,7 +20,6 @@ func TestBackend_E2E_Initialize(t *testing.T) {
// Set up the cluster. This will trigger an Initialize(); we sleep briefly
// awaiting its completion.
cluster := setupAwsTestCluster(t, ctx)
defer cluster.Cleanup()
time.Sleep(time.Second)
core := cluster.Cores[0]
@ -112,12 +111,10 @@ func setupAwsTestCluster(t *testing.T, _ context.Context) *vault.TestCluster {
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
if len(cluster.Cores) != 1 {
t.Fatalf("expected exactly one core")
}
core := cluster.Cores[0]
vault.TestWaitActive(t, core.Core)
// load the auth plugin
if err := core.Client.Sys().EnableAuthWithOptions("aws", &api.EnableAuthOptions{

View File

@ -272,10 +272,7 @@ func TestBackend_PermittedDNSDomainsIntermediateCA(t *testing.T) {
cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
cores := cluster.Cores
vault.TestWaitActive(t, cores[0].Core)
client := cores[0].Client
var err error
@ -588,10 +585,7 @@ func TestBackend_MetadataBasedACLPolicy(t *testing.T) {
cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
cores := cluster.Cores
vault.TestWaitActive(t, cores[0].Core)
client := cores[0].Client
// Enable the cert auth method

View File

@ -544,11 +544,7 @@ func Test_RotationQueueInitialized(t *testing.T) {
HandlerFunc: vaulthttp.Handler,
NumCores: 2,
})
cluster.Start()
defer cluster.Cleanup()
cores := cluster.Cores
vault.TestWaitActive(t, cores[0].Core)
client := cores[0].Client
err := client.Sys().Mount("aws", &api.MountInput{
Type: "aws",

View File

@ -28,9 +28,7 @@ func TestBackend_config_connection(t *testing.T) {
var resp *logical.Response
var err error
cluster, sys := getClusterPostgresDB(t)
defer cluster.Cleanup()
_, sys := getClusterPostgresDB(t)
config := logical.TestBackendConfig()
config.StorageView = &logical.InmemStorage{}
config.System = sys
@ -254,7 +252,6 @@ func TestBackend_connectionCrud(t *testing.T) {
t.Parallel()
dbFactory := &singletonDBFactory{}
cluster, sys := getClusterPostgresDBWithFactory(t, dbFactory.factory)
defer cluster.Cleanup()
dbFactory.sys = sys
client := cluster.Cores[0].Client.Logical()

View File

@ -69,7 +69,6 @@ func getClusterWithFactory(t *testing.T, factory logical.Factory) (*vault.TestCl
cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
cores := cluster.Cores
vault.TestWaitActive(t, cores[0].Core)
@ -157,8 +156,7 @@ func TestBackend_RoleUpgrade(t *testing.T) {
// TestBackend_BadConnectionString tests that an error response resulting from
// a failed connection does not expose the URL. The middleware should sanitize it.
func TestBackend_BadConnectionString(t *testing.T) {
cluster, sys := getClusterPostgresDB(t)
defer cluster.Cleanup()
_, sys := getClusterPostgresDB(t)
config := logical.TestBackendConfig()
config.StorageView = &logical.InmemStorage{}
@ -206,8 +204,7 @@ func TestBackend_BadConnectionString(t *testing.T) {
}
func TestBackend_basic(t *testing.T) {
cluster, sys := getClusterPostgresDB(t)
defer cluster.Cleanup()
_, sys := getClusterPostgresDB(t)
config := logical.TestBackendConfig()
config.StorageView = &logical.InmemStorage{}
@ -472,7 +469,6 @@ func TestBackend_connectionSanitizePrivateKey(t *testing.T) {
t.Parallel()
dbFactory := &singletonDBFactory{}
cluster, sys := getClusterPostgresDBWithFactory(t, dbFactory.factory)
defer cluster.Cleanup()
dbFactory.sys = sys
client := cluster.Cores[0].Client.Logical()
@ -520,8 +516,7 @@ func TestBackend_connectionSanitizePrivateKey(t *testing.T) {
}
func TestBackend_roleCrud(t *testing.T) {
cluster, sys := getClusterPostgresDB(t)
defer cluster.Cleanup()
_, sys := getClusterPostgresDB(t)
config := logical.TestBackendConfig()
config.StorageView = &logical.InmemStorage{}
@ -773,8 +768,7 @@ func TestBackend_roleCrud(t *testing.T) {
}
func TestBackend_allowedRoles(t *testing.T) {
cluster, sys := getClusterPostgresDB(t)
defer cluster.Cleanup()
_, sys := getClusterPostgresDB(t)
config := logical.TestBackendConfig()
config.StorageView = &logical.InmemStorage{}
@ -784,7 +778,6 @@ func TestBackend_allowedRoles(t *testing.T) {
if err != nil {
t.Fatal(err)
}
defer b.Cleanup(context.Background())
cleanup, connURL := postgreshelper.PrepareTestContainer(t)
defer cleanup()
@ -970,8 +963,7 @@ func TestBackend_allowedRoles(t *testing.T) {
}
func TestBackend_RotateRootCredentials(t *testing.T) {
cluster, sys := getClusterPostgresDB(t)
defer cluster.Cleanup()
_, sys := getClusterPostgresDB(t)
config := logical.TestBackendConfig()
config.StorageView = &logical.InmemStorage{}
@ -1071,8 +1063,7 @@ func TestBackend_RotateRootCredentials(t *testing.T) {
}
func TestBackend_ConnectionURL_redacted(t *testing.T) {
cluster, sys := getClusterPostgresDB(t)
t.Cleanup(cluster.Cleanup)
_, sys := getClusterPostgresDB(t)
config := logical.TestBackendConfig()
config.StorageView = &logical.InmemStorage{}
@ -1185,7 +1176,6 @@ func TestBackend_ConnectionURL_redacted(t *testing.T) {
// for each plugin type.
func TestBackend_GetConnectionMetrics(t *testing.T) {
cluster, sys := getCluster(t)
defer cluster.Cleanup()
vault.TestAddTestPlugin(t, cluster.Cores[0].Core, "cassandra-database-plugin", consts.PluginTypeDatabase, "", "TestBackend_PluginMain_CassandraMultiplexed",
[]string{fmt.Sprintf("%s=%s", pluginutil.PluginCACertPEMEnv, cluster.CACertPEMFile)})
@ -1350,7 +1340,6 @@ func TestBackend_AsyncClose(t *testing.T) {
// longer than 750ms.
cluster, sys := getCluster(t)
vault.TestAddTestPlugin(t, cluster.Cores[0].Core, "hanging-plugin", consts.PluginTypeDatabase, "", "TestBackend_PluginMain_Hanging", []string{})
t.Cleanup(cluster.Cleanup)
config := logical.TestBackendConfig()
config.StorageView = &logical.InmemStorage{}
@ -1393,8 +1382,8 @@ func TestBackend_AsyncClose(t *testing.T) {
}
func TestNewDatabaseWrapper_IgnoresBuiltinVersion(t *testing.T) {
cluster, sys := getCluster(t)
t.Cleanup(cluster.Cleanup)
_, sys := getCluster(t)
_, err := newDatabaseWrapper(context.Background(), "hana-database-plugin", "v1.0.0+builtin", sys, hclog.Default())
if err != nil {
t.Fatal(err)

View File

@ -114,7 +114,6 @@ func getCluster(t *testing.T) (*vault.TestCluster, logical.SystemView) {
}, &vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
cores := cluster.Cores
sys := vault.TestDynamicSystemView(cores[0].Core, nil)
@ -144,8 +143,7 @@ func TestPlugin_GRPC_Main(t *testing.T) {
}
func TestPlugin_Init(t *testing.T) {
cluster, sys := getCluster(t)
defer cluster.Cleanup()
_, sys := getCluster(t)
dbRaw, err := dbplugin.PluginFactoryVersion(namespace.RootContext(nil), "test-plugin", "", sys, log.NewNullLogger())
if err != nil {
@ -168,8 +166,7 @@ func TestPlugin_Init(t *testing.T) {
}
func TestPlugin_CreateUser(t *testing.T) {
cluster, sys := getCluster(t)
defer cluster.Cleanup()
_, sys := getCluster(t)
db, err := dbplugin.PluginFactoryVersion(namespace.RootContext(nil), "test-plugin", "", sys, log.NewNullLogger())
if err != nil {
@ -208,8 +205,7 @@ func TestPlugin_CreateUser(t *testing.T) {
}
func TestPlugin_RenewUser(t *testing.T) {
cluster, sys := getCluster(t)
defer cluster.Cleanup()
_, sys := getCluster(t)
db, err := dbplugin.PluginFactoryVersion(namespace.RootContext(nil), "test-plugin", "", sys, log.NewNullLogger())
if err != nil {
@ -242,8 +238,7 @@ func TestPlugin_RenewUser(t *testing.T) {
}
func TestPlugin_RevokeUser(t *testing.T) {
cluster, sys := getCluster(t)
defer cluster.Cleanup()
_, sys := getCluster(t)
db, err := dbplugin.PluginFactoryVersion(namespace.RootContext(nil), "test-plugin", "", sys, log.NewNullLogger())
if err != nil {

View File

@ -15,8 +15,7 @@ import (
)
func TestWriteConfig_PluginVersionInStorage(t *testing.T) {
cluster, sys := getCluster(t)
t.Cleanup(cluster.Cleanup)
_, sys := getCluster(t)
config := logical.TestBackendConfig()
config.StorageView = &logical.InmemStorage{}
@ -127,8 +126,7 @@ func TestWriteConfig_PluginVersionInStorage(t *testing.T) {
}
func TestWriteConfig_HelpfulErrorMessageWhenBuiltinOverridden(t *testing.T) {
cluster, sys := getClusterPostgresDB(t)
t.Cleanup(cluster.Cleanup)
_, sys := getClusterPostgresDB(t)
config := logical.TestBackendConfig()
config.StorageView = &logical.InmemStorage{}

View File

@ -207,8 +207,7 @@ func TestBackend_Roles_CredentialTypes(t *testing.T) {
}
func TestBackend_StaticRole_Config(t *testing.T) {
cluster, sys := getClusterPostgresDB(t)
defer cluster.Cleanup()
_, sys := getClusterPostgresDB(t)
config := logical.TestBackendConfig()
config.StorageView = &logical.InmemStorage{}
@ -472,8 +471,7 @@ func TestBackend_StaticRole_Config(t *testing.T) {
}
func TestBackend_StaticRole_ReadCreds(t *testing.T) {
cluster, sys := getClusterPostgresDB(t)
defer cluster.Cleanup()
_, sys := getClusterPostgresDB(t)
config := logical.TestBackendConfig()
config.StorageView = &logical.InmemStorage{}
@ -652,8 +650,7 @@ func TestBackend_StaticRole_ReadCreds(t *testing.T) {
}
func TestBackend_StaticRole_Updates(t *testing.T) {
cluster, sys := getClusterPostgresDB(t)
defer cluster.Cleanup()
_, sys := getClusterPostgresDB(t)
config := logical.TestBackendConfig()
config.StorageView = &logical.InmemStorage{}
@ -951,8 +948,7 @@ func TestBackend_StaticRole_Updates_RotationSchedule(t *testing.T) {
}
func TestBackend_StaticRole_Role_name_check(t *testing.T) {
cluster, sys := getClusterPostgresDB(t)
defer cluster.Cleanup()
_, sys := getClusterPostgresDB(t)
config := logical.TestBackendConfig()
config.StorageView = &logical.InmemStorage{}

View File

@ -19,8 +19,7 @@ func TestRotateRootPassword_Postgres(t *testing.T) {
cleanup, connURL := postgreshelper.PrepareTestContainer(t)
defer cleanup()
cluster, sys := getClusterWithFactory(t, Factory)
defer cluster.Cleanup()
_, sys := getClusterWithFactory(t, Factory)
connURL = strings.Replace(connURL, "postgres:secret", "{{username}}:{{password}}", 1)
@ -50,8 +49,7 @@ func TestRotateRootKeypair_Snowflake_Acc(t *testing.T) {
t.Skip("VAULT_SNOWFLAKE_USERNAME not set, skipping test")
}
cluster, sys := getClusterWithFactory(t, Factory)
defer cluster.Cleanup()
_, sys := getClusterWithFactory(t, Factory)
testRotateRoot(t, sys, false, connURL, "snowflake-database-plugin", username, string(keyFile))
}

View File

@ -27,8 +27,7 @@ const (
// - Password has been altered on the database
// - Password has not been updated in storage
func TestBackend_RotateRootCredentials_WAL_rollback(t *testing.T) {
cluster, sys := getClusterPostgresDB(t)
defer cluster.Cleanup()
_, sys := getClusterPostgresDB(t)
config := logical.TestBackendConfig()
config.StorageView = &logical.InmemStorage{}
@ -165,8 +164,7 @@ func TestBackend_RotateRootCredentials_WAL_rollback(t *testing.T) {
// - Password has not been altered on the database
// - Password has not been updated in storage
func TestBackend_RotateRootCredentials_WAL_no_rollback_1(t *testing.T) {
cluster, sys := getClusterPostgresDB(t)
defer cluster.Cleanup()
_, sys := getClusterPostgresDB(t)
config := logical.TestBackendConfig()
config.StorageView = &logical.InmemStorage{}
@ -264,8 +262,7 @@ func TestBackend_RotateRootCredentials_WAL_no_rollback_1(t *testing.T) {
// - Password has been altered on the database
// - Password has been updated in storage
func TestBackend_RotateRootCredentials_WAL_no_rollback_2(t *testing.T) {
cluster, sys := getClusterPostgresDB(t)
defer cluster.Cleanup()
_, sys := getClusterPostgresDB(t)
config := logical.TestBackendConfig()
config.StorageView = &logical.InmemStorage{}

View File

@ -44,8 +44,7 @@ const (
)
func TestBackend_StaticRole_Rotation_basic(t *testing.T) {
cluster, sys := getClusterPostgresDB(t)
defer cluster.Cleanup()
_, sys := getClusterPostgresDB(t)
config := logical.TestBackendConfig()
config.StorageView = &logical.InmemStorage{}
@ -253,8 +252,7 @@ func TestBackend_StaticRole_Rotation_basic(t *testing.T) {
// rotations can successfully recover and that they do not occur outside of a
// rotation window.
func TestBackend_StaticRole_Rotation_Schedule_ErrorRecover(t *testing.T) {
cluster, sys := getClusterPostgresDB(t)
t.Cleanup(cluster.Cleanup)
_, sys := getClusterPostgresDB(t)
config := logical.TestBackendConfig()
config.StorageView = &logical.InmemStorage{}
@ -441,8 +439,7 @@ func TestBackend_StaticRole_Rotation_Schedule_ErrorRecover(t *testing.T) {
// for non-static accounts, which doesn't make sense anyway, but doesn't hurt to
// verify we return an error
func TestBackend_StaticRole_Rotation_NonStaticError(t *testing.T) {
cluster, sys := getClusterPostgresDB(t)
defer cluster.Cleanup()
_, sys := getClusterPostgresDB(t)
config := logical.TestBackendConfig()
config.StorageView = &logical.InmemStorage{}
@ -545,8 +542,7 @@ func TestBackend_StaticRole_Rotation_NonStaticError(t *testing.T) {
}
func TestBackend_StaticRole_Rotation_Revoke_user(t *testing.T) {
cluster, sys := getClusterPostgresDB(t)
defer cluster.Cleanup()
_, sys := getClusterPostgresDB(t)
config := logical.TestBackendConfig()
config.StorageView = &logical.InmemStorage{}
@ -723,8 +719,7 @@ func verifyPgConn(t *testing.T, username, password, connURL string) {
//
// First scenario, WAL contains a role name that does not exist.
func TestBackend_StaticRole_Rotation_QueueWAL_discard_role_not_found(t *testing.T) {
cluster, sys := getClusterPostgresDB(t)
defer cluster.Cleanup()
_, sys := getClusterPostgresDB(t)
ctx := context.Background()
@ -764,8 +759,7 @@ func TestBackend_StaticRole_Rotation_QueueWAL_discard_role_not_found(t *testing.
// Second scenario, WAL contains a role name that does exist, but the role's
// LastVaultRotation is greater than the WAL has
func TestBackend_StaticRole_Rotation_QueueWAL_discard_role_newer_rotation_date(t *testing.T) {
cluster, sys := getClusterPostgresDB(t)
defer cluster.Cleanup()
_, sys := getClusterPostgresDB(t)
ctx := context.Background()
@ -1029,8 +1023,7 @@ func TestBackend_StaticRole_Rotation_MongoDBAtlas(t *testing.T) {
// does not break on invalid values.
func TestQueueTickIntervalKeyConfig(t *testing.T) {
t.Parallel()
cluster, sys := getCluster(t)
defer cluster.Cleanup()
_, sys := getCluster(t)
values := []string{"1", "0", "-1"}
for _, v := range values {
@ -1060,8 +1053,7 @@ func testBackend_StaticRole_Rotations(t *testing.T, createUser userCreator, opts
}
}()
cluster, sys := getClusterPostgresDB(t)
defer cluster.Cleanup()
_, sys := getClusterPostgresDB(t)
config := logical.TestBackendConfig()
config.StorageView = &logical.InmemStorage{}
@ -1224,8 +1216,7 @@ type createUserCommand struct {
// Demonstrates a bug fix for the credential rotation not releasing locks
func TestBackend_StaticRole_Rotation_LockRegression(t *testing.T) {
cluster, sys := getClusterPostgresDB(t)
defer cluster.Cleanup()
_, sys := getClusterPostgresDB(t)
config := logical.TestBackendConfig()
config.StorageView = &logical.InmemStorage{}
@ -1303,8 +1294,7 @@ func TestBackend_StaticRole_Rotation_LockRegression(t *testing.T) {
}
func TestBackend_StaticRole_Rotation_Invalid_Role(t *testing.T) {
cluster, sys := getClusterPostgresDB(t)
defer cluster.Cleanup()
_, sys := getClusterPostgresDB(t)
config := logical.TestBackendConfig()
config.StorageView = &logical.InmemStorage{}

View File

@ -23,7 +23,6 @@ import (
func TestPlugin_lifecycle(t *testing.T) {
cluster, sys := getCluster(t)
defer cluster.Cleanup()
env := []string{fmt.Sprintf("%s=%s", pluginutil.PluginCACertPEMEnv, cluster.CACertPEMFile)}
vault.TestAddTestPlugin(t, cluster.Cores[0].Core, "mock-v4-database-plugin", consts.PluginTypeDatabase, "", "TestBackend_PluginMain_MockV4", env)
@ -224,7 +223,6 @@ func TestPlugin_lifecycle(t *testing.T) {
func TestPlugin_VersionSelection(t *testing.T) {
cluster, sys := getCluster(t)
defer cluster.Cleanup()
for _, version := range []string{"v11.0.0", "v11.0.1-rc1", "v2.0.0"} {
vault.TestAddTestPlugin(t, cluster.Cores[0].Core, "mock-v5-database-plugin", consts.PluginTypeDatabase, version, "TestBackend_PluginMain_MockV5", []string{})
@ -337,7 +335,6 @@ func TestPlugin_VersionSelection(t *testing.T) {
func TestPlugin_VersionMustBeExplicitlyUpgraded(t *testing.T) {
cluster, sys := getCluster(t)
defer cluster.Cleanup()
config := logical.TestBackendConfig()
config.StorageView = &logical.InmemStorage{}

View File

@ -32,7 +32,6 @@ func TestACMEBilling(t *testing.T) {
timeutil.SkipAtEndOfMonth(t)
cluster, client, _ := setupAcmeBackend(t)
defer cluster.Cleanup()
var activeCore *vault.TestClusterCore
{

View File

@ -3646,8 +3646,6 @@ func TestBackend_AllowedURISANsTemplate(t *testing.T) {
cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
client := cluster.Cores[0].Client
// Write test policy for userpass auth method.
@ -3771,8 +3769,6 @@ func TestBackend_AllowedDomainsTemplate(t *testing.T) {
cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
client := cluster.Cores[0].Client
// Write test policy for userpass auth method.
@ -3904,8 +3900,7 @@ func TestReadWriteDeleteRoles(t *testing.T) {
cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
client := cluster.Cores[0].Client
// Mount PKI.
@ -4152,8 +4147,7 @@ func TestBackend_RevokePlusTidy_Intermediate(t *testing.T) {
cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
cores := cluster.Cores
vault.TestWaitActive(t, cores[0].Core)
client := cores[0].Client
@ -5633,8 +5627,7 @@ func TestBackend_IfModifiedSinceHeaders(t *testing.T) {
HandlerFunc: vaulthttp.Handler,
RequestResponseCallback: schema.ResponseValidatingCallback(t),
})
cluster.Start()
defer cluster.Cleanup()
client := cluster.Cores[0].Client
// Mount PKI.
@ -6812,8 +6805,6 @@ func TestStandby_Operations(t *testing.T) {
},
}, nil, teststorage.InmemBackendSetup)
cluster := vault.NewTestCluster(t, conf, opts)
cluster.Start()
defer cluster.Cleanup()
testhelpers.WaitForActiveNodeAndStandbys(t, cluster)
standbyCores := testhelpers.DeriveStandbyCores(t, cluster)
@ -7042,8 +7033,7 @@ func TestProperAuthing(t *testing.T) {
cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
client := cluster.Cores[0].Client
token := client.Token()

View File

@ -48,8 +48,6 @@ func TestBackend_CA_Steps(t *testing.T) {
cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
client := cluster.Cores[0].Client

View File

@ -961,8 +961,6 @@ func TestAutoRebuild(t *testing.T) {
cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
client := cluster.Cores[0].Client
// Mount PKI

View File

@ -493,11 +493,7 @@ func TestLDAPAiaCrlUrls(t *testing.T) {
NumCores: 1,
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
singleCore := cluster.Cores[0]
vault.TestWaitActive(t, singleCore.Core)
client := singleCore.Client
client := cluster.Cores[0].Client
mountPKIEndpoint(t, client, "pki")
@ -572,9 +568,6 @@ func TestIntegrationOCSPClientWithPKI(t *testing.T) {
cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
cores := cluster.Cores
vault.TestWaitActive(t, cores[0].Core)
client := cores[0].Client

View File

@ -45,7 +45,7 @@ import (
func TestAcmeBasicWorkflow(t *testing.T) {
t.Parallel()
cluster, client, _ := setupAcmeBackend(t)
defer cluster.Cleanup()
cases := []struct {
name string
prefixUrl string
@ -358,7 +358,7 @@ func TestAcmeBasicWorkflow(t *testing.T) {
func TestAcmeBasicWorkflowWithEab(t *testing.T) {
t.Parallel()
cluster, client, _ := setupAcmeBackend(t)
defer cluster.Cleanup()
testCtx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel()
@ -477,8 +477,7 @@ func TestAcmeBasicWorkflowWithEab(t *testing.T) {
// based on the
func TestAcmeNonce(t *testing.T) {
t.Parallel()
cluster, client, pathConfig := setupAcmeBackend(t)
defer cluster.Cleanup()
_, client, pathConfig := setupAcmeBackend(t)
cases := []struct {
name string
@ -535,8 +534,7 @@ func TestAcmeNonce(t *testing.T) {
// TestAcmeClusterPathNotConfigured basic testing of the ACME error handler.
func TestAcmeClusterPathNotConfigured(t *testing.T) {
t.Parallel()
cluster, client := setupTestPkiCluster(t)
defer cluster.Cleanup()
_, client := setupTestPkiCluster(t)
// Go sneaky, sneaky and update the acme configuration through sys/raw to bypass config/cluster path checks
pkiMount := findStorageMountUuid(t, client, "pki")
@ -590,7 +588,6 @@ func TestAcmeClusterPathNotConfigured(t *testing.T) {
func TestAcmeAccountsCrossingDirectoryPath(t *testing.T) {
t.Parallel()
cluster, _, _ := setupAcmeBackend(t)
defer cluster.Cleanup()
baseAcmeURL := "/v1/pki/acme/"
accountKey, err := cryptoutil.GenerateRSAKey(rand.Reader, 2048)
@ -619,7 +616,6 @@ func TestAcmeAccountsCrossingDirectoryPath(t *testing.T) {
func TestAcmeEabCrossingDirectoryPath(t *testing.T) {
t.Parallel()
cluster, client, _ := setupAcmeBackend(t)
defer cluster.Cleanup()
// Enable EAB
_, err := client.Logical().WriteWithContext(context.Background(), "pki/config/acme", map[string]interface{}{
@ -656,7 +652,6 @@ func TestAcmeDisabledWithEnvVar(t *testing.T) {
// Setup a cluster with the configuration set to not-required, initially as the
// configuration will validate if the environment var is set
cluster, client, _ := setupAcmeBackend(t)
defer cluster.Cleanup()
// Seal setup the environment variable, and unseal which now means we have a cluster
// with ACME configuration saying it is enabled with a bad EAB policy.
@ -681,8 +676,7 @@ func TestAcmeDisabledWithEnvVar(t *testing.T) {
// TestAcmeConfigChecksPublicAcmeEnv verifies certain EAB policy values can not be set if ENV var is enabled
func TestAcmeConfigChecksPublicAcmeEnv(t *testing.T) {
t.Setenv("VAULT_DISABLE_PUBLIC_ACME", "true")
cluster, client := setupTestPkiCluster(t)
defer cluster.Cleanup()
_, client := setupTestPkiCluster(t)
_, err := client.Logical().WriteWithContext(context.Background(), "pki/config/cluster", map[string]interface{}{
"path": "https://dadgarcorp.com/v1/pki",
@ -717,7 +711,6 @@ func TestAcmeHonorsAlwaysEnforceErr(t *testing.T) {
t.Parallel()
cluster, client, _ := setupAcmeBackend(t)
defer cluster.Cleanup()
testCtx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel()
@ -797,7 +790,6 @@ func TestAcmeTruncatesToIssuerExpiry(t *testing.T) {
t.Parallel()
cluster, client, _ := setupAcmeBackend(t)
defer cluster.Cleanup()
testCtx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel()
@ -887,7 +879,6 @@ func TestAcmeRoleExtKeyUsage(t *testing.T) {
t.Parallel()
cluster, client, _ := setupAcmeBackend(t)
defer cluster.Cleanup()
testCtx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel()
@ -991,7 +982,6 @@ func TestIssuerRoleDirectoryAssociations(t *testing.T) {
// roles (test-role, acme) that we can use with various directory
// configurations.
cluster, client, _ := setupAcmeBackend(t)
defer cluster.Cleanup()
// Setup DNS for validations.
testCtx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
@ -1126,7 +1116,6 @@ func TestACMESubjectFieldsAndExtensionsIgnored(t *testing.T) {
// roles (test-role, acme) that we can use with various directory
// configurations.
cluster, client, _ := setupAcmeBackend(t)
defer cluster.Cleanup()
// Setup DNS for validations.
testCtx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
@ -1175,7 +1164,6 @@ func TestAcmeWithCsrIncludingBasicConstraintExtension(t *testing.T) {
t.Parallel()
cluster, client, _ := setupAcmeBackend(t)
defer cluster.Cleanup()
testCtx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel()
@ -1507,7 +1495,6 @@ func testAcmeCertSignedByCa(t *testing.T, client *api.Client, derCerts [][]byte,
func TestAcmeValidationError(t *testing.T) {
t.Parallel()
cluster, _, _ := setupAcmeBackend(t)
defer cluster.Cleanup()
testCtx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel()
@ -1616,7 +1603,7 @@ func TestAcmeRevocationAcrossAccounts(t *testing.T) {
t.Parallel()
cluster, vaultClient, _ := setupAcmeBackend(t)
defer cluster.Cleanup()
testCtx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel()
@ -1701,7 +1688,6 @@ func TestAcmeRevocationAcrossAccounts(t *testing.T) {
func TestAcmeMaxTTL(t *testing.T) {
t.Parallel()
cluster, client, _ := setupAcmeBackend(t)
defer cluster.Cleanup()
testCtx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel()
@ -1786,7 +1772,7 @@ func TestAcmeMaxTTL(t *testing.T) {
func TestVaultOperatorACMEDisableWorkflow(t *testing.T) {
t.Parallel()
cluster, vaultClient, _ := setupAcmeBackend(t)
defer cluster.Cleanup()
testCtx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel()
@ -1927,7 +1913,6 @@ func setupTestPkiCluster(t *testing.T) (*vault.TestCluster, *api.Client) {
cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
client := cluster.Cores[0].Client
mountPKIEndpoint(t, client, "pki")
return cluster, client
@ -1986,7 +1971,6 @@ func getEABKey(t *testing.T, client *api.Client, baseUrl string) (string, []byte
func TestACMEClientRequestLimits(t *testing.T) {
cluster, client, _ := setupAcmeBackend(t)
defer cluster.Cleanup()
cases := []struct {
name string

View File

@ -18,7 +18,6 @@ func TestAcmeConfig(t *testing.T) {
t.Parallel()
cluster, client, _ := setupAcmeBackend(t)
defer cluster.Cleanup()
cases := []struct {
name string
@ -158,8 +157,7 @@ func TestAcmeExternalPolicyOss(t *testing.T) {
func TestAcmeIPRangeConfiguration(t *testing.T) {
t.Parallel()
cluster, client, _ := setupAcmeBackend(t)
defer cluster.Cleanup()
_, client, _ := setupAcmeBackend(t)
testCtx := context.Background()

View File

@ -14,9 +14,7 @@ import (
// to something completely incorrect (missing an intermediate issuer). In this case, the attempt to write the manual
// chain throws an error, and the manual chain is not updated.
func TestManualChainValidation(t *testing.T) {
// Set Up a Cluster
cluster, client := setupTestPkiCluster(t)
defer cluster.Cleanup()
_, client := setupTestPkiCluster(t)
// Set Up Root-A
mount := "pki"

View File

@ -384,8 +384,6 @@ func TestOcsp_HigherLevel(t *testing.T) {
cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
client := cluster.Cores[0].Client
mountPKIEndpoint(t, client, "pki")
resp, err := client.Logical().Write("pki/root/generate/internal", map[string]interface{}{

View File

@ -237,8 +237,6 @@ func TestSignRevocationList(t *testing.T) {
cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
client := cluster.Cores[0].Client
// Mount PKI, use this form of backend so our request is closer to reality (json parsed)

View File

@ -198,8 +198,6 @@ func TestAutoTidy(t *testing.T) {
cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
client := cluster.Cores[0].Client
// Mount PKI
@ -336,8 +334,6 @@ func TestAutoTidyPersistsAcrossRestarts(t *testing.T) {
NumCores: 1,
}
cluster := vault.NewTestCluster(t, coreConfig, opts)
cluster.Start()
defer cluster.Cleanup()
client := cluster.Cores[0].Client
@ -643,8 +639,6 @@ func TestCertStorageMetrics(t *testing.T) {
HandlerFunc: vaulthttp.Handler,
NumCores: 1,
})
cluster.Start()
defer cluster.Cleanup()
client := cluster.Cores[0].Client
// Mount PKI
@ -912,7 +906,6 @@ func TestTidyAcmeWithBackdate(t *testing.T) {
t.Parallel()
cluster, client, _ := setupAcmeBackend(t)
defer cluster.Cleanup()
testCtx := context.Background()
// Grab the mount UUID for sys/raw invocations.
@ -1069,7 +1062,6 @@ func TestTidyAcmeWithSafetyBuffer(t *testing.T) {
// This would still be way easier if I could do both sides
cluster, client, _ := setupAcmeBackend(t)
defer cluster.Cleanup()
testCtx := context.Background()
// Grab the mount UUID for sys/raw invocations.

View File

@ -506,7 +506,7 @@ func TestBackend_DefaultUserTemplate_WithStaticPrefix(t *testing.T) {
func TestBackend_DefaultUserTemplateFalse_AllowedUsersTemplateTrue(t *testing.T) {
cluster, userpassToken := getSshCaTestCluster(t, testUserName)
defer cluster.Cleanup()
client := cluster.Cores[0].Client
// set metadata "ssh_username" to userpass username
@ -556,7 +556,7 @@ func TestBackend_DefaultUserTemplateFalse_AllowedUsersTemplateTrue(t *testing.T)
func TestBackend_DefaultUserTemplateFalse_AllowedUsersTemplateFalse(t *testing.T) {
cluster, userpassToken := getSshCaTestCluster(t, testUserName)
defer cluster.Cleanup()
client := cluster.Cores[0].Client
// set metadata "ssh_username" to userpass username
@ -1784,7 +1784,7 @@ func TestBackend_DisallowUserProvidedKeyIDs(t *testing.T) {
func TestBackend_DefExtTemplatingEnabled(t *testing.T) {
cluster, userpassToken := getSshCaTestCluster(t, testUserName)
defer cluster.Cleanup()
client := cluster.Cores[0].Client
// Get auth accessor for identity template.
@ -1880,7 +1880,7 @@ func TestBackend_DefExtTemplatingEnabled(t *testing.T) {
func TestBackend_EmptyAllowedExtensionFailsClosed(t *testing.T) {
cluster, userpassToken := getSshCaTestCluster(t, testUserName)
defer cluster.Cleanup()
client := cluster.Cores[0].Client
// Get auth accessor for identity template.
@ -1927,7 +1927,7 @@ func TestBackend_EmptyAllowedExtensionFailsClosed(t *testing.T) {
func TestBackend_DefExtTemplatingDisabled(t *testing.T) {
cluster, userpassToken := getSshCaTestCluster(t, testUserName)
defer cluster.Cleanup()
client := cluster.Cores[0].Client
// Get auth accessor for identity template.
@ -2160,7 +2160,6 @@ func getSshCaTestCluster(t *testing.T, userIdentity string) (*vault.TestCluster,
cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
client := cluster.Cores[0].Client
// Write test policy for userpass auth method.
@ -2222,7 +2221,7 @@ func testDefaultUserTemplate(t *testing.T, testDefaultUserTemplate string,
expectedValidPrincipal string, testEntityMetadata map[string]string,
) {
cluster, userpassToken := getSshCaTestCluster(t, testUserName)
defer cluster.Cleanup()
client := cluster.Cores[0].Client
// set metadata "ssh_username" to userpass username
@ -2282,7 +2281,7 @@ func testAllowedPrincipalsTemplate(t *testing.T, testAllowedDomainsTemplate stri
roleConfigPayload map[string]interface{}, signingPayload map[string]interface{},
) {
cluster, userpassToken := getSshCaTestCluster(t, testUserName)
defer cluster.Cleanup()
client := cluster.Cores[0].Client
// set metadata "ssh_username" to userpass username
@ -3096,8 +3095,7 @@ func TestProperAuthing(t *testing.T) {
cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
client := cluster.Cores[0].Client
token := client.Token()

View File

@ -2024,8 +2024,6 @@ func TestTransitPKICSR(t *testing.T) {
cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
cores := cluster.Cores

View File

@ -128,9 +128,6 @@ func TestTransit_Certs_ImportCertChain(t *testing.T) {
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
cores := cluster.Cores
vault.TestWaitActive(t, cores[0].Core)
client := cores[0].Client
@ -272,9 +269,6 @@ func TestTransit_Certs_ImportInvalidCertChain(t *testing.T) {
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
cores := cluster.Cores
vault.TestWaitActive(t, cores[0].Core)
client := cores[0].Client

View File

@ -526,12 +526,7 @@ func TestTransit_Export_CertificateChain(t *testing.T) {
cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
cores := cluster.Cores
vault.TestWaitActive(t, cores[0].Core)
client := cores[0].Client
// Mount transit backend

View File

@ -419,8 +419,6 @@ func TestHMACBatchResultsFields(t *testing.T) {
cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
cores := cluster.Cores

View File

@ -346,8 +346,6 @@ func TestTransit_UpdateKeyConfigWithAutorotation(t *testing.T) {
cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
cores := cluster.Cores
vault.TestWaitActive(t, cores[0].Core)
client := cores[0].Client

View File

@ -34,13 +34,7 @@ func TestTransit_Issue_2958(t *testing.T) {
cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
cores := cluster.Cores
vault.TestWaitActive(t, cores[0].Core)
client := cores[0].Client
err := client.Sys().EnableAuditWithOptions("file", &api.EnableAuditOptions{
@ -143,10 +137,7 @@ func TestTransit_CreateKeyWithAutorotation(t *testing.T) {
cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
cores := cluster.Cores
vault.TestWaitActive(t, cores[0].Core)
client := cores[0].Client
err := client.Sys().Mount("transit", &api.MountInput{
Type: "transit",
@ -365,10 +356,7 @@ func TestTransit_CreateKey(t *testing.T) {
cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
cores := cluster.Cores
vault.TestWaitActive(t, cores[0].Core)
client := cores[0].Client
err := client.Sys().Mount("transit", &api.MountInput{
Type: "transit",

View File

@ -123,7 +123,6 @@ func testConfig(t *testing.T, pluginCmd string) (*logical.BackendConfig, func())
}, &vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
cores := cluster.Cores
core := cores[0]
@ -144,6 +143,5 @@ func testConfig(t *testing.T, pluginCmd string) (*logical.BackendConfig, func())
[]string{fmt.Sprintf("%s=%s", pluginutil.PluginCACertPEMEnv, cluster.CACertPEMFile)})
return config, func() {
cluster.Cleanup()
}
}

View File

@ -55,10 +55,7 @@ func TestAliCloudEndToEnd(t *testing.T) {
cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
vault.TestWaitActive(t, cluster.Cores[0].Core)
client := cluster.Cores[0].Client
// Setup Vault

View File

@ -80,14 +80,7 @@ func testAppRoleEndToEnd(t *testing.T, removeSecretIDFile bool, bindSecretID boo
cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
cores := cluster.Cores
vault.TestWaitActive(t, cores[0].Core)
client := cores[0].Client
err = client.Sys().EnableAuthWithOptions("approle", &api.EnableAuthOptions{
@ -418,14 +411,7 @@ func TestAppRoleLongRoleName(t *testing.T) {
cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
cores := cluster.Cores
vault.TestWaitActive(t, cores[0].Core)
client := cores[0].Client
err := client.Sys().EnableAuthWithOptions("approle", &api.EnableAuthOptions{
@ -482,9 +468,6 @@ func testAppRoleWithWrapping(t *testing.T, bindSecretID bool, secretIDLess bool,
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
cores := cluster.Cores
vault.TestWaitActive(t, cores[0].Core)

View File

@ -36,10 +36,7 @@ func TestTokenPreload_UsingAutoAuth(t *testing.T) {
cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
vault.TestWaitActive(t, cluster.Cores[0].Core)
client := cluster.Cores[0].Client
// Setup Vault

View File

@ -68,10 +68,7 @@ func TestAWSEndToEnd(t *testing.T) {
cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
vault.TestWaitActive(t, cluster.Cores[0].Core)
client := cluster.Cores[0].Client
// Setup Vault

View File

@ -56,9 +56,6 @@ func TestCache_UsingAutoAuthToken(t *testing.T) {
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
cores := cluster.Cores
vault.TestWaitActive(t, cores[0].Core)

View File

@ -73,10 +73,7 @@ func testCertEndToEnd(t *testing.T, withCertRoleName, ahWrapping bool) {
cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
vault.TestWaitActive(t, cluster.Cores[0].Core)
client := cluster.Cores[0].Client
// Setup Vault
@ -315,10 +312,7 @@ func TestCertEndToEnd_CertsInConfig(t *testing.T) {
cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
vault.TestWaitActive(t, cluster.Cores[0].Core)
client := cluster.Cores[0].Client
// /////////////

View File

@ -38,9 +38,6 @@ func TestCFEndToEnd(t *testing.T) {
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
cores := cluster.Cores
vault.TestWaitActive(t, cores[0].Core)
client := cores[0].Client

View File

@ -62,10 +62,7 @@ func testJWTEndToEnd(t *testing.T, ahWrapping, useSymlink, removeJWTAfterReading
cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
vault.TestWaitActive(t, cluster.Cores[0].Core)
client := cluster.Cores[0].Client
// Setup Vault

View File

@ -66,10 +66,7 @@ func TestOCIEndToEnd(t *testing.T) {
cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
vault.TestWaitActive(t, cluster.Cores[0].Core)
client := cluster.Cores[0].Client
// Setup Vault

View File

@ -26,9 +26,6 @@ func TestTokenFileEndToEnd(t *testing.T) {
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
cores := cluster.Cores
vault.TestWaitActive(t, cores[0].Core)

View File

@ -119,10 +119,7 @@ func testAgentExitAfterAuth(t *testing.T, viaFlag bool) {
cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
vault.TestWaitActive(t, cluster.Cores[0].Core)
client := cluster.Cores[0].Client
// Setup Vault
@ -308,9 +305,7 @@ func TestAgent_RequireRequestHeader(t *testing.T) {
&vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
vault.TestWaitActive(t, cluster.Cores[0].Core)
serverClient := cluster.Cores[0].Client
// Enable the approle auth method
@ -620,10 +615,7 @@ func TestAgent_Template_UserAgent(t *testing.T) {
return &h
}),
})
cluster.Start()
defer cluster.Cleanup()
vault.TestWaitActive(t, cluster.Cores[0].Core)
serverClient := cluster.Cores[0].Client
// Unset the environment variable so that agent picks up the right test
@ -790,10 +782,7 @@ func TestAgent_Template_Basic(t *testing.T) {
&vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
vault.TestWaitActive(t, cluster.Cores[0].Core)
serverClient := cluster.Cores[0].Client
// Unset the environment variable so that agent picks up the right test
@ -1097,10 +1086,7 @@ func TestAgent_Template_VaultClientFromEnv(t *testing.T) {
&vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
vault.TestWaitActive(t, cluster.Cores[0].Core)
serverClient := cluster.Cores[0].Client
roleIDPath, secretIDPath := setupAppRoleAndKVMounts(t, serverClient)
@ -1274,10 +1260,7 @@ func TestAgent_Template_ExitCounter(t *testing.T) {
&vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
vault.TestWaitActive(t, cluster.Cores[0].Core)
serverClient := cluster.Cores[0].Client
// Unset the environment variable so that agent picks up the right test
@ -1572,10 +1555,7 @@ func TestAgent_Template_Retry(t *testing.T) {
return &h
}),
})
cluster.Start()
defer cluster.Cleanup()
vault.TestWaitActive(t, cluster.Cores[0].Core)
serverClient := cluster.Cores[0].Client
// Unset the environment variable so that agent picks up the right test
@ -1852,8 +1832,6 @@ func TestAgent_AutoAuth_UserAgent(t *testing.T) {
return &h
}),
})
cluster.Start()
defer cluster.Cleanup()
serverClient := cluster.Cores[0].Client
@ -1968,8 +1946,6 @@ func TestAgent_APIProxyWithoutCache_UserAgent(t *testing.T) {
return &h
}),
})
cluster.Start()
defer cluster.Cleanup()
serverClient := cluster.Cores[0].Client
@ -2054,8 +2030,6 @@ func TestAgent_APIProxyWithCache_UserAgent(t *testing.T) {
return &h
}),
})
cluster.Start()
defer cluster.Cleanup()
serverClient := cluster.Cores[0].Client
@ -2129,8 +2103,6 @@ func TestAgent_Cache_DynamicSecret(t *testing.T) {
cluster := vault.NewTestCluster(t, nil, &vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
serverClient := cluster.Cores[0].Client
@ -2251,10 +2223,7 @@ func TestAgent_ApiProxy_Retry(t *testing.T) {
return &h
}),
})
cluster.Start()
defer cluster.Cleanup()
vault.TestWaitActive(t, cluster.Cores[0].Core)
serverClient := cluster.Cores[0].Client
// Unset the environment variable so that agent picks up the right test
@ -2397,10 +2366,7 @@ func TestAgent_TemplateConfig_ExitOnRetryFailure(t *testing.T) {
NumCores: 1,
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
vault.TestWaitActive(t, cluster.Cores[0].Core)
serverClient := cluster.Cores[0].Client
// Unset the environment variable so that agent picks up the right test
@ -2690,9 +2656,7 @@ func TestAgent_Metrics(t *testing.T) {
&vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
vault.TestWaitActive(t, cluster.Cores[0].Core)
serverClient := cluster.Cores[0].Client
// Create a config file
@ -3164,8 +3128,6 @@ func TestAgent_NonTLSListener_SIGHUP(t *testing.T) {
cluster := vault.NewTestCluster(t, nil, &vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
serverClient := cluster.Cores[0].Client
@ -3238,8 +3200,6 @@ func TestAgent_TokenRenewal(t *testing.T) {
cluster := vault.NewTestCluster(t, nil, &vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
serverClient := cluster.Cores[0].Client
@ -3479,10 +3439,7 @@ func TestAgent_DeleteAfterVersion_Rendering(t *testing.T) {
NumCores: 1,
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
vault.TestWaitActive(t, cluster.Cores[0].Core)
serverClient := cluster.Cores[0].Client
// Set up KVv2

View File

@ -73,10 +73,7 @@ func TestAuthHandler(t *testing.T) {
cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
vault.TestWaitActive(t, cluster.Cores[0].Core)
client := cluster.Cores[0].Client
ctx, cancelFunc := context.WithCancel(context.Background())

View File

@ -201,11 +201,7 @@ func setupClusterAndAgentCommon(ctx context.Context, t *testing.T, coreConfig *v
cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
cores := cluster.Cores
vault.TestWaitActive(t, cores[0].Core)
activeClient := cores[0].Client
standbyClient := cores[1].Client
@ -322,8 +318,6 @@ func setupClusterAndAgentCommon(ctx context.Context, t *testing.T, coreConfig *v
cleanup := func() {
// We wait for a tiny bit for things such as agent renewal to exit properly
time.Sleep(50 * time.Millisecond)
cluster.Cleanup()
os.Setenv(api.EnvVaultAddress, origEnvVaultAddress)
os.Setenv(api.EnvVaultCACert, origEnvVaultCACert)
listener.Close()

View File

@ -62,8 +62,6 @@ func TestCache_AutoAuthTokenStripping(t *testing.T) {
cluster := vault.NewTestCluster(t, nil, &vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
cores := cluster.Cores
vault.TestWaitActive(t, cores[0].Core)
@ -151,12 +149,7 @@ func TestCache_AutoAuthClientTokenProxyStripping(t *testing.T) {
cluster := vault.NewTestCluster(t, nil, &vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
cores := cluster.Cores
vault.TestWaitActive(t, cores[0].Core)
client := cores[0].Client
client := cluster.Cores[0].Client
cacheLogger := logging.NewVaultLogger(hclog.Trace).Named("cache")
listener, err := net.Listen("tcp", "127.0.0.1:0")

View File

@ -27,14 +27,7 @@ func TestAppRole_Integ_ConcurrentLogins(t *testing.T) {
cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
cores := cluster.Cores
vault.TestWaitActive(t, cores[0].Core)
client := cores[0].Client
err = client.Sys().EnableAuthWithOptions("approle", &api.EnableAuthOptions{

View File

@ -209,7 +209,6 @@ func testVaultServerCoreConfigWithOpts(tb testing.TB, coreConfig *vault.CoreConf
tb.Helper()
cluster := vault.NewTestCluster(tb, coreConfig, opts)
cluster.Start()
// Make it easy to get access to the active
core := cluster.Cores[0].Core
@ -226,7 +225,7 @@ func testVaultServerCoreConfigWithOpts(tb testing.TB, coreConfig *vault.CoreConf
keys = cluster.BarrierKeys
}
return client, encodeKeys(keys), cluster.Cleanup
return client, encodeKeys(keys), func() {}
}
// Convert the unseal keys to base64 encoded, since these are how the user

View File

@ -43,10 +43,6 @@ func TestOperatorUsageCommandRun(t *testing.T) {
HandlerFunc: vaulthttp.Handler,
NumCores: 1,
})
defer cluster.Cleanup()
core := cluster.Cores[0].Core
vault.TestWaitActive(t, core)
client := cluster.Cores[0].Client
_, err := client.Logical().Write("sys/internal/counters/config", map[string]interface{}{"enabled": "enable"})
require.NoError(t, err)

View File

@ -74,10 +74,7 @@ func testProxyExitAfterAuth(t *testing.T, viaFlag bool) {
cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
vault.TestWaitActive(t, cluster.Cores[0].Core)
client := cluster.Cores[0].Client
// Setup Vault
@ -237,8 +234,6 @@ func TestProxy_NoTriggerAutoAuth_BadPolicy(t *testing.T) {
HandlerFunc: vaulthttp.Handler,
Logger: vaultLogger,
})
cluster.Start()
defer cluster.Cleanup()
serverClient := cluster.Cores[0].Client
@ -550,8 +545,6 @@ func TestProxy_ReTriggerAutoAuth_ForceAutoAuthToken(t *testing.T) {
HandlerFunc: vaulthttp.Handler,
Logger: vaultLogger,
})
cluster.Start()
defer cluster.Cleanup()
serverClient := cluster.Cores[0].Client
@ -709,8 +702,6 @@ func TestProxy_ReTriggerAutoAuth_ProxyIsAutoAuthToken(t *testing.T) {
HandlerFunc: vaulthttp.Handler,
Logger: vaultLogger,
})
cluster.Start()
defer cluster.Cleanup()
serverClient := cluster.Cores[0].Client
@ -899,8 +890,6 @@ func TestProxy_ReTriggerAutoAuth_RevokedToken(t *testing.T) {
HandlerFunc: vaulthttp.Handler,
Logger: vaultLogger,
})
cluster.Start()
defer cluster.Cleanup()
serverClient := cluster.Cores[0].Client
@ -1093,8 +1082,6 @@ func TestProxy_AutoAuth_UserAgent(t *testing.T) {
return &h
}),
})
cluster.Start()
defer cluster.Cleanup()
serverClient := cluster.Cores[0].Client
@ -1240,8 +1227,6 @@ func TestProxy_APIProxyWithoutCache_UserAgent(t *testing.T) {
return &h
}),
})
cluster.Start()
defer cluster.Cleanup()
serverClient := cluster.Cores[0].Client
@ -1326,8 +1311,6 @@ func TestProxy_APIProxyWithCache_UserAgent(t *testing.T) {
return &h
}),
})
cluster.Start()
defer cluster.Cleanup()
serverClient := cluster.Cores[0].Client
@ -1403,8 +1386,6 @@ func TestProxy_Cache_DynamicSecret(t *testing.T) {
cluster := vault.NewTestCluster(t, nil, &vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
serverClient := cluster.Cores[0].Client
@ -1509,8 +1490,6 @@ func TestProxy_NoAutoAuthTokenIfNotConfigured(t *testing.T) {
cluster := vault.NewTestCluster(t, nil, &vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
serverClient := cluster.Cores[0].Client
@ -1636,10 +1615,7 @@ func TestProxy_ApiProxy_Retry(t *testing.T) {
return &h
}),
})
cluster.Start()
defer cluster.Cleanup()
vault.TestWaitActive(t, cluster.Cores[0].Core)
serverClient := cluster.Cores[0].Client
// Unset the environment variable so that proxy picks up the right test
@ -1772,9 +1748,7 @@ func TestProxy_Metrics(t *testing.T) {
&vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
vault.TestWaitActive(t, cluster.Cores[0].Core)
serverClient := cluster.Cores[0].Client
// Create a config file

View File

@ -33,7 +33,6 @@ func testStatusCommand(tb testing.TB) (*cli.MockUi, *StatusCommand) {
func TestStatusCommand_RaftCluster(t *testing.T) {
t.Parallel()
cluster := testVaultRaftCluster(t)
defer cluster.Cleanup()
toRemove := cluster.Cores[1]
expectRemovedFromCluster := func(expectCode int, removed bool) {

View File

@ -50,9 +50,6 @@ func TestBuiltinPluginsWork(t *testing.T) {
},
)
cluster.Start()
defer cluster.Cleanup()
cores := cluster.Cores
vault.TestWaitActive(t, cores[0].Core)
client := cores[0].Client

View File

@ -22,7 +22,7 @@ import (
// NewTestSoloCluster is a simpler version of NewTestCluster that only creates
// single-node clusters. It is intentionally minimalist, if you need something
// from vault.TestClusterOptions, use NewTestCluster instead. It should work fine
// with a nil config argument. There is no need to call Start or Cleanup or
// with a nil config argument. There is no need to call Cleanup or
// TestWaitActive on the resulting cluster.
func NewTestSoloCluster(t testing.TB, config *vault.CoreConfig) *vault.TestCluster {
logger := corehelpers.NewTestLogger(t)

View File

@ -36,7 +36,6 @@ func NewTransitSealServer(t testing.TB, idx int) *TransitSealServer {
}
teststorage.InmemBackendSetup(conf, opts)
cluster := vault.NewTestCluster(t, conf, opts)
cluster.Start()
if err := cluster.Cores[0].Client.Sys().Mount("transit", &api.MountInput{
Type: "transit",

View File

@ -253,9 +253,6 @@ func TestToken_InvalidTokenError(t *testing.T) {
HandlerFunc: Handler,
})
cluster.Start()
defer cluster.Cleanup()
cores := cluster.Cores
vault.TestWaitActive(t, cores[0].Core)

View File

@ -54,8 +54,6 @@ func TestHandler_XForwardedFor(t *testing.T) {
cluster := vault.NewTestCluster(t, nil, &vault.TestClusterOptions{
HandlerFunc: HandlerFunc(testHandler),
})
cluster.Start()
defer cluster.Cleanup()
client := cluster.Cores[0].Client
req := client.NewRequest("GET", "/")
@ -97,8 +95,6 @@ func TestHandler_XForwardedFor(t *testing.T) {
cluster := vault.NewTestCluster(t, nil, &vault.TestClusterOptions{
HandlerFunc: HandlerFunc(testHandler),
})
cluster.Start()
defer cluster.Cleanup()
client := cluster.Cores[0].Client
req := client.NewRequest("GET", "/")
@ -133,8 +129,6 @@ func TestHandler_XForwardedFor(t *testing.T) {
cluster := vault.NewTestCluster(t, nil, &vault.TestClusterOptions{
HandlerFunc: HandlerFunc(testHandler),
})
cluster.Start()
defer cluster.Cleanup()
client := cluster.Cores[0].Client
req := client.NewRequest("GET", "/")
@ -167,8 +161,6 @@ func TestHandler_XForwardedFor(t *testing.T) {
cluster := vault.NewTestCluster(t, nil, &vault.TestClusterOptions{
HandlerFunc: HandlerFunc(testHandler),
})
cluster.Start()
defer cluster.Cleanup()
client := cluster.Cores[0].Client
req := client.NewRequest("GET", "/")
@ -201,8 +193,6 @@ func TestHandler_XForwardedFor(t *testing.T) {
cluster := vault.NewTestCluster(t, nil, &vault.TestClusterOptions{
HandlerFunc: HandlerFunc(testHandler),
})
cluster.Start()
defer cluster.Cleanup()
client := cluster.Cores[0].Client
req := client.NewRequest("GET", "/")
@ -238,8 +228,6 @@ func TestHandler_XForwardedFor(t *testing.T) {
cluster := vault.NewTestCluster(t, nil, &vault.TestClusterOptions{
HandlerFunc: HandlerFunc(testHandler),
})
cluster.Start()
defer cluster.Cleanup()
client := cluster.Cores[0].Client
req := client.NewRequest("GET", "/")
@ -276,8 +264,6 @@ func TestHandler_XForwardedFor(t *testing.T) {
cluster := vault.NewTestCluster(t, nil, &vault.TestClusterOptions{
HandlerFunc: HandlerFunc(testHandler),
})
cluster.Start()
defer cluster.Cleanup()
client := cluster.Cores[0].Client
req := client.NewRequest("GET", "/")
@ -313,8 +299,6 @@ func TestHandler_XForwardedFor(t *testing.T) {
cluster := vault.NewTestCluster(t, nil, &vault.TestClusterOptions{
HandlerFunc: HandlerFunc(testHandler),
})
cluster.Start()
defer cluster.Cleanup()
client := cluster.Cores[0].Client
req := client.NewRequest("GET", "/")
@ -352,8 +336,6 @@ func TestHandler_XForwardedFor(t *testing.T) {
cluster := vault.NewTestCluster(t, nil, &vault.TestClusterOptions{
HandlerFunc: HandlerFunc(testHandler),
})
cluster.Start()
defer cluster.Cleanup()
client := cluster.Cores[0].Client
req := client.NewRequest("GET", "/")
@ -393,8 +375,6 @@ func TestHandler_XForwardedFor(t *testing.T) {
cluster := vault.NewTestCluster(t, nil, &vault.TestClusterOptions{
HandlerFunc: HandlerFunc(testHandler),
})
cluster.Start()
defer cluster.Cleanup()
client := cluster.Cores[0].Client
req := client.NewRequest("GET", "/")
@ -431,8 +411,6 @@ func TestHandler_XForwardedFor(t *testing.T) {
cluster := vault.NewTestCluster(t, nil, &vault.TestClusterOptions{
HandlerFunc: HandlerFunc(testHandler),
})
cluster.Start()
defer cluster.Cleanup()
client := cluster.Cores[0].Client
req := client.NewRequest("GET", "/")
@ -459,8 +437,6 @@ func TestHandler_XForwardedFor(t *testing.T) {
cluster := vault.NewTestCluster(t, nil, &vault.TestClusterOptions{
HandlerFunc: HandlerFunc(testHandler),
})
cluster.Start()
defer cluster.Cleanup()
client := cluster.Cores[0].Client
req := client.NewRequest("GET", "/")

View File

@ -35,8 +35,6 @@ func BenchmarkHTTP_Forwarding_Stress(b *testing.B) {
HandlerFunc: Handler,
Logger: logging.NewVaultLoggerWithWriter(ioutil.Discard, log.Error),
})
cluster.Start()
defer cluster.Cleanup()
cores := cluster.Cores
// make it easy to get access to the active

View File

@ -39,14 +39,8 @@ func TestHTTP_Fallback_Bad_Address(t *testing.T) {
cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{
HandlerFunc: Handler,
})
cluster.Start()
defer cluster.Cleanup()
cores := cluster.Cores
// make it easy to get access to the active
core := cores[0].Core
vault.TestWaitActive(t, core)
addrs := []string{
fmt.Sprintf("https://127.0.0.1:%d", cores[1].Listeners[0].Address.Port),
fmt.Sprintf("https://127.0.0.1:%d", cores[2].Listeners[0].Address.Port),
@ -87,14 +81,8 @@ func TestHTTP_Fallback_Disabled(t *testing.T) {
cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{
HandlerFunc: Handler,
})
cluster.Start()
defer cluster.Cleanup()
cores := cluster.Cores
// make it easy to get access to the active
core := cores[0].Core
vault.TestWaitActive(t, core)
addrs := []string{
fmt.Sprintf("https://127.0.0.1:%d", cores[1].Listeners[0].Address.Port),
fmt.Sprintf("https://127.0.0.1:%d", cores[2].Listeners[0].Address.Port),
@ -144,13 +132,8 @@ func testHTTP_Forwarding_Stress_Common(t *testing.T, parallel bool, num uint32)
cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{
HandlerFunc: Handler,
})
cluster.Start()
defer cluster.Cleanup()
cores := cluster.Cores
// make it easy to get access to the active
core := cores[0].Core
vault.TestWaitActive(t, core)
wg := sync.WaitGroup{}
@ -452,14 +435,8 @@ func TestHTTP_Forwarding_ClientTLS(t *testing.T) {
cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{
HandlerFunc: Handler,
})
cluster.Start()
defer cluster.Cleanup()
cores := cluster.Cores
// make it easy to get access to the active
core := cores[0].Core
vault.TestWaitActive(t, core)
transport := cleanhttp.DefaultTransport()
transport.TLSClientConfig = cores[0].TLSConfig()
if err := http2.ConfigureTransport(transport); err != nil {
@ -565,12 +542,8 @@ func TestHTTP_Forwarding_HelpOperation(t *testing.T) {
cluster := vault.NewTestCluster(t, &vault.CoreConfig{}, &vault.TestClusterOptions{
HandlerFunc: Handler,
})
cluster.Start()
defer cluster.Cleanup()
cores := cluster.Cores
vault.TestWaitActive(t, cores[0].Core)
testHelp := func(client *api.Client) {
help, err := client.Help("auth/token")
if err != nil {
@ -589,12 +562,8 @@ func TestHTTP_Forwarding_LocalOnly(t *testing.T) {
cluster := vault.NewTestCluster(t, nil, &vault.TestClusterOptions{
HandlerFunc: Handler,
})
cluster.Start()
defer cluster.Cleanup()
cores := cluster.Cores
vault.TestWaitActive(t, cores[0].Core)
testLocalOnly := func(client *api.Client) {
_, err := client.Logical().Read("sys/config/state/sanitized")
if err == nil {

View File

@ -897,14 +897,8 @@ func TestHandler_Parse_Form(t *testing.T) {
cluster := vault.NewTestCluster(t, &vault.CoreConfig{}, &vault.TestClusterOptions{
HandlerFunc: Handler,
})
cluster.Start()
defer cluster.Cleanup()
cores := cluster.Cores
core := cores[0].Core
vault.TestWaitActive(t, core)
c := cleanhttp.DefaultClient()
c.Transport = &http.Transport{
TLSClientConfig: &tls.Config{
@ -967,8 +961,6 @@ func TestHandler_MaxRequestSize(t *testing.T) {
HandlerFunc: Handler,
NumCores: 1,
})
cluster.Start()
defer cluster.Cleanup()
client := cluster.Cores[0].Client
_, err := client.KVv2("secret").Put(context.Background(), "foo", map[string]interface{}{
@ -1203,8 +1195,6 @@ func TestHandler_JSONLimitQuotaWrappers(t *testing.T) {
},
},
})
cluster.Start()
defer cluster.Cleanup()
client := cluster.Cores[0].Client
client.SetToken(cluster.RootToken)
@ -1253,9 +1243,6 @@ func TestAutoSnapshotLoadForwarded(t *testing.T) {
HandlerFunc: Handler,
})
cluster.Start()
defer cluster.Cleanup()
client := cluster.Cores[1].Client
client.SetToken(cluster.RootToken)

View File

@ -20,11 +20,6 @@ import (
)
func testHttpGet(t *testing.T, token string, addr string) *http.Response {
loggedToken := token
if len(token) == 0 {
loggedToken = "<empty>"
}
t.Logf("Token is %s", loggedToken)
return testHttpData(t, "GET", token, addr, "", nil, false, 0, false)
}

View File

@ -708,15 +708,7 @@ func TestLogical_AuditPort(t *testing.T) {
cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{
HandlerFunc: Handler,
})
cluster.Start()
defer cluster.Cleanup()
cores := cluster.Cores
core := cores[0].Core
c := cluster.Cores[0].Client
vault.TestWaitActive(t, core)
if err := c.Sys().Mount("kv/", &api.MountInput{
Type: "kv-v2",
@ -812,15 +804,7 @@ func TestLogical_ErrRelativePath(t *testing.T) {
cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{
HandlerFunc: Handler,
})
cluster.Start()
defer cluster.Cleanup()
cores := cluster.Cores
core := cores[0].Core
c := cluster.Cores[0].Client
vault.TestWaitActive(t, core)
err := c.Sys().EnableAuthWithOptions("userpass", &api.EnableAuthOptions{
Type: "userpass",
@ -917,15 +901,7 @@ func TestLogical_AuditEnabled_ShouldLogPluginMetadata_Auth(t *testing.T) {
cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{
HandlerFunc: Handler,
})
cluster.Start()
defer cluster.Cleanup()
cores := cluster.Cores
core := cores[0].Core
c := cluster.Cores[0].Client
vault.TestWaitActive(t, core)
// Enable the audit backend
tempDir := t.TempDir()
@ -997,15 +973,7 @@ func TestLogical_AuditEnabled_ShouldLogPluginMetadata_Secret(t *testing.T) {
cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{
HandlerFunc: Handler,
})
cluster.Start()
defer cluster.Cleanup()
cores := cluster.Cores
core := cores[0].Core
c := cluster.Cores[0].Client
vault.TestWaitActive(t, core)
if err := c.Sys().Mount("kv/", &api.MountInput{
Type: "kv-v2",

View File

@ -50,12 +50,10 @@ func getPluginClusterAndCore(t *testing.T, logger log.Logger) (*vault.TestCluste
cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{
HandlerFunc: Handler,
})
cluster.Start()
cores := cluster.Cores
core := cores[0]
vault.TestWaitActive(t, core.Core)
vault.TestAddTestPlugin(t, core.Core, "mock-plugin", consts.PluginTypeSecrets, "", "TestPlugin_PluginMain",
[]string{fmt.Sprintf("%s=%s", pluginutil.PluginCACertPEMEnv, cluster.CACertPEMFile)})
@ -101,8 +99,7 @@ func TestPlugin_MockList(t *testing.T) {
logger := log.New(&log.LoggerOptions{
Mutex: &sync.Mutex{},
})
cluster, core := getPluginClusterAndCore(t, logger)
defer cluster.Cleanup()
_, core := getPluginClusterAndCore(t, logger)
_, err := core.Client.Logical().Write("mock/kv/foo", map[string]interface{}{
"value": "baz",
@ -139,8 +136,7 @@ func TestPlugin_MockRawResponse(t *testing.T) {
logger := log.New(&log.LoggerOptions{
Mutex: &sync.Mutex{},
})
cluster, core := getPluginClusterAndCore(t, logger)
defer cluster.Cleanup()
_, core := getPluginClusterAndCore(t, logger)
resp, err := core.Client.RawRequest(core.Client.NewRequest("GET", "/v1/mock/raw"))
if err != nil {
@ -164,8 +160,7 @@ func TestPlugin_GetParams(t *testing.T) {
logger := log.New(&log.LoggerOptions{
Mutex: &sync.Mutex{},
})
cluster, core := getPluginClusterAndCore(t, logger)
defer cluster.Cleanup()
_, core := getPluginClusterAndCore(t, logger)
_, err := core.Client.Logical().Write("mock/kv/foo", map[string]interface{}{
"value": "baz",

View File

@ -15,12 +15,8 @@ func TestSysHostInfo(t *testing.T) {
cluster := vault.NewTestCluster(t, &vault.CoreConfig{}, &vault.TestClusterOptions{
HandlerFunc: Handler,
})
cluster.Start()
defer cluster.Cleanup()
cores := cluster.Cores
vault.TestWaitActive(t, cores[0].Core)
// Query against the active node, should get host information back
secret, err := cores[0].Client.Logical().Read("sys/host-info")
if err != nil {

View File

@ -168,8 +168,6 @@ func TestSysInit_Put_ValidateParams_AutoUnseal(t *testing.T) {
Logger: corehelpers.NewTestLogger(t).Named("transit-seal" + strconv.Itoa(0)),
}
cluster := vault.NewTestCluster(t, conf, opts)
cluster.Start()
defer cluster.Cleanup()
cores := cluster.Cores
core := cores[0].Core

View File

@ -20,7 +20,6 @@ func TestSysMonitorUnknownLogLevel(t *testing.T) {
HandlerFunc: Handler,
NumCores: 1,
})
defer cluster.Cleanup()
client := cluster.Cores[0].Client
request := client.NewRequest("GET", "/v1/sys/monitor")
@ -46,7 +45,6 @@ func TestSysMonitorUnknownLogFormat(t *testing.T) {
HandlerFunc: Handler,
NumCores: 1,
})
defer cluster.Cleanup()
client := cluster.Cores[0].Client
request := client.NewRequest("GET", "/v1/sys/monitor")
@ -72,7 +70,6 @@ func TestSysMonitorStreamingLogs(t *testing.T) {
HandlerFunc: Handler,
NumCores: 1,
})
defer cluster.Cleanup()
client := cluster.Cores[0].Client
stopCh := testhelpers.GenerateDebugLogs(t, client)

View File

@ -23,8 +23,6 @@ func TestSysRekey_Init_pgpKeysEntriesForRekey(t *testing.T) {
HandlerFunc: Handler,
NumCores: 1,
})
cluster.Start()
defer cluster.Cleanup()
cl := cluster.Cores[0].Client
_, err := cl.Logical().Write("sys/rekey/init", map[string]interface{}{
@ -42,7 +40,6 @@ func TestSysRekey_Init_Status(t *testing.T) {
HandlerFunc: Handler,
NumCores: 1,
})
defer cluster.Cleanup()
cl := cluster.Cores[0].Client
testCases := []struct {
@ -126,8 +123,6 @@ func TestSysRekey_Init_Setup(t *testing.T) {
HandlerFunc: Handler,
NumCores: 1,
})
cluster.Start()
defer cluster.Cleanup()
cl := cluster.Cores[0].Client
// Start rekey
@ -195,7 +190,6 @@ func TestSysRekey_Init_Cancel(t *testing.T) {
HandlerFunc: Handler,
NumCores: 1,
})
defer cluster.Cleanup()
cl := cluster.Cores[0].Client
initResp, err := cl.Logical().Write("sys/rekey/init", map[string]interface{}{
@ -295,7 +289,6 @@ func TestSysRekey_Update(t *testing.T) {
HandlerFunc: Handler,
NumCores: 1,
})
defer cluster.Cleanup()
cl := cluster.Cores[0].Client
reqToken := ""

View File

@ -20,15 +20,7 @@ func TestHTTP_Wrapping(t *testing.T) {
cluster := vault.NewTestCluster(t, &vault.CoreConfig{}, &vault.TestClusterOptions{
HandlerFunc: Handler,
})
cluster.Start()
defer cluster.Cleanup()
cores := cluster.Cores
// make it easy to get access to the active
core := cores[0].Core
vault.TestWaitActive(t, core)
client := cores[0].Client
client.SetToken(cluster.RootToken)

View File

@ -44,7 +44,6 @@ func newTestClusterForTokenHeader(t *testing.T, opts *vault.TestClusterOptions)
}
opts.HandlerFunc = Handler
cluster := vault.NewTestCluster(t, nil, opts)
cluster.Start()
core := cluster.Cores[0]
transport := cleanhttp.DefaultPooledTransport()

View File

@ -21,11 +21,6 @@ func TestUnwrapping_Raw_Body(t *testing.T) {
cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{
HandlerFunc: Handler,
})
cluster.Start()
defer cluster.Cleanup()
core := cluster.Cores[0].Core
vault.TestWaitActive(t, core)
client := cluster.Cores[0].Client
// Mount a k/v backend, version 2

View File

@ -681,7 +681,6 @@ func TestAuditBroker_AuditHeaders(t *testing.T) {
// only options on a non-Enterprise version of Vault.
func TestAudit_enableAudit(t *testing.T) {
cluster := NewTestCluster(t, nil, &TestClusterOptions{NumCores: 1})
defer cluster.Cleanup()
c := cluster.Cores[0]
@ -707,7 +706,6 @@ func TestAudit_enableAudit(t *testing.T) {
// with Enterprise only options on a non-Enterprise version of Vault.
func TestAudit_newAuditBackend(t *testing.T) {
cluster := NewTestCluster(t, nil, &TestClusterOptions{NumCores: 1})
defer cluster.Cleanup()
c := cluster.Cores[0]

View File

@ -74,10 +74,9 @@ func BenchmarkSmoke_ClusterCreation(b *testing.B) {
bench := func(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
cluster := vault.NewTestCluster(b, &vault.CoreConfig{}, &vault.TestClusterOptions{
_ = vault.NewTestCluster(b, &vault.CoreConfig{}, &vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Cleanup()
}
}

View File

@ -98,8 +98,6 @@ func TestCluster_ListenForRequests(t *testing.T) {
cluster := NewTestCluster(t, nil, &TestClusterOptions{
KeepStandbysSealed: true,
})
cluster.Start()
defer cluster.Cleanup()
cores := cluster.Cores
// Wait for core to become active
@ -216,8 +214,6 @@ func testCluster_ForwardRequestsCommon(t *testing.T, clusterOpts *TestClusterOpt
w.WriteHeader(203)
w.Write([]byte("core3"))
})
cluster.Start()
defer cluster.Cleanup()
root := cluster.RootToken

View File

@ -47,9 +47,6 @@ func TestIdentity_BackendTemplating(t *testing.T) {
cluster := NewTestCluster(t, coreConfig, &TestClusterOptions{})
cluster.Start()
defer cluster.Cleanup()
core := cluster.Cores[0].Core
TestWaitActive(t, core)
@ -181,9 +178,6 @@ func TestDynamicSystemView_GeneratePasswordFromPolicy_successful(t *testing.T) {
cluster := NewTestCluster(t, coreConfig, &TestClusterOptions{})
cluster.Start()
defer cluster.Cleanup()
core := cluster.Cores[0].Core
TestWaitActive(t, core)
@ -296,9 +290,6 @@ func TestDynamicSystemView_PluginEnv_successful(t *testing.T) {
cluster := NewTestCluster(t, coreConfig, &TestClusterOptions{})
cluster.Start()
defer cluster.Cleanup()
core := cluster.Cores[0].Core
TestWaitActive(t, core)

View File

@ -43,9 +43,6 @@ func testClusterWithContainerPlugins(t *testing.T, types []consts.PluginType) (*
Plugins: plugins,
})
cluster.Start()
t.Cleanup(cluster.Cleanup)
core := cluster.Cores[0]
TestWaitActive(t, core.Core)

View File

@ -75,9 +75,6 @@ func TestCore_EnableExternalPlugin(t *testing.T) {
},
})
cluster.Start()
defer cluster.Cleanup()
c := cluster.Cores[0].Core
TestWaitActive(t, c)

View File

@ -79,8 +79,6 @@ func Test_ActivityLog_LoseLeadership(t *testing.T) {
HandlerFunc: vaulthttp.Handler,
NumCores: 2,
})
cluster.Start()
defer cluster.Cleanup()
active := testhelpers.DeriveStableActiveCore(t, cluster)
client := active.Client

View File

@ -59,7 +59,6 @@ func testVaultServerCoreConfig(t testing.TB, coreConfig *vault.CoreConfig) (*api
HandlerFunc: http.Handler,
NumCores: 1,
})
cluster.Start()
// Make it easy to get access to the active
core := cluster.Cores[0].Core
@ -76,5 +75,5 @@ func testVaultServerCoreConfig(t testing.TB, coreConfig *vault.CoreConfig) (*api
unsealKeys[i] = base64.StdEncoding.EncodeToString(cluster.BarrierKeys[i])
}
return client, unsealKeys, func() { defer cluster.Cleanup() }
return client, unsealKeys, func() {}
}

View File

@ -22,12 +22,6 @@ func TestFeatureFlags(t *testing.T) {
HandlerFunc: vaulthttp.Handler,
RequestResponseCallback: schema.ResponseValidatingCallback(t),
})
cluster.Start()
defer cluster.Cleanup()
// Wait for core to start
core := cluster.Cores[0].Core
vault.TestWaitActive(t, core)
client := cluster.Cores[0].Client
// Create a raw http connection copying the configuration

View File

@ -63,9 +63,6 @@ func TestKVHelpers(t *testing.T) {
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
cores := cluster.Cores
core := cores[0].Core
client := cluster.Cores[0].Client

View File

@ -67,10 +67,7 @@ func testSysRekey_Verification(t *testing.T, recovery bool, legacyShamir bool) {
Physical: inm,
}
cluster := vault.NewTestCluster(t, &conf, opts)
cluster.Start()
defer cluster.Cleanup()
vault.TestWaitActive(t, cluster.Cores[0].Core)
client := cluster.Cores[0].Client
client.SetMaxRetries(0)
@ -221,7 +218,6 @@ func testSysRekey_Verification(t *testing.T, recovery bool, legacyShamir bool) {
// still be the old keys (which are still currently set)
cluster.EnsureCoresSealed(t)
cluster.UnsealCores(t)
vault.TestWaitActive(t, cluster.Cores[0].Core)
// Should be able to init again and get back to where we were
doRekeyInitialSteps()
@ -257,8 +253,6 @@ func testSysRekey_Verification(t *testing.T, recovery bool, legacyShamir bool) {
opts.SealFunc = nil // post rekey we should use the barrier config on disk
cluster = vault.NewTestCluster(t, &conf, opts)
cluster.BarrierKeys = oldKeys
cluster.Start()
defer cluster.Cleanup()
if err := cluster.UnsealCoresWithError(t, false); err == nil {
t.Fatal("expected error")

View File

@ -356,7 +356,6 @@ func TestAudit_BeforePostUnseal(t *testing.T) {
HandlerFunc: vaulthttp.Handler,
NumCores: 1,
})
defer cluster.Cleanup()
testhelpers.WaitForActiveNode(t, cluster)
err := cluster.Cores[0].Client.Sys().Mount("test", &api.MountInput{

View File

@ -139,8 +139,6 @@ func TestDelegatedAuth(t *testing.T) {
}
cluster := minimal.NewTestSoloCluster(t, coreConfig)
cluster.Start()
defer cluster.Cleanup()
client := testhelpers.WaitForActiveNode(t, cluster).Client

View File

@ -12,7 +12,6 @@ import (
func TestHCPLinkConnected(t *testing.T) {
cluster := getTestCluster(t, 2)
defer cluster.Cleanup()
vaultHCPLink, _ := TestClusterWithHCPLinkEnabled(t, cluster, false, false)
defer vaultHCPLink.Cleanup()
@ -25,9 +24,7 @@ func TestHCPLinkConnected(t *testing.T) {
func TestHCPLinkNotConfigured(t *testing.T) {
t.Parallel()
cluster := getTestCluster(t, 2)
defer cluster.Cleanup()
cluster.Start()
core := cluster.Cores[0].Core
vault.TestWaitActive(t, core)

View File

@ -103,8 +103,6 @@ func TestClusterWithHCPLinkEnabled(t *testing.T, cluster *vault.TestCluster, ena
}
hcpLinkIns := NewVaultHCPLinkInstances()
cluster.Start()
core := cluster.Cores[0].Core
vault.TestWaitActive(t, core)

View File

@ -70,9 +70,6 @@ func TestLoginMfaGenerateTOTPTestAuditIncluded(t *testing.T) {
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
client := cluster.Cores[0].Client
// Enable the audit backend

View File

@ -48,7 +48,6 @@ const (
// an initial setup of Vault.
func TestOIDC_Auth_Code_Flow_Default_Resources(t *testing.T) {
cluster := setupOIDCTestCluster(t, 2)
defer cluster.Cleanup()
active := cluster.Cores[0].Client
standby := cluster.Cores[1].Client
@ -271,7 +270,6 @@ func TestOIDC_Auth_Code_Flow_Default_Resources(t *testing.T) {
// a client secret and authenticates to the token endpoint.
func TestOIDC_Auth_Code_Flow_Confidential_CAP_Client(t *testing.T) {
cluster := setupOIDCTestCluster(t, 2)
defer cluster.Cleanup()
active := cluster.Cores[0].Client
standby := cluster.Cores[1].Client
@ -621,7 +619,6 @@ func TestOIDC_Auth_Code_Flow_Confidential_CAP_Client(t *testing.T) {
// and always uses proof key for code exchange (PKCE).
func TestOIDC_Auth_Code_Flow_Public_CAP_Client(t *testing.T) {
cluster := setupOIDCTestCluster(t, 2)
defer cluster.Cleanup()
active := cluster.Cores[0].Client
standby := cluster.Cores[1].Client
@ -963,8 +960,6 @@ func setupOIDCTestCluster(t *testing.T, numCores int) *vault.TestCluster {
HandlerFunc: vaulthttp.Handler,
}
cluster := vault.NewTestCluster(t, coreConfig, clusterOptions)
cluster.Start()
vault.TestWaitActive(t, cluster.Cores[0].Core)
return cluster
}

View File

@ -38,8 +38,6 @@ func TestIdentityStore_DisableUserLockoutTest(t *testing.T) {
cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
// standby client
client := cluster.Cores[1].Client

View File

@ -42,11 +42,8 @@ func TestKVv2_UpgradePaths(t *testing.T) {
cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
core := cluster.Cores[0]
vault.TestWaitActive(t, core.Core)
client := core.Client
// Enable KVv2

View File

@ -30,13 +30,7 @@ func TestMountTableMetrics(t *testing.T) {
NumCores: 2,
CoreMetricSinkProvider: testhelpers.TestMetricSinkProvider(time.Minute),
})
cluster.Start()
defer cluster.Cleanup()
// Wait for core to become active
cores := cluster.Cores
vault.TestWaitActive(t, cores[0].Core)
client := cores[0].Client
@ -120,13 +114,7 @@ func TestLeaderReElectionMetrics(t *testing.T) {
NumCores: 2,
CoreMetricSinkProvider: testhelpers.TestMetricSinkProvider(time.Minute),
})
cluster.Start()
defer cluster.Cleanup()
// Wait for core to become active
cores := cluster.Cores
vault.TestWaitActive(t, cores[0].Core)
client := cores[0].Client
standbyClient := cores[1].Client

View File

@ -327,11 +327,6 @@ func TestLoginMFA_ListAllMFAConfigsGlobally(t *testing.T) {
}, &vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
core := cluster.Cores[0].Core
vault.TestWaitActive(t, core)
client := cluster.Cores[0].Client
// Enable userpass authentication

View File

@ -25,11 +25,8 @@ func TestRecoverFromPanic(t *testing.T) {
cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
core := cluster.Cores[0]
vault.TestWaitActive(t, core.Core)
client := core.Client
err := client.Sys().Mount("noop", &api.MountInput{

View File

@ -36,8 +36,6 @@ func TestRecovery(t *testing.T) {
}
cluster := vault.NewTestCluster(t, &conf, &opts)
cluster.Start()
defer cluster.Cleanup()
client := cluster.Cores[0].Client
rootToken = client.Token()
@ -84,8 +82,6 @@ func TestRecovery(t *testing.T) {
}
cluster := vault.NewTestCluster(t, &conf, &opts)
cluster.BarrierKeys = keys
cluster.Start()
defer cluster.Cleanup()
client := cluster.Cores[0].Client
recoveryToken := testhelpers.GenerateRoot(t, cluster, testhelpers.GenerateRecovery)
@ -122,8 +118,6 @@ func TestRecovery(t *testing.T) {
}
cluster := vault.NewTestCluster(t, &conf, &opts)
cluster.BarrierKeys = keys
cluster.Start()
defer cluster.Cleanup()
testhelpers.EnsureCoresUnsealed(t, cluster)
vault.TestWaitActive(t, cluster.Cores[0].Core)

View File

@ -59,9 +59,6 @@ func getCluster(t *testing.T, numCores int, types ...consts.PluginType) *vault.T
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
vault.TestWaitActive(t, cluster.Cores[0].Core)
return cluster
}
@ -88,9 +85,6 @@ func TestExternalPlugin_RollbackAndReload(t *testing.T) {
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
vault.TestWaitActive(t, cluster.Cores[0].Core)
core := cluster.Cores[0]
plugin := cluster.Plugins[0]
client := core.Client
@ -183,7 +177,6 @@ func TestExternalPlugin_ContinueOnError(t *testing.T) {
func testExternalPlugin_ContinueOnError(t *testing.T, mismatch bool, pluginType consts.PluginType) {
cluster := getCluster(t, 1, pluginType)
t.Cleanup(cluster.Cleanup)
core := cluster.Cores[0]
plugin := cluster.Plugins[0]
@ -293,7 +286,6 @@ func TestExternalPlugin_AuthMethod(t *testing.T) {
// getCluster calls pluginhelper.CompilePlugin which builds the approle
// auth method as a stand-in for the PluginTypeCredential
cluster := getCluster(t, 5, consts.PluginTypeCredential)
t.Cleanup(cluster.Cleanup)
plugin := cluster.Plugins[0]
client := cluster.Cores[0].Client
@ -412,7 +404,6 @@ func TestExternalPlugin_AuthMethod(t *testing.T) {
// method after reload
func TestExternalPlugin_AuthMethodReload(t *testing.T) {
cluster := getCluster(t, 1, consts.PluginTypeCredential)
t.Cleanup(cluster.Cleanup)
plugin := cluster.Plugins[0]
client := cluster.Cores[0].Client
@ -494,7 +485,6 @@ func TestExternalPlugin_SecretsEngine(t *testing.T) {
// getCluster calls pluginhelper.CompilePlugin which builds the consul
// secrets engine as a stand-in for the PluginTypeSecrets
cluster := getCluster(t, 1, consts.PluginTypeSecrets)
t.Cleanup(cluster.Cleanup)
plugin := cluster.Plugins[0]
client := cluster.Cores[0].Client
@ -598,7 +588,6 @@ func TestExternalPlugin_SecretsEngine(t *testing.T) {
func TestExternalPlugin_SecretsEngineReload(t *testing.T) {
t.Parallel()
cluster := getCluster(t, 1, consts.PluginTypeSecrets)
t.Cleanup(cluster.Cleanup)
plugin := cluster.Plugins[0]
client := cluster.Cores[0].Client
@ -671,7 +660,6 @@ func TestExternalPlugin_Database(t *testing.T) {
// getCluster calls pluginhelper.CompilePlugin which builds the postgres
// database engine as a stand-in for the PluginTypeSecrets
cluster := getCluster(t, 1, consts.PluginTypeDatabase)
t.Cleanup(cluster.Cleanup)
plugin := cluster.Plugins[0]
client := cluster.Cores[0].Client
@ -805,7 +793,6 @@ func TestExternalPlugin_Database(t *testing.T) {
func TestExternalPlugin_DatabaseReload(t *testing.T) {
t.Parallel()
cluster := getCluster(t, 1, consts.PluginTypeDatabase)
t.Cleanup(cluster.Cleanup)
plugin := cluster.Plugins[0]
client := cluster.Cores[0].Client
@ -940,7 +927,6 @@ func testExternalPluginMetadataAuditLog(t *testing.T, log map[string]interface{}
// in audit log when it is enabled
func TestExternalPlugin_AuditEnabled_ShouldLogPluginMetadata_Auth(t *testing.T) {
cluster := getCluster(t, 1, consts.PluginTypeCredential)
t.Cleanup(cluster.Cleanup)
plugin := cluster.Plugins[0]
client := cluster.Cores[0].Client
@ -1018,7 +1004,6 @@ func TestExternalPlugin_AuditEnabled_ShouldLogPluginMetadata_Auth(t *testing.T)
// in audit log when it is enabled
func TestExternalPlugin_AuditEnabled_ShouldLogPluginMetadata_Secret(t *testing.T) {
cluster := getCluster(t, 1, consts.PluginTypeSecrets)
t.Cleanup(cluster.Cleanup)
plugin := cluster.Plugins[0]
client := cluster.Cores[0].Client
@ -1174,7 +1159,6 @@ func expectRunningVersion(t *testing.T, client *api.Client, plugin pluginhelpers
// of upgrading an external plugin gated by pinned versions.
func TestCore_UpgradePluginUsingPinnedVersion_AuthAndSecret(t *testing.T) {
cluster := getCluster(t, 1, consts.PluginTypeCredential, consts.PluginTypeSecrets)
t.Cleanup(cluster.Cleanup)
client := cluster.Cores[0].Client
@ -1226,7 +1210,6 @@ func TestCore_UpgradePluginUsingPinnedVersion_AuthAndSecret(t *testing.T) {
// of upgrading an external database plugin gated by pinned versions.
func TestCore_UpgradePluginUsingPinnedVersion_Database(t *testing.T) {
cluster := getCluster(t, 3, consts.PluginTypeDatabase)
t.Cleanup(cluster.Cleanup)
client := cluster.Cores[0].Client
plugin := cluster.Plugins[0]

View File

@ -62,7 +62,6 @@ func TestSystemBackend_Plugin_secret(t *testing.T) {
t.Run(tc.pluginVersion, func(t *testing.T) {
t.Parallel()
cluster := testSystemBackendMock(t, 1, 1, logical.TypeLogical, tc.pluginVersion)
defer cluster.Cleanup()
core := cluster.Cores[0]
@ -132,7 +131,6 @@ func TestSystemBackend_Plugin_auth(t *testing.T) {
t.Run(tc.pluginVersion, func(t *testing.T) {
t.Parallel()
cluster := testSystemBackendMock(t, 1, 1, logical.TypeCredential, tc.pluginVersion)
defer cluster.Cleanup()
core := cluster.Cores[0]
@ -162,9 +160,6 @@ func TestSystemBackend_Plugin_auth(t *testing.T) {
if core.Sealed() {
t.Fatal("should not be sealed")
}
// Wait for active so post-unseal takes place
// If it fails, it means unseal process failed
vault.TestWaitActive(t, core.Core)
}
})
}
@ -190,7 +185,6 @@ func TestSystemBackend_Plugin_MissingBinary(t *testing.T) {
t.Run(tc.pluginVersion, func(t *testing.T) {
t.Parallel()
cluster := testSystemBackendMock(t, 1, 1, logical.TypeLogical, tc.pluginVersion)
defer cluster.Cleanup()
core := cluster.Cores[0]
@ -250,7 +244,6 @@ func TestSystemBackend_Plugin_MismatchType(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.pluginVersion, func(t *testing.T) {
cluster := testSystemBackendMock(t, 1, 1, logical.TypeLogical, tc.pluginVersion)
defer cluster.Cleanup()
core := cluster.Cores[0]
@ -310,7 +303,6 @@ func testPlugin_CatalogRemoved(t *testing.T, btype logical.BackendType, testMoun
t.Run(tc.pluginVersion, func(t *testing.T) {
t.Parallel()
cluster := testSystemBackendMock(t, 1, 1, logical.TypeLogical, tc.pluginVersion)
defer cluster.Cleanup()
core := cluster.Cores[0]
@ -389,7 +381,6 @@ func TestSystemBackend_Plugin_autoReload(t *testing.T) {
t.Run(tc.pluginVersion, func(t *testing.T) {
t.Parallel()
cluster := testSystemBackendMock(t, 1, 1, logical.TypeLogical, tc.pluginVersion)
defer cluster.Cleanup()
core := cluster.Cores[0]
@ -449,7 +440,6 @@ func TestSystemBackend_Plugin_SealUnseal(t *testing.T) {
t.Run(tc.pluginVersion, func(t *testing.T) {
t.Parallel()
cluster := testSystemBackendMock(t, 1, 1, logical.TypeLogical, tc.pluginVersion)
defer cluster.Cleanup()
// Seal the cluster
cluster.EnsureCoresSealed(t)
@ -563,7 +553,6 @@ func testSystemBackend_PluginReload(t *testing.T, path string, reqData map[strin
for _, tc := range testCases {
t.Run(tc.pluginVersion, func(t *testing.T) {
cluster := testSystemBackendMock(t, 1, 2, backendType, tc.pluginVersion)
defer cluster.Cleanup()
core := cluster.Cores[0]
client := core.Client
@ -610,7 +599,6 @@ func testSystemBackend_PluginReload(t *testing.T, path string, reqData map[strin
func TestSystemBackend_PluginReload_WarningIfNoneReloaded(t *testing.T) {
cluster := testSystemBackendMock(t, 1, 2, logical.TypeLogical, "v5")
defer cluster.Cleanup()
core := cluster.Cores[0]
client := core.Client
@ -662,7 +650,6 @@ func testSystemBackendMock(t *testing.T, numCores, numMounts int, backendType lo
cluster := vault.NewTestCluster(t, conf, opts)
core := cluster.Cores[0]
vault.TestWaitActive(t, core.Core)
client := core.Client
env := []string{pluginutil.PluginCACertPEMEnv + "=" + cluster.CACertPEMFile}
@ -720,11 +707,8 @@ func TestSystemBackend_Plugin_Env(t *testing.T) {
NumCores: 1,
TempDir: pluginDir,
})
cluster.Start()
t.Cleanup(cluster.Cleanup)
core := cluster.Cores[0]
vault.TestWaitActive(t, core.Core)
client := core.Client
key := t.Name() + "_FOO"

View File

@ -31,9 +31,6 @@ func TestPolicy_NoDefaultPolicy(t *testing.T) {
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
cores := cluster.Cores
vault.TestWaitActive(t, cores[0].Core)
@ -203,8 +200,6 @@ func TestPolicy_TokenRenewal(t *testing.T) {
cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
core := cluster.Cores[0].Core
vault.TestWaitActive(t, core)

View File

@ -28,7 +28,6 @@ func TestSysPprof_Exec(t *testing.T) {
BinaryPath: binary,
BaseListenAddress: "127.0.0.1:8208",
})
defer cluster.Cleanup()
pprof.SysPprof_Test(t, cluster)
}

View File

@ -37,8 +37,6 @@ func TestSysPprof(t *testing.T) {
HandlerFunc: vaulthttp.Handler,
RequestResponseCallback: schema.ResponseValidatingCallback(t),
})
cluster.Start()
defer cluster.Cleanup()
core := cluster.Cores[0].Core
vault.TestWaitActive(t, core)
@ -58,8 +56,6 @@ func TestSysPprof_MaxRequestDuration(t *testing.T) {
cluster := vault.NewTestCluster(t, nil, &vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
})
cluster.Start()
defer cluster.Cleanup()
client := cluster.Cores[0].Client
transport := cleanhttp.DefaultPooledTransport()

View File

@ -161,11 +161,7 @@ func TestQuotas_RateLimit_DupName(t *testing.T) {
opts.NoDefaultQuotas = true
opts.RequestResponseCallback = schema.ResponseValidatingCallback(t)
cluster := vault.NewTestCluster(t, conf, opts)
cluster.Start()
defer cluster.Cleanup()
core := cluster.Cores[0].Core
client := cluster.Cores[0].Client
vault.TestWaitActive(t, core)
// create a rate limit quota w/ 'secret' path
_, err := client.Logical().Write("sys/quotas/rate-limit/secret-rlq", map[string]interface{}{
@ -197,12 +193,8 @@ func TestQuotas_RateLimit_DupPath(t *testing.T) {
opts.NoDefaultQuotas = true
opts.RequestResponseCallback = schema.ResponseValidatingCallback(t)
cluster := vault.NewTestCluster(t, conf, opts)
cluster.Start()
defer cluster.Cleanup()
core := cluster.Cores[0].Core
client := cluster.Cores[0].Client
vault.TestWaitActive(t, core)
// create a global rate limit quota
_, err := client.Logical().Write("sys/quotas/rate-limit/global-rlq", map[string]interface{}{
"rate": 10,
@ -237,12 +229,7 @@ func TestQuotas_RateLimitQuota_ExemptPaths(t *testing.T) {
opts.NoDefaultQuotas = true
opts.RequestResponseCallback = schema.ResponseValidatingCallback(t)
cluster := vault.NewTestCluster(t, conf, opts)
cluster.Start()
defer cluster.Cleanup()
core := cluster.Cores[0].Core
client := cluster.Cores[0].Client
vault.TestWaitActive(t, core)
_, err := client.Logical().Write("sys/quotas/rate-limit/rlq", map[string]interface{}{
"rate": 7.7,
@ -289,12 +276,7 @@ func TestQuotas_RateLimitQuota_DefaultExemptPaths(t *testing.T) {
opts.NoDefaultQuotas = true
opts.RequestResponseCallback = schema.ResponseValidatingCallback(t)
cluster := vault.NewTestCluster(t, conf, opts)
cluster.Start()
defer cluster.Cleanup()
core := cluster.Cores[0].Core
client := cluster.Cores[0].Client
vault.TestWaitActive(t, core)
_, err := client.Logical().Write("sys/quotas/rate-limit/rlq", map[string]interface{}{
"rate": 1,
@ -318,12 +300,7 @@ func TestQuotas_RateLimitQuota_DefaultExemptPaths(t *testing.T) {
func TestQuotas_RateLimitQuota_Mount(t *testing.T) {
conf, opts := teststorage.ClusterSetup(coreConfig, nil, nil)
cluster := vault.NewTestCluster(t, conf, opts)
cluster.Start()
defer cluster.Cleanup()
core := cluster.Cores[0].Core
client := cluster.Cores[0].Client
vault.TestWaitActive(t, core)
err := client.Sys().Mount("pki", &api.MountInput{
Type: "pki",
@ -407,14 +384,8 @@ func TestQuotas_RateLimitQuota_MountPrecedence(t *testing.T) {
conf, opts := teststorage.ClusterSetup(coreConfig, nil, nil)
opts.NoDefaultQuotas = true
cluster := vault.NewTestCluster(t, conf, opts)
cluster.Start()
defer cluster.Cleanup()
core := cluster.Cores[0].Core
client := cluster.Cores[0].Client
vault.TestWaitActive(t, core)
// create PKI mount
err := client.Sys().Mount("pki", &api.MountInput{
Type: "pki",
@ -494,14 +465,8 @@ func TestQuotas_RateLimitQuota(t *testing.T) {
conf, opts := teststorage.ClusterSetup(coreConfig, nil, nil)
opts.NoDefaultQuotas = true
cluster := vault.NewTestCluster(t, conf, opts)
cluster.Start()
defer cluster.Cleanup()
core := cluster.Cores[0].Core
client := cluster.Cores[0].Client
vault.TestWaitActive(t, core)
err := client.Sys().EnableAuthWithOptions("userpass", &api.EnableAuthOptions{
Type: "userpass",
})
@ -573,14 +538,8 @@ func TestQuotas_RateLimitQuota_GroupByConfig(t *testing.T) {
conf, opts := teststorage.ClusterSetup(coreConfig, nil, nil)
opts.NoDefaultQuotas = true
cluster := vault.NewTestCluster(t, conf, opts)
cluster.Start()
t.Cleanup(cluster.Cleanup)
core := cluster.Cores[0].Core
client := cluster.Cores[0].Client
vault.TestWaitActive(t, core)
testCases := map[string]struct {
reqData map[string]interface{}
expectedErr string
@ -757,8 +716,6 @@ func TestQuotas_RateLimitQuota_GroupByConfig(t *testing.T) {
func TestQuotas_RateLimit_ZeroRetryRegression(t *testing.T) {
conf, opts := teststorage.ClusterSetup(coreConfig, nil, nil)
cluster := vault.NewTestCluster(t, conf, opts)
cluster.Start()
defer cluster.Cleanup()
testhelpers.WaitForActiveNode(t, cluster)
client := cluster.Cores[0].Client
@ -799,7 +756,6 @@ func TestQuotas_RateLimit_NilStorage_ResolveRole(t *testing.T) {
NumCores: 1,
}, nil)
cluster := vault.NewTestCluster(t, conf, opts)
defer cluster.Cleanup()
client := cluster.Cores[0].Client
// Enable our custom panic auth method which will panic on nil storage

View File

@ -33,7 +33,6 @@ func TestRaft_Autopilot_Disable(t *testing.T) {
InmemCluster: true,
// Not setting EnableAutopilot here.
})
defer cluster.Cleanup()
cli := cluster.Cores[0].Client
state, err := cli.Sys().RaftAutopilotState()
@ -62,7 +61,6 @@ func TestRaft_Autopilot_BinaryVersionPlumbing(t *testing.T) {
require.Empty(t, coreCfg.EffectiveSDKVersion)
c := vault.NewTestCluster(t, coreCfg, &clusterOpts)
defer c.Cleanup()
// Wait for follower to be perf standby (in Ent, in CE it will only wait for
// active). In either Enterprise or CE case, this should pass if we've plumbed
@ -89,7 +87,6 @@ func TestRaft_Autopilot_Stabilization_And_State(t *testing.T) {
"performance_multiplier": "5",
},
})
defer cluster.Cleanup()
// Check that autopilot execution state is running
client := cluster.Cores[0].Client
@ -160,7 +157,6 @@ func TestRaft_Autopilot_Configuration(t *testing.T) {
InmemCluster: true,
EnableAutopilot: true,
})
defer cluster.Cleanup()
client := cluster.Cores[0].Client
configCheckFunc := func(config *api.AutopilotConfig) {
@ -267,7 +263,6 @@ func TestRaft_Autopilot_Stabilization_Delay(t *testing.T) {
})
cluster := vault.NewTestCluster(t, conf, &opts)
defer cluster.Cleanup()
testhelpers.WaitForActiveNode(t, cluster)
// Check that autopilot execution state is running
@ -363,7 +358,6 @@ func TestRaft_AutoPilot_Peersets_Equivalent(t *testing.T) {
EnableAutopilot: true,
DisableFollowerJoins: true,
})
defer cluster.Cleanup()
testhelpers.WaitForActiveNode(t, cluster)
// Create a very large stabilization time so we can test the state between
@ -423,7 +417,6 @@ func TestRaft_VotersStayVoters(t *testing.T) {
2: version.Version,
},
})
defer cluster.Cleanup()
testhelpers.WaitForActiveNode(t, cluster)
client := cluster.Cores[0].Client
@ -472,7 +465,6 @@ func TestRaft_Autopilot_DeadServerCleanup(t *testing.T) {
EnableAutopilot: true,
NumCores: 4,
})
defer cluster.Cleanup()
testhelpers.WaitForActiveNode(t, cluster)
// Join 2 extra nodes manually, store the 3rd for later

View File

@ -53,7 +53,7 @@ func TestRaft_Configuration_Docker(t *testing.T) {
defer cluster.Cleanup()
rafttest.Raft_Configuration_Test(t, cluster)
if err := cluster.AddNode(context.TODO(), opts); err != nil {
if err := cluster.AddNode(context.Background(), opts); err != nil {
t.Fatal(err)
}
rafttest.Raft_Configuration_Test(t, cluster)

Some files were not shown because too many files have changed in this diff Show More