Don't require every test to specify a VaultLicense field (#20372)
This commit is contained in:
parent
cbb5b2fa22
commit
f5b5662122
|
@ -36,8 +36,6 @@ const (
|
||||||
GenerateRecovery
|
GenerateRecovery
|
||||||
)
|
)
|
||||||
|
|
||||||
const VAULT_LICENSE_CI_ENV = "VAULT_LICENSE_CI"
|
|
||||||
|
|
||||||
// GenerateRoot generates a root token on the target cluster.
|
// GenerateRoot generates a root token on the target cluster.
|
||||||
func GenerateRoot(t testing.T, cluster *vault.TestCluster, kind GenerateRootKind) string {
|
func GenerateRoot(t testing.T, cluster *vault.TestCluster, kind GenerateRootKind) string {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
package testcluster
|
||||||
|
|
||||||
|
const (
|
||||||
|
// EnvVaultLicenseCI is the name of an environment variable that contains
|
||||||
|
// a signed license string used for Vault Enterprise binary-based tests.
|
||||||
|
// The binary will be run with the env var VAULT_LICENSE set to this value.
|
||||||
|
EnvVaultLicenseCI = "VAULT_LICENSE_CI"
|
||||||
|
)
|
|
@ -406,6 +406,9 @@ func NewTestDockerCluster(t *testing.T, opts *DockerClusterOptions) *DockerClust
|
||||||
if opts.NetworkName == "" {
|
if opts.NetworkName == "" {
|
||||||
opts.NetworkName = os.Getenv("TEST_DOCKER_NETWORK_NAME")
|
opts.NetworkName = os.Getenv("TEST_DOCKER_NETWORK_NAME")
|
||||||
}
|
}
|
||||||
|
if opts.VaultLicense == "" {
|
||||||
|
opts.VaultLicense = os.Getenv(testcluster.EnvVaultLicenseCI)
|
||||||
|
}
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
|
||||||
t.Cleanup(cancel)
|
t.Cleanup(cancel)
|
||||||
|
|
|
@ -59,6 +59,9 @@ func NewTestExecDevCluster(t *testing.T, opts *ExecDevClusterOptions) *ExecDevCl
|
||||||
if opts.Logger == nil {
|
if opts.Logger == nil {
|
||||||
opts.Logger = logging.NewVaultLogger(log.Trace).Named(t.Name()) // .Named("container")
|
opts.Logger = logging.NewVaultLogger(log.Trace).Named(t.Name()) // .Named("container")
|
||||||
}
|
}
|
||||||
|
if opts.VaultLicense == "" {
|
||||||
|
opts.VaultLicense = os.Getenv(EnvVaultLicenseCI)
|
||||||
|
}
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
|
||||||
t.Cleanup(cancel)
|
t.Cleanup(cancel)
|
||||||
|
|
|
@ -15,7 +15,6 @@ import (
|
||||||
|
|
||||||
"github.com/hashicorp/go-cleanhttp"
|
"github.com/hashicorp/go-cleanhttp"
|
||||||
"github.com/hashicorp/vault/api"
|
"github.com/hashicorp/vault/api"
|
||||||
"github.com/hashicorp/vault/helper/testhelpers"
|
|
||||||
vaulthttp "github.com/hashicorp/vault/http"
|
vaulthttp "github.com/hashicorp/vault/http"
|
||||||
"github.com/hashicorp/vault/internalshared/configutil"
|
"github.com/hashicorp/vault/internalshared/configutil"
|
||||||
"github.com/hashicorp/vault/sdk/helper/testcluster"
|
"github.com/hashicorp/vault/sdk/helper/testcluster"
|
||||||
|
@ -51,8 +50,7 @@ func TestSysPprof_Exec(t *testing.T) {
|
||||||
}
|
}
|
||||||
cluster := testcluster.NewTestExecDevCluster(t, &testcluster.ExecDevClusterOptions{
|
cluster := testcluster.NewTestExecDevCluster(t, &testcluster.ExecDevClusterOptions{
|
||||||
ClusterOptions: testcluster.ClusterOptions{
|
ClusterOptions: testcluster.ClusterOptions{
|
||||||
NumCores: 1,
|
NumCores: 1,
|
||||||
VaultLicense: os.Getenv(testhelpers.VAULT_LICENSE_CI_ENV),
|
|
||||||
},
|
},
|
||||||
BinaryPath: binary,
|
BinaryPath: binary,
|
||||||
BaseListenAddress: "127.0.0.1:8208",
|
BaseListenAddress: "127.0.0.1:8208",
|
||||||
|
@ -248,7 +246,6 @@ func TestSysPprof_Standby_Exec(t *testing.T) {
|
||||||
VaultNodeConfig: &testcluster.VaultNodeConfig{
|
VaultNodeConfig: &testcluster.VaultNodeConfig{
|
||||||
DisablePerformanceStandby: true,
|
DisablePerformanceStandby: true,
|
||||||
},
|
},
|
||||||
VaultLicense: os.Getenv(testhelpers.VAULT_LICENSE_CI_ENV),
|
|
||||||
},
|
},
|
||||||
BinaryPath: binary,
|
BinaryPath: binary,
|
||||||
BaseListenAddress: "127.0.0.1:8210",
|
BaseListenAddress: "127.0.0.1:8210",
|
||||||
|
|
|
@ -468,7 +468,6 @@ func TestRaft_Configuration_Docker(t *testing.T) {
|
||||||
// "performance_multiplier": "1",
|
// "performance_multiplier": "1",
|
||||||
//},
|
//},
|
||||||
},
|
},
|
||||||
VaultLicense: os.Getenv(testhelpers.VAULT_LICENSE_CI_ENV),
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
cluster := docker.NewTestDockerCluster(t, opts)
|
cluster := docker.NewTestDockerCluster(t, opts)
|
||||||
|
|
Loading…
Reference in New Issue